46 long long step,
double time,
double zPlane,
const std::vector<double>& xCoords,
47 const std::vector<double>& yCoords,
const std::vector<double>& phiValues, std::size_t nx,
48 std::size_t ny,
const std::string& solveTag) {
49 if (xCoords.size() != nx || yCoords.size() != ny || phiValues.size() != nx * ny) {
51 "DirichletPlaneWriter::writePlane",
52 "Invalid plane dimensions for dirichlet-plane dump.");
55 const std::string safeTag = sanitizeTag(solveTag);
57 std::ostringstream fileName;
58 fileName <<
"phi_dirichlet_" << safeTag <<
"_step-" << std::setfill(
'0') << std::setw(8) << step
62 std::ofstream out(filePath.string(), std::ios::out | std::ios::trunc);
65 "DirichletPlaneWriter::writePlane",
66 "Failed to open output file \"" + filePath.string() +
"\".");
69 out << std::setprecision(17);
70 out <<
"# Dirichlet-plane potential dump\n";
71 out <<
"# step=" << step <<
" time=" << time <<
" [s] zPlane=" << zPlane
72 <<
" [m] tag=" << safeTag <<
"\n";
73 out <<
"# nx=" << nx <<
" ny=" << ny <<
"\n";
74 out <<
"# columns: i j x[m] y[m] phi[V]\n";
76 for (std::size_t i = 0; i < nx; ++i) {
77 for (std::size_t j = 0; j < ny; ++j) {
78 const std::size_t idx = i * ny + j;
79 out << std::setw(6) << i << std::setw(6) << j <<
" " << std::scientific << xCoords[i]
80 <<
" " << yCoords[j] <<
" " << phiValues[idx] <<
"\n";
void writePlane(long long step, double time, double zPlane, const std::vector< double > &xCoords, const std::vector< double > &yCoords, const std::vector< double > &phiValues, std::size_t nx, std::size_t ny, const std::string &solveTag)
Write one plane snapshot.