DNDSR 0.2.1
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
test_MeshReorder.cpp File Reference

Unit tests for ReorderPlan, ReorderRegistry, and classification. More...

#include "doctest.h"
#include "Geom/Mesh/ReorderPlan.hpp"
#include "Geom/Mesh/Mesh.hpp"
#include <numeric>
#include <set>
Include dependency graph for test_MeshReorder.cpp:

Go to the source code of this file.

Macros

#define DOCTEST_CONFIG_IMPLEMENT
 

Typedefs

using idx = DNDS::index
 

Functions

int main (int argc, char **argv)
 
 TEST_CASE ("classifyAdj basic classification")
 
 TEST_CASE ("ReorderRegistry register and query")
 
 TEST_CASE ("ReorderPlan::apply cell-only local permutation")
 
 TEST_CASE ("ReorderPlan::apply node-only remap")
 
 TEST_CASE ("ReorderEntities cell-only local on UniformSquare_10")
 
 TEST_CASE ("ReorderEntities cell-only with face destruction on UniformSquare_10")
 
 TEST_CASE ("ReorderEntities cell distributed round-robin with follow")
 
 TEST_CASE ("ReorderEntities node-only local on UniformSquare_10")
 
 TEST_CASE ("PermutationTransfer + buildLookup: reverse permutation value tracking")
 
 TEST_CASE ("PermutationTransfer distributed value tracking cross-rank")
 
 TEST_CASE ("PermutationTransfer::buildLookup cross-rank resolve with pullSet")
 
solverDOF InitPair ("solverDOF", mpi)
 
solverDOF father Resize (nCellBefore)
 
mesh AdjLocal2GlobalPrimary ()
 
 for (DNDS::index i=0;i< nCellBefore;i++)
 
std::vector< MPI_intcellPartition (nCellBefore)
 
input explicitMaps push_back (EntityReorderMap{EntityKind::Cell, cellPartition})
 
reg registerCompanion (EntityKind::Cell, [&](const PermutationTransfer &t, const MPIInfo &m) { t.transferRows(solverDOF, m);}, "solverDOF")
 
plan apply (reg, mpi)
 
cell2node InitPair ("cell2node", mpi)
 
cell2node father Resize (nCell)
 
cell2node father createGlobalMapping ()
 
nodeArr InitPair ("nodeArr", mpi)
 
nodeArr father Resize (nNode)
 
reg registerGlobalMapping (EntityKind::Cell, cell2node.father->pLGlobalMapping)
 
reg registerGlobalMapping (EntityKind::Node, nodeArr.father->pLGlobalMapping)
 
reg registerAdj (Adj::Cell2Node, [&](const PermutationTransfer::LookupResult &lookup) { for(DNDS::index i=0;i< cell2node.father->Size();i++) for(rowsize j=0;j< 2;j++) { DNDS::index &v=cell2node(i, j);if(v !=UnInitIndex) v=lookup.resolve(v);} }, [&](const PermutationTransfer &t, const MPIInfo &m) { t.transferRows(cell2node, m);}, "cell2node")
 
std::vector< MPI_intcellPartition (nCell, mpi.rank)
 
std::vector< MPI_intnodePartition (nNode, mpi.rank)
 
input explicitMaps push_back (EntityReorderMap{EntityKind::Node, nodePartition})
 
 CHECK (plan.reorderedKinds.count(EntityKind::Cell))
 
 CHECK (plan.reorderedKinds.count(EntityKind::Node))
 
 CHECK (classifyAdj(Adj::Cell2Node, plan.reorderedKinds)==AdjAction::RELOCATE_REMAP)
 
 TEST_CASE ("buildReorderRegistry populates pullSets for off-rank references")
 

Variables

auto mesh = buildMeshPrimary(mpi, "UniformSquare_10.cgns", 2, false)
 
DNDS::index nCellBefore = mesh->NumCell()
 
ArrayAdjacencyPair< 3 > solverDOF
 
solverDOF father pLGlobalMapping = mesh->cell2node.father->pLGlobalMapping
 
DNDS::index cellOffset = (*mesh->cell2node.father->pLGlobalMapping)(mpi.rank, 0)
 
std::map< DNDS::index, std::array< DNDS::index, 3 > > expectedByOldGlobal
 
ReorderInput input
 
auto plan = mesh->buildReorderPlan(input)
 
auto reg = mesh->buildReorderRegistry(input.destroyKinds)
 
const autotransfer = plan.transfers.at(EntityKind::Cell)
 
DNDS::index nAfter = solverDOF.father->Size()
 
const DNDS::index nCell = 4
 
const DNDS::index nNode = 6
 
ArrayAdjacencyPair< 2 > cell2node
 
ArrayAdjacencyPair< 1 > nodeArr
 
DNDS::index nodeOffset = (*nodeArr.father->pLGlobalMapping)(mpi.rank, 0)
 
std::map< DNDS::index, std::array< DNDS::index, 2 > > oldCell2NodeByGlobal
 

Detailed Description

Unit tests for ReorderPlan, ReorderRegistry, and classification.

Tests:

  • AdjAction classification logic
  • ReorderRegistry registration and lookup
  • ReorderPlan::apply on synthetic data (no real mesh)
  • Full mesh ReorderEntities on real CGNS meshes (Phase 2b)

Definition in file test_MeshReorder.cpp.

Macro Definition Documentation

◆ DOCTEST_CONFIG_IMPLEMENT

#define DOCTEST_CONFIG_IMPLEMENT

Definition at line 12 of file test_MeshReorder.cpp.

Typedef Documentation

◆ idx

using idx = DNDS::index

Definition at line 24 of file test_MeshReorder.cpp.

Function Documentation

◆ AdjLocal2GlobalPrimary()

mesh AdjLocal2GlobalPrimary ( )
Here is the caller graph for this function:

◆ apply()

plan apply ( reg  ,
mpi   
)

◆ cellPartition() [1/2]

std::vector< MPI_int > cellPartition ( nCell  ,
mpi.  rank 
)

◆ cellPartition() [2/2]

std::vector< MPI_int > cellPartition ( nCellBefore  )
Here is the caller graph for this function:

◆ CHECK() [1/3]

CHECK ( classifyAdj(Adj::Cell2Node, plan.reorderedKinds)  = =AdjAction::RELOCATE_REMAP)

◆ CHECK() [2/3]

CHECK ( plan.reorderedKinds.  countEntityKind::Cell)
Here is the caller graph for this function:

◆ CHECK() [3/3]

CHECK ( plan.reorderedKinds.  countEntityKind::Node)

◆ createGlobalMapping()

cell2node father createGlobalMapping ( )

◆ for()

for ( )

Definition at line 850 of file test_MeshReorder.cpp.

◆ InitPair() [1/3]

cell2node InitPair ( "cell2node"  ,
mpi   
)

◆ InitPair() [2/3]

nodeArr InitPair ( "nodeArr"  ,
mpi   
)

◆ InitPair() [3/3]

solverDOF InitPair ( "solverDOF"  ,
mpi   
)

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file test_MeshReorder.cpp.

◆ nodePartition()

std::vector< MPI_int > nodePartition ( nNode  ,
mpi.  rank 
)
Here is the caller graph for this function:

◆ push_back() [1/2]

input explicitMaps push_back ( EntityReorderMap{EntityKind::Cell, cellPartition )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_back() [2/2]

input explicitMaps push_back ( EntityReorderMap{EntityKind::Node, nodePartition )
Here is the call graph for this function:

◆ registerAdj()

reg registerAdj ( Adj::Cell2Node  ,
[&] (const PermutationTransfer::LookupResult &lookup) { for(DNDS::index i=0;i< cell2node.father->Size();i++) for(rowsize j=0;j< 2;j++) { DNDS::index &v=cell2node(i, j);if(v !=UnInitIndex) v=lookup.resolve(v);} }  ,
[&] (const PermutationTransfer &t, const MPIInfo &m) { t.transferRows(cell2node, m);}  ,
"cell2node"   
)
Here is the call graph for this function:

◆ registerCompanion()

reg registerCompanion ( EntityKind::Cell  ,
[&] (const PermutationTransfer &t, const MPIInfo &m) { t.transferRows(solverDOF, m);}  ,
"solverDOF"   
)
Here is the call graph for this function:

◆ registerGlobalMapping() [1/2]

reg registerGlobalMapping ( EntityKind::Cell  ,
cell2node.father->  pLGlobalMapping 
)

◆ registerGlobalMapping() [2/2]

reg registerGlobalMapping ( EntityKind::Node  ,
nodeArr.father->  pLGlobalMapping 
)

◆ Resize() [1/3]

cell2node father Resize ( nCell  )

◆ Resize() [2/3]

◆ Resize() [3/3]

nodeArr father Resize ( nNode  )

◆ TEST_CASE() [1/12]

TEST_CASE ( "buildReorderRegistry populates pullSets for off-rank references"  )

Definition at line 1003 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [2/12]

TEST_CASE ( "classifyAdj basic classification"  )

Definition at line 47 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [3/12]

TEST_CASE ( "PermutationTransfer + buildLookup: reverse permutation value tracking"  )

Definition at line 652 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [4/12]

TEST_CASE ( "PermutationTransfer distributed value tracking cross-rank"  )

Definition at line 718 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [5/12]

TEST_CASE ( "PermutationTransfer::buildLookup cross-rank resolve with pullSet"  )

Definition at line 773 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [6/12]

TEST_CASE ( "ReorderEntities cell distributed round-robin with follow"  )

Definition at line 523 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [7/12]

TEST_CASE ( "ReorderEntities cell-only local on UniformSquare_10"  )

Definition at line 413 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [8/12]

TEST_CASE ( "ReorderEntities cell-only with face destruction on UniformSquare_10"  )

Definition at line 474 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [9/12]

TEST_CASE ( "ReorderEntities node-only local on UniformSquare_10"  )

Definition at line 597 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [10/12]

TEST_CASE ( "ReorderPlan::apply cell-only local permutation"  )

Definition at line 150 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [11/12]

TEST_CASE ( "ReorderPlan::apply node-only remap"  )

Definition at line 231 of file test_MeshReorder.cpp.

Here is the call graph for this function:

◆ TEST_CASE() [12/12]

TEST_CASE ( "ReorderRegistry register and query"  )

Definition at line 106 of file test_MeshReorder.cpp.

Here is the call graph for this function:

Variable Documentation

◆ cell2node

ArrayAdjacencyPair<2> cell2node

Definition at line 930 of file test_MeshReorder.cpp.

◆ cellOffset

DNDS::index cellOffset = (*mesh->cell2node.father->pLGlobalMapping)(mpi.rank, 0)

Definition at line 847 of file test_MeshReorder.cpp.

◆ expectedByOldGlobal

std::map<DNDS::index, std::array<DNDS::index, 3> > expectedByOldGlobal

Definition at line 858 of file test_MeshReorder.cpp.

◆ input

ReorderInput input

Definition at line 871 of file test_MeshReorder.cpp.

◆ mesh

auto mesh = buildMeshPrimary(mpi, "UniformSquare_10.cgns", 2, false)

Definition at line 834 of file test_MeshReorder.cpp.

◆ nAfter

DNDS::index nAfter = solverDOF.father->Size()

Definition at line 903 of file test_MeshReorder.cpp.

◆ nCell

const DNDS::index nCell = 4

Definition at line 926 of file test_MeshReorder.cpp.

◆ nCellBefore

DNDS::index nCellBefore = mesh->NumCell()

Definition at line 836 of file test_MeshReorder.cpp.

◆ nNode

const DNDS::index nNode = 6

Definition at line 927 of file test_MeshReorder.cpp.

◆ nodeArr

ArrayAdjacencyPair<1> nodeArr

Definition at line 935 of file test_MeshReorder.cpp.

◆ nodeOffset

DNDS::index nodeOffset = (*nodeArr.father->pLGlobalMapping)(mpi.rank, 0)

Definition at line 941 of file test_MeshReorder.cpp.

◆ oldCell2NodeByGlobal

std::map<DNDS::index, std::array<DNDS::index, 2> > oldCell2NodeByGlobal

Definition at line 951 of file test_MeshReorder.cpp.

◆ plan

auto plan = mesh->buildReorderPlan(input)

Definition at line 875 of file test_MeshReorder.cpp.

◆ pLGlobalMapping

solverDOF father pLGlobalMapping = mesh->cell2node.father->pLGlobalMapping

Definition at line 844 of file test_MeshReorder.cpp.

◆ reg

ReorderRegistry reg = mesh->buildReorderRegistry(input.destroyKinds)

Definition at line 878 of file test_MeshReorder.cpp.

◆ solverDOF

ArrayAdjacencyPair<3> solverDOF

Definition at line 840 of file test_MeshReorder.cpp.

◆ transfer

const auto& transfer = plan.transfers.at(EntityKind::Cell)

Definition at line 895 of file test_MeshReorder.cpp.