119 std::array<amrex::Real, NumScalars*NumFaces + NumScalars*3> packed{};
125 for (
int s = 0; s <
NumScalars; ++s) { packed[index++] = current[s]; }
127 amrex::ParallelDescriptor::ReduceRealSum(packed.data(),
static_cast<int>(packed.size()));
129 std::array<std::array<amrex::Real, NumFaces>,
NumScalars> global_faces{};
132 for (
int f = 0; f <
NumFaces; ++f) { global_faces[s][f] = packed[index++]; }
134 std::array<amrex::Real, NumScalars> initial{};
135 std::array<amrex::Real, NumScalars> global_current{};
137 for (
int s = 0; s <
NumScalars; ++s) { initial[s] = packed[index++]; }
138 for (
int s = 0; s <
NumScalars; ++s) { global_current[s] = packed[index++]; }
139 std::array<amrex::Real, NumScalars> global_internal{};
140 for (
int s = 0; s <
NumScalars; ++s) { global_internal[s] = packed[index++]; }
142 if (amrex::ParallelDescriptor::IOProcessor()) {
143 std::ofstream
out(
"cloud_chamber_budget.dat", std::ios::app);
144 if (
out.tellp() == std::streampos(0)) {
145 out <<
"# start_step start_time end_step end_time scalar units "
146 "xlo xhi ylo yhi zlo zhi net_boundary volume_change "
147 "internal_source residual tolerance status\n";
149 out << std::setprecision(17);
150 const char* names[
NumScalars] = {
"rhoTheta",
"water_vapor",
"cloud_water"};
151 const char*
units[
NumScalars] = {
"conserved_scalar",
"mixing_ratio_density",
"mixing_ratio_density"};
153 std::array<amrex::Real, NumFaces> faces = global_faces[s];
154 amrex::Real net = faces[0] - faces[1] + faces[2] - faces[3] + faces[4] - faces[5];
155 const amrex::Real change = global_current[s] - initial[s];
157 const amrex::Real residual = change - net -
internal;
159 std::abs(initial[s]), std::abs(global_current[s]),
160 std::abs(net), std::abs(
internal)});
165 for (
const auto value : faces) { boundary_scale += std::abs(
value); }
168 (effective_operations * scale + boundary_scale + std::abs(
internal));
169 const bool status = std::abs(residual) <= tolerance;
170 const char* status_text = status ?
"PASS" :
171 (cloudy && s ==
RhoTheta ?
"UNSUPPORTED_SOURCE" :
"FAIL");
173 << step <<
' ' << time <<
' ' << names[s] <<
' ' <<
units[s];
175 out <<
' ' << net <<
' ' << change <<
' ' <<
internal <<
' '
176 << residual <<
' ' << tolerance <<
' ' << status_text <<
'\n';
178 std::array<amrex::Real, NumFaces> total_faces{};
179 for (
int f = 0; f <
NumFaces; ++f) {
180 total_faces[f] = global_faces[
RhoQv][f] + global_faces[
RhoQc][f];
182 const amrex::Real total_net = total_faces[0] - total_faces[1] +
183 total_faces[2] - total_faces[3] + total_faces[4] - total_faces[5];
187 const amrex::Real total_residual = total_change - total_net - total_internal;
189 std::abs(total_net), std::abs(total_internal)});
191 for (
const auto value : total_faces) { total_boundary_scale += std::abs(
value); }
195 total_boundary_scale + std::abs(total_internal));
196 const bool total_status = std::abs(total_residual) <= total_tolerance;
198 << step <<
' ' << time <<
" total_nonprecipitating_water mixing_ratio_density";
199 for (
const auto value : total_faces) {
out <<
' ' <<
value; }
200 out <<
' ' << total_net <<
' ' << total_change <<
' ' << total_internal <<
' '
201 << total_residual <<
' ' << total_tolerance <<
' '
202 << (total_status ?
"PASS" :
"FAIL") <<
'\n';
Real value
Definition: ERF_HurricaneDiagnostics.cpp:30
std::string units
Definition: ERF_Plotfile2DCatalog.cpp:103
std::array< amrex::Real, NumScalars > m_initial_state
Definition: ERF_CloudChamberBudget.H:223
double m_interval_start_time
Definition: ERF_CloudChamberBudget.H:220
std::array< amrex::Real, NumScalars > state_integrals(const amrex::MultiFab &cons, const amrex::Geometry &geom) const
Definition: ERF_CloudChamberBudget.H:95
bool m_have_initial
Definition: ERF_CloudChamberBudget.H:221
int m_interval_start_step
Definition: ERF_CloudChamberBudget.H:219
bool due(int step) const noexcept
Definition: ERF_CloudChamberBudget.H:36
@ cons
Definition: ERF_IndexDefines.H:176
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12