![]() |
Reference documentation for deal.II version 9.6.0
|
#include <deal.II/multigrid/mg_constrained_dofs.h>
Public Types | |
using | size_dof = std::vector<std::set<types::global_dof_index>>::size_type |
Public Member Functions | |
template<int dim, int spacedim> | |
void | initialize (const DoFHandler< dim, spacedim > &dof, const MGLevelObject< IndexSet > &level_relevant_dofs=MGLevelObject< IndexSet >()) |
template<int dim, int spacedim> | |
void | make_zero_boundary_constraints (const DoFHandler< dim, spacedim > &dof, const std::set< types::boundary_id > &boundary_ids, const ComponentMask &component_mask={}) |
template<int dim, int spacedim> | |
void | add_boundary_indices (const DoFHandler< dim, spacedim > &dof, const unsigned int level, const IndexSet &boundary_indices) |
void | add_user_constraints (const unsigned int level, const AffineConstraints< double > &constraints_on_level) |
template<int dim, int spacedim> | |
void | make_no_normal_flux_constraints (const DoFHandler< dim, spacedim > &dof, const types::boundary_id bid, const unsigned int first_vector_component) |
void | clear_user_constraints () |
void | clear () |
bool | is_boundary_index (const unsigned int level, const types::global_dof_index index) const |
bool | at_refinement_edge (const unsigned int level, const types::global_dof_index index) const |
bool | is_interface_matrix_entry (const unsigned int level, const types::global_dof_index i, const types::global_dof_index j) const |
const IndexSet & | get_boundary_indices (const unsigned int level) const |
const IndexSet & | get_refinement_edge_indices (unsigned int level) const |
bool | have_boundary_indices () const |
const AffineConstraints< double > & | get_level_constraints (const unsigned int level) const |
const AffineConstraints< double > & | get_user_constraint_matrix (const unsigned int level) const |
template<typename Number > | |
void | merge_constraints (AffineConstraints< Number > &constraints, const unsigned int level, const bool add_boundary_indices, const bool add_refinement_edge_indices, const bool add_level_constraints, const bool add_user_constraints) const |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Subscriptor functionality | |
Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class. | |
void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
unsigned int | n_subscriptions () const |
template<typename StreamType > | |
void | list_subscribers (StreamType &stream) const |
void | list_subscribers () const |
Static Public Member Functions | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Private Types | |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
Private Member Functions | |
void | check_no_subscribers () const noexcept |
Private Attributes | |
std::vector< IndexSet > | boundary_indices |
std::vector< IndexSet > | refinement_edge_indices |
std::vector< AffineConstraints< double > > | level_constraints |
std::vector< AffineConstraints< double > > | user_constraints |
std::atomic< unsigned int > | counter |
std::map< std::string, unsigned int > | counter_map |
std::vector< std::atomic< bool > * > | validity_pointers |
const std::type_info * | object_info |
Static Private Attributes | |
static std::mutex | mutex |
Collection of boundary constraints and refinement edge constraints for level vectors.
Definition at line 44 of file mg_constrained_dofs.h.
using MGConstrainedDoFs::size_dof = std::vector<std::set<types::global_dof_index>>::size_type |
Definition at line 47 of file mg_constrained_dofs.h.
|
privateinherited |
The data type used in counter_map.
Definition at line 229 of file subscriptor.h.
|
privateinherited |
The iterator type used in counter_map.
Definition at line 234 of file subscriptor.h.
void MGConstrainedDoFs::initialize | ( | const DoFHandler< dim, spacedim > & | dof, |
const MGLevelObject< IndexSet > & | level_relevant_dofs = MGLevelObject<IndexSet>() ) |
Fill the internal data structures with hanging node constraints extracted from the dof handler object. Works with natural boundary conditions only. There exists a sister function setting up boundary constraints as well.
This function ensures that on every level, degrees of freedom at interior edges of a refinement level are treated corrected but leaves degrees of freedom at the boundary of the domain untouched assuming that no Dirichlet boundary conditions for them exist.
Furthermore, this call sets up an AffineConstraints object on each level that contains possible periodicity constraints in case those have been added to the underlying triangulation. The AffineConstraints object can be queried by get_level_constraints(level). Note that the current implementation of periodicity constraints in this class does not support rotation matrices in the periodicity definition, i.e., the respective argument in the GridTools::collect_periodic_faces() may not be different from the identity matrix. If no level_relevant_dofs are passed as the second argument, the function uses the locally relevant level DoFs, extracted by DoFTools::extract_locally_relevant_level_dofs(). Otherwise, the user-provided IndexSets, which should define a superset of locally relevant DoFs, are used on each level to allow the user to add additional indices to the set of constrained DoFs.
Definition at line 28 of file mg_constrained_dofs.cc.
void MGConstrainedDoFs::make_zero_boundary_constraints | ( | const DoFHandler< dim, spacedim > & | dof, |
const std::set< types::boundary_id > & | boundary_ids, | ||
const ComponentMask & | component_mask = {} ) |
Fill the internal data structures with information about Dirichlet boundary dofs.
The initialize() function has to be called before to set hanging node constraints.
This function can be called multiple times to allow considering different sets of boundary_ids for different components.
Definition at line 111 of file mg_constrained_dofs.cc.
void MGConstrainedDoFs::add_boundary_indices | ( | const DoFHandler< dim, spacedim > & | dof, |
const unsigned int | level, | ||
const IndexSet & | boundary_indices ) |
Add Dirichlet boundary dofs to the internal data structures on level level
. The indices are restricted to the set of locally relevant level dofs.
Definition at line 133 of file mg_constrained_dofs.cc.
void MGConstrainedDoFs::add_user_constraints | ( | const unsigned int | level, |
const AffineConstraints< double > & | constraints_on_level ) |
Add user defined constraints to be used on level level
.
The user can call this function multiple times and any new, conflicting constraints will overwrite the previous constraints for that DoF.
Before the transfer, the user defined constraints will be distributed to the source vector, and then any DoF index set using make_zero_boundary_constraints() will be overwritten with value zero.
Definition at line 206 of file mg_constrained_dofs.cc.
void MGConstrainedDoFs::make_no_normal_flux_constraints | ( | const DoFHandler< dim, spacedim > & | dof, |
const types::boundary_id | bid, | ||
const unsigned int | first_vector_component ) |
Fill the internal data structures with information about no normal flux boundary dofs.
This function is limited to meshes whose no normal flux boundaries have faces which are normal to the x-, y-, or z-axis. Also, for a specific boundary id, all faces must be facing in the same direction, i.e., a boundary normal to the x-axis must have a different boundary id than a boundary normal to the y- or z-axis and so on. If the mesh was produced, for example, using the GridGenerator::hyper_cube()
function, setting colorize=true
during mesh generation and calling make_no_normal_flux_constraints() for each no normal flux boundary is sufficient.
Definition at line 152 of file mg_constrained_dofs.cc.
void MGConstrainedDoFs::clear_user_constraints | ( | ) |
Clear the user constraints on all levels.
Definition at line 228 of file mg_constrained_dofs.cc.
void MGConstrainedDoFs::clear | ( | ) |
Reset the data structures.
Definition at line 237 of file mg_constrained_dofs.cc.
|
inline |
Determine whether a dof index is subject to a boundary constraint.
Definition at line 273 of file mg_constrained_dofs.h.
|
inline |
Determine whether a dof index is at the refinement edge.
Definition at line 286 of file mg_constrained_dofs.h.
|
inline |
Determine whether the (i,j) entry of the interface matrix on a given level should be set. This is taken in terms of dof i, that is, return true if i is at a refinement edge, j is not, and both are not on the external boundary.
Definition at line 297 of file mg_constrained_dofs.h.
Return the indices of level dofs on the given level that are subject to Dirichlet boundary conditions (as set by the function_map
parameter in initialize()). The indices are restricted to the set of locally relevant level dofs.
Definition at line 314 of file mg_constrained_dofs.h.
Return the indices of dofs on the given level that lie on an refinement edge (dofs on faces to neighbors that are coarser).
Definition at line 323 of file mg_constrained_dofs.h.
|
inline |
Return if Dirichlet boundary indices are set in initialize().
Definition at line 332 of file mg_constrained_dofs.h.
|
inline |
Return the AffineConstraints object for a given level, containing periodicity constraints (if enabled on the triangulation).
Definition at line 340 of file mg_constrained_dofs.h.
|
inline |
Return the user defined constraint matrix for a given level. These constraints are set using the function add_user_constraints() and should not contain constraints for DoF indices set in make_zero_boundary_constraints() as they will be overwritten during the transfer.
Definition at line 349 of file mg_constrained_dofs.h.
void MGConstrainedDoFs::merge_constraints | ( | AffineConstraints< Number > & | constraints, |
const unsigned int | level, | ||
const bool | add_boundary_indices, | ||
const bool | add_refinement_edge_indices, | ||
const bool | add_level_constraints, | ||
const bool | add_user_constraints ) const |
Merge selected constraints of a specified level
into a given single AffineConstraints object.
constraints | AffineConstraints object to be filled. |
level | Refinement to be considered. |
add_boundary_indices | Add boundary indices. |
add_refinement_edge_indices | Add refinement-edge indices. |
add_level_constraints | Add level constraints including the one passed during initialize() and periodicy constraints. |
add_user_constraints | Add user constraints. |
Definition at line 248 of file mg_constrained_dofs.cc.
|
inherited |
Subscribes a user of the object by storing the pointer validity
. The subscriber may be identified by text supplied as identifier
.
Definition at line 135 of file subscriptor.cc.
|
inherited |
Unsubscribes a user from the object.
identifier
and the validity
pointer must be the same as the one supplied to subscribe(). Definition at line 155 of file subscriptor.cc.
|
inlineinherited |
Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.
Definition at line 300 of file subscriptor.h.
|
inlineinherited |
List the subscribers to the input stream
.
Definition at line 317 of file subscriptor.h.
|
inherited |
List the subscribers to deallog
.
Definition at line 203 of file subscriptor.cc.
|
inlineinherited |
Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.
This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.
Definition at line 309 of file subscriptor.h.
|
privatenoexceptinherited |
Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.
Definition at line 52 of file subscriptor.cc.
|
private |
The indices of boundary dofs for each level.
Definition at line 250 of file mg_constrained_dofs.h.
|
private |
The degrees of freedom on a given level that live on the refinement edge between the level and cells on a coarser level.
Definition at line 256 of file mg_constrained_dofs.h.
|
private |
Constraint matrices containing information regarding potential periodic boundary conditions for each level .
Definition at line 262 of file mg_constrained_dofs.h.
|
private |
Constraint matrices defined by user.
Definition at line 267 of file mg_constrained_dofs.h.
|
mutableprivateinherited |
Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).
The creator (and owner) of an object is counted in the map below if HE manages to supply identification.
We use the mutable
keyword in order to allow subscription to constant objects also.
This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic
class template.
Definition at line 218 of file subscriptor.h.
|
mutableprivateinherited |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 224 of file subscriptor.h.
|
mutableprivateinherited |
In this vector, we store pointers to the validity bool in the SmartPointer objects that subscribe to this class.
Definition at line 240 of file subscriptor.h.
|
mutableprivateinherited |
Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.
Definition at line 248 of file subscriptor.h.
|
staticprivateinherited |
A mutex used to ensure data consistency when accessing the mutable
members of this class. This lock is used in the subscribe() and unsubscribe() functions, as well as in list_subscribers()
.
Definition at line 271 of file subscriptor.h.