21 template <
class TPartitionIdx>
23 const std::vector<TPartitionIdx> &partition,
24 std::vector<DNDS::index> &localPush,
25 std::vector<DNDS::index> &localPushStart,
const DNDS::MPIInfo &mpi)
27 std::vector<DNDS::index> localPushSizes(mpi.size, 0);
28 for (
auto r : partition)
34 localPush.resize(localPushStart[mpi.size]);
35 localPushSizes.assign(mpi.size, 0);
37 for (
size_t i = 0; i < partition.size(); i++)
38 localPush[localPushStart[partition[i]] + (localPushSizes[partition[i]]++)] =
DNDS::size_to_index(i);
46 template <
class TPartitionIdx>
48 const std::vector<TPartitionIdx> &partition,
51 serial2Global.resize(partition.size());
52 std::vector<DNDS::index> numberAtLocal(nPart, 0);
53 for (
auto r : partition)
55 std::vector<DNDS::index> numberTotal(nPart), numberPrev(nPart);
58 std::vector<DNDS::index> numberTotalPlc(nPart + 1);
59 numberTotalPlc[0] = 0;
61 numberTotalPlc[
r + 1] = numberTotalPlc[
r] + numberTotal[
r], numberPrev[
r] -= numberAtLocal[
r];
62 numberAtLocal.assign(numberAtLocal.size(), 0);
64 for (
auto r : partition)
65 serial2Global[iFill++] = (numberAtLocal[
r]++) + numberTotalPlc[
r] + numberPrev[
r];
72 template <
class TAdj = tAdj1>
74 const std::vector<DNDS::index> &partitionJSerial2Global,
78 JSG = make_ssp<tAdj1::element_type>(
ObjName{
"ConvertAdjSerial2Global::JSG"}, mpi);
79 JSGGhost = make_ssp<tAdj1::element_type>(
ObjName{
"ConvertAdjSerial2Global::JSGGhost"}, mpi);
80 JSG->Resize(partitionJSerial2Global.size());
82 (*JSG)(i, 0) = partitionJSerial2Global[i];
83 JSG->createGlobalMapping();
84 std::vector<DNDS::index> ghostJSerialQuery;
87 for (
DNDS::index i = 0; i < arraySerialAdj->Size(); i++)
89 for (
DNDS::rowsize j = 0; j < arraySerialAdj->RowSize(i); j++)
96 if (!JSG->pLGlobalMapping->search(
v, rank, val))
102 ghostJSerialQuery.reserve(nGhost);
103 for (
DNDS::index i = 0; i < arraySerialAdj->Size(); i++)
105 for (
DNDS::rowsize j = 0; j < arraySerialAdj->RowSize(i); j++)
112 bool ret = JSG->pLGlobalMapping->search(
v, rank, val);
114 if (rank != mpi.rank)
115 ghostJSerialQuery.push_back(
v);
124 for (
DNDS::index i = 0; i < arraySerialAdj->Size(); i++)
126 for (
DNDS::rowsize j = 0; j < arraySerialAdj->RowSize(i); j++)
138 v = (*JSGGhost)(val, 0);
147 template <
class TArr = tAdj1>
150 const std::vector<DNDS::index> &pushIndex,
151 const std::vector<DNDS::index> &pushIndexStart,
156 trans.createFatherGlobalMapping();
157 trans.createGhostMapping(pushIndex, pushIndexStart);
158 trans.createMPITypes();
#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 + ...
decltype(tAdj1Pair::father) tAdj1
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 Scan(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Scan (inclusive prefix reduction).
MPI_int Allreduce(const void *sendbuf, void *recvbuf, MPI_int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Wrapper over MPI_Allreduce.
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).
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
void AccumulateRowSize(const TtRowsizeVec &rowsizes, TtIndexVec &rowstarts)
Build a prefix-sum table from a row-size vector.
index size_to_index(size_t v)
Range-checked conversion from size_t to DNDS::index.
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
int MPI_int
MPI counterpart type for MPI_int (= C int). Used for counts and ranks in MPI calls.
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Tag type for naming objects created via make_ssp.
Eigen::Matrix< real, 5, 1 > v