From 12a3ac70a13154aaf419373de695bd7cf609d20c Mon Sep 17 00:00:00 2001 From: Pietro Incardona <incardon@mpi-cbg.de> Date: Tue, 20 Oct 2015 10:29:58 +0200 Subject: [PATCH] Copy decomposition for grid --- src/Decomposition/ie_loc_ghost.hpp | 2 +- src/Grid/grid_dist_id.hpp | 7 ++--- src/Grid/grid_dist_id_unit_test.hpp | 44 ++++++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/Decomposition/ie_loc_ghost.hpp b/src/Decomposition/ie_loc_ghost.hpp index e60791e6..06f13c43 100644 --- a/src/Decomposition/ie_loc_ghost.hpp +++ b/src/Decomposition/ie_loc_ghost.hpp @@ -131,7 +131,7 @@ public: * * \param id sub-domain id * - * \return the number of internal ghost box + * \return the number of external ghost box * */ inline size_t getLocalNEGhost(size_t id) diff --git a/src/Grid/grid_dist_id.hpp b/src/Grid/grid_dist_id.hpp index 8bc10131..fcfb2122 100644 --- a/src/Grid/grid_dist_id.hpp +++ b/src/Grid/grid_dist_id.hpp @@ -39,6 +39,8 @@ * \snippet grid_dist_id_unit_test.hpp Create and access a distributed grid complex * ### Synchronize a distributed grid for complex structures * \snippet grid_dist_id_unit_test.hpp Synchronized distributed grid complex + * ### Construct two grid with the same decomposition + * \snippet grid_dist_id_unit_test.hpp Construct two grid with the same decomposition * */ template<unsigned int dim, typename St, typename T, typename Decomposition,typename Memory=HeapMemory , typename device_grid=grid_cpu<dim,T> > @@ -368,11 +370,6 @@ public: // fill the global size of the grid for (size_t i = 0 ; i < dim ; i++) {this->g_sz[i] = g_sz[i];} - // Get the number of processor and calculate the number of sub-domain - // for decomposition - size_t n_proc = v_cl.getProcessingUnits(); - size_t n_sub = n_proc * SUB_UNIT_FACTOR; - // Create local grid Create(); diff --git a/src/Grid/grid_dist_id_unit_test.hpp b/src/Grid/grid_dist_id_unit_test.hpp index d5fe3841..71d50c60 100644 --- a/src/Grid/grid_dist_id_unit_test.hpp +++ b/src/Grid/grid_dist_id_unit_test.hpp @@ -616,8 +616,6 @@ void Test3D_complex(const Box<3,float> & domain, long int k) void Test3D_dup(const Box<3,float> & domain, long int k) { - typedef Point_test<float> p; - long int big_step = k / 30; big_step = (big_step == 0)?1:big_step; long int small_step = 1; @@ -646,7 +644,7 @@ void Test3D_dup(const Box<3,float> & domain, long int k) // Ghost Ghost<3,float> g(0.01 / factor); - //! [Construct two grid with the same topology] + //! [Construct two grid with the same decomposition] // Distributed grid with id decomposition grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> g_dist1(sz,domain,g); @@ -654,7 +652,9 @@ void Test3D_dup(const Box<3,float> & domain, long int k) // another grid with the same decomposition grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> g_dist2(g_dist1.getDecomposition(),sz,domain,g); - //! [Construct two grid with the same topology] + //! [Construct two grid with the same decomposition] + + BOOST_REQUIRE_EQUAL(g_dist2.getDecomposition().ref(),2); auto dom_g1 = g_dist1.getDomainIterator(); auto dom_g2 = g_dist2.getDomainIterator(); @@ -674,6 +674,42 @@ void Test3D_dup(const Box<3,float> & domain, long int k) BOOST_REQUIRE_EQUAL(check,true); } + + // 3D test + for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step ) + { + BOOST_TEST_CHECKPOINT( "Testing 3D copy decomposition grid k=" << k ); + + // grid size + size_t sz[3]; + sz[0] = k; + sz[1] = k; + sz[2] = k; + + // factor + float factor = pow(global_v_cluster->getProcessingUnits()/2.0f,1.0f/3.0f); + + // Ghost + Ghost<3,float> g(0.01 / factor); + + //! [Construct two grid with the same decomposition] + + // Distributed grid with id decomposition + grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> * g_dist1 = new grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>>(sz,domain,g); + + // another grid with the same decomposition + grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> * g_dist2 = new grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>>(g_dist1->getDecomposition(),sz,domain,g); + + //! [Construct two grid with the same decomposition] + + BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().ref(),2); + + delete g_dist1; + + BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().ref(),1); + BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().getLocalNEGhost(0) != 0, true); + BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().check_consistency(),false); + } } BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use) -- GitLab