45 namespace MeshClassifierImplementation
49 "The Triangulation has not been classified. You need to call the "
50 "reclassify()-function before using this function.");
54 "The incoming cell does not belong to the triangulation passed to "
65 template <
typename VectorType>
69 const auto [min_element, max_element] =
70 std::minmax_element(local_levelset_values.begin(),
71 local_levelset_values.end());
76 if (*min_element == 0.0 && *max_element == 0.0)
78 if (*max_element <= 0)
80 if (0 <= *min_element)
92 template <
int dim,
typename VectorType>
114 &cell)
const override;
123 const unsigned int face_index,
141 template <
int dim,
typename VectorType>
144 const VectorType &level_set)
145 : dof_handler(&dof_handler)
146 , level_set(&level_set)
151 template <
int dim,
typename VectorType>
155 return dof_handler->get_fe_collection();
160 template <
int dim,
typename VectorType>
164 const unsigned int face_index,
167 const auto cell_with_dofs = cell->as_dof_handler_iterator(*dof_handler);
169 const unsigned int n_dofs_per_face =
170 dof_handler->get_fe().n_dofs_per_face();
171 std::vector<types::global_dof_index> dof_indices(n_dofs_per_face);
172 cell_with_dofs->face(face_index)->get_dof_indices(dof_indices);
174 local_levelset_values.
reinit(dof_indices.size());
176 for (
unsigned int i = 0; i < dof_indices.size(); i++)
177 local_levelset_values[i] =
184 template <
int dim,
typename VectorType>
189 const auto cell_with_dofs = cell->as_dof_handler_iterator(*dof_handler);
191 return cell_with_dofs->active_fe_index();
223 &cell)
const override;
232 const unsigned int face_index,
260 : level_set(&level_set)
261 , fe_collection(element)
262 , fe_face_values(element,
264 element.get_unit_face_support_points()),
274 const unsigned int face_index,
278 fe_face_values.n_quadrature_points);
280 fe_face_values.reinit(cell, face_index);
281 const std::vector<Point<dim>> &points =
282 fe_face_values.get_quadrature_points();
284 for (
unsigned int i = 0; i < points.size(); i++)
285 local_levelset_values[i] = level_set->value(points[i]);
294 return fe_collection;
312 template <
typename VectorType>
314 const VectorType &level_set)
315 : triangulation(&dof_handler.get_triangulation())
316 , level_set_description(
317 std::make_unique<
internal::MeshClassifierImplementation::
318 DiscreteLevelSetDescription<dim, VectorType>>(
322#ifdef DEAL_II_WITH_LAPACK
325 for (
unsigned int i = 0; i < fe_collection.
size(); i++)
330 Assert(fe_collection[i].has_face_support_points(),
332 "The elements in the FECollection of the incoming DoFHandler "
333 "must have face support points."));
346 : triangulation(&triangulation)
347 , level_set_description(
348 std::make_unique<
internal::MeshClassifierImplementation::
349 AnalyticLevelSetDescription<dim>>(level_set,
364 cell_locations.assign(triangulation->n_active_cells(),
366 face_locations.assign(triangulation->n_raw_faces(),
372 const auto contains =
373 [](
const std::set<LocationToLevelSet> &local_face_locations,
375 return local_face_locations.count(location) > 0;
380 for (
const auto &cell : triangulation->active_cell_iterators())
381 if (!cell->is_artificial())
383 std::set<LocationToLevelSet> local_face_locations;
385 for (
unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
388 determine_face_location_to_levelset(cell, f);
390 face_locations[cell->face(f)->index()] = face_location;
391 local_face_locations.insert(face_location);
396 const bool all_faces_have_same_location =
397 local_face_locations.size() == 1;
399 if (all_faces_have_same_location)
401 cell_location = *local_face_locations.cbegin();
403 else if (contains(local_face_locations,
428 cell_locations[cell->active_cell_index()] = cell_location;
438 const unsigned int face_index)
443 face_locations.at(cell->face(face_index)->index());
449 const unsigned int fe_index = level_set_description->active_fe_index(cell);
450 const unsigned int n_local_dofs =
451 lagrange_to_bernstein_face[fe_index][face_index].m();
454 level_set_description->get_local_level_set_values(cell,
456 local_levelset_values);
459 level_set_description->get_fe_collection()[fe_index];
466 const bool is_linear = fe_q_iso_q1 !=
nullptr ||
467 (fe_poly !=
nullptr && fe_poly->
get_degree() == 1);
473 local_levelset_values);
476 lagrange_to_bernstein_face[fe_index][face_index].solve(
477 local_levelset_values);
480 local_levelset_values);
490 Assert(cell_locations.size() == triangulation->n_active_cells(),
492 Assert(&cell->get_triangulation() == triangulation,
495 return cell_locations.at(cell->active_cell_index());
504 const unsigned int face_index)
const
507 Assert(face_locations.size() == triangulation->n_raw_faces(),
509 Assert(&cell->get_triangulation() == triangulation,
512 return face_locations.at(cell->face(face_index)->index());
522 level_set_description->get_fe_collection();
527 lagrange_to_bernstein_face.resize(fe_collection.
size());
529 for (
unsigned int i = 0; i < fe_collection.
size(); i++)
539 for (
unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; f++)
545 *fe_q, face_interpolation_matrix, f);
546 lagrange_to_bernstein_face[i][f].reinit(dofs_per_face);
547 lagrange_to_bernstein_face[i][f] = face_interpolation_matrix;
548 lagrange_to_bernstein_face[i][f].compute_lu_factorization();
555#include "non_matching/mesh_classifier.inst"
const hp::FECollection< dim, spacedim > & get_fe_collection() const
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
unsigned int get_degree() const
const unsigned int dofs_per_face
unsigned int n_components() const
const unsigned int n_components
LocationToLevelSet location_to_level_set(const typename Triangulation< dim >::cell_iterator &cell) const
LocationToLevelSet determine_face_location_to_levelset(const typename Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index)
MeshClassifier(const DoFHandler< dim > &level_set_dof_handler, const VectorType &level_set)
AnalyticLevelSetDescription(const Function< dim > &level_set, const FiniteElement< dim > &element)
unsigned int active_fe_index(const typename Triangulation< dim >::active_cell_iterator &cell) const override
FEFaceValues< dim > fe_face_values
const hp::FECollection< dim > & get_fe_collection() const override
const ObserverPointer< const Function< dim > > level_set
const hp::FECollection< dim > fe_collection
void get_local_level_set_values(const typename Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index, Vector< double > &local_levelset_values) override
void get_local_level_set_values(const typename Triangulation< dim >::active_cell_iterator &cell, const unsigned int face_index, Vector< double > &local_levelset_values) override
const ObserverPointer< const DoFHandler< dim > > dof_handler
unsigned int active_fe_index(const typename Triangulation< dim >::active_cell_iterator &cell) const override
const hp::FECollection< dim > & get_fe_collection() const override
const ObserverPointer< const VectorType > level_set
DiscreteLevelSetDescription(const DoFHandler< dim > &dof_handler, const VectorType &level_set)
virtual size_type size() const override
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
unsigned int size() const
unsigned int n_components() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcNeedsLAPACK()
static ::ExceptionBase & ExcReclassifyNotCalled()
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcTriangulationMismatch()
#define AssertThrow(cond, exc)
@ update_quadrature_points
Transformed quadrature points.
LocationToLevelSet location_from_dof_signs(const VectorType &local_levelset_values)