ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_interval_means::detail Namespace Reference

Functions

bool read_int_vector (std::istream &input, amrex::IntVect &value)
 
bool read_box_array (std::istream &input, amrex::BoxArray &result)
 

Function Documentation

◆ read_box_array()

bool erf_interval_means::detail::read_box_array ( std::istream &  input,
amrex::BoxArray &  result 
)
inline
36 {
37  char delimiter;
38  long long box_count;
39  unsigned long long hash;
40  if (!(input >> delimiter) || delimiter != '(' ||
41  !(input >> box_count >> hash) || box_count < 0 ||
42  box_count > static_cast<long long>(std::numeric_limits<int>::max())) {
43  return false;
44  }
45 
46  std::vector<amrex::Box> boxes;
47  boxes.reserve(static_cast<std::size_t>(box_count));
48  for (long long ibox = 0; ibox < box_count; ++ibox) {
49  if (!(input >> delimiter) || delimiter != '(') return false;
50  amrex::IntVect small, big, type;
51  if (!read_int_vector(input, small) || !read_int_vector(input, big) ||
52  !read_int_vector(input, type) ||
53  !(input >> delimiter) || delimiter != ')') {
54  return false;
55  }
56  boxes.emplace_back(small, big, type);
57  }
58  if (!(input >> delimiter) || delimiter != ')') return false;
59 
60  result = boxes.empty()
61  ? amrex::BoxArray{}
62  : amrex::BoxArray(boxes.data(), static_cast<int>(boxes.size()));
63  return true;
64 }
bool read_int_vector(std::istream &input, amrex::IntVect &value)
Definition: ERF_IntervalMeansCheckpoint.H:20

Referenced by erf_interval_means::parse_metadata().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_int_vector()

bool erf_interval_means::detail::read_int_vector ( std::istream &  input,
amrex::IntVect &  value 
)
inline
21 {
22  char delimiter;
23  if (!(input >> delimiter) || delimiter != '(') return false;
24  for (int idir = 0; idir < AMREX_SPACEDIM; ++idir) {
25  if (idir > 0 && (!(input >> delimiter) || delimiter != ',')) return false;
26  if (!(input >> value[idir])) return false;
27  }
28  return static_cast<bool>(input >> delimiter) && delimiter == ')';
29 }

Referenced by read_box_array().

Here is the caller graph for this function: