From 694547c8560a7f0b8b1bef19f832e62dd29c190e Mon Sep 17 00:00:00 2001 From: Antonella Ritorto Date: Thu, 19 Sep 2024 10:43:24 +0200 Subject: [PATCH] Modify global_cell_ for lgrs --- opm/grid/CpGrid.hpp | 26 +- opm/grid/cpgrid/CartesianIndexMapper.hpp | 2 +- opm/grid/cpgrid/CpGrid.cpp | 86 ++- opm/grid/cpgrid/CpGridData.cpp | 15 +- opm/grid/cpgrid/CpGridData.hpp | 2 +- opm/grid/cpgrid/Entity.hpp | 14 +- tests/cpgrid/adapt_cpgrid_test.cpp | 10 +- .../cpgrid/addLgrsOnDistributedGrid_test.cpp | 5 +- tests/cpgrid/grid_lgr_test.cpp | 701 +++++++++--------- tests/cpgrid/lookupdataCpGrid_test.cpp | 5 +- 10 files changed, 478 insertions(+), 388 deletions(-) diff --git a/opm/grid/CpGrid.hpp b/opm/grid/CpGrid.hpp index a188dca8d..40c0f59d0 100644 --- a/opm/grid/CpGrid.hpp +++ b/opm/grid/CpGrid.hpp @@ -309,7 +309,7 @@ namespace Dune /// those dealing with permeability fields from the input deck /// from whence the current CpGrid was constructed. const std::vector& globalCell() const; - + /// @brief Returns either data_ or distributed_data_(if non empty). const std::vector>& currentData() const; @@ -889,10 +889,9 @@ namespace Dune const std::vector>& cells_per_dim_vec, const int& preAdaptMaxLevel) const; - /// @brief Define the cells, cell_to_point_, global_cell_, cell_to_face_, face_to_cell_, for the leaf grid view (or adapted grid). + /// @brief Define the cells, cell_to_point_, cell_to_face_, face_to_cell_, for the leaf grid view (or adapted grid). void populateLeafGridCells(Dune::cpgrid::EntityVariableBase>& adapted_cells, std::vector>& adapted_cell_to_point, - std::vector& adapted_global_cell, const int& cell_count, cpgrid::OrientedEntityTable<0,1>& adapted_cell_to_face, cpgrid::OrientedEntityTable<1,0>& adapted_face_to_cell, @@ -922,7 +921,6 @@ namespace Dune /* Leaf grid View Cells argumemts */ Dune::cpgrid::EntityVariableBase>& adapted_cells, std::vector>& adapted_cell_to_point, - std::vector& adapted_global_cell, const int& cell_count, cpgrid::OrientedEntityTable<0,1>& adapted_cell_to_face, cpgrid::OrientedEntityTable<1,0>& adapted_face_to_cell, @@ -950,6 +948,26 @@ namespace Dune const int& preAdaptMaxLevel, const int& newLevels); + + /// @brief For refined level grids created based on startIJK and endIJK values, compute the "local ijk/Cartesian index" within the LGR. + /// + /// It's confusing that this "localIJK" is stored in CpGridData member global_cell_. Potential explanation: level zero grid is also called + /// "GLOBAL" grid. + /// Example: a level zero grid with dimension 4x3x3, an LGR with startIJK = {1,2,2}, endIJK = {3,3,3}, and cells_per_dim = {2,2,2}. + /// Then the dimension of the LGR is (3-1)*2 x (3-2)*2 x (3-2)* 2 = 4x2x2 = 16. Therefore the global_cell_lgr minimim value should be 0, + /// the maximum should be 15. + /// To invoke this method, each refined level grid must have 1. logical_cartesian_size_, 2. cell_to_idxInParentCell_, and 3. cells_per_dim_ + /// already populated. + /// + /// @param [in] level Grid index where LGR is stored + /// @param [out] global_cell_lgr + void computeGlobalCellLgr(const int& level, const std::array& startIJK, std::vector& global_cell_lgr); + + /// @brief For a leaf grid with with LGRs, we assign the global_cell_ values of either the parent cell or the equivalent cell from + /// level zero. + /// For nested refinement, we lookup the oldest ancestor, from level zero. + void computeGlobalCellLeafGridViewWithLgrs(std::vector& global_cell_leaf); + /// @brief Get the ijk index of a refined corner, given its corner index of a single-cell-refinement. /// /// Given a single-cell, we refine it in {nx, ny, nz} refined children cells (per direction). Then, this single-cell-refinement diff --git a/opm/grid/cpgrid/CartesianIndexMapper.hpp b/opm/grid/cpgrid/CartesianIndexMapper.hpp index 05f28affc..bde2cdfb9 100644 --- a/opm/grid/cpgrid/CartesianIndexMapper.hpp +++ b/opm/grid/cpgrid/CartesianIndexMapper.hpp @@ -52,7 +52,7 @@ namespace Dune int compressedLevelZeroSize() const { - + return (*grid_.currentData()[0]).size(0); } diff --git a/opm/grid/cpgrid/CpGrid.cpp b/opm/grid/cpgrid/CpGrid.cpp index 5188020d3..8ac27a266 100644 --- a/opm/grid/cpgrid/CpGrid.cpp +++ b/opm/grid/cpgrid/CpGrid.cpp @@ -630,7 +630,60 @@ const std::vector& CpGrid::globalCell() const { // Temporary. For a grid with LGRs, we set the globalCell() of the as the one for level 0. // Goal: CartesianIndexMapper well-defined for CpGrid LeafView with LGRs. - return currentData().back() -> global_cell_; + return currentData().back() /*current_view_data_ */-> global_cell_; +} + +void CpGrid::computeGlobalCellLgr(const int& level, const std::array& startIJK, std::vector& global_cell_lgr) +{ + assert(level); + for (const auto& element : elements(levelGridView(level))) { + // Element belogns to an LGR, therefore has a father. Get IJK of the father in the level grid the father was born. + // For CARFIN, parent cells belong to level 0. + std::array parentIJK = {0,0,0}; + currentData()[element.father().level()]->getIJK(element.father().index(), parentIJK); + // Each parent cell has been refined in cells_per_dim[0]*cells_per_dim[1]*cells_per_dim[2] child cells. + // element has certain 'position' inside its parent cell that can be described with 'IJK' indices, let's denote them by ijk, + // where 0<= i < cells_per_dim[0], 0<= j < cells_per_dim[1], 0<= k < cells_per_dim[2]. + const auto& cells_per_dim = currentData()[level]->cells_per_dim_; + // + // Refined cell (here 'element') has "index in parent cell": k*cells_per_dim[0]*cells_per_dim[1] + j*cells_per_dim[0] + i + // and it's stored in cell_to_idxInParentCell_. + auto idx_in_parent_cell = currentData()[level]-> cell_to_idxInParentCell_[element.index()]; // deep copy + // Find ijk. + std::array childIJK = {0,0,0}; + + childIJK[0] = idx_in_parent_cell % cells_per_dim[0]; + idx_in_parent_cell -= childIJK[0]; // k*cells_per_dim[0]*cells_per_dim[1] + j*cells_per_dim[0] + idx_in_parent_cell /= cells_per_dim[0]; // k*cells_per_dim[1] + j + childIJK[1] = idx_in_parent_cell % cells_per_dim[1]; + idx_in_parent_cell -= childIJK[1]; // k*cells_per_dim[1] + childIJK[2] = idx_in_parent_cell /cells_per_dim[1]; + // The corresponding lgrIJK can be computed as follows: + const std::array& lgrIJK = { ( (parentIJK[0] - startIJK[0])*cells_per_dim[0] ) + childIJK[0], // Shift parent index according to the startIJK of the LGR. + ( (parentIJK[1] - startIJK[1])*cells_per_dim[1] ) + childIJK[1], + ( (parentIJK[2] - startIJK[2])*cells_per_dim[2] ) + childIJK[2] }; + // Dimensions of the "patch of cells" formed when providing startIJK and endIJK for an LGR + const auto& lgr_logical_cartesian_size = currentData()[level]->logical_cartesian_size_; + global_cell_lgr[element.index()] = (lgrIJK[2]*lgr_logical_cartesian_size[0]*lgr_logical_cartesian_size[1]) + (lgrIJK[1]*lgr_logical_cartesian_size[0]) + lgrIJK[0]; + } +} + +void CpGrid::computeGlobalCellLeafGridViewWithLgrs(std::vector& global_cell_leaf) +{ + for (const auto& element: elements(leafGridView())) + { + // When refine via CpGrid::addLgrsUpdateGridView(/*...*/), level-grid to lookup global_cell_ is equal to level-zero-grid + // In the context of allowed nested refinement, we lookup for the oldest ancestor, also belonging to level-zero-grid. + auto ancestor = element.getOrigin(); + int origin_in_level_zero = ancestor.index(); + while (ancestor.level()>0){ + ancestor = ancestor.getOrigin(); + origin_in_level_zero = ancestor.getOrigin().index(); + } + assert(ancestor.level()==0); + assert(origin_in_level_zero < currentData().front()->size(0)); + global_cell_leaf[element.index()] = currentData().front()-> global_cell_[origin_in_level_zero]; + } } void CpGrid::getIJK(const int c, std::array& ijk) const @@ -1809,7 +1862,6 @@ bool CpGrid::adapt(const std::vector>& cells_per_dim_vec, cornerInMarkedElemWithEquivRefinedCorner, cells_per_dim_vec); - std::vector adapted_global_cell(cell_count, 0); updateLeafGridViewGeometries( /* Leaf grid View Corners arguments */ adapted_corners, corner_count, @@ -1822,7 +1874,6 @@ bool CpGrid::adapt(const std::vector>& cells_per_dim_vec, /* Leaf grid View Cells argumemts */ adapted_cells, adapted_cell_to_point, - adapted_global_cell, cell_count, adapted_cell_to_face, adapted_face_to_cell, @@ -1895,7 +1946,6 @@ bool CpGrid::adapt(const std::vector>& cells_per_dim_vec, (*data[refinedLevelGridIdx]).child_to_parent_cells_ = refined_child_to_parent_cells_vec[level]; (*data[refinedLevelGridIdx]).cell_to_idxInParentCell_ = refined_cell_to_idxInParentCell_vec[level]; (*data[refinedLevelGridIdx]).level_to_leaf_cells_ = refined_level_to_leaf_cells_vec[level]; - (*data[refinedLevelGridIdx]).global_cell_.swap(refined_global_cell_vec[level]); (*data[refinedLevelGridIdx]).index_set_ = std::make_unique(data[refinedLevelGridIdx]->size(0), data[refinedLevelGridIdx]->size(3)); // Determine the amount of cells per direction, per parent cell, of the corresponding LGR. @@ -1912,6 +1962,7 @@ bool CpGrid::adapt(const std::vector>& cells_per_dim_vec, } else { (*data[refinedLevelGridIdx]).logical_cartesian_size_ = (*data[0]).logical_cartesian_size_; + (*data[refinedLevelGridIdx]).global_cell_.swap(refined_global_cell_vec[level]); } // One alternative definition for logical_cartesian_size_ in the case where the marked elements for refinement do not form a block of cells, // therefore, are not associated with the keyword CARFIN, is to imagine that we put all the marked elements one next to the other, along @@ -1927,7 +1978,6 @@ bool CpGrid::adapt(const std::vector>& cells_per_dim_vec, (*data[levels + preAdaptMaxLevel +1]).child_to_parent_cells_ = adapted_child_to_parent_cells; (*data[levels + preAdaptMaxLevel +1]).cell_to_idxInParentCell_ = adapted_cell_to_idxInParentCell; (*data[levels + preAdaptMaxLevel +1]).leaf_to_level_cells_ = leaf_to_level_cells; - (*data[levels + preAdaptMaxLevel +1]).global_cell_.swap(adapted_global_cell); (*data[levels + preAdaptMaxLevel +1]).index_set_ = std::make_unique(data[levels + preAdaptMaxLevel +1]->size(0), data[levels + preAdaptMaxLevel +1]->size(3)); (*data[levels + preAdaptMaxLevel +1]).logical_cartesian_size_ = (*data[0]).logical_cartesian_size_; @@ -1935,6 +1985,24 @@ bool CpGrid::adapt(const std::vector>& cells_per_dim_vec, // Update the leaf grid view current_view_data_ = data.back().get(); + // When the refinement is determined by startIJK and endIJK values, the LGR has a (local) Cartesian size. + // Therefore, each refined cell belonging to the LGR can be associated with a (local) IJK and its (local) Cartesian index. + // If the LGR has NXxNYxNZ dimension, then the Cartesian indices take values + // k*NN*NY + j*NX + i, where i.global_cell_[ refined cell index (~element.index()) ] = k*NN*NY + j*NX + i. + if (isCARFIN) { + for (int level = 0; level < levels; ++level) { + const int refinedLevelGridIdx = level + preAdaptMaxLevel +1; + std::vector global_cell_lgr(data[refinedLevelGridIdx]->size(0)); + computeGlobalCellLgr(refinedLevelGridIdx, startIJK_vec[level], global_cell_lgr); + (*data[refinedLevelGridIdx]).global_cell_.swap(global_cell_lgr); + } + } + + std::vector global_cell_leaf( data[levels + preAdaptMaxLevel +1]->size(0)); + computeGlobalCellLeafGridViewWithLgrs(global_cell_leaf); + (*data[levels + preAdaptMaxLevel +1]).global_cell_.swap(global_cell_leaf); + updateCornerHistoryLevels(cornerInMarkedElemWithEquivRefinedCorner, elemLgrAndElemLgrCorner_to_refinedLevelAndRefinedCorner, adaptedCorner_to_elemLgrAndElemLgrCorner, @@ -2112,6 +2180,7 @@ void CpGrid::addLgrsUpdateLeafView(const std::vector>& cells_p auto globalActiveLgrs = comm().sum(non_empty_lgrs); if(globalActiveLgrs == 0) { Opm::OpmLog::warning("All the LGRs contain only inactive cells.\n"); + // OPM_THROW(std::logic_error, "All the LGRs contain only inactive cells.\n"); } preAdapt(); @@ -2529,7 +2598,7 @@ CpGrid::defineChildToParentAndIdxInParentCell(const std::map,s const auto& element = Dune::cpgrid::Entity<0>(*current_view_data_, elemLgr, true); // elemLgr == parent cell index in starting grid. refined_child_to_parent_cells_vec[shiftedLevel][cell] = {element.level(), element.getEquivLevelElem().index()}; refined_cell_to_idxInParentCell_vec[shiftedLevel][cell] = elemLgrCell; - } + } } return std::make_tuple>>, std::vector>, @@ -3237,7 +3306,6 @@ void CpGrid::populateRefinedFaces(std::vector>& adapted_cells, std::vector>& adapted_cell_to_point, - std::vector& adapted_global_cell, const int& cell_count, cpgrid::OrientedEntityTable<0,1>& adapted_cell_to_face, cpgrid::OrientedEntityTable<1,0>& adapted_face_to_cell, @@ -3265,8 +3333,6 @@ void CpGrid::populateLeafGridCells(Dune::cpgrid::EntityVariableBase(elemLgrCell, true); - adapted_global_cell[cell] = current_view_data_->global_cell_[(elemLgr == -1) ? elemLgrCell : elemLgr]; - // Auxiliary cell_to_face std::vector> aux_cell_to_face; @@ -3574,7 +3640,6 @@ void CpGrid::updateLeafGridViewGeometries( /* Leaf grid View Corners arguments * /* Leaf grid View Cells argumemts */ Dune::cpgrid::EntityVariableBase>& adapted_cells, std::vector>& adapted_cell_to_point, - std::vector& adapted_global_cell, const int& cell_count, cpgrid::OrientedEntityTable<0,1>& adapted_cell_to_face, cpgrid::OrientedEntityTable<1,0>& adapted_face_to_cell, @@ -3617,7 +3682,6 @@ void CpGrid::updateLeafGridViewGeometries( /* Leaf grid View Corners arguments * // --- Adapted cells --- populateLeafGridCells(adapted_cells, adapted_cell_to_point, - adapted_global_cell, cell_count, adapted_cell_to_face, adapted_face_to_cell, diff --git a/opm/grid/cpgrid/CpGridData.cpp b/opm/grid/cpgrid/CpGridData.cpp index f9afd1c17..f76f53651 100644 --- a/opm/grid/cpgrid/CpGridData.cpp +++ b/opm/grid/cpgrid/CpGridData.cpp @@ -1710,16 +1710,17 @@ void CpGridData::computeCommunicationInterfaces([[maybe_unused]] int noExistingP #endif } -std::array,8> CpGridData::getReferenceRefinedCorners(int idxInParentCell, const std::array& cells_per_dim) const +std::array,8> CpGridData::getReferenceRefinedCorners(const int& idx_in_parent_cell, const std::array& cells_per_dim) const { // Refined cells in parent cell: k*cells_per_dim[0]*cells_per_dim[1] + j*cells_per_dim[0] + i std::array ijk = {0,0,0}; - ijk[0] = idxInParentCell % cells_per_dim[0]; - idxInParentCell -= ijk[0]; // k*cells_per_dim[0]*cells_per_dim[1] + j*cells_per_dim[0] - idxInParentCell /= cells_per_dim[0]; // k*cells_per_dim[1] + j - ijk[1] = idxInParentCell % cells_per_dim[1]; - idxInParentCell -= ijk[1]; // k*cells_per_dim[1] - ijk[2] = idxInParentCell /cells_per_dim[1]; + int idx_copy = idx_in_parent_cell; + ijk[0] = idx_copy % cells_per_dim[0]; + idx_copy -= ijk[0]; // k*cells_per_dim[0]*cells_per_dim[1] + j*cells_per_dim[0] + idx_copy /= cells_per_dim[0]; // k*cells_per_dim[1] + j + ijk[1] = idx_copy % cells_per_dim[1]; + idx_copy -= ijk[1]; // k*cells_per_dim[1] + ijk[2] = idx_copy /cells_per_dim[1]; std::array,8> corners_in_parent_reference_elem = { // corner '0' {{ double(ijk[0])/cells_per_dim[0], double(ijk[1])/cells_per_dim[1], double(ijk[2])/cells_per_dim[2] }, diff --git a/opm/grid/cpgrid/CpGridData.hpp b/opm/grid/cpgrid/CpGridData.hpp index baa1a4852..c0320f03c 100644 --- a/opm/grid/cpgrid/CpGridData.hpp +++ b/opm/grid/cpgrid/CpGridData.hpp @@ -381,7 +381,7 @@ class CpGridData void postAdapt(); private: - std::array,8> getReferenceRefinedCorners(int idxInParentCell, const std::array& cells_per_dim) const; + std::array,8> getReferenceRefinedCorners(const int& idx_in_parent_cell, const std::array& cells_per_dim) const; /// @brief Compute amount of cells in each direction of a patch of cells. (Cartesian grid required). /// diff --git a/opm/grid/cpgrid/Entity.hpp b/opm/grid/cpgrid/Entity.hpp index 737764fec..5e3ef0056 100644 --- a/opm/grid/cpgrid/Entity.hpp +++ b/opm/grid/cpgrid/Entity.hpp @@ -529,11 +529,10 @@ Dune::cpgrid::Geometry<3,3> Dune::cpgrid::Entity::geometryInFather() cons if (!(this->hasFather())){ OPM_THROW(std::logic_error, "Entity has no father."); } - if (pgrid_ -> cell_to_idxInParentCell_[this->index()] !=-1) { - int idxInParentCell = pgrid_ -> cell_to_idxInParentCell_[this->index()]; - assert(idxInParentCell>-1); + const int& idx_in_parent_cell = pgrid_ -> cell_to_idxInParentCell_[this->index()]; + if (idx_in_parent_cell !=-1) { const auto& cells_per_dim = (*(pgrid_ -> level_data_ptr_))[this->level()] -> cells_per_dim_; - const auto& auxArr = pgrid_ -> getReferenceRefinedCorners(idxInParentCell, cells_per_dim); + const auto& auxArr = pgrid_ -> getReferenceRefinedCorners(idx_in_parent_cell, cells_per_dim); FieldVector corners_in_father_reference_elem_temp[8] = { auxArr[0], auxArr[1], auxArr[2], auxArr[3], auxArr[4], auxArr[5], auxArr[6], auxArr[7]}; auto in_father_reference_elem_corners = std::make_shared, 3>>(); @@ -614,10 +613,9 @@ Dune::cpgrid::Entity<0> Dune::cpgrid::Entity::getEquivLevelElem() const template int Dune::cpgrid::Entity::getLevelCartesianIdx() const { - const auto entityLevel = this -> level(); - const auto level = (*(pgrid_ -> level_data_ptr_))[entityLevel].get(); - const auto& elemInLevel = this->getLevelElem(); // throws when the entity does not belong to the leaf grid view. - return level -> global_cell_[elemInLevel.index()]; + const auto& level_data = (*(pgrid_ -> level_data_ptr_))[level()].get(); + // getLevelElem() throws when the entity does not belong to the leaf grid view. + return level_data -> global_cell_[getLevelElem().index()]; } } // namespace cpgrid diff --git a/tests/cpgrid/adapt_cpgrid_test.cpp b/tests/cpgrid/adapt_cpgrid_test.cpp index e62bfa3a5..075296d28 100644 --- a/tests/cpgrid/adapt_cpgrid_test.cpp +++ b/tests/cpgrid/adapt_cpgrid_test.cpp @@ -105,6 +105,7 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, BOOST_CHECK(static_cast(data.size()) == coarse_grid.maxLevel() +2); const auto& leafGridIdx = coarse_grid.maxLevel() +1; const auto& adapted_leaf = *data[leafGridIdx]; + if(isBlockShape) { // For a mixed grid that gets refined a second time, isBlockShape == false, even though the marked elements form a block. const auto& blockRefinement_data = other_grid.currentData(); const auto& blockRefinement_leaf = *blockRefinement_data.back(); @@ -207,6 +208,11 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, const auto& grid_view = coarse_grid.leafGridView(); Dune::MultipleCodimMultipleGeomTypeMapper adaptMapper(grid_view, Dune::mcmgElementLayout()); + auto itMin = std::min_element((data.back() -> global_cell_).begin(), (data.back()-> global_cell_).end()); + auto itMax = std::max_element((data.back() -> global_cell_).begin(), (data.back() -> global_cell_).end()); + BOOST_CHECK_EQUAL( *itMin, 0); + BOOST_CHECK_EQUAL( *itMax, data.front()-> size(0) -1); + for(const auto& element: elements(grid_view)) { // postAdapt() has been called, therefore every element gets marked with 0 BOOST_CHECK( coarse_grid.getMark(element) == 0); @@ -241,10 +247,6 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, BOOST_CHECK_EQUAL( child_to_parent[1], element.father().index()); BOOST_CHECK( element.father() == element.getOrigin()); - const auto& auxLevel = (element.father().level() == 0) ? element.getOrigin().level() : element.getLevelElem().level(); - const auto& auxLevelIdx = (element.father().level() == 0) ? element.getOrigin().index() : element.getLevelElem().index(); - BOOST_CHECK( ( adapted_leaf.global_cell_[element.index()]) == (data[auxLevel]->global_cell_[auxLevelIdx]) ); - BOOST_CHECK( std::get<0>(data[element.father().level()]->parent_to_children_cells_[element.father().index()]) == element.level()); // Check amount of children cells of the parent cell BOOST_CHECK_EQUAL(std::get<1>(data[element.father().level()]->parent_to_children_cells_[child_to_parent[1]]).size(), diff --git a/tests/cpgrid/addLgrsOnDistributedGrid_test.cpp b/tests/cpgrid/addLgrsOnDistributedGrid_test.cpp index 5215886ce..f6bf2f407 100644 --- a/tests/cpgrid/addLgrsOnDistributedGrid_test.cpp +++ b/tests/cpgrid/addLgrsOnDistributedGrid_test.cpp @@ -175,14 +175,13 @@ void refinePatch_and_check(Dune::CpGrid& coarse_grid, } BOOST_CHECK( entity.level() == 0); } - + // LGRs for (int cell = 0; cell < data[level]-> size(0); ++cell) { Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[level], cell, true); BOOST_CHECK( entity.hasFather() == true); BOOST_CHECK( entity.getOrigin() == entity.father()); - BOOST_CHECK( entity.index() == (data[level] -> global_cell_[entity.index()])); // global_cell_ = {0,1,..., total cells -1} BOOST_CHECK( entity.getOrigin().level() == 0); BOOST_CHECK_CLOSE(entity.geometryInFather().volume(), 1./(cells_per_dim_vec[level-1][0]*cells_per_dim_vec[level-1][1]*cells_per_dim_vec[level-1][2]), 1e-6); @@ -249,8 +248,6 @@ void refinePatch_and_check(Dune::CpGrid& coarse_grid, BOOST_CHECK_EQUAL( child_to_parent[0] == 0, true); BOOST_CHECK_EQUAL( child_to_parent[1], entity.father().index()); BOOST_CHECK( entity.father() == entity.getOrigin()); - BOOST_CHECK( (data[startIJK_vec.size() +1] -> global_cell_[entity.index()]) == - (data[0] -> global_cell_[entity.getOrigin().index()]) ); BOOST_CHECK( entity.getOrigin().level() == 0); BOOST_CHECK( std::get<0>((*data[0]).parent_to_children_cells_[child_to_parent[1]]) == entity.level()); BOOST_CHECK_EQUAL((std::find(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).begin(), diff --git a/tests/cpgrid/grid_lgr_test.cpp b/tests/cpgrid/grid_lgr_test.cpp index f6ffe89f0..4c32be810 100644 --- a/tests/cpgrid/grid_lgr_test.cpp +++ b/tests/cpgrid/grid_lgr_test.cpp @@ -123,18 +123,7 @@ void refinePatch_and_check(Dune::CpGrid& coarse_grid, BOOST_CHECK( (*data[0]).child_to_parent_cells_.empty()); BOOST_CHECK(coarse_grid.getLgrNameToLevel().at("GLOBAL") == 0); const auto& all_parent_cell_indices = (*data[0]).getPatchesCells(startIJK_vec, endIJK_vec); - - for (long unsigned int level = 1; level < startIJK_vec.size() +1; ++level) // only 1 when there is only 1 patch - { - check_refinedPatch_grid(cells_per_dim_vec[level-1], startIJK_vec[level-1], endIJK_vec[level-1], - (*data[level]).geometry_.template geomVector<0>(), - (*data[level]).geometry_.template geomVector<1>(), - (*data[level]).geometry_.template geomVector<3>()); - BOOST_CHECK( (*data[level]).parent_to_children_cells_.empty()); - BOOST_CHECK(coarse_grid.getLgrNameToLevel().at(lgr_name_vec[level-1]) == static_cast(level)); - - const auto& patch_cells = (*data[0]).getPatchCells(startIJK_vec[level-1], endIJK_vec[level-1]); - + // GLOBAL grid for (int cell = 0; cell < data[0]-> size(0); ++cell) { @@ -144,422 +133,443 @@ void refinePatch_and_check(Dune::CpGrid& coarse_grid, BOOST_CHECK_THROW(entity.geometryInFather(), std::logic_error); BOOST_CHECK( entity.getOrigin() == entity); BOOST_CHECK( entity.getOrigin().level() == 0); - auto it = entity.hbegin(coarse_grid.maxLevel()); + + auto it = entity.hbegin(coarse_grid.maxLevel()); // With element.level(), fails auto endIt = entity.hend(coarse_grid.maxLevel()); - const auto& [lgr, childrenList] = (*data[0]).parent_to_children_cells_[cell]; - if (std::find(all_parent_cell_indices.begin(), all_parent_cell_indices.end(), cell) == all_parent_cell_indices.end()){ + const auto& [lgr, childrenList] = (*data[0]).parent_to_children_cells_[entity.index()]; + // If it == endIt, then entity.isLeaf() true (when dristibuted_data_ is empty) + if (it == endIt){ BOOST_CHECK_EQUAL(lgr, -1); BOOST_CHECK(childrenList.empty()); BOOST_CHECK( entity.isLeaf() == true); - // If it == endIt, then entity.isLeaf() true (when dristibuted_data_ is empty) - BOOST_CHECK( it == endIt); + BOOST_CHECK( entity.mightVanish() == false); } else{ BOOST_CHECK(lgr != -1); - BOOST_CHECK(childrenList.size() > 1); + // If it != endIt, then entity.isLeaf() false (when dristibuted_data_ is empty) + BOOST_CHECK_EQUAL( it == endIt, false); + BOOST_CHECK( entity.mightVanish() == true); + BOOST_CHECK( entity.isNew() == false); + BOOST_CHECK_EQUAL( entity.isLeaf(), false); // parent cells do not appear in the LeafView + // Auxiliary int to check amount of children double referenceElemOneParent_volume = 0.; std::array referenceElem_entity_center = {0.,0.,0.}; // Expected {.5,.5,.5} for (const auto& child : childrenList) { BOOST_CHECK( child != -1); - BOOST_CHECK( data[lgr]-> child_to_parent_cells_[child][0] == 0); - BOOST_CHECK( data[lgr]-> child_to_parent_cells_[child][1] == cell); + BOOST_CHECK( data[lgr]-> child_to_parent_cells_[child][0] == 0); // + BOOST_CHECK( data[lgr]-> child_to_parent_cells_[child][1] == entity.index()); const auto& childElem = Dune::cpgrid::Entity<0>(*data[lgr], child, true); + const auto& childGeoInFather = childElem.geometryInFather(); + BOOST_CHECK(childElem.hasFather() == true); BOOST_CHECK(childElem.level() == lgr); - referenceElemOneParent_volume += childElem.geometryInFather().volume(); + referenceElemOneParent_volume += childGeoInFather.volume(); for (int c = 0; c < 3; ++c) { - referenceElem_entity_center[c] += (childElem.geometryInFather().center())[c]; + referenceElem_entity_center[c] += childGeoInFather.center()[c]; } } - BOOST_CHECK_EQUAL( entity.isLeaf(), false); // parent cells do not appear in the LeafView - // Auxiliary int to check hierarchic iterator functionality + /// Auxiliary int to check amount of children double referenceElemOneParent_volume_it = 0.; std::array referenceElem_entity_center_it = {0.,0.,0.}; // Expected {.5,.5,.5} - // If it != endIt, then entity.isLeaf() false (when dristibuted_data_ is empty) - BOOST_CHECK( it != endIt ); for (; it != endIt; ++it) { - // Do something with the son available through it-> BOOST_CHECK(it ->hasFather() == true); BOOST_CHECK(it ->level() == lgr); - referenceElemOneParent_volume_it += it-> geometryInFather().volume(); + const auto& geoInFather = it-> geometryInFather(); + + referenceElemOneParent_volume_it += geoInFather.volume(); for (int c = 0; c < 3; ++c) { - referenceElem_entity_center_it[c] += (it-> geometryInFather().center())[c]; + referenceElem_entity_center_it[c] += geoInFather.center()[c]; } } - for (int c = 0; c < 3; ++c) - { - referenceElem_entity_center[c] - /= cells_per_dim_vec[lgr-1][0]*cells_per_dim_vec[lgr-1][1]*cells_per_dim_vec[lgr-1][2]; - referenceElem_entity_center_it[c] - /= cells_per_dim_vec[lgr-1][0]*cells_per_dim_vec[lgr-1][1]*cells_per_dim_vec[lgr-1][2]; + for (int c = 0; c < 3; ++c) { + referenceElem_entity_center[c] /= cells_per_dim_vec[lgr-1][0]*cells_per_dim_vec[lgr-1][1]*cells_per_dim_vec[lgr-1][2]; + referenceElem_entity_center_it[c] /= cells_per_dim_vec[lgr-1][0]*cells_per_dim_vec[lgr-1][1]*cells_per_dim_vec[lgr-1][2]; } BOOST_CHECK_CLOSE(referenceElemOneParent_volume, 1, 1e-13); BOOST_CHECK_CLOSE(referenceElem_entity_center[0], .5, 1e-13); BOOST_CHECK_CLOSE(referenceElem_entity_center[1], .5, 1e-13); BOOST_CHECK_CLOSE(referenceElem_entity_center[2], .5, 1e-13); + BOOST_CHECK_CLOSE(referenceElemOneParent_volume_it, 1, 1e-13); BOOST_CHECK_CLOSE(referenceElem_entity_center_it[0], .5, 1e-13); BOOST_CHECK_CLOSE(referenceElem_entity_center_it[1], .5, 1e-13); BOOST_CHECK_CLOSE(referenceElem_entity_center_it[2], .5, 1e-13); + + /////////////////////// } BOOST_CHECK( entity.level() == 0); - } + } // end-GLOBAL/LevelZero-grid - // LGRs - for (int cell = 0; cell < data[level]-> size(0); ++cell) - { - Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[level], cell, true); - BOOST_CHECK( entity.hasFather() == true); - BOOST_CHECK( entity.getOrigin() == entity.father()); - BOOST_CHECK( entity.index() == (data[level] -> global_cell_[entity.index()])); // global_cell_ = {0,1,..., total cells -1} - BOOST_CHECK( entity.getOrigin().level() == 0); - BOOST_CHECK_CLOSE(entity.geometryInFather().volume(), - 1./(cells_per_dim_vec[level-1][0]*cells_per_dim_vec[level-1][1]*cells_per_dim_vec[level-1][2]), 1e-6); - BOOST_CHECK(entity.father().level() == 0); - // Check entity.father().index() belongs to the patch_cells (corresponding LGR parents) - BOOST_CHECK_EQUAL((std::find(patch_cells.begin(), patch_cells.end(), - entity.father().index()) == patch_cells.end()) , false); - const auto& child_to_parent = (*data[level]).child_to_parent_cells_[cell]; - BOOST_CHECK_EQUAL( child_to_parent[0] == -1, false); - BOOST_CHECK_EQUAL( child_to_parent[0] == 0, true); - BOOST_CHECK_EQUAL( child_to_parent[1], entity.father().index()); - BOOST_CHECK( std::get<0>((*data[0]).parent_to_children_cells_[child_to_parent[1]]) == entity.level()); - BOOST_CHECK_EQUAL((std::find(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).begin(), - std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).end(), - entity.index()) == - std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).end()) , false); - // Check amount of children cells of the parent cell - BOOST_CHECK_EQUAL(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).size(), - cells_per_dim_vec[level-1][0]*cells_per_dim_vec[level-1][1]*cells_per_dim_vec[level-1][2]); - BOOST_CHECK( entity.level() == static_cast(level)); - BOOST_CHECK( entity.isLeaf() == true); - auto it = entity.hbegin(coarse_grid.maxLevel()); - auto endIt = entity.hend(coarse_grid.maxLevel()); - // If entity.isLeaf(), then it == endIt (when dristibuted_data_ is empty) - BOOST_CHECK( it == endIt); - } - // LeafView faces - for (int face = 0; face < data[startIJK_vec.size()+1]-> face_to_cell_.size(); ++face) + for (long unsigned int level = 1; level < startIJK_vec.size() +1; ++level) // only 1 when there is only 1 patch { - const auto& faceToPoint = (*data[startIJK_vec.size() +1]).face_to_point_[face]; - BOOST_CHECK(faceToPoint.size() == 4); - for (int i = 0; i < 4; ++i) { - BOOST_CHECK((*data[startIJK_vec.size() +1]).face_to_point_[face][i] != -1); - } + check_refinedPatch_grid(cells_per_dim_vec[level-1], startIJK_vec[level-1], endIJK_vec[level-1], + (*data[level]).geometry_.template geomVector<0>(), + (*data[level]).geometry_.template geomVector<1>(), + (*data[level]).geometry_.template geomVector<3>()); + BOOST_CHECK( (*data[level]).parent_to_children_cells_.empty()); + BOOST_CHECK(coarse_grid.getLgrNameToLevel().at(lgr_name_vec[level-1]) == static_cast(level)); - Dune::cpgrid::EntityRep<1> faceEntity(face, true); - BOOST_CHECK((*data[startIJK_vec.size() +1]).face_to_cell_[faceEntity].size() < 3); - } + auto itMin = std::min_element((data[level] -> global_cell_).begin(), (data[level] -> global_cell_).end()); + auto itMax = std::max_element((data[level] -> global_cell_).begin(), (data[level] -> global_cell_).end()); + BOOST_CHECK_EQUAL( *itMin, 0); + BOOST_CHECK_EQUAL( *itMax, data[level]-> size(0) -1); - // LeafView - for (int cell = 0; cell < data[startIJK_vec.size()+1]-> size(0); ++cell) - { - BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_point_[cell].size() == 8); - for (int i = 0; i < 8; ++i) - { - BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_point_[cell][i] != -1); - } - Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[startIJK_vec.size()+1], cell, true); - for (int i = 0; i < data[startIJK_vec.size()+1] -> cell_to_face_[entity].size(); ++i) + + // LGRs + for (int cell = 0; cell < data[level]-> size(0); ++cell) { - BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_face_[entity][i].index() != -1); - } - const auto& child_to_parent = (*data[startIJK_vec.size()+1]).child_to_parent_cells_[cell]; - const auto& level_cellIdx = (*data[startIJK_vec.size()+1]).leaf_to_level_cells_[entity.index()]; - auto it = entity.hbegin(coarse_grid.maxLevel()); - auto endIt = entity.hend(coarse_grid.maxLevel()); - BOOST_CHECK(entity.isLeaf()); - BOOST_CHECK(it == endIt); - if (entity.hasFather()){ + Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[level], cell, true); + BOOST_CHECK( entity.hasFather() == true); + BOOST_CHECK( entity.getOrigin() == entity.father()); + BOOST_CHECK( entity.getOrigin().level() == 0); BOOST_CHECK_CLOSE(entity.geometryInFather().volume(), - 1./(cells_per_dim_vec[entity.level()-1][0] - *cells_per_dim_vec[entity.level()-1][1] - *cells_per_dim_vec[entity.level()-1][2]), 1e-6); + 1./(cells_per_dim_vec[level-1][0]*cells_per_dim_vec[level-1][1]*cells_per_dim_vec[level-1][2]), 1e-6); BOOST_CHECK(entity.father().level() == 0); - BOOST_CHECK_EQUAL( (std::find(all_parent_cell_indices.begin(), all_parent_cell_indices.end(), - entity.father().index()) == all_parent_cell_indices.end()), false); - BOOST_CHECK(child_to_parent[0] != -1); + const auto& child_to_parent = (*data[level]).child_to_parent_cells_[cell]; + BOOST_CHECK_EQUAL( child_to_parent[0] == -1, false); BOOST_CHECK_EQUAL( child_to_parent[0] == 0, true); BOOST_CHECK_EQUAL( child_to_parent[1], entity.father().index()); - BOOST_CHECK( entity.father() == entity.getOrigin()); - BOOST_CHECK( (data[startIJK_vec.size() +1] -> global_cell_[entity.index()]) == - (data[0] -> global_cell_[entity.getOrigin().index()]) ); - BOOST_CHECK( entity.getOrigin().level() == 0); BOOST_CHECK( std::get<0>((*data[0]).parent_to_children_cells_[child_to_parent[1]]) == entity.level()); BOOST_CHECK_EQUAL((std::find(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).begin(), std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).end(), - level_cellIdx[1]) == + entity.index()) == std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).end()) , false); // Check amount of children cells of the parent cell BOOST_CHECK_EQUAL(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).size(), - cells_per_dim_vec[entity.level()-1][0]* - cells_per_dim_vec[entity.level()-1][1]*cells_per_dim_vec[entity.level()-1][2]); - BOOST_CHECK( entity.father().isLeaf() == false); - BOOST_CHECK( (entity.level() > 0) || (entity.level() < static_cast(startIJK_vec.size()) +1)); - BOOST_CHECK( level_cellIdx[0] == entity.level()); + cells_per_dim_vec[level-1][0]*cells_per_dim_vec[level-1][1]*cells_per_dim_vec[level-1][2]); + BOOST_CHECK( entity.level() == static_cast(level)); + BOOST_CHECK( entity.isLeaf() == true); + auto it = entity.hbegin(coarse_grid.maxLevel()); + auto endIt = entity.hend(coarse_grid.maxLevel()); + // If entity.isLeaf(), then it == endIt (when dristibuted_data_ is empty) + BOOST_CHECK( it == endIt); } - else{ - BOOST_CHECK_THROW(entity.father(), std::logic_error); - BOOST_CHECK_THROW(entity.geometryInFather(), std::logic_error); - BOOST_CHECK_EQUAL(child_to_parent[0], -1); - BOOST_CHECK_EQUAL(child_to_parent[1], -1); - BOOST_CHECK( level_cellIdx[0] == 0); - BOOST_CHECK( std::get<0>((*data[0]).parent_to_children_cells_[level_cellIdx[1]]) == -1); - BOOST_CHECK( std::get<1>((*data[0]).parent_to_children_cells_[level_cellIdx[1]]).empty()); - BOOST_CHECK( entity.level() == 0); - // Get index of the cell in level 0 - const auto& entityOldIdx = (*data[startIJK_vec.size()+1]).leaf_to_level_cells_[entity.index()][1]; - BOOST_CHECK( entity.getOrigin().index() == entityOldIdx); - BOOST_CHECK( entity.getOrigin().level() == 0); - // Get IJK of the old index - std::array entityOldIJK; - (*data[0]).getIJK(entityOldIdx, entityOldIJK); // ijk - // Get the entity cell_to_face_ on the LeafView - const auto& leaf_cell_to_face = - (*data[startIJK_vec.size()+1]).cell_to_face_[Dune::cpgrid::EntityRep<0>(entity.index(), true)]; - int face_count = 0; - bool touch_patch_onLeftFace = false; // false -> 0, true -> 1 - bool touch_patch_onRightFace = false; - bool touch_patch_onFrontFace = false; - bool touch_patch_onBackFace = false; - bool touch_patch_onBottomFace = false; - bool touch_patch_onTopFace = false; - // CHECK LEFT FACE(S) - for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) + + // LeafView faces + for (int face = 0; face < data[startIJK_vec.size()+1]-> face_to_cell_.size(); ++face) + { + const auto& faceToPoint = (*data[startIJK_vec.size() +1]).face_to_point_[face]; + BOOST_CHECK(faceToPoint.size() == 4); + for (int i = 0; i < 4; ++i) { + BOOST_CHECK((*data[startIJK_vec.size() +1]).face_to_point_[face][i] != -1); + } + + Dune::cpgrid::EntityRep<1> faceEntity(face, true); + BOOST_CHECK((*data[startIJK_vec.size() +1]).face_to_cell_[faceEntity].size() < 3); + } + + // LeafView + for (int cell = 0; cell < data[startIJK_vec.size()+1]-> size(0); ++cell) + { + BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_point_[cell].size() == 8); + for (int i = 0; i < 8; ++i) { - // LEFT Check if i == endIJK_vec[patch][0] (and j, k in the range) for some patch. - // If true, increase amount of faces by cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2] - // Auxiliary bool - touch_patch_onLeftFace = touch_patch_onLeftFace || - ((entityOldIJK[0] == endIJK_vec[patch][0]) && - (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1]) && - (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); - if (touch_patch_onLeftFace) + BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_point_[cell][i] != -1); + } + Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[startIJK_vec.size()+1], cell, true); + for (int i = 0; i < data[startIJK_vec.size()+1] -> cell_to_face_[entity].size(); ++i) + { + BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_face_[entity][i].index() != -1); + } + const auto& child_to_parent = (*data[startIJK_vec.size()+1]).child_to_parent_cells_[cell]; + const auto& level_cellIdx = (*data[startIJK_vec.size()+1]).leaf_to_level_cells_[entity.index()]; + auto it = entity.hbegin(coarse_grid.maxLevel()); + auto endIt = entity.hend(coarse_grid.maxLevel()); + BOOST_CHECK(entity.isLeaf()); + BOOST_CHECK(it == endIt); + if (entity.hasFather()){ + BOOST_CHECK_CLOSE(entity.geometryInFather().volume(), + 1./(cells_per_dim_vec[entity.level()-1][0] + *cells_per_dim_vec[entity.level()-1][1] + *cells_per_dim_vec[entity.level()-1][2]), 1e-6); + BOOST_CHECK(entity.father().level() == 0); + BOOST_CHECK_EQUAL( (std::find(all_parent_cell_indices.begin(), all_parent_cell_indices.end(), + entity.father().index()) == all_parent_cell_indices.end()), false); + BOOST_CHECK(child_to_parent[0] != -1); + BOOST_CHECK_EQUAL( child_to_parent[0] == 0, true); + BOOST_CHECK_EQUAL( child_to_parent[1], entity.father().index()); + BOOST_CHECK( entity.father() == entity.getOrigin()); + BOOST_CHECK( entity.getOrigin().level() == 0); + BOOST_CHECK( std::get<0>((*data[0]).parent_to_children_cells_[child_to_parent[1]]) == entity.level()); + BOOST_CHECK_EQUAL((std::find(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).begin(), + std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).end(), + level_cellIdx[1]) == + std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).end()) , false); + // Check amount of children cells of the parent cell + BOOST_CHECK_EQUAL(std::get<1>((*data[0]).parent_to_children_cells_[child_to_parent[1]]).size(), + cells_per_dim_vec[entity.level()-1][0]* + cells_per_dim_vec[entity.level()-1][1]*cells_per_dim_vec[entity.level()-1][2]); + BOOST_CHECK( entity.father().isLeaf() == false); + BOOST_CHECK( (entity.level() > 0) || (entity.level() < static_cast(startIJK_vec.size()) +1)); + BOOST_CHECK( level_cellIdx[0] == entity.level()); + } + else{ + BOOST_CHECK_THROW(entity.father(), std::logic_error); + BOOST_CHECK_THROW(entity.geometryInFather(), std::logic_error); + BOOST_CHECK_EQUAL(child_to_parent[0], -1); + BOOST_CHECK_EQUAL(child_to_parent[1], -1); + BOOST_CHECK( level_cellIdx[0] == 0); + BOOST_CHECK( std::get<0>((*data[0]).parent_to_children_cells_[level_cellIdx[1]]) == -1); + BOOST_CHECK( std::get<1>((*data[0]).parent_to_children_cells_[level_cellIdx[1]]).empty()); + BOOST_CHECK( entity.level() == 0); + // Get index of the cell in level 0 + const auto& entityOldIdx = (*data[startIJK_vec.size()+1]).leaf_to_level_cells_[entity.index()][1]; + BOOST_CHECK( entity.getOrigin().index() == entityOldIdx); + BOOST_CHECK( entity.getOrigin().level() == 0); + // Get IJK of the old index + std::array entityOldIJK; + (*data[0]).getIJK(entityOldIdx, entityOldIJK); // ijk + // Get the entity cell_to_face_ on the LeafView + const auto& leaf_cell_to_face = + (*data[startIJK_vec.size()+1]).cell_to_face_[Dune::cpgrid::EntityRep<0>(entity.index(), true)]; + int face_count = 0; + bool touch_patch_onLeftFace = false; // false -> 0, true -> 1 + bool touch_patch_onRightFace = false; + bool touch_patch_onFrontFace = false; + bool touch_patch_onBackFace = false; + bool touch_patch_onBottomFace = false; + bool touch_patch_onTopFace = false; + // CHECK LEFT FACE(S) + for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) + { + // LEFT Check if i == endIJK_vec[patch][0] (and j, k in the range) for some patch. + // If true, increase amount of faces by cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2] + // Auxiliary bool + touch_patch_onLeftFace = touch_patch_onLeftFace || + ((entityOldIJK[0] == endIJK_vec[patch][0]) && + (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1]) && + (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); + if (touch_patch_onLeftFace) + { + face_count += touch_patch_onLeftFace*(cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2]); + break; + } + } // end patch-for-loop + // CHECK RIGHT FACE(S) + for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) + { + // RIGHT Check if i+1 == startIJK_vec[patch][0] (and j, k in the range) for some patch. + // If true, increase amount of faces by cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2] + // Auxiliary bool + touch_patch_onRightFace = touch_patch_onRightFace || + ((entityOldIJK[0]+1 == startIJK_vec[patch][0]) && + (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1]) && + (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); + if (touch_patch_onRightFace) + { + face_count += touch_patch_onRightFace*(cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2]); + break; + } + } // end patch-for-loop + // CHECK FRONT FACE(S) + for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) { - face_count += touch_patch_onLeftFace*(cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2]); - break; + // FRONT Check if j == endIJK_vec[patch][1] (and i, k in the range) for some patch. + // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2] + // Auxiliary bool + touch_patch_onFrontFace = touch_patch_onFrontFace || + ((entityOldIJK[1] == endIJK_vec[patch][1]) && + (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && + (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); + if (touch_patch_onFrontFace) + { + face_count += touch_patch_onFrontFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2]); + break; + } + } // end patch-for-loop + // CHECK BACK FACE(S) + for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) + { + // BACK Check if j+1 == statIJK_vec[patch][1] (and i, k in the range) for some patch. + // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2] + // Auxiliary bool + touch_patch_onBackFace = touch_patch_onBackFace || + ((entityOldIJK[1]+1 == startIJK_vec[patch][1]) && + (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && + (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); + if (touch_patch_onBackFace) + { + face_count += touch_patch_onBackFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2]); + break; + } + } // end patch-for-loop + // CHECK BOTTOM FACE(S) + for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) + { + // BOTTOM Check if k == endIJK_vec[patch][2] (and i, j in the range) for some patch. + // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][1] + // Auxiliary bool + touch_patch_onBottomFace = touch_patch_onBottomFace || + ((entityOldIJK[2] == endIJK_vec[patch][2]) && + (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && + (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1])); + if (touch_patch_onBottomFace) + { + face_count += touch_patch_onBottomFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][1]); + break; + } + } // end patch-for-loop + // CHECK TOP FACE(S) + for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) + { + // TOP Check if k+1 == startIJK_vec[patch][2] (and i, j in the range) for some patch. + // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2] + // Auxiliary bool + touch_patch_onTopFace = touch_patch_onTopFace || + ((entityOldIJK[2]+1 == startIJK_vec[patch][2]) && + (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && + (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1])); + if (touch_patch_onTopFace) + { + face_count += touch_patch_onTopFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][1]); + break; + } + } // end patch-for-loop + if (!touch_patch_onLeftFace) + { + face_count +=1; } - } // end patch-for-loop - // CHECK RIGHT FACE(S) - for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) - { - // RIGHT Check if i+1 == startIJK_vec[patch][0] (and j, k in the range) for some patch. - // If true, increase amount of faces by cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2] - // Auxiliary bool - touch_patch_onRightFace = touch_patch_onRightFace || - ((entityOldIJK[0]+1 == startIJK_vec[patch][0]) && - (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1]) && - (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); - if (touch_patch_onRightFace) + if (!touch_patch_onRightFace) { - face_count += touch_patch_onRightFace*(cells_per_dim_vec[patch][1]*cells_per_dim_vec[patch][2]); - break; + face_count +=1; } - } // end patch-for-loop - // CHECK FRONT FACE(S) - for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) - { - // FRONT Check if j == endIJK_vec[patch][1] (and i, k in the range) for some patch. - // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2] - // Auxiliary bool - touch_patch_onFrontFace = touch_patch_onFrontFace || - ((entityOldIJK[1] == endIJK_vec[patch][1]) && - (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && - (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); - if (touch_patch_onFrontFace) + if (!touch_patch_onFrontFace) { - face_count += touch_patch_onFrontFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2]); - break; + face_count +=1; } - } // end patch-for-loop - // CHECK BACK FACE(S) - for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) - { - // BACK Check if j+1 == statIJK_vec[patch][1] (and i, k in the range) for some patch. - // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2] - // Auxiliary bool - touch_patch_onBackFace = touch_patch_onBackFace || - ((entityOldIJK[1]+1 == startIJK_vec[patch][1]) && - (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && - (entityOldIJK[2] >= startIJK_vec[patch][2]) && (entityOldIJK[2] < endIJK_vec[patch][2])); - if (touch_patch_onBackFace) + if (!touch_patch_onBackFace) { - face_count += touch_patch_onBackFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2]); - break; + face_count +=1; } - } // end patch-for-loop - // CHECK BOTTOM FACE(S) - for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) - { - // BOTTOM Check if k == endIJK_vec[patch][2] (and i, j in the range) for some patch. - // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][1] - // Auxiliary bool - touch_patch_onBottomFace = touch_patch_onBottomFace || - ((entityOldIJK[2] == endIJK_vec[patch][2]) && - (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && - (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1])); - if (touch_patch_onBottomFace) + if (!touch_patch_onBottomFace) { - face_count += touch_patch_onBottomFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][1]); - break; + face_count +=1; } - } // end patch-for-loop - // CHECK TOP FACE(S) - for (long unsigned int patch = 0; patch < startIJK_vec.size(); ++patch) - { - // TOP Check if k+1 == startIJK_vec[patch][2] (and i, j in the range) for some patch. - // If true, increase amount of faces by cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][2] - // Auxiliary bool - touch_patch_onTopFace = touch_patch_onTopFace || - ((entityOldIJK[2]+1 == startIJK_vec[patch][2]) && - (entityOldIJK[0] >= startIJK_vec[patch][0]) && (entityOldIJK[0] < endIJK_vec[patch][0]) && - (entityOldIJK[1] >= startIJK_vec[patch][1]) && (entityOldIJK[1] < endIJK_vec[patch][1])); - if (touch_patch_onTopFace) + if (!touch_patch_onTopFace) { - face_count += touch_patch_onTopFace*(cells_per_dim_vec[patch][0]*cells_per_dim_vec[patch][1]); - break; + face_count +=1; } - } // end patch-for-loop - if (!touch_patch_onLeftFace) - { - face_count +=1; - } - if (!touch_patch_onRightFace) - { - face_count +=1; - } - if (!touch_patch_onFrontFace) - { - face_count +=1; - } - if (!touch_patch_onBackFace) - { - face_count +=1; - } - if (!touch_patch_onBottomFace) - { - face_count +=1; - } - if (!touch_patch_onTopFace) - { - face_count +=1; - } - BOOST_CHECK( leaf_cell_to_face.size() == face_count); - } // end else - } - } // end-level-for-loop + BOOST_CHECK( leaf_cell_to_face.size() == face_count); + } // end else + } + } // end-level-for-loop - BOOST_CHECK( static_cast(startIJK_vec.size()) == coarse_grid.maxLevel()); - BOOST_CHECK( (*data[data.size()-1]).parent_to_children_cells_.empty()); + BOOST_CHECK( static_cast(startIJK_vec.size()) == coarse_grid.maxLevel()); + BOOST_CHECK( (*data[data.size()-1]).parent_to_children_cells_.empty()); - for (long unsigned int l = 0; l < startIJK_vec.size() +1; ++l) // level 0,1,2,... , last patch - { - const auto& view = coarse_grid.levelGridView(l); - for (const auto& element: elements(view)){ - BOOST_CHECK_EQUAL(element.level(), l); + auto itMin = std::min_element((data.back() -> global_cell_).begin(), (data.back()-> global_cell_).end()); + auto itMax = std::max_element((data.back() -> global_cell_).begin(), (data.back() -> global_cell_).end()); + BOOST_CHECK_EQUAL( *itMin, 0); + BOOST_CHECK_EQUAL( *itMax, data.front()-> size(0) -1); + + for (long unsigned int l = 0; l < startIJK_vec.size() +1; ++l) // level 0,1,2,... , last patch + { + const auto& view = coarse_grid.levelGridView(l); + for (const auto& element: elements(view)){ + BOOST_CHECK_EQUAL(element.level(), l); + } } - } - std::vector leaf_to_parent_cell; // To store parent cell index, when leaf cell has a parent. Empty entry otherwise. - leaf_to_parent_cell.resize(data[startIJK_vec.size()+1]-> size(0)); // Correct size. - - Dune::MultipleCodimMultipleGeomTypeMapper leafMapper(coarse_grid.leafGridView(), Dune::mcmgElementLayout()); - Dune::MultipleCodimMultipleGeomTypeMapper level0Mapper(coarse_grid.levelGridView(0), Dune::mcmgElementLayout()); - - for (const auto& element: elements(coarse_grid.leafGridView())){ - BOOST_CHECK( ((element.level() >= 0) || (element.level() < static_cast(startIJK_vec.size()) +1))); - if (element.hasFather()) { // leaf_cell has a father! - leaf_to_parent_cell[leafMapper.index(element)] = level0Mapper.index(element.father()); - const auto& parent_id = data[0]->localIdSet().id(element.father()); - BOOST_CHECK(element.index() == leafMapper.index(element)); - BOOST_CHECK(element.father().index() == leaf_to_parent_cell[element.index()]); - BOOST_CHECK(element.father().index() == parent_id); - BOOST_CHECK(element.father().index() == level0Mapper.index(element.father())); + std::vector leaf_to_parent_cell; // To store parent cell index, when leaf cell has a parent. Empty entry otherwise. + leaf_to_parent_cell.resize(data[startIJK_vec.size()+1]-> size(0)); // Correct size. + + Dune::MultipleCodimMultipleGeomTypeMapper leafMapper(coarse_grid.leafGridView(), Dune::mcmgElementLayout()); + Dune::MultipleCodimMultipleGeomTypeMapper level0Mapper(coarse_grid.levelGridView(0), Dune::mcmgElementLayout()); + + for (const auto& element: elements(coarse_grid.leafGridView())){ + BOOST_CHECK( ((element.level() >= 0) || (element.level() < static_cast(startIJK_vec.size()) +1))); + if (element.hasFather()) { // leaf_cell has a father! + leaf_to_parent_cell[leafMapper.index(element)] = level0Mapper.index(element.father()); + const auto& parent_id = data[0]->localIdSet().id(element.father()); + BOOST_CHECK(element.index() == leafMapper.index(element)); + BOOST_CHECK(element.father().index() == leaf_to_parent_cell[element.index()]); + BOOST_CHECK(element.father().index() == parent_id); + BOOST_CHECK(element.father().index() == level0Mapper.index(element.father())); + } } - } - std::set allIds_set; - std::vector allIds_vec; - allIds_vec.reserve(data.back()->size(0) + data.back()->size(3)); - for (const auto& element: elements(coarse_grid.leafGridView())){ - const auto& localId = data.back()->localIdSet().id(element); - const auto& globalId = data.back()->globalIdSet().id(element); - // In serial run, local and global id coincide: - BOOST_CHECK_EQUAL(localId, globalId); - allIds_set.insert(localId); - allIds_vec.push_back(localId); - // Check that the global_id_set_ptr_ has the correct id (id from the level where the entity was born). - BOOST_CHECK_EQUAL( coarse_grid.globalIdSet().id(element), data[element.level()]->localIdSet().id(element.getEquivLevelElem())); - } - // Check injectivity of the map local_id_set_ (and, indirectly, global_id_set_) after adding cell ids. - BOOST_CHECK( allIds_set.size() == allIds_vec.size()); - - for (const auto& point : vertices(coarse_grid.leafGridView())){ - const auto& localId = data.back()->localIdSet().id(point); - const auto& globalId = data.back()->globalIdSet().id(point); - BOOST_CHECK_EQUAL(localId, globalId); - allIds_set.insert(localId); - allIds_vec.push_back(localId); - // Check that the global_id_set_ptr_ has the correct id (id from the level where the entity was born). - } - // Check injectivity of the map local_id_set_ (and, indirectly, global_id_set_) after adding point ids. - BOOST_CHECK( allIds_set.size() == allIds_vec.size()); - - // Local/Global id sets for level grids (level 0, 1, ..., maxLevel) - for (int level = 0; level < coarse_grid.maxLevel() +1; ++level) - { - std::set levelIds_set; - std::vector levelIds_vec; - levelIds_vec.reserve(data[level]->size(0) + data[level]->size(3)); - for (const auto& element: elements(coarse_grid.levelGridView(level))){ - const auto& localId = data[level]->localIdSet().id(element); - const auto& globalId = data[level]->globalIdSet().id(element); + std::set allIds_set; + std::vector allIds_vec; + allIds_vec.reserve(data.back()->size(0) + data.back()->size(3)); + for (const auto& element: elements(coarse_grid.leafGridView())){ + const auto& localId = data.back()->localIdSet().id(element); + const auto& globalId = data.back()->globalIdSet().id(element); // In serial run, local and global id coincide: BOOST_CHECK_EQUAL(localId, globalId); - levelIds_set.insert(localId); - levelIds_vec.push_back(localId); - // Search in the leaf grid view elements for the element with the same id, if it exists. - if (auto itIsLeaf = std::find_if( elements(coarse_grid.leafGridView()).begin(), - elements(coarse_grid.leafGridView()).end(), - [localId, data](const Dune::cpgrid::Entity<0>& leafElem) - { return (localId == data.back()->localIdSet().id(leafElem)); }); - itIsLeaf != elements(coarse_grid.leafGridView()).end()) { - BOOST_CHECK( itIsLeaf->getEquivLevelElem() == element); - } - if (element.isLeaf()) { // Check that the id of a cell not involved in any further refinement appears on the IdSet of the leaf grid view. - BOOST_CHECK( std::find(allIds_set.begin(), allIds_set.end(), localId) != allIds_set.end()); - } - else { // Check that the id of a cell that vanished during refinement does not appear on the IdSet of the leaf grid view. - BOOST_CHECK( std::find(allIds_set.begin(), allIds_set.end(), localId) == allIds_set.end()); - } - const auto& idx = data[level]->indexSet().index(element); - // In serial run, local and global id coincide: - BOOST_CHECK_EQUAL(idx, element.index()); + allIds_set.insert(localId); + allIds_vec.push_back(localId); + // Check that the global_id_set_ptr_ has the correct id (id from the level where the entity was born). + BOOST_CHECK_EQUAL( coarse_grid.globalIdSet().id(element), data[element.level()]->localIdSet().id(element.getEquivLevelElem())); } + // Check injectivity of the map local_id_set_ (and, indirectly, global_id_set_) after adding cell ids. + BOOST_CHECK( allIds_set.size() == allIds_vec.size()); - for (const auto& point : vertices(coarse_grid.levelGridView(level))) { - const auto& localId = data[level]->localIdSet().id(point); - const auto& globalId = data[level]->globalIdSet().id(point); + for (const auto& point : vertices(coarse_grid.leafGridView())){ + const auto& localId = data.back()->localIdSet().id(point); + const auto& globalId = data.back()->globalIdSet().id(point); BOOST_CHECK_EQUAL(localId, globalId); - levelIds_set.insert(localId); - levelIds_vec.push_back(localId); - // Search in the leaf grid view elements for the element with the same id, if it exists. - if (auto itIsLeaf = std::find_if( vertices(coarse_grid.leafGridView()).begin(), - vertices(coarse_grid.leafGridView()).end(), - [localId, data](const Dune::cpgrid::Entity<3>& leafPoint) - { return (localId == data.back()->localIdSet().id(leafPoint)); }); - itIsLeaf != vertices(coarse_grid.leafGridView()).end()) { - BOOST_CHECK( (*itIsLeaf).geometry().center() == point.geometry().center() ); + allIds_set.insert(localId); + allIds_vec.push_back(localId); + // Check that the global_id_set_ptr_ has the correct id (id from the level where the entity was born). + } + // Check injectivity of the map local_id_set_ (and, indirectly, global_id_set_) after adding point ids. + BOOST_CHECK( allIds_set.size() == allIds_vec.size()); + + // Local/Global id sets for level grids (level 0, 1, ..., maxLevel) + for (int level = 0; level < coarse_grid.maxLevel() +1; ++level) + { + std::set levelIds_set; + std::vector levelIds_vec; + levelIds_vec.reserve(data[level]->size(0) + data[level]->size(3)); + for (const auto& element: elements(coarse_grid.levelGridView(level))){ + const auto& localId = data[level]->localIdSet().id(element); + const auto& globalId = data[level]->globalIdSet().id(element); + // In serial run, local and global id coincide: + BOOST_CHECK_EQUAL(localId, globalId); + levelIds_set.insert(localId); + levelIds_vec.push_back(localId); + // Search in the leaf grid view elements for the element with the same id, if it exists. + if (auto itIsLeaf = std::find_if( elements(coarse_grid.leafGridView()).begin(), + elements(coarse_grid.leafGridView()).end(), + [localId, data](const Dune::cpgrid::Entity<0>& leafElem) + { return (localId == data.back()->localIdSet().id(leafElem)); }); + itIsLeaf != elements(coarse_grid.leafGridView()).end()) { + BOOST_CHECK( itIsLeaf->getEquivLevelElem() == element); + } + if (element.isLeaf()) { // Check that the id of a cell not involved in any further refinement appears on the IdSet of the leaf grid view. + BOOST_CHECK( std::find(allIds_set.begin(), allIds_set.end(), localId) != allIds_set.end()); + } + else { // Check that the id of a cell that vanished during refinement does not appear on the IdSet of the leaf grid view. + BOOST_CHECK( std::find(allIds_set.begin(), allIds_set.end(), localId) == allIds_set.end()); + } + const auto& idx = data[level]->indexSet().index(element); + // In serial run, local and global id coincide: + BOOST_CHECK_EQUAL(idx, element.index()); } + + for (const auto& point : vertices(coarse_grid.levelGridView(level))) { + const auto& localId = data[level]->localIdSet().id(point); + const auto& globalId = data[level]->globalIdSet().id(point); + BOOST_CHECK_EQUAL(localId, globalId); + levelIds_set.insert(localId); + levelIds_vec.push_back(localId); + // Search in the leaf grid view elements for the element with the same id, if it exists. + if (auto itIsLeaf = std::find_if( vertices(coarse_grid.leafGridView()).begin(), + vertices(coarse_grid.leafGridView()).end(), + [localId, data](const Dune::cpgrid::Entity<3>& leafPoint) + { return (localId == data.back()->localIdSet().id(leafPoint)); }); + itIsLeaf != vertices(coarse_grid.leafGridView()).end()) { + BOOST_CHECK( (*itIsLeaf).geometry().center() == point.geometry().center() ); + } + } + // Check injectivity of the map local_id_set_ (and, indirectly, global_id_set_) + BOOST_CHECK( levelIds_set.size() == levelIds_vec.size()); } - // Check injectivity of the map local_id_set_ (and, indirectly, global_id_set_) - BOOST_CHECK( levelIds_set.size() == levelIds_vec.size()); - } } catch (const std::exception& e) { std::cout << e.what() << "'\n"; @@ -890,4 +900,3 @@ BOOST_AUTO_TEST_CASE(global_norefine) check_global_refine(coarse_grid, fine_grid); } - diff --git a/tests/cpgrid/lookupdataCpGrid_test.cpp b/tests/cpgrid/lookupdataCpGrid_test.cpp index 2722574d3..7acd83275 100644 --- a/tests/cpgrid/lookupdataCpGrid_test.cpp +++ b/tests/cpgrid/lookupdataCpGrid_test.cpp @@ -195,6 +195,7 @@ BOOST_AUTO_TEST_CASE(one_lgr_grid) const std::array cells_per_dim = {2,2,2}; const std::array startIJK = {1,0,1}; const std::array endIJK = {3,2,3}; // patch_dim = {3-1, 2-0, 3-1} ={2,2,2} + // Cells to be refined {13,14,17,18, 25,26,29,30} const std::string lgr_name = {"LGR1"}; grid.addLgrsUpdateLeafView({cells_per_dim}, {startIJK}, {endIJK}, {lgr_name}); @@ -353,7 +354,7 @@ void fieldProp_check(const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::st BOOST_AUTO_TEST_CASE(fieldProp) { - const std::string deckString = + const std::string deckString = R"( RUNSPEC DIMENS 1 1 5 / @@ -405,7 +406,7 @@ BOOST_AUTO_TEST_CASE(fieldProp) { BOOST_AUTO_TEST_CASE(fieldPropLgr) { - const std::string deckString = R"( RUNSPEC + const std::string deckString = R"( RUNSPEC DIMENS 1 1 5 /