Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtLd: require use of InflowWind #2412

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions glue-codes/openfast-cpp/src/FAST_Prog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ void readTurbineData(int iTurb, fast::fastInputs & fi, YAML::Node turbNode) {

get_if_present(turbNode, "az_blend_mean", fi.globTurbineData[iTurb].azBlendMean, 20*360.0*M_PI/180.0); //20 revs
get_if_present(turbNode, "az_blend_delta", fi.globTurbineData[iTurb].azBlendDelta, 3.0*360.0*M_PI/180.0); // 3 rev
get_required(turbNode, "vel_mean", fi.globTurbineData[iTurb].velMean);
get_required(turbNode, "wind_dir", fi.globTurbineData[iTurb].windDir);
get_required(turbNode, "z_ref", fi.globTurbineData[iTurb].zRef);
get_required(turbNode, "shear_exp", fi.globTurbineData[iTurb].shearExp);

}

Expand Down
12 changes: 0 additions & 12 deletions glue-codes/openfast-cpp/src/OpenFAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,6 @@ void fast::OpenFAST::init() {
&turbineData[iTurb].numBlades,
&turbineData[iTurb].azBlendMean,
&turbineData[iTurb].azBlendDelta,
&turbineData[iTurb].velMean,
&turbineData[iTurb].windDir,
&turbineData[iTurb].zRef,
&turbineData[iTurb].shearExp,
&extld_i_f_FAST[iTurb],
&extld_p_f_FAST[iTurb],
&extld_o_t_FAST[iTurb],
Expand Down Expand Up @@ -1664,10 +1660,6 @@ void fast::OpenFAST::get_turbineParams(int iTurbGlob, turbineDataType & turbData
turbData.nBRfsiPtsTwr = turbineData[iTurbLoc].nBRfsiPtsTwr;
turbData.azBlendMean = turbineData[iTurbLoc].azBlendMean;
turbData.azBlendDelta = turbineData[iTurbLoc].azBlendDelta;
turbData.velMean = turbineData[iTurbLoc].velMean;
turbData.windDir = turbineData[iTurbLoc].windDir;
turbData.zRef = turbineData[iTurbLoc].zRef;
turbData.shearExp = turbineData[iTurbLoc].shearExp;

}

Expand Down Expand Up @@ -2075,10 +2067,6 @@ void fast::OpenFAST::allocateMemory_preInit() {
turbineData[iTurb].numForcePtsTwr = globTurbineData[iTurbGlob].numForcePtsTwr;
turbineData[iTurb].azBlendMean = globTurbineData[iTurbGlob].azBlendMean;
turbineData[iTurb].azBlendDelta = globTurbineData[iTurbGlob].azBlendDelta;
turbineData[iTurb].velMean = globTurbineData[iTurbGlob].velMean;
turbineData[iTurb].windDir = globTurbineData[iTurbGlob].windDir;
turbineData[iTurb].zRef = globTurbineData[iTurbGlob].zRef;
turbineData[iTurb].shearExp = globTurbineData[iTurbGlob].shearExp;

velForceNodeData[iTurb].resize(4); // To hold data for 4 time steps
brFSIData[iTurb].resize(4);
Expand Down
2 changes: 1 addition & 1 deletion modules/extloads/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ add_library(extloadslib STATIC
target_include_directories(extloadslib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
target_link_libraries(extloadslib beamdynlib nwtclibs versioninfolib ifwlib)
target_link_libraries(extloadslib beamdynlib nwtclibs versioninfolib)
set_target_properties(extloadslib PROPERTIES PUBLIC_HEADER "src/ExtLoadsDX_Types.h")

install(TARGETS extloadslib
Expand Down
31 changes: 3 additions & 28 deletions modules/extloads/src/ExtLoads.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module ExtLoads

use NWTC_Library
use ExtLoads_Types
use IfW_FlowField
use InflowWind_IO_Types
use InflowWind_IO

Expand All @@ -50,8 +49,8 @@ module ExtLoads
!! FAST)
subroutine ExtLd_SetInitOut(p, InitOut, errStat, errMsg)

type(ExtLd_InitOutputType), intent( out) :: InitOut ! output data
type(ExtLd_ParameterType), intent(in ) :: p ! Parameters
type(ExtLd_InitOutputType), intent(inout) :: InitOut ! output data
type(ExtLd_ParameterType), intent(in ) :: p ! Parameters
integer(IntKi), intent( out) :: errStat ! Error status of the operation
character(*), intent( out) :: errMsg ! Error message if ErrStat /= ErrID_None

Expand Down Expand Up @@ -129,10 +128,6 @@ subroutine ExtLd_Init( InitInp, u, xd, p, y, m, interval, InitOut, ErrStat, ErrM

p%az_blend_mean = InitInp%az_blend_mean
p%az_blend_delta = InitInp%az_blend_delta
p%vel_mean = InitInp%vel_mean
p%wind_dir = InitInp%wind_dir
p%z_ref = InitInp%z_ref
p%shear_exp = InitInp%shear_exp

!............................................................................................
! Define and initialize inputs here
Expand All @@ -150,34 +145,14 @@ subroutine ExtLd_Init( InitInp, u, xd, p, y, m, interval, InitOut, ErrStat, ErrM
m%phi_cfd = 0.0

write(*,*) 'Initializing y '
!

!............................................................................................
! Define outputs here
!............................................................................................
call Init_y(y, u, m, p, errStat2, errMsg2) ! do this after input meshes have been initialized
call SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
if (ErrStat >= AbortErrLev) return

!............................................................................................
! Initialize InflowWind FlowField
!............................................................................................
if (associated(m%FlowField)) deallocate(m%FlowField)
allocate(m%FlowField, stat=ErrStat2)
if (ErrStat2 /= 0) then
call SetErrStat( ErrID_Fatal, 'Error allocating m%FlowField', ErrStat, ErrMsg, RoutineName )
return
end if

! Initialize flowfield points type
m%FlowField%FieldType = Point_FieldType
Points_InitInput%NumWindPoints = InitInp%nNodesVel
call IfW_Points_Init(Points_InitInput, m%FlowField%Points, ErrStat2, ErrMsg2); if (Failed()) return

! Set pointer to flow field in InitOut
InitOut%FlowField => m%FlowField


write(*,*) 'Initializing InitOut '

!............................................................................................
! Define initialization output here
Expand Down
9 changes: 0 additions & 9 deletions modules/extloads/src/ExtLoads_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ typedef ^ InitInputType ReKi TwrPos {:}{:} - - "X-Y-Z reference
typedef ^ InitInputType R8Ki TwrOrient {:}{:}{:} - - "DCM reference orientation of tower (3x3 x NumTowerNodes)" -
typedef ^ InitInputType ReKi az_blend_mean - - - "Mean azimuth at which to blend the external and aerodyn loads" -
typedef ^ InitInputType ReKi az_blend_delta - - - "The width of the tanh function over which to blend the external and aerodyn loads" -
typedef ^ InitInputType ReKi vel_mean - - - "Mean velocity at reference height" m/s
typedef ^ InitInputType ReKi wind_dir - - - "Wind direction" degrees
typedef ^ InitInputType ReKi z_ref - - - "Reference height for velocity profile" m
typedef ^ InitInputType ReKi shear_exp - - - "Shear exponent" -
typedef ^ InitInputType ReKi BldChord {:}{:} - - "Blade chord (NumBladeNodesMax x NumBlades)" m
typedef ^ InitInputType ReKi BldRloc {:}{:} - - "Radial location of each node along the blade" m
typedef ^ InitInputType ReKi TwrDia {:} - - "Tower diameter (NumTwrNodes)" m
Expand All @@ -51,7 +47,6 @@ typedef ^ InitOutputType CHARACTER(ChanLen) WriteOutputHdr {:} - - "Names of the
typedef ^ InitOutputType CHARACTER(ChanLen) WriteOutputUnt {:} - - "Units of the output-to-file channels" -
typedef ^ InitOutputType ProgDesc Ver - - - "This module's name, version, and date" -
typedef ^ InitOutputType ReKi AirDens - - - "Air density" kg/m^3
typedef ^ InitOutputType FlowFieldType *FlowField - - - "Pointer of flow field data type" -

# ..... States ....................................................................................................................
# Define continuous (differentiable) states here:
Expand Down Expand Up @@ -84,10 +79,6 @@ typedef ^ ParameterType Logical TwrAero - .FALSE. - "Flag that tells thi
typedef ^ ParameterType IntKi NumTwrNds - - - "Number of tower nodes" -
typedef ^ ParameterType ReKi az_blend_mean - - - "Mean azimuth at which to blend the external and aerodyn loads" -
typedef ^ ParameterType ReKi az_blend_delta - - - "The width of the tanh function over which to blend the external and aerodyn loads" -
typedef ^ ParameterType ReKi vel_mean - - - "Mean velocity at reference height" m/s
typedef ^ ParameterType ReKi wind_dir - - - "Wind direction" m
typedef ^ ParameterType ReKi z_ref - - - "Reference height for velocity profile" degrees
typedef ^ ParameterType ReKi shear_exp - - - "Shear exponent" -

# ..... Inputs ....................................................................................................................
# Define inputs that are contained on the mesh here:
Expand Down
63 changes: 0 additions & 63 deletions modules/extloads/src/ExtLoads_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ MODULE ExtLoads_Types
REAL(R8Ki) , DIMENSION(:,:,:), ALLOCATABLE :: TwrOrient !< DCM reference orientation of tower (3x3 x NumTowerNodes) [-]
REAL(ReKi) :: az_blend_mean = 0.0_ReKi !< Mean azimuth at which to blend the external and aerodyn loads [-]
REAL(ReKi) :: az_blend_delta = 0.0_ReKi !< The width of the tanh function over which to blend the external and aerodyn loads [-]
REAL(ReKi) :: vel_mean = 0.0_ReKi !< Mean velocity at reference height [m/s]
REAL(ReKi) :: wind_dir = 0.0_ReKi !< Wind direction [degrees]
REAL(ReKi) :: z_ref = 0.0_ReKi !< Reference height for velocity profile [m]
REAL(ReKi) :: shear_exp = 0.0_ReKi !< Shear exponent [-]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: BldChord !< Blade chord (NumBladeNodesMax x NumBlades) [m]
REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: BldRloc !< Radial location of each node along the blade [m]
REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: TwrDia !< Tower diameter (NumTwrNodes) [m]
Expand All @@ -70,7 +66,6 @@ MODULE ExtLoads_Types
CHARACTER(ChanLen) , DIMENSION(:), ALLOCATABLE :: WriteOutputUnt !< Units of the output-to-file channels [-]
TYPE(ProgDesc) :: Ver !< This module's name, version, and date [-]
REAL(ReKi) :: AirDens = 0.0_ReKi !< Air density [kg/m^3]
TYPE(FlowFieldType) , POINTER :: FlowField => NULL() !< Pointer of flow field data type [-]
END TYPE ExtLd_InitOutputType
! =======================
! ========= ExtLd_ContinuousStateType =======
Expand Down Expand Up @@ -110,10 +105,6 @@ MODULE ExtLoads_Types
INTEGER(IntKi) :: NumTwrNds = 0_IntKi !< Number of tower nodes [-]
REAL(ReKi) :: az_blend_mean = 0.0_ReKi !< Mean azimuth at which to blend the external and aerodyn loads [-]
REAL(ReKi) :: az_blend_delta = 0.0_ReKi !< The width of the tanh function over which to blend the external and aerodyn loads [-]
REAL(ReKi) :: vel_mean = 0.0_ReKi !< Mean velocity at reference height [m/s]
REAL(ReKi) :: wind_dir = 0.0_ReKi !< Wind direction [m]
REAL(ReKi) :: z_ref = 0.0_ReKi !< Reference height for velocity profile [degrees]
REAL(ReKi) :: shear_exp = 0.0_ReKi !< Shear exponent [-]
END TYPE ExtLd_ParameterType
! =======================
! ========= ExtLd_InputType =======
Expand Down Expand Up @@ -242,10 +233,6 @@ subroutine ExtLd_CopyInitInput(SrcInitInputData, DstInitInputData, CtrlCode, Err
end if
DstInitInputData%az_blend_mean = SrcInitInputData%az_blend_mean
DstInitInputData%az_blend_delta = SrcInitInputData%az_blend_delta
DstInitInputData%vel_mean = SrcInitInputData%vel_mean
DstInitInputData%wind_dir = SrcInitInputData%wind_dir
DstInitInputData%z_ref = SrcInitInputData%z_ref
DstInitInputData%shear_exp = SrcInitInputData%shear_exp
if (allocated(SrcInitInputData%BldChord)) then
LB(1:2) = lbound(SrcInitInputData%BldChord, kind=B8Ki)
UB(1:2) = ubound(SrcInitInputData%BldChord, kind=B8Ki)
Expand Down Expand Up @@ -360,10 +347,6 @@ subroutine ExtLd_PackInitInput(RF, Indata)
call RegPackAlloc(RF, InData%TwrOrient)
call RegPack(RF, InData%az_blend_mean)
call RegPack(RF, InData%az_blend_delta)
call RegPack(RF, InData%vel_mean)
call RegPack(RF, InData%wind_dir)
call RegPack(RF, InData%z_ref)
call RegPack(RF, InData%shear_exp)
call RegPackAlloc(RF, InData%BldChord)
call RegPackAlloc(RF, InData%BldRloc)
call RegPackAlloc(RF, InData%TwrDia)
Expand Down Expand Up @@ -396,10 +379,6 @@ subroutine ExtLd_UnPackInitInput(RF, OutData)
call RegUnpackAlloc(RF, OutData%TwrOrient); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%az_blend_mean); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%az_blend_delta); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%vel_mean); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%wind_dir); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%z_ref); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%shear_exp); if (RegCheckErr(RF, RoutineName)) return
call RegUnpackAlloc(RF, OutData%BldChord); if (RegCheckErr(RF, RoutineName)) return
call RegUnpackAlloc(RF, OutData%BldRloc); if (RegCheckErr(RF, RoutineName)) return
call RegUnpackAlloc(RF, OutData%TwrDia); if (RegCheckErr(RF, RoutineName)) return
Expand Down Expand Up @@ -447,7 +426,6 @@ subroutine ExtLd_CopyInitOutput(SrcInitOutputData, DstInitOutputData, CtrlCode,
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
if (ErrStat >= AbortErrLev) return
DstInitOutputData%AirDens = SrcInitOutputData%AirDens
DstInitOutputData%FlowField => SrcInitOutputData%FlowField
end subroutine

subroutine ExtLd_DestroyInitOutput(InitOutputData, ErrStat, ErrMsg)
Expand All @@ -467,26 +445,17 @@ subroutine ExtLd_DestroyInitOutput(InitOutputData, ErrStat, ErrMsg)
end if
call NWTC_Library_DestroyProgDesc(InitOutputData%Ver, ErrStat2, ErrMsg2)
call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
nullify(InitOutputData%FlowField)
end subroutine

subroutine ExtLd_PackInitOutput(RF, Indata)
type(RegFile), intent(inout) :: RF
type(ExtLd_InitOutputType), intent(in) :: InData
character(*), parameter :: RoutineName = 'ExtLd_PackInitOutput'
logical :: PtrInIndex
if (RF%ErrStat >= AbortErrLev) return
call RegPackAlloc(RF, InData%WriteOutputHdr)
call RegPackAlloc(RF, InData%WriteOutputUnt)
call NWTC_Library_PackProgDesc(RF, InData%Ver)
call RegPack(RF, InData%AirDens)
call RegPack(RF, associated(InData%FlowField))
if (associated(InData%FlowField)) then
call RegPackPointer(RF, c_loc(InData%FlowField), PtrInIndex)
if (.not. PtrInIndex) then
call IfW_FlowField_PackFlowFieldType(RF, InData%FlowField)
end if
end if
if (RegCheckErr(RF, RoutineName)) return
end subroutine

Expand All @@ -497,31 +466,11 @@ subroutine ExtLd_UnPackInitOutput(RF, OutData)
integer(B8Ki) :: LB(1), UB(1)
integer(IntKi) :: stat
logical :: IsAllocAssoc
integer(B8Ki) :: PtrIdx
type(c_ptr) :: Ptr
if (RF%ErrStat /= ErrID_None) return
call RegUnpackAlloc(RF, OutData%WriteOutputHdr); if (RegCheckErr(RF, RoutineName)) return
call RegUnpackAlloc(RF, OutData%WriteOutputUnt); if (RegCheckErr(RF, RoutineName)) return
call NWTC_Library_UnpackProgDesc(RF, OutData%Ver) ! Ver
call RegUnpack(RF, OutData%AirDens); if (RegCheckErr(RF, RoutineName)) return
if (associated(OutData%FlowField)) deallocate(OutData%FlowField)
call RegUnpack(RF, IsAllocAssoc); if (RegCheckErr(RF, RoutineName)) return
if (IsAllocAssoc) then
call RegUnpackPointer(RF, Ptr, PtrIdx); if (RegCheckErr(RF, RoutineName)) return
if (c_associated(Ptr)) then
call c_f_pointer(Ptr, OutData%FlowField)
else
allocate(OutData%FlowField,stat=stat)
if (stat /= 0) then
call SetErrStat(ErrID_Fatal, 'Error allocating OutData%FlowField.', RF%ErrStat, RF%ErrMsg, RoutineName)
return
end if
RF%Pointers(PtrIdx) = c_loc(OutData%FlowField)
call IfW_FlowField_UnpackFlowFieldType(RF, OutData%FlowField) ! FlowField
end if
else
OutData%FlowField => null()
end if
end subroutine

subroutine ExtLd_CopyContState(SrcContStateData, DstContStateData, CtrlCode, ErrStat, ErrMsg)
Expand Down Expand Up @@ -804,10 +753,6 @@ subroutine ExtLd_CopyParam(SrcParamData, DstParamData, CtrlCode, ErrStat, ErrMsg
DstParamData%NumTwrNds = SrcParamData%NumTwrNds
DstParamData%az_blend_mean = SrcParamData%az_blend_mean
DstParamData%az_blend_delta = SrcParamData%az_blend_delta
DstParamData%vel_mean = SrcParamData%vel_mean
DstParamData%wind_dir = SrcParamData%wind_dir
DstParamData%z_ref = SrcParamData%z_ref
DstParamData%shear_exp = SrcParamData%shear_exp
end subroutine

subroutine ExtLd_DestroyParam(ParamData, ErrStat, ErrMsg)
Expand Down Expand Up @@ -839,10 +784,6 @@ subroutine ExtLd_PackParam(RF, Indata)
call RegPack(RF, InData%NumTwrNds)
call RegPack(RF, InData%az_blend_mean)
call RegPack(RF, InData%az_blend_delta)
call RegPack(RF, InData%vel_mean)
call RegPack(RF, InData%wind_dir)
call RegPack(RF, InData%z_ref)
call RegPack(RF, InData%shear_exp)
if (RegCheckErr(RF, RoutineName)) return
end subroutine

Expand All @@ -862,10 +803,6 @@ subroutine ExtLd_UnPackParam(RF, OutData)
call RegUnpack(RF, OutData%NumTwrNds); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%az_blend_mean); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%az_blend_delta); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%vel_mean); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%wind_dir); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%z_ref); if (RegCheckErr(RF, RoutineName)) return
call RegUnpack(RF, OutData%shear_exp); if (RegCheckErr(RF, RoutineName)) return
end subroutine

subroutine ExtLd_CopyInput(SrcInputData, DstInputData, CtrlCode, ErrStat, ErrMsg)
Expand Down
10 changes: 1 addition & 9 deletions modules/openfast-library/src/FAST_Library.f90
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ end subroutine FAST_Restart

!==================================================================================================================================
subroutine FAST_ExtLoads_Init(iTurb_c, TMax, InputFileName_c, TurbIDforName, OutFileRoot_c, TurbPosn, AbortErrLev_c, dtDriver_c, dt_c, NumBl_c, &
az_blend_mean_c, az_blend_delta_c, vel_mean_c, wind_dir_c, z_ref_c, shear_exp_c, &
az_blend_mean_c, az_blend_delta_c, &
ExtLd_Input_from_FAST, ExtLd_Parameter_from_FAST, ExtLd_Output_to_FAST, SC_DX_Input_from_FAST, SC_DX_Output_to_FAST, ErrStat_c, ErrMsg_c) BIND (C, NAME='FAST_ExtLoads_Init')
IMPLICIT NONE
#ifndef IMPLICIT_DLLEXPORT
Expand All @@ -545,10 +545,6 @@ subroutine FAST_ExtLoads_Init(iTurb_c, TMax, InputFileName_c, TurbIDforName, Out
REAL(C_DOUBLE), INTENT(IN ) :: dtDriver_c
REAL(C_DOUBLE), INTENT(IN ) :: az_blend_mean_c
REAL(C_DOUBLE), INTENT(IN ) :: az_blend_delta_c
REAL(C_DOUBLE), INTENT(IN ) :: vel_mean_c
REAL(C_DOUBLE), INTENT(IN ) :: wind_dir_c
REAL(C_DOUBLE), INTENT(IN ) :: z_ref_c
REAL(C_DOUBLE), INTENT(IN ) :: shear_exp_c
REAL(C_DOUBLE), INTENT( OUT) :: dt_c
INTEGER(C_INT), INTENT( OUT) :: AbortErrLev_c
INTEGER(C_INT), INTENT( OUT) :: NumBl_c
Expand Down Expand Up @@ -590,10 +586,6 @@ subroutine FAST_ExtLoads_Init(iTurb_c, TMax, InputFileName_c, TurbIDforName, Out
ExternInitData%DTdriver = dtDriver_c
ExternInitData%az_blend_mean = az_blend_mean_c
ExternInitData%az_blend_delta = az_blend_delta_c
ExternInitData%vel_mean = vel_mean_c
ExternInitData%wind_dir = wind_dir_c
ExternInitData%z_ref = z_ref_c
ExternInitData%shear_exp = shear_exp_c

CALL FAST_InitializeAll_T( t_initial, 1_IntKi, Turbine(iTurb), ErrStat, ErrMsg, InputFileName, ExternInitData )

Expand Down
Loading