From 9cb47c0085c58178faddee2e0da6de8318afdcaf Mon Sep 17 00:00:00 2001 From: Antonella Ritorto Date: Mon, 16 Sep 2024 11:51:15 +0200 Subject: [PATCH 1/3] Remove testInactiveCellsLgrs friend decl from CpGridData.hpp --- opm/grid/cpgrid/CpGridData.cpp | 25 ++++++ opm/grid/cpgrid/CpGridData.hpp | 27 +++--- tests/cpgrid/inactiveCell_lgr_test.cpp | 113 ++++++------------------- 3 files changed, 66 insertions(+), 99 deletions(-) diff --git a/opm/grid/cpgrid/CpGridData.cpp b/opm/grid/cpgrid/CpGridData.cpp index f9afd1c17..13ab22195 100644 --- a/opm/grid/cpgrid/CpGridData.cpp +++ b/opm/grid/cpgrid/CpGridData.cpp @@ -1710,6 +1710,31 @@ void CpGridData::computeCommunicationInterfaces([[maybe_unused]] int noExistingP #endif } +int CpGridData::numFaces() const +{ + return face_to_cell_.size(); +} + +int CpGridData::numFaceVertices(int face_idx) const +{ + return face_to_point_[face_idx].size(); +} + +int CpGridData::faceVertex(int face_idx, int local_vertex_index) const +{ + return face_to_point_[face_idx][local_vertex_index]; +} + +int CpGridData::numFaceCells(Dune::cpgrid::EntityRep<1> face) const +{ + return face_to_cell_[face].size(); +} + +int CpGridData::faceCell(Dune::cpgrid::EntityRep<1> face, int local_cell_index) const +{ + return face_to_cell_[face][local_cell_index].index(); +} + std::array,8> CpGridData::getReferenceRefinedCorners(int idxInParentCell, 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 diff --git a/opm/grid/cpgrid/CpGridData.hpp b/opm/grid/cpgrid/CpGridData.hpp index baa1a4852..938084fd8 100644 --- a/opm/grid/cpgrid/CpGridData.hpp +++ b/opm/grid/cpgrid/CpGridData.hpp @@ -124,12 +124,6 @@ void check_global_refine(const Dune::CpGrid&, void fieldProp_check(const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::string deck_string); -void testInactiveCellsLgrs(const std::string&, - const std::vector>&, - const std::vector>&, - const std::vector>&, - const std::vector&); - namespace Dune { namespace cpgrid @@ -182,12 +176,6 @@ class CpGridData const Dune::CpGrid&); friend void ::fieldProp_check(const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::string deck_string); - friend - void ::testInactiveCellsLgrs(const std::string&, - const std::vector>&, - const std::vector>&, - const std::vector>&, - const std::vector&); private: CpGridData(const CpGridData& g); @@ -309,6 +297,21 @@ class CpGridData ijk[2] = gc / logical_cartesian_size_[1]; } + /// Total amount of faces on the grid. + int numFaces() const; + + /// Given a face index, total amount of its corners/points/vertices. + int numFaceVertices(int face_idx) const; + + /// Given a face index and the local index of a vertex (0,..., numFaceVertices() -1), returns the vertex index (on the grid). + int faceVertex(int face_idx, int local_vertex_index) const; + + /// Given a face index, total amount of its cells (1 or 2 maximum). + int numFaceCells(Dune::cpgrid::EntityRep<1> face) const; + + /// Given a face index and the local index of a cell (0,1 maximum), returns the cell index (on the grid). + int faceCell(Dune::cpgrid::EntityRep<1> face, int local_cell_index) const; + /// @brief Determine if a finite amount of patches (of cells) are disjoint, namely, they do not share any corner nor face. /// /// @param [in] startIJK_vec Vector of Cartesian triplet indices where each patch starts. diff --git a/tests/cpgrid/inactiveCell_lgr_test.cpp b/tests/cpgrid/inactiveCell_lgr_test.cpp index d648a9c36..bbf76d291 100644 --- a/tests/cpgrid/inactiveCell_lgr_test.cpp +++ b/tests/cpgrid/inactiveCell_lgr_test.cpp @@ -88,17 +88,13 @@ void testInactiveCellsLgrs(const std::string& deckString, auto& data = grid.currentData(); BOOST_CHECK(data.size() == startIJK_vec.size() + 2); - BOOST_CHECK( (*data[0]).child_to_parent_cells_.empty()); BOOST_CHECK(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 { - BOOST_CHECK( (*data[level]).parent_to_children_cells_.empty()); BOOST_CHECK(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) { @@ -110,44 +106,30 @@ void testInactiveCellsLgrs(const std::string& deckString, BOOST_CHECK( entity.getOrigin().level() == 0); auto it = entity.hbegin(grid.maxLevel()); auto endIt = entity.hend(grid.maxLevel()); - const auto& [lgr, childrenList] = (*data[0]).parent_to_children_cells_[cell]; if (data[0]->getMark(entity) == 0){ - 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); } else{ - BOOST_CHECK(lgr != -1); - BOOST_CHECK(childrenList.size() > 1); - // 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); - - const auto& childElem = Dune::cpgrid::Entity<0>(*data[lgr], child, true); - BOOST_CHECK(childElem.hasFather() == true); - BOOST_CHECK(childElem.level() == lgr); - referenceElemOneParent_volume += childElem.geometryInFather().volume(); - for (int c = 0; c < 3; ++c) { - referenceElem_entity_center[c] += (childElem.geometryInFather().center())[c]; - } - } + BOOST_CHECK(data[0]->getMark(entity) == 1); BOOST_CHECK_EQUAL( entity.isLeaf(), false); // parent cells do not appear in the LeafView // Auxiliary int to check hierarchic iterator functionality 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 ); + // Auxiliary integer to get refined level grid where the entity got refined + int lgr = 0; for (; it != endIt; ++it) { // Do something with the son available through it-> BOOST_CHECK(it ->hasFather() == true); - BOOST_CHECK(it ->level() == lgr); + BOOST_CHECK(it -> father() == entity); + BOOST_CHECK(it -> father().level() == 0); + BOOST_CHECK(it ->father().index() == entity.index()); + BOOST_CHECK(it ->level() > 0); // When adhere to DUNE's Grid interface, it should be it->level() == it->father().level() +1. + lgr = it->level(); // All children in the same refined grid. referenceElemOneParent_volume_it += it-> geometryInFather().volume(); for (int c = 0; c < 3; ++c) { @@ -156,15 +138,9 @@ void testInactiveCellsLgrs(const std::string& deckString, } 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); @@ -179,25 +155,13 @@ void testInactiveCellsLgrs(const std::string& deckString, 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.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() has been marked for refinement (corresponding LGR parents) BOOST_CHECK_EQUAL( data[0]->getMark(entity.father()), 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( 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(grid.maxLevel()); @@ -207,33 +171,31 @@ void testInactiveCellsLgrs(const std::string& deckString, } // LeafView faces - for (int face = 0; face < data[startIJK_vec.size()+1]-> face_to_cell_.size(); ++face) + for (int face = 0; face < data[startIJK_vec.size()+1]-> numFaces(); ++face) { - const auto& faceToPoint = (*data[startIJK_vec.size() +1]).face_to_point_[face]; - BOOST_CHECK(faceToPoint.size() == 4); + BOOST_CHECK( (*data[startIJK_vec.size() +1]).numFaceVertices(face) == 4); for (int i = 0; i < 4; ++i) { - BOOST_CHECK((*data[startIJK_vec.size() +1]).face_to_point_[face][i] != -1); + BOOST_CHECK((*data[startIJK_vec.size() +1]).faceVertex(face,i) != -1); } - Dune::cpgrid::EntityRep<1> faceEntity(face, true); - BOOST_CHECK((*data[startIJK_vec.size() +1]).face_to_cell_[faceEntity].size() < 3); + BOOST_CHECK((*data[startIJK_vec.size() +1]).numFaceCells(faceEntity) < 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) - { - 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) + for (const auto& intersection : intersections(grid.leafGridView(), entity)) { - BOOST_CHECK( data[startIJK_vec.size()+1] -> cell_to_face_[entity][i].index() != -1); + BOOST_CHECK( intersection.id() > -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()]; + for (int i = 0; i < 8; ++i){ + for (int j = i+1; j < 8; ++j){ + BOOST_CHECK( entity.geometry().corner(i) != entity.geometry().corner(j)); + } + } + BOOST_CHECK( entity.geometry().corners() == 8); // Geometry::corners() always return 8. + auto it = entity.hbegin(grid.maxLevel()); auto endIt = entity.hend(grid.maxLevel()); BOOST_CHECK(entity.isLeaf()); @@ -245,48 +207,25 @@ void testInactiveCellsLgrs(const std::string& deckString, *cells_per_dim_vec[entity.level()-1][2]), 1e-6); BOOST_CHECK(entity.father().level() == 0); BOOST_CHECK_EQUAL( data[0]->getMark(entity.father()), 1); - 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_EQUAL( entity.getOrigin().index(), 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( (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]) == - 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().index() == entity.getEquivLevelElem().index()); BOOST_CHECK( entity.getOrigin().level() == 0); - // Get IJK of the old index - std::array entityOldIJK; - (*data[0]).getIJK(entityOldIdx, entityOldIJK); // ijk } } } // end-level-for-loop BOOST_CHECK( static_cast(startIJK_vec.size()) == 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 { From 7568415153f9c8c22eb355be573c1021076a1b08 Mon Sep 17 00:00:00 2001 From: Antonella Ritorto Date: Mon, 16 Sep 2024 14:14:50 +0200 Subject: [PATCH 2/3] Remove fieldProp_check friend decl from CpGridData.hpp --- opm/grid/cpgrid/CpGridData.hpp | 4 - opm/grid/cpgrid/Entity.hpp | 26 ++++-- tests/cpgrid/inactiveCell_lgr_test.cpp | 108 ++++++++++++------------- tests/cpgrid/lookupdataCpGrid_test.cpp | 8 +- 4 files changed, 77 insertions(+), 69 deletions(-) diff --git a/opm/grid/cpgrid/CpGridData.hpp b/opm/grid/cpgrid/CpGridData.hpp index 938084fd8..8f94f8511 100644 --- a/opm/grid/cpgrid/CpGridData.hpp +++ b/opm/grid/cpgrid/CpGridData.hpp @@ -122,8 +122,6 @@ void refinePatch_and_check(Dune::CpGrid&, void check_global_refine(const Dune::CpGrid&, const Dune::CpGrid&); -void fieldProp_check(const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::string deck_string); - namespace Dune { namespace cpgrid @@ -174,8 +172,6 @@ class CpGridData friend void ::check_global_refine(const Dune::CpGrid&, const Dune::CpGrid&); - friend - void ::fieldProp_check(const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::string deck_string); private: CpGridData(const CpGridData& g); diff --git a/opm/grid/cpgrid/Entity.hpp b/opm/grid/cpgrid/Entity.hpp index 737764fec..db8d6da5c 100644 --- a/opm/grid/cpgrid/Entity.hpp +++ b/opm/grid/cpgrid/Entity.hpp @@ -294,6 +294,9 @@ class Entity : public EntityRep /// \brief Get equivalent element on the level grid where the entity was born, if grid = leaf-grid-view. Otherwise, return itself. Entity<0> getEquivLevelElem() const; + /// \brief Get equivalent element on the leaf grid. If grid = leaf-grid-view, return itself. Requirement: isLeaf(). + Entity<0> getEquivLeafElem() const; + /// \brief Get Cartesian Index in the level grid view where the Entity was born. int getLevelCartesianIdx() const; @@ -470,7 +473,7 @@ int Entity::level() const template bool Entity::isLeaf() const { - if (pgrid_ -> parent_to_children_cells_.empty()){ // LGR cells + if (pgrid_ -> parent_to_children_cells_.empty()){ // Then pgrid_ must be the leaf grid view, therefore entity is leaf. return true; } else { @@ -611,13 +614,26 @@ Dune::cpgrid::Entity<0> Dune::cpgrid::Entity::getEquivLevelElem() const } } +template +Dune::cpgrid::Entity<0> Dune::cpgrid::Entity::getEquivLeafElem() const +{ + // Check if the element belongs to the leaf grid view or the level zero grid. + if (isLeaf()) { + const int& entityLeafIdx = pgrid_-> level_to_leaf_cells_[this->index()]; + // leaf_to_level_cells_ [leaf idx] = {level where the entity was born, equivalent cell idx in that level} + return Dune::cpgrid::Entity<0>( *((*(pgrid_ -> level_data_ptr_)).back()).get(), entityLeafIdx, true); + } + else { + return *this; + } +} + 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_))[this->level()].get(); + // getLevelElem() throws when the entity does not belong to the leaf grid view. + return level_data -> global_cell_[this->getLevelElem().index()]; } } // namespace cpgrid diff --git a/tests/cpgrid/inactiveCell_lgr_test.cpp b/tests/cpgrid/inactiveCell_lgr_test.cpp index bbf76d291..9c0c52c12 100644 --- a/tests/cpgrid/inactiveCell_lgr_test.cpp +++ b/tests/cpgrid/inactiveCell_lgr_test.cpp @@ -89,73 +89,71 @@ void testInactiveCellsLgrs(const std::string& deckString, BOOST_CHECK(data.size() == startIJK_vec.size() + 2); BOOST_CHECK(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 + // GLOBAL grid + for (int cell = 0; cell < data[0]-> size(0); ++cell) { - BOOST_CHECK(grid.getLgrNameToLevel().at(lgr_name_vec[level-1]) == static_cast(level)); - - // GLOBAL grid - for (int cell = 0; cell < data[0]-> size(0); ++cell) - { - Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[0], cell, true); - BOOST_CHECK( entity.hasFather() == false); - BOOST_CHECK_THROW(entity.father(), std::logic_error); - BOOST_CHECK_THROW(entity.geometryInFather(), std::logic_error); - BOOST_CHECK( entity.getOrigin() == entity); - BOOST_CHECK( entity.getOrigin().level() == 0); - auto it = entity.hbegin(grid.maxLevel()); - auto endIt = entity.hend(grid.maxLevel()); - if (data[0]->getMark(entity) == 0){ - BOOST_CHECK( entity.isLeaf() == true); - // If it == endIt, then entity.isLeaf() true (when dristibuted_data_ is empty) - BOOST_CHECK( it == endIt); - } - else{ - BOOST_CHECK(data[0]->getMark(entity) == 1); - BOOST_CHECK_EQUAL( entity.isLeaf(), false); // parent cells do not appear in the LeafView - // Auxiliary int to check hierarchic iterator functionality - 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 ); - // Auxiliary integer to get refined level grid where the entity got refined - int lgr = 0; - for (; it != endIt; ++it) - { - // Do something with the son available through it-> - BOOST_CHECK(it ->hasFather() == true); - BOOST_CHECK(it -> father() == entity); - BOOST_CHECK(it -> father().level() == 0); - BOOST_CHECK(it ->father().index() == entity.index()); - BOOST_CHECK(it ->level() > 0); // When adhere to DUNE's Grid interface, it should be it->level() == it->father().level() +1. - lgr = it->level(); // All children in the same refined grid. - referenceElemOneParent_volume_it += it-> geometryInFather().volume(); - for (int c = 0; c < 3; ++c) - { - referenceElem_entity_center_it[c] += (it-> geometryInFather().center())[c]; - } - } + Dune::cpgrid::Entity<0> entity = Dune::cpgrid::Entity<0>(*data[0], cell, true); + BOOST_CHECK( entity.hasFather() == false); + BOOST_CHECK_THROW(entity.father(), std::logic_error); + BOOST_CHECK_THROW(entity.geometryInFather(), std::logic_error); + BOOST_CHECK( entity.getOrigin() == entity); + BOOST_CHECK( entity.getOrigin().level() == 0); + auto it = entity.hbegin(grid.maxLevel()); + auto endIt = entity.hend(grid.maxLevel()); + if (data[0]->getMark(entity) == 0){ + BOOST_CHECK( entity.isLeaf() == true); + // If it == endIt, then entity.isLeaf() true (when dristibuted_data_ is empty) + BOOST_CHECK( it == endIt); + } + else{ + BOOST_CHECK(data[0]->getMark(entity) == 1); + BOOST_CHECK_EQUAL( entity.isLeaf(), false); // parent cells do not appear in the LeafView + // Auxiliary int to check hierarchic iterator functionality + 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 ); + // Auxiliary integer to get refined level grid where the entity got refined + int lgr = 0; + for (; it != endIt; ++it) + { + // Do something with the son available through it-> + BOOST_CHECK(it ->hasFather() == true); + BOOST_CHECK(it -> father() == entity); + BOOST_CHECK(it -> father().level() == 0); + BOOST_CHECK(it ->father().index() == entity.index()); + BOOST_CHECK(it ->level() > 0); // When adhere to DUNE's Grid interface, it should be it->level() == it->father().level() +1. + lgr = it->level(); // All children in the same refined grid. + referenceElemOneParent_volume_it += it-> geometryInFather().volume(); for (int c = 0; c < 3; ++c) { - 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]; + referenceElem_entity_center_it[c] += (it-> geometryInFather().center())[c]; } - 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); + for (int c = 0; c < 3; ++c) + { + 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_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); + } + + // LGRs + for (long unsigned int level = 1; level < startIJK_vec.size() +1; ++level) + { + BOOST_CHECK(grid.getLgrNameToLevel().at(lgr_name_vec[level-1]) == static_cast(level)); - // 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); @@ -209,8 +207,6 @@ void testInactiveCellsLgrs(const std::string& deckString, BOOST_CHECK_EQUAL( data[0]->getMark(entity.father()), 1); BOOST_CHECK_EQUAL( entity.getOrigin().index(), 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( entity.father().isLeaf() == false); BOOST_CHECK( (entity.level() > 0) || (entity.level() < static_cast(startIJK_vec.size()) +1)); diff --git a/tests/cpgrid/lookupdataCpGrid_test.cpp b/tests/cpgrid/lookupdataCpGrid_test.cpp index 2722574d3..ae3c29f85 100644 --- a/tests/cpgrid/lookupdataCpGrid_test.cpp +++ b/tests/cpgrid/lookupdataCpGrid_test.cpp @@ -332,13 +332,13 @@ void fieldProp_check(const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::st // Remark: not optimal, repeted computation for children with the same parent cell. const auto& parentIdx = elem.father().index(); const auto& parentPorv = porv[parentIdx]; - // Remark: children_list indices are the indices on the LGR - Not on the leaf grid View. - const auto& [lgr, children_list] = (*grid.currentData()[0]).parent_to_children_cells_[parentIdx]; // Get child indices on the leaf grid view, get their porv value, sum them up, and compare // the sum with the pore volume of their parent. double sumChildrenPorv = 0.; - for (const auto& child : children_list) { - const auto& childIdxOnLeaf = (*grid.currentData()[lgr]).level_to_leaf_cells_[child]; + auto it = elem.father().hbegin(grid.maxLevel()); + auto endIt = elem.father().hend(grid.maxLevel()); + for (; it != endIt; ++it){ + const auto& childIdxOnLeaf = it->getEquivLeafElem().index(); sumChildrenPorv += porvOnLeaf[childIdxOnLeaf]; } BOOST_CHECK_CLOSE(parentPorv, sumChildrenPorv, 1e-6); From 5f2815dea0a392eb4cee221338c15c19c4e84c86 Mon Sep 17 00:00:00 2001 From: Antonella Ritorto Date: Fri, 27 Sep 2024 12:01:00 +0200 Subject: [PATCH 3/3] Removing impl details checks from adapt_cpgrid_test --- tests/cpgrid/adapt_cpgrid_test.cpp | 158 ++++++++++------------------- 1 file changed, 53 insertions(+), 105 deletions(-) diff --git a/tests/cpgrid/adapt_cpgrid_test.cpp b/tests/cpgrid/adapt_cpgrid_test.cpp index e62bfa3a5..38ff000ff 100644 --- a/tests/cpgrid/adapt_cpgrid_test.cpp +++ b/tests/cpgrid/adapt_cpgrid_test.cpp @@ -77,7 +77,7 @@ BOOST_GLOBAL_FIXTURE(Fixture); BOOST_TEST(c1[c] == c2[c], boost::test_tools::tolerance(1e-12)); \ } -void markAndAdapt_check(Dune::CpGrid& coarse_grid, +void markAndAdapt_check(Dune::CpGrid& grid, const std::array& cells_per_dim, const std::vector& markedCells, Dune::CpGrid& other_grid, @@ -85,42 +85,40 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, bool hasBeenRefinedAtLeastOnce, bool isGlobalRefinement) { - const int startingGridIdx = coarse_grid.currentData().size() -1; // size before calling adapt - - std::vector assignRefinedLevel(coarse_grid.currentData()[startingGridIdx]->size(0)); + const int startingGridIdx = grid.currentData().size() -1; // size before calling adapt + std::vector assignRefinedLevel(grid.currentData()[startingGridIdx]->size(0)); for (const auto& elemIdx : markedCells) { - const auto& elem = Dune::cpgrid::Entity<0>(*(coarse_grid.currentData()[startingGridIdx]), elemIdx, true); - coarse_grid.mark(1, elem); - assignRefinedLevel[elemIdx] = coarse_grid.maxLevel() + 1; - BOOST_CHECK( coarse_grid.getMark(elem) == 1); + const auto& elem = Dune::cpgrid::Entity<0>(*(grid.currentData()[startingGridIdx]), elemIdx, true); + grid.mark(1, elem); + assignRefinedLevel[elemIdx] = grid.maxLevel() + 1; + BOOST_CHECK( grid.getMark(elem) == 1); BOOST_CHECK( elem.mightVanish() == true); } - bool preAdapt = coarse_grid.preAdapt(); - const auto& data = coarse_grid.currentData(); - if(preAdapt) { - coarse_grid.adapt({cells_per_dim}, assignRefinedLevel, {"LGR"+std::to_string(coarse_grid.maxLevel() +1)}); - coarse_grid.postAdapt(); - BOOST_CHECK(static_cast(data.size()) == coarse_grid.maxLevel() +2); - const auto& leafGridIdx = coarse_grid.maxLevel() +1; - const auto& adapted_leaf = *data[leafGridIdx]; + + const auto& data = grid.currentData(); + + if(grid.preAdapt()) { + + grid.adapt({cells_per_dim}, assignRefinedLevel, {"LGR"+std::to_string(grid.maxLevel() +1)}); + grid.postAdapt(); + + BOOST_CHECK(static_cast(data.size()) == grid.maxLevel() +2); + + const auto& adapted_leaf = *data[grid.maxLevel()+1]; + const auto& grid_view = grid.leafGridView(); + 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(); // Check the container sizes - BOOST_CHECK_EQUAL(adapted_leaf.geomVector<3>().size(), blockRefinement_leaf.geomVector<3>().size()); - BOOST_CHECK_EQUAL(adapted_leaf.face_to_cell_.size(), blockRefinement_leaf.face_to_cell_.size()); - BOOST_CHECK_EQUAL(adapted_leaf.face_to_point_.size(), blockRefinement_leaf.face_to_point_.size()); - BOOST_CHECK_EQUAL(adapted_leaf.face_normals_.size(), blockRefinement_leaf.face_normals_.size()); - BOOST_CHECK_EQUAL(adapted_leaf.face_tag_.size(), blockRefinement_leaf.face_tag_.size()); - BOOST_CHECK_EQUAL(adapted_leaf.cell_to_point_.size(), blockRefinement_leaf.cell_to_point_.size()); - BOOST_CHECK_EQUAL(adapted_leaf.cell_to_face_.size(), blockRefinement_leaf.cell_to_face_.size()); - BOOST_CHECK_EQUAL(coarse_grid.size(3), other_grid.size(3)); - BOOST_CHECK_EQUAL(coarse_grid.size(0), other_grid.size(0)); - BOOST_CHECK_EQUAL(coarse_grid.size(1,0), other_grid.size(1,0)); // equal amount of cells in level 1 - BOOST_CHECK_EQUAL(coarse_grid.size(1,3), other_grid.size(1,3)); // equal amount of corners in level 1 + BOOST_CHECK_EQUAL(adapted_leaf.numFaces(), blockRefinement_leaf.numFaces()); + BOOST_CHECK_EQUAL(grid.size(3), other_grid.size(3)); + BOOST_CHECK_EQUAL(grid.size(0), other_grid.size(0)); + BOOST_CHECK_EQUAL(grid.size(1,0), other_grid.size(1,0)); // equal amount of cells in level 1 + BOOST_CHECK_EQUAL(grid.size(1,3), other_grid.size(1,3)); // equal amount of corners in level 1 for(const auto& point: adapted_leaf.geomVector<3>()){ @@ -146,7 +144,6 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, ///// THE FOLLOWING CODE WOULD FIT FOR TESTING GLOBAL REFINEMENT if (isGlobalRefinement) { - const auto& grid_view = coarse_grid.leafGridView(); const auto& equiv_grid_view = other_grid.leafGridView(); for(const auto& element: elements(grid_view)) { @@ -204,84 +201,64 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, } // end-if-isGlobalRefinement } // end-if-isBlockShape - const auto& grid_view = coarse_grid.leafGridView(); Dune::MultipleCodimMultipleGeomTypeMapper adaptMapper(grid_view, Dune::mcmgElementLayout()); 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); - BOOST_CHECK( adapted_leaf.cell_to_point_[element.index()].size() == 8); - for (int i = 0; i < 8; ++i) { - BOOST_CHECK( adapted_leaf.cell_to_point_[element.index()][i] != -1); + BOOST_CHECK( grid.getMark(element) == 0); // postAdapt() has been called, therefore every element gets marked with 0 + + // Check element has 8 different corners + BOOST_CHECK( element.geometry().corners() == 8); // Geometry::corners() always return 8. + for (int i = 0; i < 8; ++i){ + for (int j = i+1; j < 8; ++j){ + BOOST_CHECK( element.geometry().corner(i) != element.geometry().corner(j)); + } } - for (int i = 0; i < adapted_leaf.cell_to_face_[element].size(); ++i) { - BOOST_CHECK( adapted_leaf.cell_to_face_[element][i].index() != -1); + // Check intersections of element have valid ids. + for (const auto& intersection : intersections(grid_view, element)) + { + BOOST_CHECK( intersection.id() > -1); } - const auto& child_to_parent = adapted_leaf.child_to_parent_cells_[element.index()]; - const auto& level_cellIdx = adapted_leaf.leaf_to_level_cells_[element.index()]; - auto it = element.hbegin(level_cellIdx[0] /*level*/);//coarse_grid.maxLevel()); - auto endIt = element.hend(level_cellIdx[0] /*level*/); //coarse_grid.maxLevel()); + + auto it = element.hbegin(grid.maxLevel()); + auto endIt = element.hend(grid.maxLevel()); BOOST_CHECK(element.isLeaf()); BOOST_CHECK(it == endIt); if (element.hasFather()){ BOOST_CHECK( element.isNew() == true); BOOST_CHECK_CLOSE(element.geometryInFather().volume(), 1./(cells_per_dim[0]*cells_per_dim[1]*cells_per_dim[2]), 1e-6); if (hasBeenRefinedAtLeastOnce){ - BOOST_CHECK(element.father().level() <= startingGridIdx); + BOOST_CHECK( element.father().level() <= startingGridIdx); BOOST_CHECK( element.getOrigin().level() <= startingGridIdx); - BOOST_CHECK( data[element.father().level()] ->mark_[element.father().index()] == 1); + BOOST_CHECK_EQUAL( data[element.father().level()] ->getMark(element.father()), 1); } else { - BOOST_CHECK(element.father().level() == 0); + BOOST_CHECK( element.father().level() == 0); BOOST_CHECK( element.getOrigin().level() == 0); BOOST_CHECK_EQUAL( (std::find(markedCells.begin(), markedCells.end(), element.father().index()) == markedCells.end()), false); } - BOOST_CHECK(child_to_parent[0] != -1); - BOOST_CHECK_EQUAL( child_to_parent[0], element.father().level()); - 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(), - (*data[element.level()]).cells_per_dim_[0]*(*data[element.level()]).cells_per_dim_[1]*(*data[element.level()]).cells_per_dim_[2]); if(!hasBeenRefinedAtLeastOnce) { BOOST_CHECK( element.father().isLeaf() == false); } - BOOST_CHECK( (element.level() > 0) || (element.level() < coarse_grid.maxLevel() +1)); - BOOST_CHECK( level_cellIdx[0] == element.level()); + BOOST_CHECK( (element.level() > 0) || (element.level() < grid.maxLevel() +1)); BOOST_CHECK(element.index() == adaptMapper.index(element)); BOOST_CHECK(element.index() == adaptMapper.index(element)); /** Not ideal to define this for each element. Remove?*/ - const auto& preAdapt_view = coarse_grid.levelGridView(element.father().level()); + const auto& preAdapt_view = grid.levelGridView(element.father().level()); Dune::MultipleCodimMultipleGeomTypeMapper preAdaptMapper(preAdapt_view, Dune::mcmgElementLayout()); BOOST_CHECK(element.father().index() == preAdaptMapper.index(element.father())); } else{ BOOST_CHECK_THROW(element.father(), std::logic_error); BOOST_CHECK_THROW(element.geometryInFather(), std::logic_error); - BOOST_CHECK_EQUAL(child_to_parent[0], -1); - BOOST_CHECK_EQUAL(child_to_parent[1], -1); if (hasBeenRefinedAtLeastOnce){ - BOOST_CHECK( level_cellIdx[0] == element.level()); BOOST_CHECK( element.level() <= startingGridIdx); BOOST_CHECK( element.getOrigin().level() <= startingGridIdx); } else { - BOOST_CHECK( level_cellIdx[0] == 0); BOOST_CHECK( element.level() == 0); - BOOST_CHECK( element.getOrigin().level() == 0); } - BOOST_CHECK( std::get<0>(data[element.level()]-> parent_to_children_cells_[level_cellIdx[1]]) == -1); - BOOST_CHECK( std::get<1>(data[element.level()]->parent_to_children_cells_[level_cellIdx[1]]).empty()); - // Get index of the cell in level 0 - const auto& entityOldIdx = adapted_leaf.leaf_to_level_cells_[element.index()][1]; - BOOST_CHECK( element.getOrigin().index() == entityOldIdx); BOOST_CHECK( element.getOrigin().level() == 0); BOOST_CHECK( element.isNew() == false); } @@ -291,9 +268,8 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, if (startingGridIdx == 0) { - const auto& preAdapt_view = coarse_grid.levelGridView(startingGridIdx); + const auto& preAdapt_view = grid.levelGridView(startingGridIdx); Dune::MultipleCodimMultipleGeomTypeMapper preAdaptMapper(preAdapt_view, Dune::mcmgElementLayout()); - // const auto& preAdapt_idSet = (*data[startingGridIdx+1]).local_id_set_; // Some checks on the preAdapt grid for(const auto& element: elements(preAdapt_view)) { @@ -303,49 +279,27 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, BOOST_CHECK( element.getOrigin() == element); BOOST_CHECK( element.getOrigin().level() == startingGridIdx); BOOST_CHECK( element.isNew() == false); - auto it = element.hbegin(coarse_grid.maxLevel()); // With element.level(), fails - auto endIt = element.hend(coarse_grid.maxLevel()); - const auto& [lgr, childrenList] = (*data[startingGridIdx]).parent_to_children_cells_[element.index()]; + auto it = element.hbegin(grid.maxLevel()); // With element.level(), fails + auto endIt = element.hend(grid.maxLevel()); if (std::find(markedCells.begin(), markedCells.end(), element.index()) == markedCells.end()){ - BOOST_CHECK_EQUAL(lgr, -1); - BOOST_CHECK(childrenList.empty()); BOOST_CHECK( element.isLeaf() == true); // If it == endIt, then entity.isLeaf() true (when dristibuted_data_ is empty) BOOST_CHECK( it == endIt); BOOST_CHECK( element.mightVanish() == false); } else{ - BOOST_CHECK(lgr != -1); - BOOST_CHECK(static_cast(childrenList.size()) == cells_per_dim[0]*cells_per_dim[1]*cells_per_dim[2]); // If it != endIt, then entity.isLeaf() false (when dristibuted_data_ is empty) BOOST_CHECK_EQUAL( it == endIt, false); BOOST_CHECK( element.mightVanish() == true); BOOST_CHECK( element.isNew() == false); BOOST_CHECK_EQUAL( element.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[startingGridIdx+1]-> child_to_parent_cells_[child][0] == startingGridIdx); // - BOOST_CHECK( data[startingGridIdx+1]-> child_to_parent_cells_[child][1] == element.index()); - - const auto& childElem = Dune::cpgrid::Entity<0>(*data[startingGridIdx+1], child, true); - BOOST_CHECK(childElem.hasFather() == true); - BOOST_CHECK(childElem.level() == lgr); - referenceElemOneParent_volume += childElem.geometryInFather().volume(); - for (int c = 0; c < 3; ++c) { - referenceElem_entity_center[c] += (childElem.geometryInFather().center())[c]; - } - } /// 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} for (; it != endIt; ++it) { BOOST_CHECK(it ->hasFather() == true); - BOOST_CHECK(it ->level() == lgr); referenceElemOneParent_volume_it += it-> geometryInFather().volume(); for (int c = 0; c < 3; ++c) { @@ -353,14 +307,8 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, } } for (int c = 0; c < 3; ++c) { - referenceElem_entity_center[c] /= cells_per_dim[0]*cells_per_dim[1]*cells_per_dim[2]; referenceElem_entity_center_it[c] /= cells_per_dim[0]*cells_per_dim[1]*cells_per_dim[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); @@ -381,7 +329,7 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, 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())); + BOOST_CHECK_EQUAL( 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()); @@ -398,16 +346,16 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, // CpGrid supports only elements (cells) and vertices (corners). Total amount of ids for the leaf grid view should coincide // with the total amount of cells and corners on the leaf grid view. BOOST_CHECK( static_cast(allIds_set.size()) == (data.back()->size(0) + data.back()->size(3))); - + // Local/Global id sets for level grids (level 0, 1, ..., maxLevel) - for (int level = 0; level < coarse_grid.maxLevel() +1; ++level) + for (int level = 0; level < 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))){ + for (const auto& element: elements(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: @@ -435,7 +383,7 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid, BOOST_CHECK_EQUAL(idx, element.index()); } - for (const auto& point : vertices(coarse_grid.levelGridView(level))) { + for (const auto& point : vertices(grid.levelGridView(level))) { const auto& localId = data[level]->localIdSet().id(point); const auto& globalId = data[level]->globalIdSet().id(point); BOOST_CHECK_EQUAL(localId, globalId);