7 #include "../coordinates/coordinates.hpp"
8 #include "../debugger/debugger.hpp"
9 #include "../globals.hpp"
10 #include "../mesh/mesh.hpp"
24 pmb->pdebug->Enter(
"Diagnostics List");
25 std::stringstream msg;
27 std::string diag_names = pin->GetOrAddString(
"problem",
"diagnostics",
"");
28 std::strcpy(cstr, diag_names.c_str());
29 char *
p = std::strtok(cstr,
" ,");
34 }
else if (name ==
"curl")
36 else if (name ==
"mean")
38 else if (name ==
"tempa")
40 else if (name ==
"presa")
42 else if (name ==
"eddyflux")
44 else if (name ==
"hydroflux")
46 else if (name ==
"div_h")
50 else if (name ==
"radflux")
52 else if (name ==
"am")
54 else if (name ==
"eke")
56 else if (name ==
"tendency")
59 msg <<
"### FATAL ERROR in function Diagnostics::Diagnostics" << std::endl
60 <<
"Diagnostic variable " << name <<
" not defined";
64 p = std::strtok(NULL,
" ,");
67 #if MAIN_TASKLIST != InversionTaskList
69 msg <<
"### FATAL ERROR in function Diagnostics::Diagnostics" << std::endl
70 <<
"Most diagnostic variables require at least 2 ghost cells";
86 pmb->pdebug->Enter(
"Diagnostics-" + name);
87 std::stringstream msg;
88 ncells1_ = pmb->block_size.nx1 + 2 * (NGHOST);
91 if (pmb->pmy_mesh->f2)
ncells2_ = pmb->block_size.nx2 + 2 * (NGHOST);
92 if (pmb->pmy_mesh->f3)
ncells3_ = pmb->block_size.nx3 + 2 * (NGHOST);
109 brank_.resize(Globals::nranks);
110 color_.resize(Globals::nranks);
112 for (
int i = 0; i < Globals::nranks; ++i) {
117 pmb->pdebug->Leave();
127 while (
p !=
nullptr) {
128 if (
p->myname == name)
return p;
136 NeighborBlock bblock, tblock;
137 pmb->FindNeighbors(dir, bblock, tblock);
140 if (pmb->block_size.x1min <= pmb->pmy_mesh->mesh_size.x1min) {
142 bblock.snb.rank = -1;
144 if (pmb->block_size.x1max >= pmb->pmy_mesh->mesh_size.x1max) {
146 tblock.snb.rank = -1;
148 }
else if (dir == X2DIR) {
149 if (pmb->block_size.x2min <= pmb->pmy_mesh->mesh_size.x2min) {
151 bblock.snb.rank = -1;
153 if (pmb->block_size.x2max >= pmb->pmy_mesh->mesh_size.x2max) {
155 tblock.snb.rank = -1;
158 if (pmb->block_size.x3min <= pmb->pmy_mesh->mesh_size.x3min) {
160 bblock.snb.rank = -1;
162 if (pmb->block_size.x3max >= pmb->pmy_mesh->mesh_size.x3max) {
164 tblock.snb.rank = -1;
169 MPI_Allgather(&bblock.snb.rank, 1, MPI_INT,
brank_.data(), 1, MPI_INT,
176 for (
int i = 0; i < Globals::nranks; ++i) {
179 if (color[i] == -1) color[i] = c++;
181 color[i] = color[
brank_[i]];
190 total_vol.ZeroClear();
191 for (
int k = pmb->ks; k <= pmb->ke; ++k)
192 for (
int j = pmb->js; j <= pmb->je; ++
j) {
193 pmb->pcoord->CellVolume(k,
j, pmb->is, pmb->ie,
vol_);
194 for (
int i = pmb->is; i <= pmb->ie; ++i) total_vol(i) +=
vol_(i);
200 std::fill(
color_.data(),
color_.data() + Globals::nranks, -1);
203 MPI_Comm_split(MPI_COMM_WORLD,
color_[Globals::my_rank], Globals::my_rank,
208 MPI_Allreduce(MPI_IN_PLACE, total_vol.data(), total_vol.GetSize(),
209 MPI_ATHENA_REAL, MPI_SUM, comm);
210 MPI_Allreduce(MPI_IN_PLACE, total_data.data(), total_data.GetSize(),
211 MPI_ATHENA_REAL, MPI_SUM, comm);
212 MPI_Comm_free(&comm);
void gatherAllData23_(AthenaArray< Real > &total_vol, AthenaArray< Real > &total_data)
AthenaArray< Real > x2area_p1_
AthenaArray< Real > x3edge_p1_
void setColor_(int *color, CoordinateDirection dir)
std::vector< int > color_
MPI color of each rank.
AthenaArray< Real > x2edge_p1_
AthenaArray< Real > x3area_
Diagnostics(MeshBlock *pmb, ParameterInput *pin)
AthenaArray< Real > x1area_
scratch geometric arrays
Diagnostics * AddDiagnostics(Dg const &d)
AthenaArray< Real > x1edge_
std::vector< int > brank_
rank of the bottom block
AthenaArray< Real > x2edge_
AthenaArray< Real > x3edge_
AthenaArray< Real > x1edge_p1_
AthenaArray< Real > x2area_
AthenaArray< Real > x3area_p1_
Diagnostics * operator[](std::string name)
AthenaArray< Real > total_vol_