Skip to content

Commit

Permalink
Merge pull request #13390 from simonsticko/fix_reclassify_multiple_times
Browse files Browse the repository at this point in the history
Overwrite LocationToLevelSet values with unassigned in MeshClassifier
  • Loading branch information
kronbichler committed Feb 15, 2022
2 parents 18a3861 + ca24e89 commit 6d91abe
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/non_matching/mesh_classifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ namespace NonMatching
MeshClassifier<dim>::reclassify()
{
initialize();
cell_locations.resize(triangulation->n_active_cells(),
cell_locations.assign(triangulation->n_active_cells(),
LocationToLevelSet::unassigned);
face_locations.resize(triangulation->n_raw_faces(),
face_locations.assign(triangulation->n_raw_faces(),
LocationToLevelSet::unassigned);

// Loop over all cells and determine the location of all non artificial
Expand Down
44 changes: 44 additions & 0 deletions tests/non_matching/mesh_classifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,48 @@ test_lagrange_coefficents_positive()



// Check that the values of LocationToLevelSet for the cells and faces get
// updated correctly when calling reclassify() multiple times.
//
// First, make the level set function all negative, call reclassify(), and check
// that the values of LocationToLevelSet for all cells and faces equals
// LocationToLevelSet::inside. Then, change the level set function to all
// positive, call reclassify() again, and check that all values have been
// changed to LocationToLevelSet::outside.
template <int dim>
void
test_reclassify_called_multiple_times()
{
deallog << "test_reclassify_called_multiple_times" << std::endl;
Triangulation<dim> triangulation;
GridGenerator::hyper_cube(triangulation);

const FE_Q<dim> element(1);

DoFHandler<dim> dof_handler(triangulation);
dof_handler.distribute_dofs(element);

Vector<double> level_set(element.dofs_per_cell);
NonMatching::MeshClassifier<dim> classifier(dof_handler, level_set);

const typename Triangulation<dim>::active_cell_iterator cell =
triangulation.begin_active();

deallog << "Level set negative" << std::endl;
level_set = -1;
classifier.reclassify();
print_cell_and_face_locations(classifier, cell);

deallog << "Level set positive" << std::endl;
level_set = 1;
classifier.reclassify();
print_cell_and_face_locations(classifier, cell);

deallog << std::endl;
}



template <int dim>
void
run_test()
Expand All @@ -327,6 +369,8 @@ run_test()
// This test doesn't make sense in 1D.
if (dim != 1)
test_lagrange_coefficents_positive<dim>();

test_reclassify_called_multiple_times<dim>();
}


Expand Down
42 changes: 42 additions & 0 deletions tests/non_matching/mesh_classifier.output
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ DEAL::cell intersected
DEAL::face 0 inside
DEAL::face 1 outside
DEAL::
DEAL::test_reclassify_called_multiple_times
DEAL::Level set negative
DEAL::cell inside
DEAL::face 0 inside
DEAL::face 1 inside
DEAL::Level set positive
DEAL::cell outside
DEAL::face 0 outside
DEAL::face 1 outside
DEAL::
DEAL::dim = 2
DEAL::test_negative_function
DEAL::
Expand Down Expand Up @@ -92,6 +102,20 @@ DEAL::face 1 outside
DEAL::face 2 intersected
DEAL::face 3 outside
DEAL::
DEAL::test_reclassify_called_multiple_times
DEAL::Level set negative
DEAL::cell inside
DEAL::face 0 inside
DEAL::face 1 inside
DEAL::face 2 inside
DEAL::face 3 inside
DEAL::Level set positive
DEAL::cell outside
DEAL::face 0 outside
DEAL::face 1 outside
DEAL::face 2 outside
DEAL::face 3 outside
DEAL::
DEAL::dim = 3
DEAL::test_negative_function
DEAL::
Expand Down Expand Up @@ -162,3 +186,21 @@ DEAL::face 3 outside
DEAL::face 4 intersected
DEAL::face 5 outside
DEAL::
DEAL::test_reclassify_called_multiple_times
DEAL::Level set negative
DEAL::cell inside
DEAL::face 0 inside
DEAL::face 1 inside
DEAL::face 2 inside
DEAL::face 3 inside
DEAL::face 4 inside
DEAL::face 5 inside
DEAL::Level set positive
DEAL::cell outside
DEAL::face 0 outside
DEAL::face 1 outside
DEAL::face 2 outside
DEAL::face 3 outside
DEAL::face 4 outside
DEAL::face 5 outside
DEAL::

0 comments on commit 6d91abe

Please sign in to comment.