384 {
386 return;
387 const size_t nstep =
data.currentStep();
389 return;
390 double max_u = 0.;
391 for (
const auto &u :
data.d_u)
392 max_u = std::
max(max_u, u.length());
394 MPI_Allreduce(MPI_IN_PLACE, &max_u, 1, MPI_DOUBLE, MPI_MAX,
396 double com0x = 0., com0y = 0.;
397 if (!
data.d_particlesListTypeParticle.empty()) {
398 const auto c =
data.d_particlesListTypeParticle[0]->getXCenter();
399 com0x = c.d_x;
400 com0y = c.d_y;
401 }
403 d_metricOs << std::format(
"{},{:.12e},{:.12e},{:.12e},{:.12e}\n", nstep,
404 data.d_time, max_u, com0x, com0y);
406 }
407 const size_t n =
data.d_u.size();
408 std::vector<double> buf(6 * n, 0.);
409 for (size_t i = 0; i < n; ++i) {
411 continue;
412 buf[6 * i + 0] =
data.d_u[i].d_x;
413 buf[6 * i + 1] =
data.d_u[i].d_y;
414 buf[6 * i + 2] =
data.d_u[i].d_z;
415 buf[6 * i + 3] =
data.d_v[i].d_x;
416 buf[6 * i + 4] =
data.d_v[i].d_y;
417 buf[6 * i + 5] =
data.d_v[i].d_z;
418 }
420 MPI_Allreduce(MPI_IN_PLACE, buf.data(), static_cast<int>(buf.size()),
423 return;
425 std::ofstream xr(
d_outDir /
"nodal" /
"x_ref.bin", std::ios::binary);
426 const uint32_t nn = static_cast<uint32_t>(n);
427 xr.write(reinterpret_cast<const char *>(&nn), sizeof(nn));
428 for (size_t i = 0; i < n; ++i) {
429 const double p[3] = {
data.d_xRef[i].d_x,
data.d_xRef[i].d_y,
431 xr.write(reinterpret_cast<const char *>(p), sizeof(p));
432 }
434 }
435 std::ofstream os(
d_outDir /
"nodal" / std::format(
"uv_{:06d}.bin", nstep),
436 std::ios::binary);
437 const char magic[4] = {'P', 'D', 'U', 'V'};
438 const uint32_t step32 = static_cast<uint32_t>(nstep);
439 const uint32_t nn = static_cast<uint32_t>(n);
440 os.write(magic, 4);
441 os.write(reinterpret_cast<const char *>(&step32), sizeof(step32));
442 os.write(reinterpret_cast<const char *>(&nn), sizeof(nn));
443 os.write(reinterpret_cast<const char *>(buf.data()),
444 static_cast<std::streamsize>(buf.size() * sizeof(double)));
445 }
static bool ownsNode(const data::ModelData &data, size_t i)
T max(const std::vector< T > &data)
Returns the maximum from list of data.
int mpiSize()
Get size (number) of processors.
MPI_Comm mpiComm()
Get MPI comm.