34 mesh.RecoverNode2CellAndNode2Bnd();
35 mesh.RecoverCell2CellAndBnd2Cell();
36 mesh.BuildGhostPrimary(nGhostLayers);
37 mesh.AdjGlobal2LocalPrimary();
38 mesh.AdjGlobal2LocalN2CB();
64 const std::string &meshFile,
66 real periodicTol = 1e-9,
69 std::function<
t_index(
const std::string &)> nameMapper =
nullptr)
71 auto &mpi =
mesh->getMPI();
72 int dim =
mesh->getDim();
75 reader->ReadFromCGNSSerial(meshFile, nameMapper);
77 reader->ReadFromCGNSSerial(meshFile);
79 reader->Deduplicate1to1Periodic(periodicTol);
80 reader->BuildCell2Cell();
81 reader->MeshPartitionCell2Cell(partOpts);
82 reader->PartitionReorderToMeshCell2Cell();
91 meshO2->BuildO2FromO1Elevation(*
mesh);
92 std::swap(meshO2,
mesh);
100 for (
int iter = 1; iter <= bisect; iter++)
102 ssp<UnstructuredMesh> meshO2;
104 meshO2->BuildO2FromO1Elevation(*
mesh);
106 meshO2->RecoverNode2CellAndNode2Bnd();
107 meshO2->RecoverCell2CellAndBnd2Cell();
108 meshO2->BuildGhostPrimary();
110 ssp<UnstructuredMesh> meshO1B;
112 meshO1B->BuildBisectO1FormO2(*meshO2);
114 std::swap(meshO1B,
mesh);
121 log() << fmt::format(
"Mesh Direct Bisect {} done, nCell [{}], nNode [{}]",
138 const std::string &h5Path,
141 auto &mpi =
mesh.getMPI();
142 auto [pathMod, pathPart] = factory.
ModifyFilePath(h5Path, mpi,
"part_%d",
true);
146 log() <<
"ReadMeshFromH5: distributed read via [" << factory.
type
149 serializerP->OpenFile(pathMod,
true);
150 mesh.ReadSerializeAndDistribute(serializerP,
"meshPart", partOpts);
151 serializerP->CloseFile();
164 const std::string &h5Path)
166 auto &mpi =
mesh.getMPI();
167 auto [pathMod, pathPart] = factory.
ModifyFilePath(h5Path, mpi,
"part_%d",
true);
171 log() <<
"ReadMeshFromH5Parallel: reading via [" << factory.
type
174 serializerP->OpenFile(pathMod,
true);
175 mesh.ReadSerialize(serializerP,
"meshPart");
176 serializerP->CloseFile();
209 auto &mpi =
mesh.getMPI();
211 if (opts.reorderCells == 1)
212 mesh.ReorderLocalCells(opts.reorderParts);
214 mesh.InterpolateFace();
215 mesh.AssertOnFaces();
217 mesh.AdjLocal2GlobalN2CB();
218 mesh.BuildGhostN2CB();
219 mesh.AdjGlobal2LocalN2CB();
220 log() << fmt::format(
"{}, NumBndGhost {}", mpi.rank,
mesh.NumBndGhost())
225 for (
index iNode = 0; iNode <
mesh.NumNode(); iNode++)
229 if (opts.buildSerialOut)
231 mesh.AdjLocal2GlobalPrimary();
233 mesh.AdjGlobal2LocalPrimary();
252 bool buildSerialOut =
true)
254 mesh.ConstructBndMesh(meshBnd);
273 const std::string &outputPath,
276 auto &mpi =
mesh.getMPI();
277 auto [pathMod, pathPart] = factory.
ModifyFilePath(outputPath, mpi,
"part_%d",
false);
280 serializerP->OpenFile(pathMod,
false);
281 mesh.AdjLocal2GlobalPrimary();
282 mesh.WriteSerialize(serializerP,
"meshPart");
283 mesh.AdjGlobal2LocalPrimary();
284 serializerP->CloseFile();
297 const std::string &base,
int mpiSize,
298 int elevation = 0,
int bisect = 0)
300 using namespace std::literals;
301 std::string name = base +
"_part_" + std::to_string(mpiSize);
305 name +=
"_bisect" + std::to_string(bisect);
#define DNDS_MAKE_SSP(ssp,...)
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
Configurable factory that builds either a SerializerJSON or a SerializerH5 with all tunables exposed ...
void BuildGhostPrimary(UnstructuredMesh &mesh, int nGhostLayers=1)
Build connectivity and ghost layer for a freshly-distributed mesh.
void ReadMeshFromCGNS(ssp< UnstructuredMesh > &mesh, ssp< UnstructuredMeshSerialRW > &reader, const std::string &meshFile, const PartitionOptions &partOpts={}, real periodicTol=1e-9, int elevation=0, int bisect=0, std::function< t_index(const std::string &)> nameMapper=nullptr)
Read a CGNS mesh, partition, and optionally elevate/bisect.
void BuildBndMesh(UnstructuredMesh &mesh, UnstructuredMesh &meshBnd, UnstructuredMeshSerialRW &readerBnd, bool buildSerialOut=true)
Extract the boundary surface mesh from a solver-ready volume mesh.
void SerializeMesh(UnstructuredMesh &mesh, const std::string &outputPath, Serializer::SerializerFactory &factory)
Write a partitioned mesh to H5 for later distributed read.
void ReadMeshFromH5(UnstructuredMesh &mesh, Serializer::SerializerFactory factory, const std::string &h5Path, const PartitionOptions &partOpts={})
Read a mesh from DNDSR H5 with even-split + ParMetis repartition.
std::string MeshH5Path(const std::string &base, int mpiSize, int elevation=0, int bisect=0)
Build the conventional H5 filename for a partitioned mesh.
void PrepareMesh(UnstructuredMesh &mesh, UnstructuredMeshSerialRW &reader, const PrepareMeshOptions &opts={})
Prepare a distributed mesh for solver use.
void ReadMeshFromH5Parallel(UnstructuredMesh &mesh, Serializer::SerializerFactory factory, const std::string &h5Path)
Read a pre-partitioned mesh from H5 (exact np match required).
ssp< SerializerBase > SerializerBaseSSP
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
std::ostream & log()
Return the current DNDSR log stream (either std::cout or the installed file).
bool buildSerialOut
build serial output arrays
int reorderCells
0 = natural, 1 = reorder
int reorderParts
nParts for ReorderLocalCells
void BuildSerialOut()
should be called to build data for serial out
void AdjGlobal2LocalPrimaryForBnd()
void AdjLocal2GlobalPrimaryForBnd()
Config-backed factory selecting between JSON and HDF5 serializers.
std::tuple< std::string, std::string > ModifyFilePath(std::string fname, const MPIInfo &mpi, const std::string &rank_part_fmt="%06d", bool read=false) const
Expand a user-supplied base file name into the backend-specific path layout.
std::string type
Backend selector: "JSON" or "H5".
SerializerBaseSSP BuildSerializer(const MPIInfo &mpi) const
Instantiate the selected serializer and apply its tunables.