From 9402615ea51af18e6715bbc4372f942f1b0e5133 Mon Sep 17 00:00:00 2001 From: Jian Sun Date: Wed, 31 Jul 2024 10:31:19 -0600 Subject: [PATCH] Read THERMO variables from TDRP file (#85) * add thermo variables to TDRP fiel * read in the namelist variables required by thermo * fix some typos and add missing code * fix segmentation fault issue and read in thermo params correctly * Added notes to remember TODO items. --------- Co-authored-by: johnmauff --- ncar_scripts/TDRP/beltrami.tdrp | 3 +- ncar_scripts/TDRP/beltramiTR.tdrp | 113 ++++++++++++++++ src/Args.cpp | 22 ++++ src/CostFunction3D.cpp | 2 + src/Params.cc | 210 ++++++++++++++++++++++++++++++ src/Params.hh | 38 +++++- src/VarDriver3D.cpp | 6 +- src/paramdef.samurai | 111 ++++++++++++++++ 8 files changed, 501 insertions(+), 4 deletions(-) diff --git a/ncar_scripts/TDRP/beltrami.tdrp b/ncar_scripts/TDRP/beltrami.tdrp index 05b5b20..56c83d9 100644 --- a/ncar_scripts/TDRP/beltrami.tdrp +++ b/ncar_scripts/TDRP/beltrami.tdrp @@ -1233,5 +1233,4 @@ j_max_wavenumber = { -1, -1 }; // Type: float // 1D array - variable length. -k_max_wavenumber = { -1, -1 }; - +k_max_wavenumber = { -1, -1 }; \ No newline at end of file diff --git a/ncar_scripts/TDRP/beltramiTR.tdrp b/ncar_scripts/TDRP/beltramiTR.tdrp index ac73bd8..fa5763c 100644 --- a/ncar_scripts/TDRP/beltramiTR.tdrp +++ b/ncar_scripts/TDRP/beltramiTR.tdrp @@ -1235,3 +1235,116 @@ j_max_wavenumber = { -1, -1 }; k_max_wavenumber = { -1, -1 }; +//====================================================================== +// +// VARIABLES NEEDED BY THERMO. +// +//====================================================================== + +///////////// i_pip_bcL /////////////////////////////// +// +// Type: int + +i_pip_bcL = -1; + +///////////// i_pip_bcR /////////////////////////////// +// +// Type: int + +i_pip_bcR = -1; + +///////////// i_thetarhop_bcL /////////////////////////////// +// +// Type: int + +i_thetarhop_bcL = -1; + +///////////// i_thetarhop_bcR /////////////////////////////// +// +// Type: int + +i_thetarhop_bcR = -1; + +///////////// i_ftheta_bcL /////////////////////////////// +// +// Type: int + +i_ftheta_bcL = -1; + +///////////// i_ftheta_bcR /////////////////////////////// +// +// Type: int + +i_ftheta_bcR = -1; + +///////////// j_pip_bcL /////////////////////////////// +// +// Type: int + +j_pip_bcL = -1; + +///////////// j_pip_bcR /////////////////////////////// +// +// Type: int + +j_pip_bcR = -1; + +///////////// j_thetarhop_bcL /////////////////////////////// +// +// Type: int + +j_thetarhop_bcL = -1; + +///////////// j_thetarhop_bcR /////////////////////////////// +// +// Type: int + +j_thetarhop_bcR = -1; + +///////////// j_ftheta_bcL /////////////////////////////// +// +// Type: int + +j_ftheta_bcL = -1; + +///////////// j_ftheta_bcR /////////////////////////////// +// +// Type: int + +j_ftheta_bcR = -1; + +///////////// k_pip_bcL /////////////////////////////// +// +// Type: int + +k_pip_bcL = -1; + +///////////// k_pip_bcR /////////////////////////////// +// +// Type: int + +k_pip_bcR = -1; + +///////////// k_thetarhop_bcL /////////////////////////////// +// +// Type: int + +k_thetarhop_bcL = -1; + +///////////// k_thetarhop_bcR /////////////////////////////// +// +// Type: int + +k_thetarhop_bcR = -1; + +///////////// k_ftheta_bcL /////////////////////////////// +// +// Type: int + +k_ftheta_bcL = -1; + +///////////// k_ftheta_bcR /////////////////////////////// +// +// Type: int + +k_ftheta_bcR = -1; \ No newline at end of file diff --git a/src/Args.cpp b/src/Args.cpp index e2aafda..c73e876 100644 --- a/src/Args.cpp +++ b/src/Args.cpp @@ -308,5 +308,27 @@ bool Args::paramsToHash(HashMap *configHash) { CONFIG_INSERT_FLOAT_ARRAY(neumann_v_weight, iter); CONFIG_INSERT_FLOAT_ARRAY(dirichlet_w_weight, iter); } + // arguments required by THERMO + CONFIG_INSERT_INT(i_pip_bcL); + CONFIG_INSERT_INT(i_pip_bcR); + CONFIG_INSERT_INT(i_thetarhop_bcL); + CONFIG_INSERT_INT(i_thetarhop_bcR); + CONFIG_INSERT_INT(i_ftheta_bcL); + CONFIG_INSERT_INT(i_ftheta_bcR); + + CONFIG_INSERT_INT(j_pip_bcL); + CONFIG_INSERT_INT(j_pip_bcR); + CONFIG_INSERT_INT(j_thetarhop_bcL); + CONFIG_INSERT_INT(j_thetarhop_bcR); + CONFIG_INSERT_INT(j_ftheta_bcL); + CONFIG_INSERT_INT(j_ftheta_bcR); + + CONFIG_INSERT_INT(k_pip_bcL); + CONFIG_INSERT_INT(k_pip_bcR); + CONFIG_INSERT_INT(k_thetarhop_bcL); + CONFIG_INSERT_INT(k_thetarhop_bcR); + CONFIG_INSERT_INT(k_ftheta_bcL); + CONFIG_INSERT_INT(k_ftheta_bcR); + return true; } diff --git a/src/CostFunction3D.cpp b/src/CostFunction3D.cpp index 6ecaccc..778f643 100644 --- a/src/CostFunction3D.cpp +++ b/src/CostFunction3D.cpp @@ -147,6 +147,8 @@ void CostFunction3D::initialize(HashMap* config, dataPath = (*configHash)["data_directory"]; outputPath = (*configHash)["output_directory"]; + //JMD TODO: Need to plug in the Thermo boundary conditions here. + //JMD Currently this is only the wind boundary condidtions. // Horizontal boundary conditions iBCL[0] = bcHash[(*configHash)["i_rhou_bcL"]]; iBCR[0] = bcHash[(*configHash)["i_rhou_bcR"]]; diff --git a/src/Params.cc b/src/Params.cc index 5370d4f..6e6f1ff 100644 --- a/src/Params.cc +++ b/src/Params.cc @@ -2999,7 +2999,217 @@ tt->array_vals[0].f = -1; tt->array_vals[1].f = -1; tt++; + + // Parameter 'Comment 15' + + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = COMMENT_TYPE; + tt->param_name = tdrpStrDup("Comment 15"); + tt->comment_hdr = tdrpStrDup("VARIABLES NEEDED BY THERMO"); + tt->comment_text = tdrpStrDup(""); + tt++; + + // Parameter 'i_pip_bcL' + // ctype is 'int' + + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("i_pip_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &i_pip_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'i_pip_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("i_pip_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &i_pip_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'i_thetarhop_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("i_thetarhop_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &i_thetarhop_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'i_thetarhop_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("i_thetarhop_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &i_thetarhop_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'i_ftheta_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("i_ftheta_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &i_ftheta_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'i_ftheta_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("i_ftheta_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &i_ftheta_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'j_pip_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("j_pip_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &j_pip_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'j_pip_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("j_pip_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &j_pip_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'j_thetarhop_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("j_thetarhop_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &j_thetarhop_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'j_thetarhop_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("j_thetarhop_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &j_thetarhop_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'j_ftheta_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("j_ftheta_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &j_ftheta_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'j_ftheta_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("j_ftheta_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &j_ftheta_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'k_pip_bcL' + // ctype is 'int' + + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("k_pip_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &k_pip_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'k_pip_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("k_pip_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &k_pip_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'k_thetarhop_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("k_thetarhop_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &k_thetarhop_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'k_thetarhop_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("k_thetarhop_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &k_thetarhop_bcR - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'k_ftheta_bcL' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("k_ftheta_bcL"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &k_ftheta_bcL - &_start_; + tt->single_val.i = -999; + tt++; + + // Parameter 'k_ftheta_bcR' + // ctype is 'int' + memset(tt, 0, sizeof(TDRPtable)); + tt->ptype = INT_TYPE; + tt->param_name = tdrpStrDup("k_ftheta_bcR"); + tt->descr = tdrpStrDup(""); + tt->help = tdrpStrDup(""); + tt->val_offset = (char *) &k_ftheta_bcR - &_start_; + tt->single_val.i = -999; + tt++; + // trailing entry has param_name set to NULL tt->param_name = NULL; diff --git a/src/Params.hh b/src/Params.hh index 1fb2f93..14a725f 100644 --- a/src/Params.hh +++ b/src/Params.hh @@ -756,6 +756,42 @@ public: float *_k_max_wavenumber; int k_max_wavenumber_n; + int i_pip_bcL; + + int i_pip_bcR; + + int i_thetarhop_bcL; + + int i_thetarhop_bcR; + + int i_ftheta_bcL; + + int i_ftheta_bcR; + + int j_pip_bcL; + + int j_pip_bcR; + + int j_thetarhop_bcL; + + int j_thetarhop_bcR; + + int j_ftheta_bcL; + + int j_ftheta_bcR; + + int k_pip_bcL; + + int k_pip_bcR; + + int k_thetarhop_bcL; + + int k_thetarhop_bcR; + + int k_ftheta_bcL; + + int k_ftheta_bcR; + char _end_; // end of data region // needed for zeroing out data @@ -763,7 +799,7 @@ private: void _init(); - mutable TDRPtable _table[191]; + mutable TDRPtable _table[210]; const char *_className; diff --git a/src/VarDriver3D.cpp b/src/VarDriver3D.cpp index 4096417..d8912e7 100644 --- a/src/VarDriver3D.cpp +++ b/src/VarDriver3D.cpp @@ -103,7 +103,11 @@ bool VarDriver3D::validateDriver() // Print the analysis_type from the TDRP config file std::cout << "Analysis type: " << configHash["analysis_type"] << std::endl; - if(configHash["analysis_type"] != "WIND") { + if(configHash["analysis_type"] != "WIND") + { + std::cout << "i_pip_bcL = " << configHash["i_pip_bcL"] << std::endl; + std::cout << "j_pip_bcR = " << configHash["j_pip_bcR"] << std::endl; + std::cout << "k_ftheta_bcL = " << configHash["k_ftheta_bcL"] << std::endl; std::cout << "Currently unsupported Analysis type: " << configHash["analysis_type"] << ", Aborting..." << std::endl; return false; } diff --git a/src/paramdef.samurai b/src/paramdef.samurai index db401e2..32f3929 100644 --- a/src/paramdef.samurai +++ b/src/paramdef.samurai @@ -1131,4 +1131,115 @@ paramdef float { p_help = ""; } k_max_wavenumber[]; +commentdef { + p_header = "VARIABLES NEEDED BY THERMO"; + p_help = ""; +} + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} i_pip_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} i_pip_bcR; +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} i_thetarhop_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} i_thetarhop_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} i_ftheta_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} i_ftheta_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} j_pip_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} j_pip_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} j_thetarhop_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} j_thetarhop_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} j_ftheta_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} j_ftheta_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} k_pip_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} k_pip_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} k_thetarhop_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} k_thetarhop_bcR; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} k_ftheta_bcL; + +paramdef int { + p_default = -999; + p_descr = ""; + p_help = ""; +} k_ftheta_bcR; \ No newline at end of file