7#include <unordered_set>
16 template <
class TArray>
17 static void EvenSplitReadFather(
21 const std::string &name)
23 father = std::make_shared<TArray>(mpi);
24 son = std::make_shared<TArray>(mpi);
25 auto offset = Serializer::ArrayGlobalOffset_EvenSplit;
26 father->ReadSerializer(serializerP, name, offset);
30 template <
class TArray>
31 static void EvenSplitReadFather(
35 const std::string &name,
36 MPI_Datatype commType,
int commMult)
38 father = std::make_shared<TArray>(commType, commMult, mpi);
39 son = std::make_shared<TArray>(commType, commMult, mpi);
40 auto offset = Serializer::ArrayGlobalOffset_EvenSplit;
41 father->ReadSerializer(serializerP, name, offset);
51 const std::string &name,
55 "ReadSerializeAndDistribute requires a collective (H5) serializer");
58 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: begin" << std::endl;
82 bnd2node.father->createGlobalMapping();
90 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute done, "
91 << fmt::format(
"nCellGlobal [{}], nNodeGlobal [{}], nBndGlobal [{}]",
96 {
log() << fmt::format(
" Rank {}: nCell {}, nNode {}, nBnd {}",
125 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: even-split read" << std::endl;
171 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: even-split read done, "
172 <<
"nCellLocal=" <<
cell2node.father->Size()
174 <<
" nBndLocal=" <<
bnd2node.father->Size() << std::endl;
185 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: building distributed cell2cell" << std::endl;
192 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: building facial cell2cell" << std::endl;
197 cell2cell.trans.createFatherGlobalMapping();
212 cell2node.trans.createFatherGlobalMapping();
259 std::set_intersection(
vertI.begin(),
vertI.end(),
280 const ssp<tAdj::element_type> &cell2cellFacial,
281 const PartitionOptions &partitionOptions)
284 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: ParMetis repartition" << std::endl;
310 "ParMetis requires > 0 cells on each proc");
314 std::vector<real_t>
tpWeights(
static_cast<size_t>(nPart) *
nCon, 1.0 / nPart);
315 std::array<real_t, 1>
ubVec{1.05};
328 fmt::format(
"ParMETIS_V3_PartKway returned {}",
ret));
348 index nCellGlobal = 0;
351 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: partition done, "
352 << fmt::format(
"nCellGlobal [{}], ave [{}], min [{}], max [{}], ratio [{:.4f}]",
384 result.nodePartition[val] = std::min(
result.nodePartition[val],
423 fmt::format(
"bnd {} has no owner cell after RecoverCell2CellAndBnd2Cell",
iBnd));
452 const EntityPartitions &partitions)
455 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: redistributing" << std::endl;
475 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: redistribute done" << std::endl;
480 const EntityPartitions &partitions)
483 log() <<
"UnstructuredMesh === ReadSerializeAndDistribute: redistributing" << std::endl;
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
#define DNDS_check_throw_info(expr, info)
Same as DNDS_check_throw but attaches a user-supplied info message to the thrown std::runtime_error.
Layered DAG of mesh adjacency relations with composable DSL operations.
Internal helpers for mesh partition redistribution.
constexpr AdjKind Cell2Cell
void Partition2LocalIdx(const std::vector< TPartitionIdx > &partition, std::vector< DNDS::index > &localPush, std::vector< DNDS::index > &localPushStart, const DNDS::MPIInfo &mpi)
void Partition2Serial2Global(const std::vector< TPartitionIdx > &partition, std::vector< DNDS::index > &serial2Global, const DNDS::MPIInfo &mpi, DNDS::MPI_int nPart)
void TransferDataSerial2Global(TArr &arraySerial, TArr &arrayDist, const std::vector< DNDS::index > &pushIndex, const std::vector< DNDS::index > &pushIndexStart, const DNDS::MPIInfo &mpi)
void ConvertAdjSerial2Global(TAdj &arraySerialAdj, const std::vector< DNDS::index > &partitionJSerial2Global, const DNDS::MPIInfo &mpi)
MPI_int Allreduce(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Allreduce.
ssp< SerializerBase > SerializerBaseSSP
const MPI_Datatype DNDS_MPI_INDEX
MPI datatype matching index (= MPI_INT64_T).
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
void MPISerialDo(const MPIInfo &mpi, F f)
Execute f on each rank serially, in rank order.
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
constexpr MPI_int UnInitMPIInt
Sentinel "not initialised" MPI_int value (= -1, invalid rank).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
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).
int MPI_int
MPI counterpart type for MPI_int (= C int). Used for counts and ranks in MPI calls.
void TransAttach()
Bind the transformer to the current father / son pointers.
ssp< TArray > father
Owned-side array (must be resized before ghost setup).
void InitPair(const std::string &name, Args &&...args)
Allocate both father and son arrays, forwarding all args to TArray constructor.
ssp< TArray > son
Ghost-side array (sized automatically by createMPITypes / BorrowAndPull).
TTrans trans
Ghost-communication engine bound to father and son.
static CompiledGhostTree compile(const GhostSpec &spec)
static MPI_Datatype CommType()
static MPI_Datatype CommType()
DNDS_HOST void ReadSerializer(Serializer::SerializerBaseSSP serializerP, const std::string &name)
UnstructuredMeshDeviceView< B > t_deviceView
tPbiPair cell2nodePbi
periodic only, after reader
void fillRegistry(MeshConnectivity &dag) const
Populate a MeshConnectivity registry from this mesh's currently-built adjacencies.
void ReorderEntities(const ReorderInput &input)
Reorder entities using the general framework.
void RecoverNode2CellAndNode2Bnd()
only requires father part of cell2node, bnd2node and coords generates node2cell and node2bnd (father ...
AdjPairTracked< tAdjPair > cell2cell
MeshAdjState adjPrimaryState
AdjPairTracked< tAdjPair > cell2node
void RecoverCell2CellAndBnd2Cell()
needs to use RecoverNode2CellAndNode2Bnd before doing this. Requires node2cell.father and builds a ve...
tElemInfoArrayPair cellElemInfo
AdjPairTracked< tAdjPair > node2bnd
void ReadSerializeAndDistribute(Serializer::SerializerBaseSSP serializerP, const std::string &name, const PartitionOptions &partitionOptions)
Reads mesh from an H5 serializer using even-split distribution, then repartitions via ParMetis for lo...
AdjPairTracked< tAdjPair > bnd2node
AdjPairTracked< tAdjPair > node2cell
inverse relations
tElemInfoArrayPair bndElemInfo
AdjPairTracked< tAdj2Pair > bnd2cell
int size
Number of ranks in comm (-1 until initialised).
int rank
This rank's 0-based index within comm (-1 until initialised).
MPI_Comm comm
The underlying MPI communicator handle.
if(DEFINED ENV{DNDS_TEST_NP_LIST}) set(DNDS_TEST_NP_LIST "$ENV
std::vector< GhostCell > ghostCells
std::vector< MPI_int > nodePartition(nNode, mpi.rank)
std::vector< MPI_int > cellPartition(nCellBefore)
const tPoint const tPoint const tPoint & p