Skip to content

Commit

Permalink
Update OpenFAST interface to work with OF-3.0 (Exawind#570)
Browse files Browse the repository at this point in the history
* Update fast_func arguments and data types for OF-3.0

* Added SC ifdefs for version specific OpenFAST integration

* Fixed formatting - extra whitespace

* More whitespace fixes

* Update CMakeLists.txt

Co-authored-by: Shreyas Ananthan <[email protected]>

* Newline fix

* Use target_compile_definitions instead of add_definitions

* Status message fix

* Status message removal

Co-authored-by: Shreyas Ananthan <[email protected]>
  • Loading branch information
ndevelder and sayerhs authored Mar 2, 2022
1 parent 51cde3e commit 5cceaf1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ if (AMR_WIND_ENABLE_OPENFAST)
if(OpenFAST_FOUND)
message(STATUS "Found OpenFAST = ${OPENFAST_DIR}")
endif()
include(CheckIncludeFileCXX)
set(CMAKE_REQUIRED_INCLUDES "${OpenFAST_INCLUDE_DIRS}")
check_include_file_cxx("SCDataEx_Types.h" USE_SCDX)
if(USE_SCDX)
target_compile_definitions(${amr_wind_lib_name} PUBLIC AMR_WIND_FAST_USE_SCDX)
endif()
target_compile_definitions(${amr_wind_lib_name} PUBLIC AMR_WIND_USE_OPENFAST)
target_include_directories(${amr_wind_lib_name} PUBLIC ${OpenFAST_INCLUDE_DIRS})
target_link_libraries(${amr_wind_lib_name} PUBLIC ${OpenFAST_LIBRARIES})
Expand Down
6 changes: 6 additions & 0 deletions amr-wind/wind_energy/actuator/turbine/fast/FastIface.H
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ protected:
int m_num_sc_inputs{0};
int m_num_sc_outputs{0};

#ifdef AMR_WIND_FAST_USE_SCDX
int m_num_sc_inputs_glob{0};
float m_init_sc_inputs_glob{0.0};
float m_init_sc_inputs_turbine{0.0};
#endif

bool m_is_initialized{false};
};

Expand Down
9 changes: 9 additions & 0 deletions amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,20 @@ void FastIface::fast_init_turbine(FastTurbine& fi)
char inp_file[fast_strlen()];
copy_filename(fi.input_file, inp_file);

#ifdef AMR_WIND_FAST_USE_SCDX
fast_func(
FAST_OpFM_Init, &fi.tid_local, &fi.stop_time, inp_file, &fi.tid_global,
&m_num_sc_inputs_glob, &m_num_sc_inputs, &m_num_sc_outputs,
&m_init_sc_inputs_glob, &m_init_sc_inputs_turbine, &fi.num_pts_blade,
&fi.num_pts_tower, fi.base_pos, &abort_lev, &fi.dt_fast, &fi.num_blades,
&fi.num_blade_elem, &fi.to_cfd, &fi.from_cfd, &fi.to_sc, &fi.from_sc);
#else
fast_func(
FAST_OpFM_Init, &fi.tid_local, &fi.stop_time, inp_file, &fi.tid_global,
&m_num_sc_inputs, &m_num_sc_outputs, &fi.num_pts_blade,
&fi.num_pts_tower, fi.base_pos, &abort_lev, &fi.dt_fast, &fi.num_blades,
&fi.num_blade_elem, &fi.to_cfd, &fi.from_cfd, &fi.to_sc, &fi.from_sc);
#endif

{
#ifdef AMR_WIND_USE_OPENFAST
Expand Down
5 changes: 5 additions & 0 deletions amr-wind/wind_energy/actuator/turbine/fast/fast_types.H
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ struct FastTurbine
exw_fast::OpFM_InputType to_cfd;
exw_fast::OpFM_OutputType from_cfd;

#ifdef AMR_WIND_FAST_USE_SCDX
exw_fast::SC_DX_InputType to_sc;
exw_fast::SC_DX_OutputType from_sc;
#else
exw_fast::SC_InputType to_sc;
exw_fast::SC_OutputType from_sc;
#endif
};

} // namespace exw_fast
Expand Down
21 changes: 21 additions & 0 deletions amr-wind/wind_energy/actuator/turbine/fast/fast_wrapper.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ struct OpFM_InputType
{};
struct OpFM_OutputType
{};

#ifdef AMR_WIND_FAST_USE_SCDX
struct SC_DX_InputType
{};
struct SC_DX_OutputType
{};
#else
struct SC_InputType
{};
struct SC_OutputType
{};
#endif

inline constexpr int fast_strlen() { return 1025; }

Expand All @@ -38,6 +46,18 @@ inline void FAST_OpFM_Solution0(int*, int*, char*) {}
inline void FAST_OpFM_Step(int*, int*, char*) {}

// clang-format off
#ifdef AMR_WIND_FAST_USE_SCDX
inline void FAST_OpFM_Init(
int*, double*, const char*, int*, int*, int*, int*, float*,
float*, int*, int*, float*, int*, double*, int*, int*,
OpFM_InputType*, OpFM_OutputType*, SC_DX_InputType*,
SC_DX_OutputType*, int*, char*) {}

inline void FAST_OpFM_Restart(
int*, char*, int*, double*, int*, int*, int*,
OpFM_InputType*, OpFM_OutputType*,
SC_DX_InputType*, SC_DX_OutputType*, int*, char*) {}
#else
inline void FAST_OpFM_Init(
int*, double*, const char*, int*, int*, int*, int*, int*, float*,
int*, double*, int*, int*, OpFM_InputType*, OpFM_OutputType*,
Expand All @@ -47,6 +67,7 @@ inline void FAST_OpFM_Restart(
int*, char*, int*, double*, int*, int*, int*,
OpFM_InputType*, OpFM_OutputType*,
SC_InputType*, SC_OutputType*, int*, char*) {}
#endif
// clang-format on
#endif
} // namespace exw_fast
Expand Down

0 comments on commit 5cceaf1

Please sign in to comment.