Skip to content

Commit

Permalink
Removing impl details checks from adapt_cpgrid_test
Browse files Browse the repository at this point in the history
  • Loading branch information
aritorto committed Sep 27, 2024
1 parent c937675 commit 081749a
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions tests/cpgrid/adapt_cpgrid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,7 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid,
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(adapted_leaf.numFaces(), blockRefinement_leaf.numFaces());
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
Expand Down Expand Up @@ -210,15 +204,20 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid,
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);

// 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.leafGridView(), 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());
BOOST_CHECK(element.isLeaf());
Expand All @@ -227,34 +226,21 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid,
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().index()), 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.index() == adaptMapper.index(element));
BOOST_CHECK(element.index() == adaptMapper.index(element));
/** Not ideal to define this for each element. Remove?*/
Expand All @@ -265,23 +251,13 @@ void markAndAdapt_check(Dune::CpGrid& coarse_grid,
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);
}
Expand Down

0 comments on commit 081749a

Please sign in to comment.