55 Kokkos::View<int*, CCMem> idMap,
int rank = 0) {
57 if (level <= 0 ||
nRows <= 0)
59 const auto h_cell = Kokkos::create_mirror_view_and_copy(
60 Kokkos::HostSpace(), Kokkos::subview(ov.
cell, Kokkos::make_pair(0,
nRows)));
61 const auto h_rho = Kokkos::create_mirror_view_and_copy(
62 Kokkos::HostSpace(), Kokkos::subview(ov.
rescale, Kokkos::make_pair(0,
nRows)));
63 const auto h_cpl = Kokkos::create_mirror_view_and_copy(
64 Kokkos::HostSpace(), Kokkos::subview(ov.
coupled, Kokkos::make_pair(0,
nRows)));
65 const auto sub6 = Kokkos::make_pair(0, 6 *
nRows);
66 const auto h_st = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),
69 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Kokkos::subview(ov.
th,
sub6));
70 const auto h_wm1 = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),
72 const auto h_wm2 = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(),
75 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Kokkos::subview(ov.
w_n1,
sub6));
77 Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), Kokkos::subview(ov.
w_n2,
sub6));
78 const auto h_id = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), idMap);
80 const char*
stName[5] = {
"COUPLED",
"QUAD",
"LIN",
"BC_ONLY",
"EXPLICIT"};
81 long stCount[5] = {0, 0, 0, 0, 0};
84 long rhoDec[7] = {0, 0, 0, 0, 0, 0, 0};
85 long wDec[8] = {0, 0, 0, 0, 0, 0, 0, 0};
90 for (
int s = 0; s <
nRows; ++s) {
93 const float rho =
h_rho(s);
95 int d = rho >= 1.0f ? 6 : (int)std::floor(std::log10((
double)rho)) + 6;
96 rhoDec[d < 0 ? 0 : (d > 6 ? 6 : d)]++;
98 for (
int k = 0;
k < 6; ++
k) {
101 const float th =
h_th(s * 6 +
k);
105 if (th <= (
float)(1e-4 * 1.0000001))
109 const float a1 = std::fabs(
h_wm1(s * 6 +
k)),
a2 = std::fabs(
h_wm2(s * 6 +
k));
112 const float b1 = std::fabs(
h_w1(s * 6 +
k)),
b2 = std::fabs(
h_w2(s * 6 +
k));
119 int wd =
mw <= 1.0f ? 0 : (int)std::floor(std::log10((
double)
mw));
127 long mmDec[6] = {0, 0, 0, 0, 0, 0};
129 auto rhoAt = [&](
int x,
int y,
int z) ->
float {
135 const int s =
h_id(c);
136 return s >= 0 ?
h_rho(s) : 1.0f;
139 for (
int s = 0; s <
nRows; ++s) {
141 const int x = c %
nn.x, y = (c /
nn.x) %
nn.y, z = c / (
nn.x *
nn.y);
142 const double lr = std::log10((
double)
h_rho(s));
144 const int off[6][3] = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}};
145 for (
auto& o :
off) {
146 const double d = std::fabs(lr - std::log10((
double)
rhoAt(x + o[0], y + o[1], z + o[2])));
152 mmDec[b < 0 ? 0 : (b > 5 ? 5 : b)]++;
155 std::printf(
"[gp] rank %d overlay census: %d rows of %ld inner cells (%.2f %%), %ld decoupled\n",
157 std::printf(
"[gp] face states:");
158 for (
int i = 0;
i < 5; ++
i)
160 std::printf(
"\n[gp] theta: EXTENDED(1,2)=%ld clamped-low(1e-4)=%ld clamped-high(2)=%ld\n",
162 std::printf(
"[gp] rho decades [1e-5,1e-4)=%ld [1e-4,1e-3)=%ld [1e-3,1e-2)=%ld "
163 "[1e-2,1e-1)=%ld [1e-1,1)=%ld ==1:%ld min=%.3e\n",
165 std::printf(
"[gp] max|w| decades");
166 for (
int i = 0;
i < 8; ++
i)
167 std::printf(
" 1e%d:%ld",
i,
wDec[
i]);
168 std::printf(
" max=%.3e\n",
wMax);
169 std::printf(
"[gp] neighbour rho mismatch |log10| bins");
170 for (
int i = 0;
i < 6; ++
i)
171 std::printf(
" %d:%ld",
i,
mmDec[
i]);
172 std::printf(
" max=%.2f decades\n",
mmMax);
175 std::vector<int>
ord((std::size_t)
nRows);
177 ord[(std::size_t)
i] =
i;
179 std::partial_sort(
ord.begin(),
ord.begin() +
show,
ord.end(),
180 [&](
int a,
int b) { return h_rho(a) < h_rho(b); });
181 std::printf(
"[gp] worst %d rows by rho:\n",
show);
182 for (
int i = 0;
i <
show; ++
i) {
183 const int s =
ord[(std::size_t)
i];
185 std::printf(
"[gp] (%4d,%4d,%4d) rho=%.4e maxw=%.3e mism=%.2f |", c %
nn.x,
188 for (
int k = 0;
k < 6; ++
k)
189 std::printf(
" %s(th=%.3e,wm=%.3e/%.3e)",
stName[
h_st(s * 6 +
k)],
h_th(s * 6 +
k),
197 const char*
fenv = std::getenv(
"PECLET_FLOW_GP_DEBUG_FILE");
198 std::string
path =
fenv ? std::string(
fenv) : std::string(
"gp_rows");
199 path +=
"_rank" + std::to_string(rank) +
".bin";
200 std::FILE* f = std::fopen(
path.c_str(),
"wb");
202 std::printf(
"[gp] COULD NOT OPEN %s for the per-row dump\n",
path.c_str());
205 for (
int s = 0; s <
nRows; ++s) {
208 const float rho =
h_rho(s);
212 for (
int k = 0;
k < 6; ++
k) {
221 std::fwrite(&rho,
sizeof(
float), 1, f);
223 std::fwrite(st,
sizeof(
int8_t), 6, f);
224 std::fwrite(th,
sizeof(
float), 6, f);
225 std::fwrite(
wm1,
sizeof(
float), 6, f);
226 std::fwrite(
wm2,
sizeof(
float), 6, f);
227 std::fwrite(
w1,
sizeof(
float), 6, f);
228 std::fwrite(
w2,
sizeof(
float), 6, f);
231 std::printf(
"[gp] per-row dump -> %s (%d records)\n",
path.c_str(),
nRows);
void gpDebugReport(const GpOverlay &ov, int nRows, C3 nn, Kokkos::View< int *, CCMem > idMap, int rank=0)
Census + optional per-row dump of the built overlay.
void ibmFillEntry(const OV &o, int list_idx, int c_idx, float sdf_c, const float sdf_n[6], int bc_type, const float *thEx)