diff --git a/Exec/Make.auto_source b/Exec/Make.auto_source index 178e0f43e2..77b48e8fb3 100644 --- a/Exec/Make.auto_source +++ b/Exec/Make.auto_source @@ -69,7 +69,7 @@ CPP_PARAMETERS := $(TOP)/Source/driver/_cpp_parameters $(CASTRO_AUTO_SOURCE_DIR)/castro_params.H: $(CPP_PARAMETERS) @if [ ! -d $(CASTRO_AUTO_SOURCE_DIR) ]; then mkdir -p $(CASTRO_AUTO_SOURCE_DIR); fi - PYTHONPATH=$(MICROPHYSICS_HOME)/util/build_scripts $(TOP)/Source/driver/parse_castro_params.py -o $(CASTRO_AUTO_SOURCE_DIR) $(CPP_PARAMETERS) + PYTHONPATH=$(MICROPHYSICS_HOME)/util/build_scripts $(TOP)/Source/driver/parse_castro_params.py --constexpr -o $(CASTRO_AUTO_SOURCE_DIR) $(CPP_PARAMETERS) # for debugging test_cxx_params: $(CASTRO_AUTO_SOURCE_DIR)/castro_params.H diff --git a/Source/driver/Castro.cpp b/Source/driver/Castro.cpp index f10c59b0e7..ae47a6b380 100644 --- a/Source/driver/Castro.cpp +++ b/Source/driver/Castro.cpp @@ -415,9 +415,9 @@ Castro::read_params () } // Make sure not to call refluxing if we're not actually doing any hydro. - if (do_hydro == 0) { - do_reflux = 0; - } +// if (do_hydro == 0) { +// do_reflux = 0; +// } if (max_dt < fixed_dt) { @@ -475,9 +475,9 @@ Castro::read_params () } } - if (dgeom.IsRZ() == 1) { - rot_axis = 2; - } +// if (dgeom.IsRZ() == 1) { +// rot_axis = 2; +// } #if (AMREX_SPACEDIM == 1) if (do_rotation == 1) { std::cerr << "ERROR:Castro::Rotation not implemented in 1d\n"; @@ -2070,7 +2070,8 @@ Castro::post_timestep (int iteration_local) Real max_field_val = std::numeric_limits::min(); for (int lev = 0; lev <= parent->finestLevel(); ++lev) { - auto mf = getLevel(lev).derive(castro::stopping_criterion_field, state[State_Type].curTime(), 0); + std::string scf{castro::stopping_criterion_field}; + auto mf = getLevel(lev).derive(scf, state[State_Type].curTime(), 0); max_field_val = std::max(max_field_val, mf->max(0)); } diff --git a/Source/driver/Castro_advance_ctu.cpp b/Source/driver/Castro_advance_ctu.cpp index 911a2780e9..ebd22a4480 100644 --- a/Source/driver/Castro_advance_ctu.cpp +++ b/Source/driver/Castro_advance_ctu.cpp @@ -364,7 +364,7 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration, // approximately compensate for that. if (in_retry) { - sdc_iters += 1; + //sdc_iters += 1; amrex::Print() << "Adding an SDC iteration due to the retry." << std::endl << std::endl; } @@ -412,7 +412,7 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration, // Set sdc_iters to its original value, in case we modified it above. - sdc_iters = sdc_iters_old; + //sdc_iters = sdc_iters_old; // If we're allowing for retries, check for that here. diff --git a/Source/driver/Castro_io.cpp b/Source/driver/Castro_io.cpp index ea0336669e..e31697d60c 100644 --- a/Source/driver/Castro_io.cpp +++ b/Source/driver/Castro_io.cpp @@ -181,7 +181,8 @@ Castro::restart (Amr& papa, PMFile.open(FullPathPMFile.c_str(), std::ios::in); if (PMFile.good()) { - PMFile >> point_mass; + Real pm; + PMFile >> pm; // point_mass; PMFile.close(); } @@ -198,7 +199,8 @@ Castro::restart (Amr& papa, RotationFile.open(FullPathRotationFile.c_str(), std::ios::in); if (RotationFile.is_open()) { - RotationFile >> castro::rotational_period; + Real rp; + RotationFile >> rp; //castro::rotational_period; amrex::Print() << " Based on the checkpoint, setting the rotational period to " << std::setprecision(7) << std::fixed << castro::rotational_period << " s.\n"; RotationFile.close(); diff --git a/Source/driver/Castro_setup.cpp b/Source/driver/Castro_setup.cpp index 9506fdde2c..4c22e10f03 100644 --- a/Source/driver/Castro_setup.cpp +++ b/Source/driver/Castro_setup.cpp @@ -209,6 +209,7 @@ Castro::variableSetUp () // set small positive values of the "small" quantities if they are // negative +#if 0 if (small_dens < 0.0_rt) { small_dens = 1.e-100_rt; } @@ -224,13 +225,16 @@ Castro::variableSetUp () if (small_ener < 0.0_rt) { small_ener = 1.e-100_rt; } +#endif // now initialize the C++ Microphysics #ifdef REACTIONS network_init(); #endif - eos_init(castro::small_temp, castro::small_dens); + Real st{castro::small_temp}; + Real sd{castro::small_dens}; + eos_init(st, sd); #ifdef RADIATION opacity_init(); @@ -240,11 +244,11 @@ Castro::variableSetUp () // with the minimum permitted by the EOS, and vice versa. Real new_min_T = std::max(small_temp, EOSData::mintemp); - small_temp = new_min_T; + //small_temp = new_min_T; EOSData::mintemp = new_min_T; Real new_min_rho = std::max(small_dens, EOSData::mindens); - small_dens = new_min_rho; + //small_dens = new_min_rho; EOSData::mindens = new_min_rho; // Given small_temp and small_dens, compute small_pres @@ -267,8 +271,8 @@ Castro::variableSetUp () eos(eos_input_rt, eos_state); - castro::small_pres = amrex::max(castro::small_pres, eos_state.p); - castro::small_ener = amrex::max(castro::small_ener, eos_state.e); + //castro::small_pres = amrex::max(castro::small_pres, eos_state.p); + //castro::small_ener = amrex::max(castro::small_ener, eos_state.e); // some consistency checks on the parameters #ifdef REACTIONS diff --git a/Source/driver/parse_castro_params.py b/Source/driver/parse_castro_params.py index aedeea6624..f742be2bba 100755 --- a/Source/driver/parse_castro_params.py +++ b/Source/driver/parse_castro_params.py @@ -129,7 +129,7 @@ def read_param_file(infile): return params -def write_headers(params, out_directory, struct_name): +def write_headers(params, out_directory, struct_name, constexpr): # output @@ -152,19 +152,23 @@ def write_headers(params, out_directory, struct_name): cd.write(f"#ifndef {nm.upper()}_DECLARES_H\n") cd.write(f"#define {nm.upper()}_DECLARES_H\n") - cd.write("\n") - cd.write(f"namespace {nm} {{\n") - - for ifdef in ifdefs: - if ifdef is None: - for p in [q for q in params_nm if q.ifdef is None]: - cd.write(p.get_declare_string()) - else: - cd.write(f"#ifdef {ifdef}\n") - for p in [q for q in params_nm if q.ifdef == ifdef]: - cd.write(p.get_declare_string()) - cd.write("#endif\n") - cd.write("}\n\n") + if constexpr: + pass + else: + cd.write("\n") + cd.write(f"namespace {nm} {{\n") + + for ifdef in ifdefs: + if ifdef is None: + for p in [q for q in params_nm if q.ifdef is None]: + cd.write(p.get_declare_string()) + else: + cd.write(f"#ifdef {ifdef}\n") + for p in [q for q in params_nm if q.ifdef == ifdef]: + cd.write(p.get_declare_string()) + cd.write("#endif\n") + + cd.write("}\n\n") cd.write("#endif\n") cd.close() @@ -177,19 +181,27 @@ def write_headers(params, out_directory, struct_name): cp.write(CWARNING) cp.write(f"#ifndef {nm.upper()}_PARAMS_H\n") cp.write(f"#define {nm.upper()}_PARAMS_H\n") - + cp.write("#include \n") + cp.write(f"using namespace amrex::literals;\n") cp.write("\n") cp.write(f"namespace {nm} {{\n") - for ifdef in ifdefs: - if ifdef is None: - for p in [q for q in params_nm if q.ifdef is None]: - cp.write(p.get_declare_string(with_extern=True)) - else: - cp.write(f"#ifdef {ifdef}\n") - for p in [q for q in params_nm if q.ifdef == ifdef]: - cp.write(p.get_declare_string(with_extern=True)) - cp.write("#endif\n") + if constexpr: + for p in params_nm: + type = p.get_cxx_decl() + if type == "std::string": + type = "std::string_view" + cp.write(f"constexpr {type} {p.cpp_var_name}{{{p.default_format()}}};\n") + else: + for ifdef in ifdefs: + if ifdef is None: + for p in [q for q in params_nm if q.ifdef is None]: + cp.write(p.get_declare_string(with_extern=True)) + else: + cp.write(f"#ifdef {ifdef}\n") + for p in [q for q in params_nm if q.ifdef == ifdef]: + cp.write(p.get_declare_string(with_extern=True)) + cp.write("#endif\n") cp.write("}\n\n") cp.write("#endif\n") cp.close() @@ -202,22 +214,25 @@ def write_headers(params, out_directory, struct_name): cq.write(CWARNING) - for ifdef in ifdefs: - if ifdef is None: - for p in [q for q in params_nm if q.ifdef is None]: - cq.write(p.get_default_string()) - cq.write(p.get_query_string()) - cq.write(p.get_query_struct_string(struct_name=struct_name, class_name="Castro")) - cq.write("\n") - else: - cq.write(f"#ifdef {ifdef}\n") - for p in [q for q in params_nm if q.ifdef == ifdef]: - cq.write(p.get_default_string()) - cq.write(p.get_query_string()) - cq.write(p.get_query_struct_string(struct_name=struct_name, class_name="Castro")) - cq.write("\n") - cq.write("#endif\n") - cq.write("\n") + if constexpr: + pass + else: + for ifdef in ifdefs: + if ifdef is None: + for p in [q for q in params_nm if q.ifdef is None]: + cq.write(p.get_default_string()) + cq.write(p.get_query_string()) + cq.write(p.get_query_struct_string(struct_name=struct_name, class_name="Castro")) + cq.write("\n") + else: + cq.write(f"#ifdef {ifdef}\n") + for p in [q for q in params_nm if q.ifdef == ifdef]: + cq.write(p.get_default_string()) + cq.write(p.get_query_string()) + cq.write(p.get_query_struct_string(struct_name=struct_name, class_name="Castro")) + cq.write("\n") + cq.write("#endif\n") + cq.write("\n") cq.close() # write the job info tests @@ -289,13 +304,15 @@ def main(): help="output directory for the generated files") parser.add_argument("-s", type=str, default="params", help="name for the name struct that will hold the parameters") + parser.add_argument("--constexpr", action="store_true", + help="force the parameters to be constexpr without being able to query") parser.add_argument("input_file", type=str, nargs=1, help="input file containing the list of parameters we will define") args = parser.parse_args() p = read_param_file(args.input_file[0]) - write_headers(p, args.o, args.s) + write_headers(p, args.o, args.s, args.constexpr) if __name__ == "__main__": main() diff --git a/Source/gravity/Castro_pointmass.cpp b/Source/gravity/Castro_pointmass.cpp index 1bbdca2050..485a3b6886 100644 --- a/Source/gravity/Castro_pointmass.cpp +++ b/Source/gravity/Castro_pointmass.cpp @@ -103,7 +103,7 @@ Castro::pointmass_update(Real time, Real dt) << ", to " << point_mass + mass_change_at_center << std::endl << std::endl; } - point_mass += mass_change_at_center; + //point_mass += mass_change_at_center; #ifdef _OPENMP #pragma omp parallel diff --git a/Source/gravity/Gravity.cpp b/Source/gravity/Gravity.cpp index 6665b0ef38..df6b046211 100644 --- a/Source/gravity/Gravity.cpp +++ b/Source/gravity/Gravity.cpp @@ -342,7 +342,7 @@ Gravity::install_level (int level, std::string Gravity::get_gravity_type() { - return gravity::gravity_type; + return std::string{gravity::gravity_type}; } int Gravity::get_max_solve_level() diff --git a/Source/scf/scf_relax.cpp b/Source/scf/scf_relax.cpp index 1add2074e3..796a188a0b 100644 --- a/Source/scf/scf_relax.cpp +++ b/Source/scf/scf_relax.cpp @@ -327,7 +327,7 @@ Castro::do_hscf_solve() if (std::abs(scf_polar_radius - scf_equatorial_radius) / std::abs(scf_equatorial_radius) < 1.e-6) { - rotational_period = 0.0; + //rotational_period = 0.0; } else { @@ -344,9 +344,9 @@ Castro::do_hscf_solve() // Let's also be sure not to let the period // change by too much in a single iteration. - rotational_period = amrex::min(1.1_rt * rotational_period, - amrex::max(0.9_rt * rotational_period, - 2.0_rt * M_PI / omega)); + //rotational_period = amrex::min(1.1_rt * rotational_period, + // amrex::max(0.9_rt * rotational_period, + // 2.0_rt * M_PI / omega)); }