diff options
Diffstat (limited to 'Source/WarpX.cpp')
-rw-r--r-- | Source/WarpX.cpp | 230 |
1 files changed, 136 insertions, 94 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index aa6301a6e..7f697f668 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -166,7 +166,7 @@ bool WarpX::refine_plasma = false; int WarpX::num_mirrors = 0; -IntervalsParser WarpX::sort_intervals; +utils::parser::IntervalsParser WarpX::sort_intervals; amrex::IntVect WarpX::sort_bin_size(AMREX_D_DECL(1,1,1)); bool WarpX::do_back_transformed_diagnostics = false; @@ -454,8 +454,8 @@ WarpX::ReadParameters () { ParmParse pp;// Traditionally, max_step and stop_time do not have prefix. - queryWithParser(pp, "max_step", max_step); - queryWithParser(pp, "stop_time", stop_time); + utils::parser::queryWithParser(pp, "max_step", max_step); + utils::parser::queryWithParser(pp, "stop_time", stop_time); pp.query("authors", authors); } @@ -500,7 +500,9 @@ WarpX::ReadParameters () } std::vector<int> numprocs_in; - queryArrWithParser(pp_warpx, "numprocs", numprocs_in, 0, AMREX_SPACEDIM); + utils::parser::queryArrWithParser( + pp_warpx, "numprocs", numprocs_in, 0, AMREX_SPACEDIM); + if (not numprocs_in.empty()) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE (numprocs_in.size() == AMREX_SPACEDIM, @@ -578,20 +580,22 @@ WarpX::ReadParameters () } } - queryWithParser(pp_warpx, "cfl", cfl); + utils::parser::queryWithParser(pp_warpx, "cfl", cfl); pp_warpx.query("verbose", verbose); - queryWithParser(pp_warpx, "regrid_int", regrid_int); + utils::parser::queryWithParser(pp_warpx, "regrid_int", regrid_int); pp_warpx.query("do_subcycling", do_subcycling); pp_warpx.query("do_multi_J", do_multi_J); if (do_multi_J) { - getWithParser(pp_warpx, "do_multi_J_n_depositions", do_multi_J_n_depositions); + utils::parser::getWithParser( + pp_warpx, "do_multi_J_n_depositions", do_multi_J_n_depositions); } pp_warpx.query("use_hybrid_QED", use_hybrid_QED); pp_warpx.query("safe_guard_cells", safe_guard_cells); std::vector<std::string> override_sync_intervals_string_vec = {"1"}; pp_warpx.queryarr("override_sync_intervals", override_sync_intervals_string_vec); - override_sync_intervals = IntervalsParser(override_sync_intervals_string_vec); + override_sync_intervals = + utils::parser::IntervalsParser(override_sync_intervals_string_vec); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(do_subcycling != 1 || max_level <= 1, "Subcycling method 1 only works for 2 levels."); @@ -602,15 +606,17 @@ WarpX::ReadParameters () // queryWithParser returns 1 if argument zmax_plasma_to_compute_max_step is // specified by the user, 0 otherwise. - do_compute_max_step_from_zmax = - queryWithParser(pp_warpx, "zmax_plasma_to_compute_max_step", - zmax_plasma_to_compute_max_step); + do_compute_max_step_from_zmax = utils::parser::queryWithParser( + pp_warpx, "zmax_plasma_to_compute_max_step", + zmax_plasma_to_compute_max_step); pp_warpx.query("do_moving_window", do_moving_window); if (do_moving_window) { - queryWithParser(pp_warpx, "start_moving_window_step", start_moving_window_step); - queryWithParser(pp_warpx, "end_moving_window_step", end_moving_window_step); + utils::parser::queryWithParser( + pp_warpx, "start_moving_window_step", start_moving_window_step); + utils::parser::queryWithParser( + pp_warpx, "end_moving_window_step", end_moving_window_step); std::string s; pp_warpx.get("moving_window_dir", s); if (s == "x" || s == "X") { @@ -633,7 +639,8 @@ WarpX::ReadParameters () moving_window_x = geom[0].ProbLo(moving_window_dir); - getWithParser(pp_warpx, "moving_window_v", moving_window_v); + utils::parser::getWithParser( + pp_warpx, "moving_window_v", moving_window_v); moving_window_v *= PhysConst::c; } @@ -650,20 +657,25 @@ WarpX::ReadParameters () WARPX_ALWAYS_ASSERT_WITH_MESSAGE( (s == "z" || s == "Z"), "The boosted frame diagnostic currently only works if the boost is in the z direction."); - queryWithParser(pp_warpx, "num_snapshots_lab", num_snapshots_lab); + utils::parser::queryWithParser( + pp_warpx, "num_snapshots_lab", num_snapshots_lab); // Read either dz_snapshots_lab or dt_snapshots_lab Real dz_snapshots_lab = 0; - bool snapshot_interval_is_specified = queryWithParser(pp_warpx, "dt_snapshots_lab", dt_snapshots_lab); - if ( queryWithParser(pp_warpx, "dz_snapshots_lab", dz_snapshots_lab) ){ - dt_snapshots_lab = dz_snapshots_lab/PhysConst::c; - snapshot_interval_is_specified = true; - } + const bool dt_snapshots_specified = + utils::parser::queryWithParser(pp_warpx, "dt_snapshots_lab", dt_snapshots_lab); + const bool dz_snapshots_specified = + utils::parser::queryWithParser(pp_warpx, "dz_snapshots_lab", dz_snapshots_lab); + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - snapshot_interval_is_specified, + dt_snapshots_specified || dz_snapshots_specified, "When using back-transformed diagnostics, user should specify either dz_snapshots_lab or dt_snapshots_lab."); - getWithParser(pp_warpx, "gamma_boost", gamma_boost); + if (dz_snapshots_specified){ + dt_snapshots_lab = dz_snapshots_lab/PhysConst::c; + } + + utils::parser::getWithParser(pp_warpx, "gamma_boost", gamma_boost); pp_warpx.query("do_back_transformed_fields", do_back_transformed_fields); @@ -685,9 +697,12 @@ WarpX::ReadParameters () if (do_electrostatic == ElectrostaticSolverAlgo::LabFrame) { // Note that with the relativistic version, these parameters would be // input for each species. - queryWithParser(pp_warpx, "self_fields_required_precision", self_fields_required_precision); - queryWithParser(pp_warpx, "self_fields_absolute_tolerance", self_fields_absolute_tolerance); - queryWithParser(pp_warpx, "self_fields_max_iters", self_fields_max_iters); + utils::parser::queryWithParser( + pp_warpx, "self_fields_required_precision", self_fields_required_precision); + utils::parser::queryWithParser( + pp_warpx, "self_fields_absolute_tolerance", self_fields_absolute_tolerance); + utils::parser::queryWithParser( + pp_warpx, "self_fields_max_iters", self_fields_max_iters); pp_warpx.query("self_fields_verbosity", self_fields_verbosity); } // Parse the input file for domain boundary potentials @@ -701,7 +716,7 @@ WarpX::ReadParameters () pp_warpx.query("eb_potential(x,y,z,t)", m_poisson_boundary_handler.potential_eb_str); m_poisson_boundary_handler.buildParsers(); - queryWithParser(pp_warpx, "const_dt", const_dt); + utils::parser::queryWithParser(pp_warpx, "const_dt", const_dt); // Filter currently not working with FDTD solver in RZ geometry: turn OFF by default // (see https://github.com/ECP-WarpX/WarpX/issues/1943) @@ -714,7 +729,8 @@ WarpX::ReadParameters () pp_warpx.query("use_filter", use_filter); pp_warpx.query("use_filter_compensation", use_filter_compensation); Vector<int> parse_filter_npass_each_dir(AMREX_SPACEDIM,1); - queryArrWithParser(pp_warpx, "filter_npass_each_dir", parse_filter_npass_each_dir, 0, AMREX_SPACEDIM); + utils::parser::queryArrWithParser( + pp_warpx, "filter_npass_each_dir", parse_filter_npass_each_dir, 0, AMREX_SPACEDIM); filter_npass_each_dir[0] = parse_filter_npass_each_dir[0]; #if (AMREX_SPACEDIM >= 2) filter_npass_each_dir[1] = parse_filter_npass_each_dir[1]; @@ -740,14 +756,18 @@ WarpX::ReadParameters () } #endif - queryWithParser(pp_warpx, "num_mirrors", num_mirrors); + utils::parser::queryWithParser( + pp_warpx, "num_mirrors", num_mirrors); if (num_mirrors>0){ mirror_z.resize(num_mirrors); - getArrWithParser(pp_warpx, "mirror_z", mirror_z, 0, num_mirrors); + utils::parser::getArrWithParser( + pp_warpx, "mirror_z", mirror_z, 0, num_mirrors); mirror_z_width.resize(num_mirrors); - getArrWithParser(pp_warpx, "mirror_z_width", mirror_z_width, 0, num_mirrors); + utils::parser::getArrWithParser( + pp_warpx, "mirror_z_width", mirror_z_width, 0, num_mirrors); mirror_z_npoints.resize(num_mirrors); - getArrWithParser(pp_warpx, "mirror_z_npoints", mirror_z_npoints, 0, num_mirrors); + utils::parser::getArrWithParser( + pp_warpx, "mirror_z_npoints", mirror_z_npoints, 0, num_mirrors); } pp_warpx.query("do_single_precision_comms", do_single_precision_comms); @@ -765,11 +785,14 @@ WarpX::ReadParameters () pp_warpx.query("refine_plasma", refine_plasma); pp_warpx.query("do_dive_cleaning", do_dive_cleaning); pp_warpx.query("do_divb_cleaning", do_divb_cleaning); - queryWithParser(pp_warpx, "n_field_gather_buffer", n_field_gather_buffer); - queryWithParser(pp_warpx, "n_current_deposition_buffer", n_current_deposition_buffer); + utils::parser::queryWithParser( + pp_warpx, "n_field_gather_buffer", n_field_gather_buffer); + utils::parser::queryWithParser( + pp_warpx, "n_current_deposition_buffer", n_current_deposition_buffer); amrex::Real quantum_xi_tmp; - int quantum_xi_is_specified = queryWithParser(pp_warpx, "quantum_xi", quantum_xi_tmp); + const auto quantum_xi_is_specified = + utils::parser::queryWithParser(pp_warpx, "quantum_xi", quantum_xi_tmp); if (quantum_xi_is_specified) { double const quantum_xi = quantum_xi_tmp; quantum_xi_c2 = static_cast<amrex::Real>(quantum_xi * PhysConst::c * PhysConst::c); @@ -796,15 +819,15 @@ WarpX::ReadParameters () } } - queryWithParser(pp_warpx, "pml_ncell", pml_ncell); - queryWithParser(pp_warpx, "pml_delta", pml_delta); + utils::parser::queryWithParser(pp_warpx, "pml_ncell", pml_ncell); + utils::parser::queryWithParser(pp_warpx, "pml_delta", pml_delta); pp_warpx.query("pml_has_particles", pml_has_particles); pp_warpx.query("do_pml_j_damping", do_pml_j_damping); pp_warpx.query("do_pml_in_domain", do_pml_in_domain); pp_warpx.query("do_similar_dm_pml", do_similar_dm_pml); // Read `v_particle_pml` in units of the speed of light v_particle_pml = 1._rt; - queryWithParser(pp_warpx, "v_particle_pml", v_particle_pml); + utils::parser::queryWithParser(pp_warpx, "v_particle_pml", v_particle_pml); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(0._rt < v_particle_pml && v_particle_pml <= 1._rt, "Input value for the velocity warpx.v_particle_pml of the macroparticle must be in (0,1] (in units of c)."); // Scale by the speed of light @@ -885,19 +908,19 @@ WarpX::ReadParameters () ParmParse pp_vismf("vismf"); pp_vismf.add("usesingleread", use_single_read); pp_vismf.add("usesinglewrite", use_single_write); - queryWithParser(pp_warpx, "mffile_nstreams", mffile_nstreams); + utils::parser::queryWithParser(pp_warpx, "mffile_nstreams", mffile_nstreams); VisMF::SetMFFileInStreams(mffile_nstreams); - queryWithParser(pp_warpx, "field_io_nfiles", field_io_nfiles); + utils::parser::queryWithParser(pp_warpx, "field_io_nfiles", field_io_nfiles); VisMF::SetNOutFiles(field_io_nfiles); - queryWithParser(pp_warpx, "particle_io_nfiles", particle_io_nfiles); + utils::parser::queryWithParser(pp_warpx, "particle_io_nfiles", particle_io_nfiles); ParmParse pp_particles("particles"); pp_particles.add("particles_nfiles", particle_io_nfiles); } if (maxLevel() > 0) { Vector<Real> lo, hi; - getArrWithParser(pp_warpx, "fine_tag_lo", lo); - getArrWithParser(pp_warpx, "fine_tag_hi", hi); + utils::parser::getArrWithParser(pp_warpx, "fine_tag_lo", lo); + utils::parser::getArrWithParser(pp_warpx, "fine_tag_hi", hi); fine_tag_lo = RealVect{lo}; fine_tag_hi = RealVect{hi}; } @@ -910,7 +933,7 @@ WarpX::ReadParameters () #ifdef WARPX_DIM_RZ // Only needs to be set with WARPX_DIM_RZ, otherwise defaults to 1 - queryWithParser(pp_warpx, "n_rz_azimuthal_modes", n_rz_azimuthal_modes); + utils::parser::queryWithParser(pp_warpx, "n_rz_azimuthal_modes", n_rz_azimuthal_modes); WARPX_ALWAYS_ASSERT_WITH_MESSAGE( n_rz_azimuthal_modes > 0, "The number of azimuthal modes (n_rz_azimuthal_modes) must be at least 1"); #endif @@ -996,14 +1019,17 @@ WarpX::ReadParameters () // Load balancing parameters std::vector<std::string> load_balance_intervals_string_vec = {"0"}; pp_algo.queryarr("load_balance_intervals", load_balance_intervals_string_vec); - load_balance_intervals = IntervalsParser(load_balance_intervals_string_vec); + load_balance_intervals = utils::parser::IntervalsParser( + load_balance_intervals_string_vec); pp_algo.query("load_balance_with_sfc", load_balance_with_sfc); pp_algo.query("load_balance_knapsack_factor", load_balance_knapsack_factor); - queryWithParser(pp_algo, "load_balance_efficiency_ratio_threshold", + utils::parser::queryWithParser(pp_algo, "load_balance_efficiency_ratio_threshold", load_balance_efficiency_ratio_threshold); load_balance_costs_update_algo = GetAlgorithmInteger(pp_algo, "load_balance_costs_update"); - queryWithParser(pp_algo, "costs_heuristic_cells_wt", costs_heuristic_cells_wt); - queryWithParser(pp_algo, "costs_heuristic_particles_wt", costs_heuristic_particles_wt); + utils::parser::queryWithParser( + pp_algo, "costs_heuristic_cells_wt", costs_heuristic_cells_wt); + utils::parser::queryWithParser( + pp_algo, "costs_heuristic_particles_wt", costs_heuristic_particles_wt); // Parse algo.particle_shape and check that input is acceptable // (do this only if there is at least one particle or laser species) @@ -1018,7 +1044,7 @@ WarpX::ReadParameters () std::vector<std::string> sort_intervals_string_vec = {"-1"}; int particle_shape; if (!species_names.empty() || !lasers_names.empty()) { - if (queryWithParser(pp_algo, "particle_shape", particle_shape)){ + if (utils::parser::queryWithParser(pp_algo, "particle_shape", particle_shape)){ WARPX_ALWAYS_ASSERT_WITH_MESSAGE( (particle_shape >= 1) && (particle_shape <=3), @@ -1053,11 +1079,13 @@ WarpX::ReadParameters () amrex::ParmParse pp_warpx("warpx"); pp_warpx.queryarr("sort_intervals", sort_intervals_string_vec); - sort_intervals = IntervalsParser(sort_intervals_string_vec); + sort_intervals = utils::parser::IntervalsParser(sort_intervals_string_vec); Vector<int> vect_sort_bin_size(AMREX_SPACEDIM,1); - bool sort_bin_size_is_specified = queryArrWithParser(pp_warpx, "sort_bin_size", - vect_sort_bin_size, 0, AMREX_SPACEDIM); + bool sort_bin_size_is_specified = + utils::parser::queryArrWithParser( + pp_warpx, "sort_bin_size", + vect_sort_bin_size, 0, AMREX_SPACEDIM); if (sort_bin_size_is_specified){ for (int i=0; i<AMREX_SPACEDIM; i++) sort_bin_size[i] = vect_sort_bin_size[i]; @@ -1077,17 +1105,23 @@ WarpX::ReadParameters () if (WarpX::field_gathering_algo == GatheringAlgo::MomentumConserving && WarpX::do_nodal == 0) { - queryWithParser(pp_interpolation, "field_centering_nox", field_centering_nox); - queryWithParser(pp_interpolation, "field_centering_noy", field_centering_noy); - queryWithParser(pp_interpolation, "field_centering_noz", field_centering_noz); + utils::parser::queryWithParser( + pp_interpolation, "field_centering_nox", field_centering_nox); + utils::parser::queryWithParser( + pp_interpolation, "field_centering_noy", field_centering_noy); + utils::parser::queryWithParser( + pp_interpolation, "field_centering_noz", field_centering_noz); } // Read order of finite-order centering of currents (nodal to staggered) if (WarpX::do_current_centering) { - queryWithParser(pp_interpolation, "current_centering_nox", current_centering_nox); - queryWithParser(pp_interpolation, "current_centering_noy", current_centering_noy); - queryWithParser(pp_interpolation, "current_centering_noz", current_centering_noz); + utils::parser::queryWithParser( + pp_interpolation, "current_centering_nox", current_centering_nox); + utils::parser::queryWithParser( + pp_interpolation, "current_centering_noy", current_centering_noy); + utils::parser::queryWithParser( + pp_interpolation, "current_centering_noz", current_centering_noz); } // Finite-order centering is not implemented with mesh refinement @@ -1137,17 +1171,17 @@ WarpX::ReadParameters () if(nox_str == "inf") { nox_fft = -1; } else { - queryWithParser(pp_psatd, "nox", nox_fft); + utils::parser::queryWithParser(pp_psatd, "nox", nox_fft); } if(noy_str == "inf") { noy_fft = -1; } else { - queryWithParser(pp_psatd, "noy", noy_fft); + utils::parser::queryWithParser(pp_psatd, "noy", noy_fft); } if(noz_str == "inf") { noz_fft = -1; } else { - queryWithParser(pp_psatd, "noz", noz_fft); + utils::parser::queryWithParser(pp_psatd, "noz", noz_fft); } if (!fft_periodic_single_box) { @@ -1227,7 +1261,8 @@ WarpX::ReadParameters () } else { - queryArrWithParser(pp_psatd, "v_galilean", m_v_galilean, 0, 3); + utils::parser::queryArrWithParser( + pp_psatd, "v_galilean", m_v_galilean, 0, 3); } // Check whether the default comoving velocity should be used @@ -1245,7 +1280,8 @@ WarpX::ReadParameters () } else { - queryArrWithParser(pp_psatd, "v_comoving", m_v_comoving, 0, 3); + utils::parser::queryArrWithParser( + pp_psatd, "v_comoving", m_v_comoving, 0, 3); } // Scale the Galilean/comoving velocity by the speed of light @@ -1384,39 +1420,45 @@ WarpX::ReadParameters () // for slice generation // { - ParmParse pp_slice("slice"); - amrex::Vector<Real> slice_lo(AMREX_SPACEDIM); - amrex::Vector<Real> slice_hi(AMREX_SPACEDIM); - Vector<int> slice_crse_ratio(AMREX_SPACEDIM); - // set default slice_crse_ratio // - for (int idim=0; idim < AMREX_SPACEDIM; ++idim ) - { - slice_crse_ratio[idim] = 1; - } - queryArrWithParser(pp_slice, "dom_lo", slice_lo, 0, AMREX_SPACEDIM); - queryArrWithParser(pp_slice, "dom_hi", slice_hi, 0, AMREX_SPACEDIM); - queryArrWithParser(pp_slice, "coarsening_ratio",slice_crse_ratio,0,AMREX_SPACEDIM); - queryWithParser(pp_slice, "plot_int",slice_plot_int); - slice_realbox.setLo(slice_lo); - slice_realbox.setHi(slice_hi); - slice_cr_ratio = IntVect(AMREX_D_DECL(1,1,1)); - for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) - { - if (slice_crse_ratio[idim] > 1 ) { - slice_cr_ratio[idim] = slice_crse_ratio[idim]; - } - } - - if (do_back_transformed_diagnostics) { - WARPX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0, - "gamma_boost must be > 1 to use the boost frame diagnostic"); - queryWithParser(pp_slice, "num_slice_snapshots_lab", num_slice_snapshots_lab); - if (num_slice_snapshots_lab > 0) { - getWithParser(pp_slice, "dt_slice_snapshots_lab", dt_slice_snapshots_lab ); - getWithParser(pp_slice, "particle_slice_width_lab",particle_slice_width_lab); - } - } + ParmParse pp_slice("slice"); + amrex::Vector<Real> slice_lo(AMREX_SPACEDIM); + amrex::Vector<Real> slice_hi(AMREX_SPACEDIM); + Vector<int> slice_crse_ratio(AMREX_SPACEDIM); + // set default slice_crse_ratio // + for (int idim=0; idim < AMREX_SPACEDIM; ++idim ) + { + slice_crse_ratio[idim] = 1; + } + utils::parser::queryArrWithParser( + pp_slice, "dom_lo", slice_lo, 0, AMREX_SPACEDIM); + utils::parser::queryArrWithParser( + pp_slice, "dom_hi", slice_hi, 0, AMREX_SPACEDIM); + utils::parser::queryArrWithParser( + pp_slice, "coarsening_ratio",slice_crse_ratio,0,AMREX_SPACEDIM); + utils::parser::queryWithParser( + pp_slice, "plot_int",slice_plot_int); + slice_realbox.setLo(slice_lo); + slice_realbox.setHi(slice_hi); + slice_cr_ratio = IntVect(AMREX_D_DECL(1,1,1)); + for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) + { + if (slice_crse_ratio[idim] > 1 ) { + slice_cr_ratio[idim] = slice_crse_ratio[idim]; + } + } + if (do_back_transformed_diagnostics) { + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(gamma_boost > 1.0, + "gamma_boost must be > 1 to use the boost frame diagnostic"); + utils::parser::queryWithParser( + pp_slice, "num_slice_snapshots_lab", num_slice_snapshots_lab); + if (num_slice_snapshots_lab > 0) { + utils::parser::getWithParser( + pp_slice, "dt_slice_snapshots_lab", dt_slice_snapshots_lab ); + utils::parser::getWithParser( + pp_slice, "particle_slice_width_lab",particle_slice_width_lab); + } + } } } |