From 69fb0b87f6f55e74dd909085e9ef6d0bf4768aa3 Mon Sep 17 00:00:00 2001 From: Ganesh Vijayakumar Date: Mon, 11 Dec 2023 12:10:04 -0700 Subject: [PATCH] Fix issues to get C++ API to run --- glue-codes/openfast-cpp/src/FAST_Prog.cpp | 7 +++++-- glue-codes/openfast-cpp/src/OpenFAST.cpp | 16 +++++++++++++--- modules/openfast-library/src/FAST_Library.f90 | 12 +++++++++--- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/glue-codes/openfast-cpp/src/FAST_Prog.cpp b/glue-codes/openfast-cpp/src/FAST_Prog.cpp index ab68e388ef..1143313b3e 100644 --- a/glue-codes/openfast-cpp/src/FAST_Prog.cpp +++ b/glue-codes/openfast-cpp/src/FAST_Prog.cpp @@ -71,6 +71,9 @@ void readTurbineData(int iTurb, fast::fastInputs & fi, YAML::Node turbNode) { get_if_present(turbNode, "num_force_pts_blade", fi.globTurbineData[iTurb].numForcePtsBlade, 0); get_if_present(turbNode, "num_force_pts_tower", fi.globTurbineData[iTurb].numForcePtsTwr, 0); + fi.globTurbineData[iTurb].numForcePts = + fi.globTurbineData[iTurb].numForcePtsBlade + + fi.globTurbineData[iTurb].numForcePtsTwr; float fZero = 0.0; get_if_present(turbNode, "nacelle_cd", fi.globTurbineData[iTurb].nacelle_cd, fZero); @@ -145,7 +148,7 @@ void readInputFile(fast::fastInputs & fi, std::string cInterfaceInputFile, doubl get_if_present(cDriverInp, "set_exp_law_wind", *setExpLawWind, false); get_if_present(cDriverInp, "set_uniform_x_blade_forces", *setUniformXBladeForces, false); if (setUniformXBladeForces) - get_required(cDriverInp, "x_blade_force", *xBladeForce); + get_if_present(cDriverInp, "x_blade_force", *xBladeForce, 0.0); get_if_present(cDriverInp, "super_controller", fi.scStatus, false); if(fi.scStatus) { @@ -197,7 +200,7 @@ int main(int argc, char** argv) { bool setUniformXBladeForces; // Set uniform X blade forces on all blade nodes int nIter; double xBladeForce = 0.0; - + std::string cDriverInputFile=argv[1]; fast::OpenFAST FAST; fast::fastInputs fi ; diff --git a/glue-codes/openfast-cpp/src/OpenFAST.cpp b/glue-codes/openfast-cpp/src/OpenFAST.cpp index 0b002df101..d9fd1cb20c 100644 --- a/glue-codes/openfast-cpp/src/OpenFAST.cpp +++ b/glue-codes/openfast-cpp/src/OpenFAST.cpp @@ -224,7 +224,8 @@ void fast::OpenFAST::prepareRestartFile(int iTurbLoc) { ierr = nc_enddef(ncid); check_nc_error(ierr, "nc_enddef"); - if (turbineData[iTurbLoc].sType == EXTINFLOW) { + if ( (turbineData[iTurbLoc].sType == EXTINFLOW) && (turbineData[iTurbLoc].inflowType == 2) ) { + int nfpts_data = 3*get_numForcePtsLoc(iTurbLoc); int ierr = nc_put_var_double(ncid, ncRstVarIDs_["xref_force"], velForceNodeData[iTurbLoc][fast::STATE_NP1].xref_force.data()); } @@ -729,6 +730,8 @@ void fast::OpenFAST::init() { ErrMsg); checkError(ErrStat, ErrMsg); + std::cerr << "turbineData[iTurb].inflowType = " << turbineData[iTurb].inflowType << std::endl; + turbineData[iTurb].numVelPtsTwr = extinfw_o_t_FAST[iTurb].u_Len - turbineData[iTurb].numBlades*turbineData[iTurb].numVelPtsBlade - 1; if(turbineData[iTurb].numVelPtsTwr == 0) { turbineData[iTurb].numForcePtsTwr = 0; @@ -2118,6 +2121,11 @@ void fast::OpenFAST::allocateMemory_postInit(int iTurbLoc) { } } } + std::cerr << "turbineData[iTurbLoc].inflowType " << turbineData[iTurbLoc].inflowType << std::endl; + std::cerr << "turbineData[iTurbLoc].numForcePtsTwr = " << turbineData[iTurbLoc].numForcePtsTwr << std::endl; + std::cerr << "turbineData[iTurbLoc].numForcePtsBlade = " << turbineData[iTurbLoc].numForcePtsBlade << std::endl; + std::cerr << "turbineData[iTurbLoc].numForcePts = " << turbineData[iTurbLoc].numForcePts << std::endl; + } else if (turbineData[iTurbLoc].sType == EXTLOADS) { turbineData[iTurbLoc].nBRfsiPtsBlade.resize(turbineData[iTurbLoc].numBlades); @@ -2360,6 +2368,8 @@ void fast::OpenFAST::get_data_from_openfast(timeStep t) { if (turbineData[iTurb].inflowType == 2) { int nvelpts = get_numVelPtsLoc(iTurb); int nfpts = get_numForcePtsLoc(iTurb); + std::cerr << "nvelpts = " << nvelpts << std::endl; + std::cerr << "nfpts = " << nfpts << " " << get_numForcePtsBladeLoc(iTurb) << " " << get_numForcePtsTwrLoc(iTurb) << std::endl; for (int i=0; i