Skip to content

Commit

Permalink
Merge pull request #1493 from mchurchf/v3.4.1-branch
Browse files Browse the repository at this point in the history
Updates to Allow Non-Uniform Force Point Distribution on Blades
  • Loading branch information
andrew-platt committed May 8, 2023
2 parents bb72d26 + 8ef2c01 commit 69e7121
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 53 deletions.
2 changes: 2 additions & 0 deletions glue-codes/openfast-cpp/src/OpenFAST.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct globTurbineDataType {
std::string FASTRestartFileName;
std::vector<double> TurbineBasePos;
std::vector<double> TurbineHubPos;
std::string forcePtsBladeDistributionType;
int numForcePtsBlade;
int numForcePtsTwr;
float nacelle_cd{0.0};
Expand Down Expand Up @@ -104,6 +105,7 @@ class OpenFAST {
int ntStart; // The time step to start the FAST simulation
int nEveryCheckPoint; // Check point files will be written every 'nEveryCheckPoint' time steps
std::vector<int> numBlades; // Number of blades
std::vector<std::string> forcePtsBladeDistributionType;
std::vector<int> numForcePtsBlade;
std::vector<int> numForcePtsTwr;
std::vector<int> numVelPtsBlade;
Expand Down
16 changes: 15 additions & 1 deletion glue-codes/openfast-cpp/src/OpenFAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ void fast::OpenFAST::init() {
// this calls the Init() routines of each module

for (int iTurb=0; iTurb < nTurbinesProc; iTurb++) {
int nodeClusterType = 0;
if (forcePtsBladeDistributionType[iTurb] == "chordClustered")
{
nodeClusterType = 1;
}
std::copy(
FASTInputFileName[iTurb].data(),
FASTInputFileName[iTurb].data() + (FASTInputFileName[iTurb].size() + 1),
Expand All @@ -128,6 +133,7 @@ void fast::OpenFAST::init() {
&dtFAST,
&numBlades[iTurb],
&numVelPtsBlade[iTurb],
&nodeClusterType,
&cDriver_Input_from_FAST[iTurb],
&cDriver_Output_to_FAST[iTurb],
&sc.ip_from_FAST[iTurb],
Expand Down Expand Up @@ -170,6 +176,11 @@ void fast::OpenFAST::init() {
}

for (int iTurb=0; iTurb < nTurbinesProc; iTurb++) {
int nodeClusterType = 0;
if (forcePtsBladeDistributionType[iTurb] == "chordClustered")
{
nodeClusterType = 1;
}
std::copy(
FASTInputFileName[iTurb].data(),
FASTInputFileName[iTurb].data() + (FASTInputFileName[iTurb].size() + 1),
Expand All @@ -192,6 +203,7 @@ void fast::OpenFAST::init() {
&dtFAST,
&numBlades[iTurb],
&numVelPtsBlade[iTurb],
&nodeClusterType,
&cDriver_Input_from_FAST[iTurb],
&cDriver_Output_to_FAST[iTurb],
&sc.ip_from_FAST[iTurb],
Expand Down Expand Up @@ -807,6 +819,7 @@ void fast::OpenFAST::allocateMemory() {
nacelle_area.resize(nTurbinesProc);
air_density.resize(nTurbinesProc);
numBlades.resize(nTurbinesProc);
forcePtsBladeDistributionType.resize(nTurbinesProc);
numForcePtsBlade.resize(nTurbinesProc);
numForcePtsTwr.resize(nTurbinesProc);
numVelPtsBlade.resize(nTurbinesProc);
Expand All @@ -824,6 +837,7 @@ void fast::OpenFAST::allocateMemory() {
for(int i=0;i<3;i++) {
TurbineBasePos[iTurb][i] = globTurbineData[globProc].TurbineBasePos[i];
}
forcePtsBladeDistributionType[iTurb] = globTurbineData[globProc].forcePtsBladeDistributionType;
numForcePtsBlade[iTurb] = globTurbineData[globProc].numForcePtsBlade;
numForcePtsTwr[iTurb] = globTurbineData[globProc].numForcePtsTwr;
nacelle_cd[iTurb] = globTurbineData[globProc].nacelle_cd;
Expand All @@ -837,7 +851,7 @@ void fast::OpenFAST::allocateMemory() {
// Allocate memory for OpFM Input types in FAST
cDriver_Input_from_FAST.resize(nTurbinesProc) ;
cDriver_Output_to_FAST.resize(nTurbinesProc) ;

if(scStatus) {
std::cout << "Use of Supercontroller is not supported through the C++ API right now" << std::endl;
// scio.from_SC.resize(nTurbinesProc);
Expand Down
5 changes: 4 additions & 1 deletion modules/openfast-library/src/FAST_Library.f90
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ subroutine FAST_Restart(iTurb, CheckpointRootName_c, AbortErrLev_c, NumOuts_c, d

end subroutine FAST_Restart
!==================================================================================================================================
subroutine FAST_OpFM_Init(iTurb, TMax, InputFileName_c, TurbID, NumSC2CtrlGlob, NumSC2Ctrl, NumCtrl2SC, InitSCOutputsGlob, InitSCOutputsTurbine, NumActForcePtsBlade, NumActForcePtsTower, TurbPosn, AbortErrLev_c, dt_c, NumBl_c, NumBlElem_c, &
subroutine FAST_OpFM_Init(iTurb, TMax, InputFileName_c, TurbID, NumSC2CtrlGlob, NumSC2Ctrl, NumCtrl2SC, InitSCOutputsGlob, InitSCOutputsTurbine, NumActForcePtsBlade, NumActForcePtsTower, TurbPosn, AbortErrLev_c, dt_c, NumBl_c, NumBlElem_c, NodeClusterType_c, &
OpFM_Input_from_FAST, OpFM_Output_to_FAST, SC_DX_Input_from_FAST, SC_DX_Output_to_FAST, ErrStat_c, ErrMsg_c) BIND (C, NAME='FAST_OpFM_Init')
IMPLICIT NONE
#ifndef IMPLICIT_DLLEXPORT
Expand All @@ -524,6 +524,7 @@ subroutine FAST_OpFM_Init(iTurb, TMax, InputFileName_c, TurbID, NumSC2CtrlGlob,
REAL(C_FLOAT), INTENT(IN ) :: InitScOutputsTurbine (*) ! Initial Supercontroller turbine specific outputs = controller inputs
INTEGER(C_INT), INTENT(IN ) :: NumActForcePtsBlade ! number of actuator line force points in blade
INTEGER(C_INT), INTENT(IN ) :: NumActForcePtsTower ! number of actuator line force points in tower
INTEGER(C_INT), INTENT(IN ):: NodeClusterType_c
REAL(C_FLOAT), INTENT(IN ) :: TurbPosn(3)
INTEGER(C_INT), INTENT( OUT) :: AbortErrLev_c
REAL(C_DOUBLE), INTENT( OUT) :: dt_c
Expand Down Expand Up @@ -583,6 +584,8 @@ subroutine FAST_OpFM_Init(iTurb, TMax, InputFileName_c, TurbID, NumSC2CtrlGlob,
ExternInitData%NumActForcePtsBlade = NumActForcePtsBlade
ExternInitData%NumActForcePtsTower = NumActForcePtsTower

ExternInitData%NodeClusterType = NodeClusterType_c

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

! set values for return to OpenFOAM
Expand Down
2 changes: 1 addition & 1 deletion modules/openfast-library/src/FAST_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ EXTERNAL_ROUTINE void FAST_DeallocateTurbines(int *ErrStat, char *ErrMsg);
EXTERNAL_ROUTINE void FAST_OpFM_Restart(int * iTurb, const char *CheckpointRootName, int *AbortErrLev, double * dt, int * NumBl, int * NumBlElem, int * n_t_global,
OpFM_InputType_t* OpFM_Input, OpFM_OutputType_t* OpFM_Output, SC_DX_InputType_t* SC_DX_Input, SC_DX_OutputType_t* SC_DX_Output, int *ErrStat, char *ErrMsg);
EXTERNAL_ROUTINE void FAST_OpFM_Init(int * iTurb, double *TMax, const char *InputFileName, int * TurbineID, int * NumSC2CtrlGlob, int * NumSC2Ctrl, int * NumCtrl2SC, float * initSCInputsGlob, float * initSCInputsTurbine, int * NumActForcePtsBlade, int * NumActForcePtsTower, float * TurbinePosition,
int *AbortErrLev, double * dt, int * NumBl, int * NumBlElem, OpFM_InputType_t* OpFM_Input, OpFM_OutputType_t* OpFM_Output, SC_DX_InputType_t* SC_DX_Input, SC_DX_OutputType_t* SC_DX_Output,
int *AbortErrLev, double * dt, int * NumBl, int * NumBlElem, int * NodeClusterType, OpFM_InputType_t* OpFM_Input, OpFM_OutputType_t* OpFM_Output, SC_DX_InputType_t* SC_DX_Input, SC_DX_OutputType_t* SC_DX_Output,
int *ErrStat, char *ErrMsg);
EXTERNAL_ROUTINE void FAST_OpFM_Solution0(int * iTurb, int *ErrStat, char *ErrMsg);
EXTERNAL_ROUTINE void FAST_OpFM_Step(int * iTurb, int *ErrStat, char *ErrMsg);
Expand Down
3 changes: 2 additions & 1 deletion modules/openfast-library/src/FAST_Registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ typedef ^ FAST_ParameterType LOGICAL LinOutJac - - - "Include full Jacabians in
typedef ^ FAST_ParameterType LOGICAL LinOutMod - - - "Write module-level linearization output files in addition to output for full system? (flag) [unused if Linearize=False]" -
typedef ^ FAST_ParameterType FAST_VTK_ModeShapeType VTK_modes - - - "Data for VTK mode-shape visualization" -

typedef ^ FAST_ParameterType LOGICAL UseSC - - - "Use Supercontroller" -
typedef ^ FAST_ParameterType LOGICAL UseSC - - - "Use Supercontroller" -
typedef ^ FAST_ParameterType IntKi Lin_NumMods - - - "number of modules in the linearization"
typedef ^ FAST_ParameterType IntKi Lin_ModOrder {NumModules} - - "indices that determine which order the modules are in the glue-code linearization matrix"
typedef ^ FAST_ParameterType IntKi LinInterpOrder - - - "Interpolation order for CalcSteady solution" -
Expand Down Expand Up @@ -747,6 +747,7 @@ typedef ^ FAST_ExternInitType ReKi windGrid_pZero 3 - - "fixed position of the X
typedef ^ FAST_ExternInitType CHARACTER(1024) RootName - - - "Root name of FAST output files (overrides normal operation)" -
typedef ^ FAST_ExternInitType IntKi NumActForcePtsBlade - - - "number of actuator line force points in blade" -
typedef ^ FAST_ExternInitType IntKi NumActForcePtsTower - - - "number of actuator line force points in tower" -
typedef ^ FAST_ExternInitType logical NodeClusterType - - - "Node clustering for actuator line (0 - Uniform, 1 - Non-uniform clustered towards tip)" -

# ..... FAST Turbine Data (one realization) .......................................................................................................
typedef ^ FAST_TurbineType IntKi TurbID - 1 - "Turbine ID Number" -
Expand Down
3 changes: 3 additions & 0 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,9 @@ SUBROUTINE FAST_InitializeAll( t_initial, p_FAST, y_FAST, m_FAST, ED, BD, SrvD,
CALL Cleanup()
RETURN
END IF

!Set node clustering type
Init%InData_OpFM%NodeClusterType = ExternInitData%NodeClusterType
! set up the data structures for integration with OpenFOAM
CALL Init_OpFM( Init%InData_OpFM, p_FAST, AirDens, AD%Input(1), Init%OutData_AD, AD%y, OpFM, Init%OutData_OpFM, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName)
Expand Down
7 changes: 7 additions & 0 deletions modules/openfast-library/src/FAST_Types.f90
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ MODULE FAST_Types
CHARACTER(1024) :: RootName !< Root name of FAST output files (overrides normal operation) [-]
INTEGER(IntKi) :: NumActForcePtsBlade !< number of actuator line force points in blade [-]
INTEGER(IntKi) :: NumActForcePtsTower !< number of actuator line force points in tower [-]
INTEGER(IntKi) :: NodeClusterType !< Node clustering for actuator line (0 - Uniform, 1 - Non-uniform clustered towards tip) [-]
END TYPE FAST_ExternInitType
! =======================
! ========= FAST_TurbineType =======
Expand Down Expand Up @@ -48056,6 +48057,7 @@ SUBROUTINE FAST_CopyExternInitType( SrcExternInitTypeData, DstExternInitTypeData
DstExternInitTypeData%RootName = SrcExternInitTypeData%RootName
DstExternInitTypeData%NumActForcePtsBlade = SrcExternInitTypeData%NumActForcePtsBlade
DstExternInitTypeData%NumActForcePtsTower = SrcExternInitTypeData%NumActForcePtsTower
DstExternInitTypeData%NodeClusterType = SrcExternInitTypeData%NodeClusterType
END SUBROUTINE FAST_CopyExternInitType

SUBROUTINE FAST_DestroyExternInitType( ExternInitTypeData, ErrStat, ErrMsg, DEALLOCATEpointers )
Expand Down Expand Up @@ -48148,6 +48150,7 @@ SUBROUTINE FAST_PackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat,
Int_BufSz = Int_BufSz + 1*LEN(InData%RootName) ! RootName
Int_BufSz = Int_BufSz + 1 ! NumActForcePtsBlade
Int_BufSz = Int_BufSz + 1 ! NumActForcePtsTower
Int_BufSz = Int_BufSz + 1 ! NodeClusterType
IF ( Re_BufSz .GT. 0 ) THEN
ALLOCATE( ReKiBuf( Re_BufSz ), STAT=ErrStat2 )
IF (ErrStat2 /= 0) THEN
Expand Down Expand Up @@ -48247,6 +48250,8 @@ SUBROUTINE FAST_PackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Indata, ErrStat,
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = InData%NumActForcePtsTower
Int_Xferred = Int_Xferred + 1
IntKiBuf(Int_Xferred) = TRANSFER(InData%NodeClusterType, IntKiBuf(1))
Int_Xferred = Int_Xferred + 1
END SUBROUTINE FAST_PackExternInitType

SUBROUTINE FAST_UnPackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrStat, ErrMsg )
Expand Down Expand Up @@ -48362,6 +48367,8 @@ SUBROUTINE FAST_UnPackExternInitType( ReKiBuf, DbKiBuf, IntKiBuf, Outdata, ErrSt
Int_Xferred = Int_Xferred + 1
OutData%NumActForcePtsTower = IntKiBuf(Int_Xferred)
Int_Xferred = Int_Xferred + 1
OutData%NodeClusterType = TRANSFER(IntKiBuf(Int_Xferred), OutData%NodeClusterType)
Int_Xferred = Int_Xferred + 1
END SUBROUTINE FAST_UnPackExternInitType

SUBROUTINE FAST_CopyTurbineType( SrcTurbineTypeData, DstTurbineTypeData, CtrlCode, ErrStat, ErrMsg )
Expand Down
Loading

0 comments on commit 69e7121

Please sign in to comment.