16#include <unordered_map>
17#include <unordered_set>
26 static void GeneralCell2NodeToNode2Cell(
31 const auto &mpi = coords.father->getMPI();
32 std::unordered_set<index> ghostNodesCompactSet;
33 std::vector<index> ghostNodesCompact;
34 std::unordered_map<index, std::unordered_set<index>> node2CellLocalRecord;
39 auto [ret, rank, val] = coords.father->pLGlobalMapping->search(iNode);
42 ghostNodesCompact.push_back(iNode), ghostNodesCompactSet.insert(iNode);
43 node2CellLocalRecord[iNode].insert(CellIndexLocal2Global_NoSon(iCell));
50 node2cell.
InitPair(
"node2cell", mpi);
51 node2cellPast = make_ssp<tAdj::element_type>(
ObjName{
"node2cellPast"}, mpi);
53 node2cell.
father->Resize(coords.father->Size());
54 for (
index iNode = 0; iNode < coords.father->Size(); iNode++)
56 index iNodeG = NodeIndexLocal2Global_NoSon(iNode);
57 if (node2CellLocalRecord.count(iNodeG))
59 node2cell.
ResizeRow(iNode, node2CellLocalRecord[iNodeG].size());
61 for (
auto v : node2CellLocalRecord[iNodeG])
62 node2cell(iNode, in2c++) =
v;
66 node2cell.
trans.createFatherGlobalMapping();
67 node2cell.
trans.createGhostMapping(ghostNodesCompact);
69 node2cell.
son->Resize(node2cell.
trans.pLGhostMapping->ghostIndex.size());
71 for (
auto &[k, s] : node2CellLocalRecord)
75 if (!node2cell.
trans.pLGhostMapping->search(k, rank, val))
79 node2cell.
son->ResizeRow(val, s.size());
82 node2cell.
son->operator()(val, in2c++) =
v;
92 std::vector<index> pushSonSeries(node2cell.
son->
Size());
103 for (
index i = 0;
i < node2cellPast->Size();
i++)
105 index iNodeG = node2cell.
trans.pLGhostMapping->pushingIndexGlobal[
i];
106 for (
auto iCell : (*node2cellPast)[
i])
107 node2CellLocalRecord[iNodeG].insert(iCell);
122 node2cell.
InitPair(
"node2cell", mpi);
124 node2cell.
father->Resize(coords.father->Size());
125 for (
index iNode = 0; iNode < coords.father->Size(); iNode++)
127 index iNodeG = NodeIndexLocal2Global_NoSon(iNode);
128 if (node2CellLocalRecord.count(iNodeG))
130 node2cell.
ResizeRow(iNode, node2CellLocalRecord[iNodeG].size());
132 for (
auto v : node2CellLocalRecord[iNodeG])
133 node2cell(iNode, in2c++) =
v;
155 GeneralCell2NodeToNode2Cell(
162 if (!
bnd2node.father->pLGlobalMapping)
163 bnd2node.father->createGlobalMapping();
164 GeneralCell2NodeToNode2Cell(
209 cell2node.trans.createFatherGlobalMapping();
211 bnd2node.trans.createFatherGlobalMapping();
231 node2cell.trans.createFatherGlobalMapping();
339 DNDS_assert_info(
ret, fmt::format(
"periodic bnd {} candidate cell {} not found in ghost mapping",
i,
ic));
364 fmt::format(
"periodic bnd {} has {} cells after pbi filter",
i,
cellRecFiltered.size()));
382 std::vector<Geom::NodePeriodicBits>
pbi0,
pbi1;
410 if (
bndElemInfo(
i, 0).zone == Geom::BC_ID_PERIODIC_1_DONOR)
412 else if (
bndElemInfo(
i, 0).zone == Geom::BC_ID_PERIODIC_2_DONOR)
414 else if (
bndElemInfo(
i, 0).zone == Geom::BC_ID_PERIODIC_3_DONOR)
445 ?
"this periodic bnd matches both sides"
446 :
"this periodic bnd matches no sides");
475 cell2cell.trans.createFatherGlobalMapping();
543 bnd2cell.trans.createFatherGlobalMapping();
679 face2cell.trans.createFatherGlobalMapping();
745 log() <<
"UnstructuredMesh === InterpolateFaceLegacy: total faces " <<
gSize << 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 + ...
std::function< index(index)> tIndexMapFunc
decltype(tAdjPair::father) tAdj
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicDonor(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicMain(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic3(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic2(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic1(t_index id)
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).
constexpr MPI_int UnInitMPIInt
Sentinel "not initialised" MPI_int value (= -1, invalid rank).
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).
ssp< T > make_ssp(Args &&...args)
Type-safe replacement for DNDS_MAKE_SSP. Creates ssp<T> with forwarded args.
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.
DNDS_DEVICE_CALLABLE index Size() const
Combined father + son row count.
void TransAttach()
Bind the transformer to the current father / son pointers.
ssp< TArray > father
Owned-side array (must be resized before ghost setup).
index Size() const
Combined row count (father->Size() + son->Size()).
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).
void BorrowAndPull(TPrimaryPair &primary)
Attach, borrow ghost indexing from a primary pair, create MPI types, and pull once.
void ResizeRow(index i, rowsize rs)
Resize a single row in the combined address space.
TTrans trans
Ghost-communication engine bound to father and son.
static MPI_Datatype CommType()
UnstructuredMeshDeviceView< B > t_deviceView
index NodeIndexGlobal2Local_NoSon(index i)
void BuildGhostPrimaryLegacy()
tPbiPair cell2nodePbi
periodic only, after reader
std::unordered_map< index, index > face2bndM
void RecoverCell2CellAndBnd2CellLegacy()
index CellIndexLocal2Global_NoSon(index i)
tPbiPair face2nodePbi
periodic only, after interpolated
AdjPairTracked< tAdj1Pair > face2bnd
void AdjLocal2GlobalC2F()
AdjPairTracked< tAdj2Pair > face2cell
index NodeIndexLocal2Global_NoSon(index i)
void AdjLocal2GlobalFacial()
index BndIndexLocal2Global_NoSon(index i)
MeshAdjState adjN2CBState
AdjPairTracked< tAdjPair > cell2face
interpolated
void AdjGlobal2LocalC2F()
void RecoverNode2CellAndNode2BndLegacy()
AdjPairTracked< tAdjPair > cell2cell
std::vector< index > bnd2faceV
AdjPairTracked< tAdjPair > face2node
MeshAdjState adjPrimaryState
AdjPairTracked< tAdj1Pair > bnd2face
tElemInfoArrayPair faceElemInfo
MeshAdjState adjFacialState
AdjPairTracked< tAdjPair > cell2node
tElemInfoArrayPair cellElemInfo
AdjPairTracked< tAdjPair > node2bnd
void InterpolateFaceLegacy()
AdjPairTracked< tAdjPair > bnd2node
AdjPairTracked< tAdjPair > node2cell
inverse relations
void AdjGlobal2LocalFacial()
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.
Tag type for naming objects created via make_ssp.
Eigen::Matrix< real, 5, 1 > v
std::vector< DNDS::index > ghostNodes(ghostNodeSet.begin(), ghostNodeSet.end())
std::vector< GhostCell > ghostCells