Loading src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_1D.cpp +64 −11 Original line number Diff line number Diff line Loading @@ -79,9 +79,9 @@ void check_Inner_1D(int rank, int nproc, const DofType& dof, typename DofType::R }; /* * Light check of 1D distriover grid and its synchronization. * Number of process is not limitated. * Overlap is limitated to 1 * Light check of 1D distributed grid and its synchronization. * Number of process is not limited. * Overlap is limited to 1 * Only double is tested as dof Real type -- it may be changed, extend test * Global size is hardcoded as 10 -- it can be changed, extend test */ Loading Loading @@ -222,7 +222,7 @@ TEST_F(DistributedGridTest_1D, SynchronizerNeighborsTest ) } TEST_F(DistributedGridTest_1D, LinearFunctionTest ) TEST_F(DistributedGridTest_1D, EvaluateLinearFunction ) { //fill mesh function with linear function (physical center of cell corresponds with its coordinates in grid) setDof_1D(dof,-1); Loading @@ -239,7 +239,7 @@ TEST_F(DistributedGridTest_1D, LinearFunctionTest ) } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithoutMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST Loading @@ -253,8 +253,30 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr, constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true ); if( rank == 0 ) EXPECT_EQ( dof[ 1 ], -nproc ) << "Left Overlap was filled by wrong process."; if( rank == nproc-1 ) EXPECT_EQ( dof[ dof.getSize() - 2 ], -1 )<< "Right Overlap was filled by wrong process."; } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithActiveMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridptr); dof.setSize( gridptr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridptr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); // Test with active mask setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr, constFunctionPtr ); Loading @@ -263,9 +285,24 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) EXPECT_EQ( dof[ 1 ], -nproc ) << "Left Overlap was filled by wrong process."; if( rank == nproc-1 ) EXPECT_EQ( dof[ dof.getSize() - 2 ], -1 )<< "Right Overlap was filled by wrong process."; } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithInactiveMaskOnLeft ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridptr); dof.setSize( gridptr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridptr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); // Test with inactive mask on the left boundary setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); maskDofs.setElement( 1, false ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); Loading @@ -274,9 +311,25 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) EXPECT_EQ( dof[ 1 ], 0 ) << "Left Overlap was filled by wrong process."; if( rank == nproc-1 ) EXPECT_EQ( dof[ dof.getSize() - 2 ], -1 )<< "Right Overlap was filled by wrong process."; } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithInactiveMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridptr); dof.setSize( gridptr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridptr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); // Test with inactive mask on both sides setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); maskDofs.setElement( 1, false ); maskDofs.setElement( dof.getSize() - 2, false ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); Loading src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp +423 −7 Original line number Diff line number Diff line Loading @@ -315,22 +315,28 @@ void check_Inner_2D(int rank, GridType grid, DofType dof, typename DofType::Real typedef MpiCommunicator CommunicatorType; typedef Grid<2,double,Host,int> GridType; typedef MeshFunction<GridType> MeshFunctionType; typedef MeshFunction< GridType, GridType::getMeshDimension(), bool > MaskType; typedef Vector<double,Host,int> DofType; typedef Vector< bool, Host, int > MaskDofType; typedef typename GridType::Cell Cell; typedef typename GridType::IndexType IndexType; typedef typename GridType::PointType PointType; typedef DistributedMesh<GridType> DistributedGridType; class DistributedGirdTest_2D : public ::testing::Test class DistributedGridTest_2D : public ::testing::Test { public: using CoordinatesType = typename GridType::CoordinatesType; DistributedGridType *distributedGrid; DofType *dof; MaskDofType maskDofs; Pointers::SharedPointer<GridType> gridPtr; Pointers::SharedPointer<MeshFunctionType> meshFunctionPtr; Pointers::SharedPointer< MaskType > maskPointer; MeshFunctionEvaluator< MeshFunctionType, ConstFunction<double,2> > constFunctionEvaluator; Pointers::SharedPointer< ConstFunction<double,2>, Host > constFunctionPtr; Loading Loading @@ -381,7 +387,7 @@ class DistributedGirdTest_2D : public ::testing::Test } }; TEST_F(DistributedGirdTest_2D, evaluateAllEntities) TEST_F(DistributedGridTest_2D, evaluateAllEntities) { //Check Traversars //All entities, without overlap Loading @@ -393,7 +399,7 @@ TEST_F(DistributedGirdTest_2D, evaluateAllEntities) check_Inner_2D(rank, *gridPtr, *dof, rank); } TEST_F(DistributedGirdTest_2D, evaluateBoundaryEntities) TEST_F(DistributedGridTest_2D, evaluateBoundaryEntities) { //Boundary entities, without overlap setDof_2D(*dof,-1); Loading @@ -404,7 +410,7 @@ TEST_F(DistributedGirdTest_2D, evaluateBoundaryEntities) check_Inner_2D(rank, *gridPtr, *dof, -1); } TEST_F(DistributedGirdTest_2D, evaluateInteriorEntities) TEST_F(DistributedGridTest_2D, evaluateInteriorEntities) { //Inner entities, without overlap setDof_2D(*dof,-1); Loading @@ -414,7 +420,7 @@ TEST_F(DistributedGirdTest_2D, evaluateInteriorEntities) check_Inner_2D(rank, *gridPtr, *dof, rank); } TEST_F(DistributedGirdTest_2D, LinearFunctionTest) TEST_F(DistributedGridTest_2D, LinearFunctionTest) { //fill meshfunction with linear function (physical center of cell corresponds with its coordinates in grid) setDof_2D(*dof,-1); Loading @@ -430,7 +436,7 @@ TEST_F(DistributedGirdTest_2D, LinearFunctionTest) } } TEST_F(DistributedGirdTest_2D, SynchronizerNeighborTest ) TEST_F(DistributedGridTest_2D, SynchronizerNeighborTest ) { //Expect 9 processes setDof_2D(*dof,-1); Loading Loading @@ -516,7 +522,7 @@ TEST_F(DistributedGirdTest_2D, SynchronizerNeighborTest ) } } TEST_F(DistributedGirdTest_2D, SynchronizerNeighborPeriodicBoundariesTest ) TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithoutMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup Loading Loading @@ -587,6 +593,416 @@ TEST_F(DistributedGirdTest_2D, SynchronizerNeighborPeriodicBoundariesTest ) } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithActiveMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInactiveMaskOnLeft ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Left ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().y(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( 1, i ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, 0 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, 3 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, 6 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiveMaskOnRight ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Right ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().y(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( gridPtr->getDimensions().x() - 2, i ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, 2 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, 5 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, 8 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiveMaskUp ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Up ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().x(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( i, 1 ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, 0 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, 1 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, 2 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiveMaskDown ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Down ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().x(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( i, gridPtr->getDimensions().y() - 2 ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, 6 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, 7 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, 8 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } #else TEST(NoMPI, NoTest) { Loading Loading
src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_1D.cpp +64 −11 Original line number Diff line number Diff line Loading @@ -79,9 +79,9 @@ void check_Inner_1D(int rank, int nproc, const DofType& dof, typename DofType::R }; /* * Light check of 1D distriover grid and its synchronization. * Number of process is not limitated. * Overlap is limitated to 1 * Light check of 1D distributed grid and its synchronization. * Number of process is not limited. * Overlap is limited to 1 * Only double is tested as dof Real type -- it may be changed, extend test * Global size is hardcoded as 10 -- it can be changed, extend test */ Loading Loading @@ -222,7 +222,7 @@ TEST_F(DistributedGridTest_1D, SynchronizerNeighborsTest ) } TEST_F(DistributedGridTest_1D, LinearFunctionTest ) TEST_F(DistributedGridTest_1D, EvaluateLinearFunction ) { //fill mesh function with linear function (physical center of cell corresponds with its coordinates in grid) setDof_1D(dof,-1); Loading @@ -239,7 +239,7 @@ TEST_F(DistributedGridTest_1D, LinearFunctionTest ) } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithoutMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST Loading @@ -253,8 +253,30 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr, constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true ); if( rank == 0 ) EXPECT_EQ( dof[ 1 ], -nproc ) << "Left Overlap was filled by wrong process."; if( rank == nproc-1 ) EXPECT_EQ( dof[ dof.getSize() - 2 ], -1 )<< "Right Overlap was filled by wrong process."; } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithActiveMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridptr); dof.setSize( gridptr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridptr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); // Test with active mask setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr, constFunctionPtr ); Loading @@ -263,9 +285,24 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) EXPECT_EQ( dof[ 1 ], -nproc ) << "Left Overlap was filled by wrong process."; if( rank == nproc-1 ) EXPECT_EQ( dof[ dof.getSize() - 2 ], -1 )<< "Right Overlap was filled by wrong process."; } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithInactiveMaskOnLeft ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridptr); dof.setSize( gridptr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridptr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); // Test with inactive mask on the left boundary setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); maskDofs.setElement( 1, false ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); Loading @@ -274,9 +311,25 @@ TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsTest ) EXPECT_EQ( dof[ 1 ], 0 ) << "Left Overlap was filled by wrong process."; if( rank == nproc-1 ) EXPECT_EQ( dof[ dof.getSize() - 2 ], -1 )<< "Right Overlap was filled by wrong process."; } TEST_F(DistributedGridTest_1D, SynchronizePeriodicNeighborsWithInactiveMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridptr); dof.setSize( gridptr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridptr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridptr, dof ); maskPointer->bind( gridptr, maskDofs ); // Test with inactive mask on both sides setDof_1D( dof, -rank-1 ); maskDofs.setValue( true ); maskDofs.setElement( 1, false ); maskDofs.setElement( dof.getSize() - 2, false ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); Loading
src/UnitTests/Meshes/DistributedMeshes/DistributedGridTest_2D.cpp +423 −7 Original line number Diff line number Diff line Loading @@ -315,22 +315,28 @@ void check_Inner_2D(int rank, GridType grid, DofType dof, typename DofType::Real typedef MpiCommunicator CommunicatorType; typedef Grid<2,double,Host,int> GridType; typedef MeshFunction<GridType> MeshFunctionType; typedef MeshFunction< GridType, GridType::getMeshDimension(), bool > MaskType; typedef Vector<double,Host,int> DofType; typedef Vector< bool, Host, int > MaskDofType; typedef typename GridType::Cell Cell; typedef typename GridType::IndexType IndexType; typedef typename GridType::PointType PointType; typedef DistributedMesh<GridType> DistributedGridType; class DistributedGirdTest_2D : public ::testing::Test class DistributedGridTest_2D : public ::testing::Test { public: using CoordinatesType = typename GridType::CoordinatesType; DistributedGridType *distributedGrid; DofType *dof; MaskDofType maskDofs; Pointers::SharedPointer<GridType> gridPtr; Pointers::SharedPointer<MeshFunctionType> meshFunctionPtr; Pointers::SharedPointer< MaskType > maskPointer; MeshFunctionEvaluator< MeshFunctionType, ConstFunction<double,2> > constFunctionEvaluator; Pointers::SharedPointer< ConstFunction<double,2>, Host > constFunctionPtr; Loading Loading @@ -381,7 +387,7 @@ class DistributedGirdTest_2D : public ::testing::Test } }; TEST_F(DistributedGirdTest_2D, evaluateAllEntities) TEST_F(DistributedGridTest_2D, evaluateAllEntities) { //Check Traversars //All entities, without overlap Loading @@ -393,7 +399,7 @@ TEST_F(DistributedGirdTest_2D, evaluateAllEntities) check_Inner_2D(rank, *gridPtr, *dof, rank); } TEST_F(DistributedGirdTest_2D, evaluateBoundaryEntities) TEST_F(DistributedGridTest_2D, evaluateBoundaryEntities) { //Boundary entities, without overlap setDof_2D(*dof,-1); Loading @@ -404,7 +410,7 @@ TEST_F(DistributedGirdTest_2D, evaluateBoundaryEntities) check_Inner_2D(rank, *gridPtr, *dof, -1); } TEST_F(DistributedGirdTest_2D, evaluateInteriorEntities) TEST_F(DistributedGridTest_2D, evaluateInteriorEntities) { //Inner entities, without overlap setDof_2D(*dof,-1); Loading @@ -414,7 +420,7 @@ TEST_F(DistributedGirdTest_2D, evaluateInteriorEntities) check_Inner_2D(rank, *gridPtr, *dof, rank); } TEST_F(DistributedGirdTest_2D, LinearFunctionTest) TEST_F(DistributedGridTest_2D, LinearFunctionTest) { //fill meshfunction with linear function (physical center of cell corresponds with its coordinates in grid) setDof_2D(*dof,-1); Loading @@ -430,7 +436,7 @@ TEST_F(DistributedGirdTest_2D, LinearFunctionTest) } } TEST_F(DistributedGirdTest_2D, SynchronizerNeighborTest ) TEST_F(DistributedGridTest_2D, SynchronizerNeighborTest ) { //Expect 9 processes setDof_2D(*dof,-1); Loading Loading @@ -516,7 +522,7 @@ TEST_F(DistributedGirdTest_2D, SynchronizerNeighborTest ) } } TEST_F(DistributedGirdTest_2D, SynchronizerNeighborPeriodicBoundariesTest ) TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithoutMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup Loading Loading @@ -587,6 +593,416 @@ TEST_F(DistributedGirdTest_2D, SynchronizerNeighborPeriodicBoundariesTest ) } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithActiveMask ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInactiveMaskOnLeft ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Left ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().y(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( 1, i ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, 0 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, 3 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, 6 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiveMaskOnRight ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Right ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().y(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( gridPtr->getDimensions().x() - 2, i ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, 2 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, 5 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, 8 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiveMaskUp ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Up ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().x(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( i, 1 ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, 0 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, 1 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, 2 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, -1 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, -2 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, -3 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } TEST_F(DistributedGridTest_2D, SynchronizerNeighborPeriodicBoundariesWithInActiveMaskDown ) { // Setup periodic boundaries // TODO: I do not know how to do it better with GTEST - additional setup // of the periodic boundaries typename DistributedGridType::SubdomainOverlapsType lowerOverlap, upperOverlap; SubdomainOverlapsGetter< GridType, CommunicatorType >:: getOverlaps( distributedGrid, lowerOverlap, upperOverlap, 1, 1 ); distributedGrid->setOverlaps( lowerOverlap, upperOverlap ); distributedGrid->setupGrid(*gridPtr); dof->setSize( gridPtr->template getEntitiesCount< Cell >() ); maskDofs.setSize( gridPtr->template getEntitiesCount< Cell >() ); meshFunctionPtr->bind( gridPtr, *dof ); maskPointer->bind( gridPtr, maskDofs ); //Expecting 9 processes setDof_2D(*dof, -rank-1 ); maskDofs.setValue( true ); if( distributedGrid->getNeighbors()[ Down ] == -1 ) { for( IndexType i = 0; i < gridPtr->getDimensions().x(); i++ ) { typename GridType::Cell cell( *gridPtr ); cell.getCoordinates() = CoordinatesType( i, gridPtr->getDimensions().y() - 2 ); cell.refresh(); maskPointer->getData().setElement( cell.getIndex(), false ); } } constFunctionEvaluator.evaluateAllEntities( meshFunctionPtr , constFunctionPtr ); meshFunctionPtr->template synchronize<CommunicatorType>( true, maskPointer ); if( rank == 0 ) { SCOPED_TRACE( "Up Left" ); checkLeftBoundary( *gridPtr, *dof, false, true, -3 ); checkUpBoundary( *gridPtr, *dof, false, true, -7 ); } if( rank == 1 ) { SCOPED_TRACE( "Up Center" ); checkUpBoundary( *gridPtr, *dof, true, true, -8 ); } if( rank == 2 ) { SCOPED_TRACE( "Up Right" ); checkRightBoundary( *gridPtr, *dof, false, true, -1 ); checkUpBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 3 ) { SCOPED_TRACE( "Center Left" ); checkLeftBoundary( *gridPtr, *dof, true, true, -6 ); } if( rank == 5 ) { SCOPED_TRACE( "Center Right" ); checkRightBoundary( *gridPtr, *dof, true, true, -4 ); } if( rank == 6 ) { SCOPED_TRACE( "Down Left" ); checkDownBoundary( *gridPtr, *dof, false, true, 6 ); checkLeftBoundary( *gridPtr, *dof, true, false, -9 ); } if( rank == 7 ) { SCOPED_TRACE( "Down Center" ); checkDownBoundary( *gridPtr, *dof, true, true, 7 ); } if( rank == 8 ) { SCOPED_TRACE( "Down Right" ); checkDownBoundary( *gridPtr, *dof, true, false, 8 ); checkRightBoundary( *gridPtr, *dof, true, false, -7 ); } } #else TEST(NoMPI, NoTest) { Loading