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

ExternalInflow: rename files, change names in files #1687

Merged
merged 3 commits into from
Jul 17, 2023
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ set(OPENFAST_MODULES
map
turbsim
supercontroller
openfoam
externalinflow
openfast-library
)

Expand Down
12 changes: 6 additions & 6 deletions glue-codes/openfast-cpp/src/OpenFAST.H
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <set>
#include <map>
#include "dlfcn.h"
//TODO: The skip MPICXX is put in place primarily to get around errors in OpenFOAM. This will cause problems if the driver program uses C++ API for MPI.
//TODO: The skip MPICXX is put in place primarily to get around errors in ExternalInflow. This will cause problems if the driver program uses C++ API for MPI.
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
Expand Down Expand Up @@ -115,8 +115,8 @@ class OpenFAST {
std::vector<std::vector<double> > velNodeData; // Position and velocity data at the velocity (aerodyn) nodes - (nTurbines, nTimesteps * nPoints * 6)
hid_t velNodeDataFile; // HDF-5 tag of file containing velocity (aerodyn) node data file

std::vector<OpFM_InputType_t> cDriver_Input_from_FAST;
std::vector<OpFM_OutputType_t> cDriver_Output_to_FAST;
std::vector<ExtInfw_InputType_t> cDriver_Input_from_FAST;
std::vector<ExtInfw_OutputType_t> cDriver_Output_to_FAST;

// Turbine Number is DIFFERENT from TurbID. Turbine Number simply runs from 0:n-1 locally and globally.
std::map<int, int> turbineMapGlobToProc; // Mapping global turbine number to processor number
Expand Down Expand Up @@ -171,7 +171,7 @@ class OpenFAST {

hid_t openVelocityDataFile(bool createFile);
void readVelocityData(int nTimesteps);
void writeVelocityData(hid_t h5file, int iTurb, int iTimestep, OpFM_InputType_t iData, OpFM_OutputType_t oData);
void writeVelocityData(hid_t h5file, int iTurb, int iTimestep, ExtInfw_InputType_t iData, ExtInfw_OutputType_t oData);
herr_t closeVelocityDataFile(int nt_global, hid_t velDataFile);
void backupVelocityDataFile(int curTimeStep, hid_t & velDataFile);

Expand Down Expand Up @@ -286,8 +286,8 @@ class OpenFAST {

void loadSuperController(const fastInputs & fi);

void setOutputsToFAST(OpFM_InputType_t cDriver_Input_from_FAST, OpFM_OutputType_t cDriver_Output_to_FAST) ; // An example to set velocities at the Aerodyn nodes
void applyVelocityData(int iPrestart, int iTurb, OpFM_OutputType_t cDriver_Output_to_FAST, std::vector<double> & velData) ;
void setOutputsToFAST(ExtInfw_InputType_t cDriver_Input_from_FAST, ExtInfw_OutputType_t cDriver_Output_to_FAST) ; // An example to set velocities at the Aerodyn nodes
void applyVelocityData(int iPrestart, int iTurb, ExtInfw_OutputType_t cDriver_Output_to_FAST, std::vector<double> & velData) ;

};

Expand Down
24 changes: 12 additions & 12 deletions glue-codes/openfast-cpp/src/OpenFAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void fast::OpenFAST::init() {
CheckpointFileRoot[iTurb].data() + (CheckpointFileRoot[iTurb].size() + 1),
currentFileName
);
FAST_OpFM_Restart(
FAST_ExtInfw_Restart(
&iTurb,
currentFileName,
&AbortErrLev,
Expand Down Expand Up @@ -116,7 +116,7 @@ void fast::OpenFAST::init() {
FASTInputFileName[iTurb].data() + (FASTInputFileName[iTurb].size() + 1),
currentFileName
);
FAST_OpFM_Init(
FAST_ExtInfw_Init(
&iTurb,
&tMax,
currentFileName,
Expand Down Expand Up @@ -186,7 +186,7 @@ void fast::OpenFAST::init() {
FASTInputFileName[iTurb].data() + (FASTInputFileName[iTurb].size() + 1),
currentFileName
);
FAST_OpFM_Init(
FAST_ExtInfw_Init(
&iTurb,
&tMax,
currentFileName,
Expand Down Expand Up @@ -275,7 +275,7 @@ void fast::OpenFAST::solution0() {
}

for (int iTurb=0; iTurb < nTurbinesProc; iTurb++) {
FAST_OpFM_Solution0(&iTurb, &ErrStat, ErrMsg);
FAST_ExtInfw_Solution0(&iTurb, &ErrStat, ErrMsg);
checkError(ErrStat, ErrMsg);
}

Expand All @@ -301,7 +301,7 @@ void fast::OpenFAST::step() {
// setOutputsToFAST(cDriver_Input_from_FAST[iTurb], cDriver_Output_to_FAST[iTurb]);

// this advances the states, calls CalcOutput, and solves for next inputs. Predictor-corrector loop is imbeded here:
// (note OpenFOAM could do subcycling around this step)
// (note ExternalInflow could do subcycling around this step)

writeVelocityData(velNodeDataFile, iTurb, nt_global, cDriver_Input_from_FAST[iTurb], cDriver_Output_to_FAST[iTurb]);

Expand All @@ -316,7 +316,7 @@ void fast::OpenFAST::step() {
fastcpp_velocity_file.close() ;
}

FAST_OpFM_Step(&iTurb, &ErrStat, ErrMsg);
FAST_ExtInfw_Step(&iTurb, &ErrStat, ErrMsg);
checkError(ErrStat, ErrMsg);

// Compute the force from the nacelle only if the drag coefficient is
Expand Down Expand Up @@ -394,8 +394,8 @@ void fast::OpenFAST::stepNoWrite() {
// setOutputsToFAST(cDriver_Input_from_FAST[iTurb], cDriver_Output_to_FAST[iTurb]);

// this advances the states, calls CalcOutput, and solves for next inputs. Predictor-corrector loop is imbeded here:
// (note OpenFOAM could do subcycling around this step)
FAST_OpFM_Step(&iTurb, &ErrStat, ErrMsg);
// (note ExternalInflow could do subcycling around this step)
FAST_ExtInfw_Step(&iTurb, &ErrStat, ErrMsg);
checkError(ErrStat, ErrMsg);

}
Expand Down Expand Up @@ -480,7 +480,7 @@ void fast::OpenFAST::checkError(const int ErrStat, const char * ErrMsg){
}
}

void fast::OpenFAST::setOutputsToFAST(OpFM_InputType_t cDriver_Input_from_FAST, OpFM_OutputType_t cDriver_Output_to_FAST){
void fast::OpenFAST::setOutputsToFAST(ExtInfw_InputType_t cDriver_Input_from_FAST, ExtInfw_OutputType_t cDriver_Output_to_FAST){

// routine sets the u-v-w wind speeds used in FAST and the SuperController inputs

Expand Down Expand Up @@ -848,7 +848,7 @@ void fast::OpenFAST::allocateMemory() {
// Allocate memory for Turbine datastructure for all turbines
FAST_AllocateTurbines(&nTurbinesProc, &ErrStat, ErrMsg);

// Allocate memory for OpFM Input types in FAST
// Allocate memory for ExtInfw Input types in FAST
cDriver_Input_from_FAST.resize(nTurbinesProc) ;
cDriver_Output_to_FAST.resize(nTurbinesProc) ;

Expand Down Expand Up @@ -994,7 +994,7 @@ void fast::OpenFAST::backupVelocityDataFile(int curTimeStep, hid_t & velDataFile
velDataFile = openVelocityDataFile(false);
}

void fast::OpenFAST::writeVelocityData(hid_t h5File, int iTurb, int iTimestep, OpFM_InputType_t iData, OpFM_OutputType_t oData) {
void fast::OpenFAST::writeVelocityData(hid_t h5File, int iTurb, int iTimestep, ExtInfw_InputType_t iData, ExtInfw_OutputType_t oData) {

hsize_t start[3]; start[0] = iTimestep; start[1] = 0; start[2] = 0;
int nVelPts = get_numVelPtsLoc(iTurb) ;
Expand Down Expand Up @@ -1028,7 +1028,7 @@ void fast::OpenFAST::writeVelocityData(hid_t h5File, int iTurb, int iTimestep, O

}

void fast::OpenFAST::applyVelocityData(int iPrestart, int iTurb, OpFM_OutputType_t cDriver_Output_to_FAST, std::vector<double> & velData) {
void fast::OpenFAST::applyVelocityData(int iPrestart, int iTurb, ExtInfw_OutputType_t cDriver_Output_to_FAST, std::vector<double> & velData) {
int nVelPts = get_numVelPtsLoc(iTurb);
for (int j = 0; j < nVelPts; j++){
cDriver_Output_to_FAST.u[j] = velData[(iPrestart*nVelPts+j)*6 + 3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
#

if (GENERATE_TYPES)
generate_f90_types(src/OpenFOAM_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/OpenFOAM_Types.f90 -ccode)
generate_f90_types(src/ExternalInflow_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/ExternalInflow_Types.f90 -ccode)
endif()

add_library(foamtypeslib STATIC
src/OpenFOAM_Types.f90
add_library(extinflowtypeslib STATIC
src/ExternalInflow_Types.f90
)
target_link_libraries(foamtypeslib nwtclibs)
target_link_libraries(extinflowtypeslib nwtclibs)

add_library(foamfastlib STATIC
src/OpenFOAM.f90
add_library(extinflowlib STATIC
src/ExternalInflow.f90
)
target_link_libraries(foamfastlib openfast_prelib)
target_include_directories(foamfastlib PUBLIC
target_link_libraries(extinflowlib openfast_prelib)
target_include_directories(extinflowlib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
set_target_properties(foamfastlib PROPERTIES PUBLIC_HEADER src/OpenFOAM_Types.h)
set_target_properties(extinflowlib PROPERTIES PUBLIC_HEADER src/ExternalInflow_Types.h)

install(TARGETS foamtypeslib foamfastlib
install(TARGETS extinflowtypeslib extinflowlib
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
Expand Down
5 changes: 5 additions & 0 deletions modules/externalinflow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ExternalInflow Module

## Overview
This is a pseudo module used to couple OpenFAST with CFD codes (NALU-Wind, AMR-Wind, SOWFA);
it is considered part of the OpenFAST glue code.
Loading
Loading