ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_RefinementCriterion.H
Go to the documentation of this file.
1 #ifndef ERF_REFINEMENT_CRITERION_H_
2 #define ERF_REFINEMENT_CRITERION_H_
3 
4 #include <AMReX_REAL.H>
5 #include <AMReX_RealBox.H>
6 #include <AMReX_Vector.H>
7 
8 #include <algorithm>
9 #include <limits>
10 #include <string>
11 
12 /**
13  * One test in a refinement criterion: a field compared against a threshold that may differ by level
14  */
16 {
18 
19  std::string field;
21 
22  // Threshold at level lev is values[lev]; the last entry holds for all higher levels
23  amrex::Vector<amrex::Real> values;
24 
25  [[nodiscard]] amrex::Real threshold (int lev) const {
26  return values[std::min(lev, static_cast<int>(values.size())-1)];
27  }
28 };
29 
30 /**
31  * A refinement indicator from erf.refinement_indicators, tagged by ERF itself.
32  *
33  * A cell is tagged when the conditions hold (all of them, or any of them, as require_all says)
34  * and the cell is inside the box, if there is one. A criterion without conditions tags every
35  * cell in its box.
36  */
38 {
39  // Name in erf.refinement_indicators, which is also the ParmParse prefix erf.<name>
40  std::string name;
41 
42  amrex::Vector<TagCondition> conditions;
43 
44  // Whether every condition must hold (erf.<name>.combine = and) or any one (= or)
45  bool require_all = true;
46 
47  // Region the tags are restricted to, as placed at the current time; not ok() when there is none
48  amrex::RealBox real_box;
49 
50  // Height a cell center has when it is tested against the box's z extent
51  enum struct BoxZ {
52  Grid, // on the undeformed grid: a static nest, possibly given by indices
53  Physical, // z_phys_cc
54  AboveGround // z_phys_cc less the height of the bottom of its column
55  };
56 
57  // For a criterion with conditions, the box is only a restriction: it is read from
58  // in_box_lo/in_box_hi into base_box (where it is before any move_* motion), and its z
59  // extent is compared with the physical height or, by default, the height above ground
60  // (erf.<name>.box_z_coordinate). A box given with two values leaves z unrestricted.
61  // Without conditions the box is a static nest and is compared on the undeformed grid.
63  amrex::RealBox base_box;
64 
65  // Tag only at levels below max_level, and only for min_time <= time <= max_time
66  int max_level = 1000;
67  amrex::Real min_time = std::numeric_limits<amrex::Real>::lowest();
68  amrex::Real max_time = std::numeric_limits<amrex::Real>::max();
69 
70  [[nodiscard]] bool is_active (int lev, amrex::Real time) const {
71  return (lev >= 0) && (lev < max_level) && (time >= min_time) && (time <= max_time);
72  }
73 };
74 
75 #endif
Definition: ERF_RefinementCriterion.H:38
amrex::RealBox real_box
Definition: ERF_RefinementCriterion.H:48
bool is_active(int lev, amrex::Real time) const
Definition: ERF_RefinementCriterion.H:70
amrex::Vector< TagCondition > conditions
Definition: ERF_RefinementCriterion.H:42
bool require_all
Definition: ERF_RefinementCriterion.H:45
BoxZ
Definition: ERF_RefinementCriterion.H:51
amrex::Real max_time
Definition: ERF_RefinementCriterion.H:68
std::string name
Definition: ERF_RefinementCriterion.H:40
amrex::Real min_time
Definition: ERF_RefinementCriterion.H:67
int max_level
Definition: ERF_RefinementCriterion.H:66
BoxZ box_z
Definition: ERF_RefinementCriterion.H:62
amrex::RealBox base_box
Definition: ERF_RefinementCriterion.H:63
Definition: ERF_RefinementCriterion.H:16
std::string field
Definition: ERF_RefinementCriterion.H:19
Test
Definition: ERF_RefinementCriterion.H:17
Test test
Definition: ERF_RefinementCriterion.H:20
amrex::Real threshold(int lev) const
Definition: ERF_RefinementCriterion.H:25
amrex::Vector< amrex::Real > values
Definition: ERF_RefinementCriterion.H:23