Unit tests for MeshConnectivity Interpolate (local) and InterpolateGlobal (distributed).
More...
|
| | CHECK (res.nEntities==12) |
| |
| | for (DNDS::index i=0;i< 4;i++) |
| |
| | CHECK (nInternal==4) |
| |
| | CHECK (res.nEntities - nInternal==8) |
| |
| | CHECK (actualFaces==expectedFaces) |
| |
| | CHECK (actualEdges==expectedEdges) |
| |
| | CHECK (nShared==3) |
| |
| | CHECK (actualShared==expectedShared) |
| |
| | TEST_CASE ("Regression: Interpolate matches InterpolateFace on UniformSquare_10") |
| |
| | TEST_CASE ("Interpolate: 2x2 periodic quad mesh — collaborating check required") |
| |
| | CHECK (hasMultiParent==true) |
| |
| std::vector< int > | edgeRefCount (res.nEntities, 0) |
| |
| for(DNDS::index iCell=0;iCell< 8;iCell++) for(DNDS j< res.parent2entity.father-> | RowSize (iCell) |
| |
| mesh | build (4, false, g_mpi) |
| |
| | CHECK (globalOwned==expectedFaces) |
| |
| | CHECK (globalBnd==expectedBnd) |
| |
| | CHECK (globalInt==expectedFaces - expectedBnd) |
| |
| mesh | build (4, true, g_mpi) |
| |
| cellGM | setMPIAlignBcast (g_mpi, nCellLocal) |
| |
| nodeGM | setMPIAlignBcast (g_mpi, nNodeLocal) |
| |
| cell2node | InitPair ("c2n", g_mpi) |
| |
| cell2node father | Resize (nCellLocal, 8) |
| |
| cell2nodePbi | InitPair ("c2nPbi", g_mpi) |
| |
| cellElemInfo | InitPair ("cInfo", g_mpi) |
| |
| cellElemInfo father | Resize (nCellLocal) |
| |
| for(DNDS::index ix=0;ix< N;ix++) for(DNDS iy< N;iy++) for(DNDS::index iz=0;iz< N;iz++) { DNDS::index iCell=ix *N *N+iy *N+iz;DNDS::index gx=g_mpi.rank *N+ix;for(int k=0;k< 8;k++) { cell2node.father-> | operator() (iCell, k) |
| |
| cellElemInfo father | operator() (iCell, 0) |
| |
| | addGhostLayer (leftRank, N - 1, g_mpi.rank *N - 1) |
| |
| | addGhostLayer (rightRank, 0,(g_mpi.rank+1) *N) |
| |
| k< 8;k++) allNodeGlobals.insert(cell2node.father->operator()(iCell, k));for(auto &gc :ghostCells) for(auto ng :gc.nodes) allNodeGlobals.insert(ng);std::vector< DNDS::index > ghostNodeGlobals;for(auto ng :allNodeGlobals) { DNDS::MPI_int r;DNDS::index v;if(nodeGM->search(ng, r, v) &&r !=g_mpi.rank) ghostNodeGlobals.push_back(ng);} tAdjPair dummyNode;dummyNode.InitPair("dn", g_mpi);dummyNode.father-> | Resize (nNodeLocal) |
| |
| dummyNode | TransAttach () |
| |
| dummyNode trans | createFatherGlobalMapping () |
| |
| dummyNode trans | createGhostMapping (ghostNodeGlobals) |
| |
| dummyNode trans | createMPITypes () |
| |
| | for (auto &gc :ghostCells) ghostGlobals.push_back(gc.global) |
| |
| cell2node son | Resize (static_cast< DNDS::index >(ghostCells.size()), 8) |
| |
| cellElemInfo son | Resize (static_cast< DNDS::index >(ghostCells.size())) |
| |
| cell2node trans | createGhostMapping (ghostGlobals) |
| |
| cell2nodePbi trans | BorrowGGIndexing (cell2node.trans) |
| |
| k< 8;k++) { DNDS::index &ng=cell2node(iCell, k);auto[found, r, la]=nodeGhostMapping-> | search_indexAppend (ng) |
| |
| | DNDS_assert (found) |
| |
| | CHECK (globalNBnd==0) |
| |
| | CHECK (globalNFail==0) |
| |
| | REQUIRE (bool(result.parent2entityPbi.father)) |
| |
| | CHECK (edgeGlobalOwned==expectedEdges) |
| |
| | if (bits > 1) nMultiBit++ |
| |
| | CHECK (globalMultiBit==0) |
| |
| int | main (int argc, char **argv) |
| |
|
| auto | m |
| |
| auto | query = makeFaceQuery(m.cellElemInfo) |
| |
| auto | res = MeshConnectivity::Interpolate(m.cell2node, query, 4, 9, g_mpi) |
| |
| int | nInternal = 0 |
| |
| std::set< std::set< DNDS::index > > | allVertSets |
| |
| std::set< std::set< DNDS::index > > | expectedFaces |
| |
| std::set< std::set< DNDS::index > > | actualFaces |
| |
| res | entityElemInfo |
| |
| res | i |
| |
| std::set< std::set< DNDS::index > > | expectedEdges |
| |
| std::set< std::set< DNDS::index > > | actualEdges |
| |
| int | nShared = 0 |
| |
| std::set< std::set< DNDS::index > > | expectedShared = {{1, 2}, {1, 3}, {2, 3}} |
| |
| std::set< std::set< DNDS::index > > | actualShared |
| |
| auto | pm = makePeriodic2x2x2Mesh(g_mpi) |
| |
| bool | hasMultiParent = false |
| |
| q | matchExtra = makePeriodicMatchExtra(pm.cellElemInfo, pm.cell2node, pm.cell2nodePbi, false) |
| |
| std::map< DNDS::index, std::set< DNDS::index > > | cellFN |
| |
| j | edgeRefCount [res.parent2entity.father->operator()(iCell, j)] |
| |
| DNDS::index | N = 4 |
| |
| DNDS::index | np = g_mpi.size |
| |
| DNDS::index | nCellAll = mesh.cell2node.Size() |
| |
| DNDS::index | nLocalCells = mesh.nCellLocal |
| |
| auto | faceQuery = makeHex8FaceQueryPbi(mesh.cellElemInfo) |
| |
| OwnershipResolverMulti | resolver |
| |
| auto | result |
| |
| DNDS::index | localOwned = result.nOwnedEntities |
| |
| DNDS::index | globalOwned = 0 |
| |
| DNDS::index | nBndFaces = 0 |
| |
| DNDS::index | nIntFaces = 0 |
| |
| DNDS::index | globalBnd = 0 |
| |
| DNDS::index | globalInt = 0 |
| |
| DNDS::index | expectedBnd = 2 * N * N + 2 * np * N * N + 2 * np * N * N |
| |
| DistributedHex3D | mesh |
| |
| auto | edgeQuery = makeHex8EdgeQueryPbi(mesh.cellElemInfo) |
| |
| const DNDS::index | nCellLocal = N * N * N |
| |
| const DNDS::index | nNodeLocal = N * N * N |
| |
| auto | cellGM = std::make_shared<GlobalOffsetsMapping>() |
| |
| auto | nodeGM = std::make_shared<GlobalOffsetsMapping>() |
| |
| DNDS::index | cellOff = (*cellGM)(g_mpi.rank, 0) |
| |
| DNDS::index | nodeOff = (*nodeGM)(g_mpi.rank, 0) |
| |
| auto | nodeGlobal |
| |
| auto | nodePbi |
| |
| tAdjPair | cell2node |
| |
| tPbiPair | cell2nodePbi |
| |
| tElemInfoArrayPair | cellElemInfo |
| |
| const int | di8 [8] = {0, 1, 1, 0, 0, 1, 1, 0} |
| |
| const int | dj8 [8] = {0, 0, 1, 1, 0, 0, 1, 1} |
| |
| const int | dk8 [8] = {0, 0, 0, 0, 1, 1, 1, 1} |
| |
| DNDS::MPI_int | leftRank = (g_mpi.rank - 1 + g_mpi.size) % g_mpi.size |
| |
| DNDS::MPI_int | rightRank = (g_mpi.rank + 1) % g_mpi.size |
| |
| std::vector< GhostCell > | ghostCells |
| |
| auto | addGhostLayer |
| |
| std::set< DNDS::index > | allNodeGlobals |
| |
| auto | nodeGhostMapping = dummyNode.trans.pLGhostMapping |
| |
| DNDS::index | nNodeTotal = nNodeLocal + static_cast<DNDS::index>(ghostNodeGlobals.size()) |
| |
| std::vector< DNDS::index > | ghostGlobals |
| |
| cell2node | son = std::make_shared<tAdj::element_type>(ObjName{"c2n.son"}, g_mpi) |
| |
| auto | cellGhostMapping = cell2node.trans.pLGhostMapping |
| |
| | ng = la |
| |
| faceQuery | extractPbi |
| |
| DNDS::index | nBnd = 0 |
| |
| DNDS::index | globalNBnd = 0 |
| |
| DNDS::index | globalNFail = 0 |
| |
| MPI_Allreduce & | nFail |
| |
| auto | edgeResult |
| |
| DNDS::index | edgeLocalOwned = edgeResult.nOwnedEntities |
| |
| DNDS::index | edgeGlobalOwned = 0 |
| |
| | j |
| |
| int | bits = __builtin_popcount(v) |
| |
| DNDS::index | globalMultiBit = 0 |
| |
| MPI_Allreduce & | nMultiBit |
| |
| auto | makeCoord |
| |
| auto | applyPbi |
| |
Unit tests for MeshConnectivity Interpolate (local) and InterpolateGlobal (distributed).
Tests cover face and edge extraction from 2D/3D meshes, periodic dedup with pbi collaborating check, and distributed interpolation with ownership resolution.
Definition in file test_MeshConnectivity_Interpolate.cpp.
| TEST_CASE |
( |
"Interpolate: 2x2 periodic quad mesh — collaborating check required" |
| ) |
|
Build a 2×2 quad mesh on [0,2]×[0,2], doubly-periodic (X period 2, Y period 2).
After periodic deduplication, 9 original nodes collapse to 4:
Original layout: After dedup (4 nodes): 6—7—8 0=(0,0) 1=(1,0) | 2 | 3 | 2=(0,1) 3=(1,1) 3—4—5 | 0 | 1 | Right col → left col + P1 0—1—2 Top row → bottom row + P2 Corner 8 → 0 + P1|P2
cell2node (deduped):
Definition at line 528 of file test_MeshConnectivity_Interpolate.cpp.