diff --git a/CMakeLists.txt b/CMakeLists.txt index 3df72b3f56..2bf4587188 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/amr-wind/wind_energy/actuator/turbine/fast/FastIface.H b/amr-wind/wind_energy/actuator/turbine/fast/FastIface.H index a8d80c33d7..d3a6ed45be 100644 --- a/amr-wind/wind_energy/actuator/turbine/fast/FastIface.H +++ b/amr-wind/wind_energy/actuator/turbine/fast/FastIface.H @@ -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}; }; diff --git a/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp b/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp index 1c2b9ac1eb..c3430e8448 100644 --- a/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp +++ b/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp @@ -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 diff --git a/amr-wind/wind_energy/actuator/turbine/fast/fast_types.H b/amr-wind/wind_energy/actuator/turbine/fast/fast_types.H index ff22a9e6af..2e0c9f7695 100644 --- a/amr-wind/wind_energy/actuator/turbine/fast/fast_types.H +++ b/amr-wind/wind_energy/actuator/turbine/fast/fast_types.H @@ -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 diff --git a/amr-wind/wind_energy/actuator/turbine/fast/fast_wrapper.H b/amr-wind/wind_energy/actuator/turbine/fast/fast_wrapper.H index b7ed23faae..1196ff8df9 100644 --- a/amr-wind/wind_energy/actuator/turbine/fast/fast_wrapper.H +++ b/amr-wind/wind_energy/actuator/turbine/fast/fast_wrapper.H @@ -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; } @@ -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*, @@ -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