16#ifndef dealii_mg_constrained_dofs_h
17#define dealii_mg_constrained_dofs_h
35template <
int dim,
int spacedim>
49 using size_dof = std::vector<std::set<types::global_dof_index>>::size_type;
75 template <
int dim,
int spacedim>
91 template <
int dim,
int spacedim>
95 const std::set<types::boundary_id> &boundary_ids,
104 template <
int dim,
int spacedim>
107 const unsigned int level,
142 template <
int dim,
int spacedim>
146 const unsigned int first_vector_component);
246template <
int dim,
int spacedim>
258 const unsigned int min_level = level_relevant_dofs.
min_level();
259 const unsigned int max_level = (level_relevant_dofs.
max_level() == 0) ?
262 const bool user_level_dofs =
263 (level_relevant_dofs.
max_level() == 0) ?
false :
true;
269 for (
unsigned int l = min_level; l <= max_level; ++l)
286 for (; cell != endc; ++cell)
289 for (
auto f : cell->face_indices())
290 if (cell->has_periodic_neighbor(f) &&
291 cell->periodic_neighbor(f)->level() == cell->level())
293 if (cell->is_locally_owned_on_level())
296 cell->periodic_neighbor(f)->level_subdomain_id() !=
299 "Periodic neighbor of a locally owned cell must either be owned or ghost."));
303 else if (cell->periodic_neighbor(f)->level_subdomain_id() ==
306 Assert(cell->is_locally_owned_on_level() ==
false,
311 const unsigned int dofs_per_face =
313 std::vector<types::global_dof_index> dofs_1(dofs_per_face);
314 std::vector<types::global_dof_index> dofs_2(dofs_per_face);
316 cell->periodic_neighbor(f)
317 ->face(cell->periodic_neighbor_face_no(f))
318 ->get_mg_dof_indices(l, dofs_1, 0);
319 cell->face(f)->get_mg_dof_indices(l, dofs_2, 0);
325 for (
unsigned int i = 0; i < dofs_per_face; ++i)
348template <
int dim,
int spacedim>
352 const std::set<types::boundary_id> &boundary_ids,
370template <
int dim,
int spacedim>
373 const unsigned int level,
374 const IndexSet &level_boundary_indices)
380 for (
unsigned int i = 0; i < n_levels; ++i)
389template <
int dim,
int spacedim>
394 const unsigned int first_vector_component)
407 for (; face != endf; ++face)
408 if (face->at_boundary() && face->boundary_id() == bid)
409 for (
unsigned int d = 0; d < dim; ++d)
415 face->get_manifold().normal_vector(face, face->center());
418 comp_mask.
set(d + first_vector_component,
true);
421 std::abs(unit_vec * normal_vec) < 1e-10,
423 "We can currently only support no normal flux conditions "
424 "for a specific boundary id if all faces are normal to the "
425 "x, y, or z axis."));
430 "We can currently only support no normal flux conditions "
431 "for a specific boundary id if all faces are facing in the "
432 "same direction, i.e., a boundary normal to the x-axis must "
433 "have a different boundary id than a boundary normal to the "
434 "y- or z-axis and so on. If the mesh here was produced using "
435 "GridGenerator::..., setting colorize=true during mesh generation "
436 "and calling make_no_normal_flux_constraints() for each no normal "
437 "flux boundary will fulfill the condition."));
445 const unsigned int level,
456 constraints_on_level,
493 const unsigned int level,
497 const IndexSet &interface_dofs_on_level =
void set(const unsigned int index, const bool value)
unsigned int n_selected_components(const unsigned int overall_number_of_components=numbers::invalid_unsigned_int) const
cell_iterator end() const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
const hp::FECollection< dim, spacedim > & get_fe_collection() const
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
cell_iterator begin(const unsigned int level=0) const
unsigned int n_dofs_per_face(unsigned int face_no=0, unsigned int child=0) const
bool is_element(const size_type index) const
std::vector< IndexSet > refinement_edge_indices
std::vector< AffineConstraints< double > > user_constraints
void make_no_normal_flux_constraints(const DoFHandler< dim, spacedim > &dof, const types::boundary_id bid, const unsigned int first_vector_component)
bool is_interface_matrix_entry(const unsigned int level, const types::global_dof_index i, const types::global_dof_index j) const
std::vector< IndexSet > boundary_indices
void add_boundary_indices(const DoFHandler< dim, spacedim > &dof, const unsigned int level, const IndexSet &boundary_indices)
bool at_refinement_edge(const unsigned int level, const types::global_dof_index index) const
void initialize(const DoFHandler< dim, spacedim > &dof, const MGLevelObject< IndexSet > &level_relevant_dofs=MGLevelObject< IndexSet >())
bool is_boundary_index(const unsigned int level, const types::global_dof_index index) const
std::vector< AffineConstraints< double > > level_constraints
bool have_boundary_indices() const
void add_user_constraints(const unsigned int level, const AffineConstraints< double > &constraints_on_level)
const IndexSet & get_refinement_edge_indices(unsigned int level) const
const AffineConstraints< double > & get_user_constraint_matrix(const unsigned int level) const
std::vector< std::set< types::global_dof_index > >::size_type size_dof
void make_zero_boundary_constraints(const DoFHandler< dim, spacedim > &dof, const std::set< types::boundary_id > &boundary_ids, const ComponentMask &component_mask=ComponentMask())
const AffineConstraints< double > & get_level_constraints(const unsigned int level) const
const IndexSet & get_boundary_indices(const unsigned int level) const
unsigned int max_level() const
unsigned int min_level() const
face_iterator end_face() const
virtual unsigned int n_global_levels() const
face_iterator begin_face() const
unsigned int n_components() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
const types::subdomain_id artificial_subdomain_id
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)