libMesh
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
libMesh::DofMap Class Reference

This class handles the numbering of degrees of freedom on a mesh. More...

#include <dof_map.h>

Inheritance diagram for libMesh::DofMap:
[legend]

Classes

class  AugmentSendList
 Abstract base class to be used to add user-defined parallel degree of freedom couplings. More...
 
class  AugmentSparsityPattern
 Backwards compatibility for prior AugmentSparsityPattern users. More...
 

Public Types

typedef std::vector< GhostingFunctor * >::const_iterator GhostingFunctorIterator
 Iterator type for coupling and algebraic ghosting functor ranges.
 

Public Member Functions

 DofMap (const unsigned int sys_number, MeshBase &mesh)
 Constructor.
 
 ~DofMap ()
 Destructor.
 
void attach_matrix (SparseMatrix< Number > &matrix)
 Additional matrices may be attached to this DofMap.
 
void update_sparsity_pattern (SparseMatrix< Number > &matrix) const
 Additional matrices may be be temporarily initialized by this DofMap.
 
bool is_attached (SparseMatrix< Number > &matrix)
 Matrices should not be attached more than once.
 
std::size_t distribute_dofs (MeshBase &)
 Distribute dofs on the current mesh.
 
void compute_sparsity (const MeshBase &)
 Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear Algebra packages for preallocation of sparse matrices.
 
bool computed_sparsity_already () const
 Returns true iff a sparsity pattern has already been computed.
 
void set_constrained_sparsity_construction (bool use_constraints)
 Sets the current policy for constructing sparsity patterns: if use_constraints is true (for robustness), we explicitly account for sparsity entries created by constraint matrix pre- and post- application.
 
void full_sparsity_pattern_needed ()
 Sets _need_full_sparsity_pattern to true regardless of the requirements by matrices.
 
void ghost_constraints_needed ()
 Sets _need_ghost_constraints to true regardless of the requirements by static condensation.
 
bool constrained_sparsity_construction ()
 Returns true iff the current policy when constructing sparsity patterns is to explicitly account for sparsity entries created by constraint matrix pre- and post- application.
 
void clear_sparsity ()
 Clears the sparsity pattern.
 
void remove_default_ghosting ()
 Remove any default ghosting functor(s).
 
void add_default_ghosting ()
 Add the default functor(s) for coupling and algebraic ghosting.
 
void add_coupling_functor (GhostingFunctor &coupling_functor, bool to_mesh=true)
 Adds a functor which can specify coupling requirements for creation of sparse matrices.
 
void add_coupling_functor (std::shared_ptr< GhostingFunctor > coupling_functor, bool to_mesh=true)
 Adds a functor which can specify coupling requirements for creation of sparse matrices.
 
void remove_coupling_functor (GhostingFunctor &coupling_functor)
 Removes a functor which was previously added to the set of coupling functors, from both this DofMap and from the underlying mesh.
 
GhostingFunctorIterator coupling_functors_begin () const
 Beginning of range of coupling functors.
 
GhostingFunctorIterator coupling_functors_end () const
 End of range of coupling functors.
 
DefaultCoupling & default_coupling ()
 Default coupling functor.
 
void add_algebraic_ghosting_functor (GhostingFunctor &evaluable_functor, bool to_mesh=true)
 Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors.
 
void add_algebraic_ghosting_functor (std::shared_ptr< GhostingFunctor > evaluable_functor, bool to_mesh=true)
 Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors.
 
void remove_algebraic_ghosting_functor (GhostingFunctor &evaluable_functor)
 Removes a functor which was previously added to the set of algebraic ghosting functors, from both this DofMap and from the underlying mesh.
 
GhostingFunctorIterator algebraic_ghosting_functors_begin () const
 Beginning of range of algebraic ghosting functors.
 
GhostingFunctorIterator algebraic_ghosting_functors_end () const
 End of range of algebraic ghosting functors.
 
DefaultCoupling & default_algebraic_ghosting ()
 Default algebraic ghosting functor.
 
void attach_extra_sparsity_object (SparsityPattern::AugmentSparsityPattern &asp)
 Attach an object to use to populate the sparsity pattern with extra entries.
 
void attach_extra_sparsity_function (void(*func)(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *), void *context=nullptr)
 Attach a function pointer to use as a callback to populate the sparsity pattern with extra entries.
 
void attach_extra_send_list_object (DofMap::AugmentSendList &asl)
 Attach an object to populate the send_list with extra entries.
 
void attach_extra_send_list_function (void(*func)(std::vector< dof_id_type > &, void *), void *context=nullptr)
 Attach a function pointer to use as a callback to populate the send_list with extra entries.
 
void prepare_send_list ()
 Takes the _send_list vector (which may have duplicate entries) and sorts it.
 
void clear_send_list ()
 Clears the _send_list vector.
 
void reinit_send_list (MeshBase &mesh)
 Clears the _send_list vector and then rebuilds it.
 
const std::vector< dof_id_type > & get_send_list () const
 
const std::vector< dof_id_type > & get_n_nz () const
 
const std::vector< dof_id_type > & get_n_oz () const
 
const SparsityPattern::Build * get_sparsity_pattern () const
 
unsigned int n_vars () const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned int n_components (const MeshBase &mesh) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification.
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FEType & variable_type (const unsigned int i) const
 
const FEType & variable_type (std::string_view var) const
 
unsigned int variable_number (std::string_view var) const
 
bool has_variable (std::string_view var) const
 
void get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const
 Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.
 
unsigned int add_variable (System &sys, std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system.
 
unsigned int add_variables (System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variables vars to the list of variables for this system.
 
unsigned int add_variable_array (System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds variables vars to the list of variables for this system.
 
void set_error_on_cyclic_constraint (bool error_on_cyclic_constraint)
 Specify whether or not we perform an extra (opt-mode enabled) check for constraint loops.
 
void set_error_on_constraint_loop (bool error_on_constraint_loop)
 
const VariableGroup & variable_group (const unsigned int c) const
 
const Variable & variable (const unsigned int c) const override
 
Order variable_order (const unsigned int c) const
 
Order variable_group_order (const unsigned int vg) const
 
const FEType & variable_group_type (const unsigned int vg) const
 
unsigned int n_variable_groups () const
 
unsigned int n_variables () const override
 
unsigned int var_group_from_var_number (unsigned int var_num) const
 
bool has_blocked_representation () const
 
unsigned int block_size () const
 
dof_id_type n_dofs (const unsigned int vn) const
 
dof_id_type n_SCALAR_dofs () const
 
dof_id_type n_local_dofs (const unsigned int vn) const
 
std::vector< dof_id_type > n_dofs_per_processor (const unsigned int vn) const
 
processor_id_type dof_owner (const dof_id_type dof) const
 
void dof_indices (const Elem *const elem, std::vector< dof_id_type > &di) const
 
void dof_indices (const Elem *const elem, std::vector< dof_id_type > &di, const unsigned int vn, int p_level=-12345) const override
 Fills the vector di with the global degree of freedom indices for the element.
 
void array_dof_indices (const Elem *const elem, std::vector< dof_id_type > &di, const unsigned int vn, int p_level=-12345) const
 Fills the vector di with the global degree of freedom indices for the element.
 
void array_dof_indices (const Node *const node, std::vector< dof_id_type > &di, const unsigned int vn) const
 
template<typename DofIndicesFunctor >
void array_dof_indices (const DofIndicesFunctor &functor, std::vector< dof_id_type > &di, const unsigned int vn) const
 
template<typename ScalarDofsFunctor , typename FieldDofsFunctor >
void dof_indices (const Elem *const elem, std::vector< dof_id_type > &di, const unsigned int vn, ScalarDofsFunctor scalar_dofs_functor, FieldDofsFunctor field_dofs_functor, int p_level=-12345) const
 Retrieves degree of freedom indices for a given elem and then performs actions for these indices defined by the user-provided functors scalar_dofs_functor and field_dofs_functor.
 
void dof_indices (const Node *const node, std::vector< dof_id_type > &di) const
 Fills the vector di with the global degree of freedom indices for the node.
 
void dof_indices (const Node *const node, std::vector< dof_id_type > &di, const unsigned int vn) const override
 Fills the vector di with the global degree of freedom indices for the node, for one variable vn.
 
void dof_indices (const Elem &elem, unsigned int n, std::vector< dof_id_type > &di, const unsigned int vn) const
 Appends to the vector di the global degree of freedom indices for elem.node_ref(n), for one variable vn.
 
void old_dof_indices (const Elem &elem, unsigned int n, std::vector< dof_id_type > &di, const unsigned int vn) const
 Appends to the vector di the old global degree of freedom indices for elem.node_ref(n), for one variable vn.
 
void SCALAR_dof_indices (std::vector< dof_id_type > &di, const unsigned int vn, const bool old_dofs=false) const
 Fills the vector di with the global degree of freedom indices corresponding to the SCALAR variable vn.
 
bool semilocal_index (dof_id_type dof_index) const
 
bool all_semilocal_indices (const std::vector< dof_id_type > &dof_indices) const
 
bool local_index (dof_id_type dof_index) const
 
template<typename DofObjectSubclass >
bool is_evaluable (const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
 
void set_implicit_neighbor_dofs (bool implicit_neighbor_dofs)
 Allow the implicit_neighbor_dofs flag to be set programmatically.
 
void set_verify_dirichlet_bc_consistency (bool val)
 Set the _verify_dirichlet_bc_consistency flag.
 
bool use_coupled_neighbor_dofs (const MeshBase &mesh) const
 Tells other library functions whether or not this problem includes coupling between dofs in neighboring cells, as can currently be specified on the command line or inferred from the use of all discontinuous variables.
 
void extract_local_vector (const NumericVector< Number > &Ug, const std::vector< dof_id_type > &dof_indices, DenseVectorBase< Number > &Ue) const
 Builds the local element vector Ue from the global vector Ug, accounting for any constrained degrees of freedom.
 
template<typename T , std::enable_if_t< std::is_same_v< T, dof_id_type >||std::is_same_v< T, std::vector< dof_id_type > >, int > = 0>
void local_variable_indices (T &idx, const MeshBase &mesh, unsigned int var_num) const
 If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices which belong to the given variable number and live on the current processor.
 
template<typename T , std::enable_if_t< std::is_same_v< T, dof_id_type >||std::is_same_v< T, std::vector< dof_id_type > >, int > = 0>
void local_variable_indices (T &idx, unsigned int var_num) const
 If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices which belong to the given variable number and live on the current processor.
 
dof_id_type n_constrained_dofs () const
 
dof_id_type n_local_constrained_dofs () const
 
dof_id_type n_constrained_nodes () const
 
void create_dof_constraints (const MeshBase &, Real time=0)
 Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary objects and on non-conforming interface in adapted meshes.
 
void allgather_recursive_constraints (MeshBase &)
 Gathers constraint equation dependencies from other processors.
 
void scatter_constraints (MeshBase &)
 Sends constraint equations to constraining processors.
 
void gather_constraints (MeshBase &mesh, std::set< dof_id_type > &unexpanded_dofs, bool look_for_constrainees)
 Helper function for querying about constraint equations on other processors.
 
void process_constraints (MeshBase &)
 Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dofs, then adds unconstrained dofs to the send_list and prepares that for use.
 
void check_for_cyclic_constraints ()
 Throw an error if we detect any constraint loops, i.e.
 
void check_for_constraint_loops ()
 
void add_constraint_row (const dof_id_type dof_number, const DofConstraintRow &constraint_row, const Number constraint_rhs, const bool forbid_constraint_overwrite)
 Adds a copy of the user-defined row to the constraint matrix, using an inhomogeneous right-hand-side for the constraint equation.
 
void add_adjoint_constraint_row (const unsigned int qoi_index, const dof_id_type dof_number, const DofConstraintRow &constraint_row, const Number constraint_rhs, const bool forbid_constraint_overwrite)
 Adds a copy of the user-defined row to the constraint matrix, using an inhomogeneous right-hand-side for the adjoint constraint equation.
 
void add_constraint_row (const dof_id_type dof_number, const DofConstraintRow &constraint_row, const bool forbid_constraint_overwrite=true)
 Adds a copy of the user-defined row to the constraint matrix, using a homogeneous right-hand-side for the constraint equation.
 
DofConstraints::const_iterator constraint_rows_begin () const
 
DofConstraints::const_iterator constraint_rows_end () const
 
const DofConstraints & get_dof_constraints () const
 Provide a const accessor to the DofConstraints map.
 
void stash_dof_constraints ()
 
void unstash_dof_constraints ()
 
void swap_dof_constraints ()
 Similar to the stash/unstash_dof_constraints() API, but swaps _dof_constraints and _stashed_dof_constraints without asserting that the source or destination is empty first.
 
NodeConstraints::const_iterator node_constraint_rows_begin () const
 
NodeConstraints::const_iterator node_constraint_rows_end () const
 
bool is_constrained_dof (const dof_id_type dof) const
 
bool has_heterogeneous_adjoint_constraints (const unsigned int qoi_num) const
 
bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
 Backwards compatibility with misspelling.
 
Number has_heterogeneous_adjoint_constraint (const unsigned int qoi_num, const dof_id_type dof) const
 
Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num, const dof_id_type dof) const
 Backwards compatibility with misspelling.
 
DofConstraintValueMap & get_primal_constraint_values ()
 
bool is_constrained_node (const Node *node) const
 
void print_dof_constraints (std::ostream &os=libMesh::out, bool print_nonlocal=false) const
 Prints (from processor 0) all DoF and Node constraints.
 
std::string get_local_constraints (bool print_nonlocal=false) const
 Gets a string reporting all DoF and Node constraints local to this processor.
 
std::pair< Real, Real > max_constraint_error (const System &system, NumericVector< Number > *v=nullptr) const
 Tests the constrained degrees of freedom on the numeric vector v, which represents a solution defined on the mesh, returning a pair whose first entry is the maximum absolute error on a constrained DoF and whose second entry is the maximum relative error.
 
void constrain_element_matrix (DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
 Constrains the element matrix.
 
void constrain_element_matrix (DenseMatrix< Number > &matrix, std::vector< dof_id_type > &row_dofs, std::vector< dof_id_type > &col_dofs, bool asymmetric_constraint_rows=true) const
 Constrains the element matrix.
 
void constrain_element_vector (DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
 Constrains the element vector.
 
void constrain_element_matrix_and_vector (DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
 Constrains the element matrix and vector.
 
void heterogeneously_constrain_element_matrix_and_vector (DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
 Constrains the element matrix and vector.
 
void heterogenously_constrain_element_matrix_and_vector (DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
 
void heterogeneously_constrain_element_vector (const DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
 Constrains the element vector.
 
void heterogenously_constrain_element_vector (const DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
 
void heterogeneously_constrain_element_jacobian_and_residual (DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
 Constrains the element Jacobian and residual.
 
void heterogeneously_constrain_element_residual (DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
 Constrains the element residual.
 
void constrain_element_residual (DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
 Constrains the element residual.
 
void constrain_element_dyad_matrix (DenseVector< Number > &v, DenseVector< Number > &w, std::vector< dof_id_type > &row_dofs, bool asymmetric_constraint_rows=true) const
 Constrains a dyadic element matrix B = v w'.
 
void constrain_nothing (std::vector< dof_id_type > &dofs) const
 Does not actually constrain anything, but modifies dofs in the same way as any of the constrain functions would do, i.e.
 
void enforce_constraints_exactly (const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
 Constrains the numeric vector v, which represents a solution defined on the mesh.
 
void enforce_adjoint_constraints_exactly (NumericVector< Number > &v, unsigned int q) const
 Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the mesh for quantity fo interest q.
 
void enforce_constraints_on_residual (const NonlinearImplicitSystem &system, NumericVector< Number > *rhs, NumericVector< Number > const *solution, bool homogeneous=true) const
 
void enforce_constraints_on_jacobian (const NonlinearImplicitSystem &system, SparseMatrix< Number > *jac) const
 
void add_periodic_boundary (const PeriodicBoundaryBase &periodic_boundary)
 Adds a copy of the specified periodic boundary to the system.
 
void add_periodic_boundary (const PeriodicBoundaryBase &boundary, const PeriodicBoundaryBase &inverse_boundary)
 Add a periodic boundary pair.
 
bool is_periodic_boundary (const boundary_id_type boundaryid) const
 
PeriodicBoundaries * get_periodic_boundaries ()
 
const PeriodicBoundaries * get_periodic_boundaries () const
 
void add_dirichlet_boundary (const DirichletBoundary &dirichlet_boundary)
 Adds a copy of the specified Dirichlet boundary to the system.
 
void add_adjoint_dirichlet_boundary (const DirichletBoundary &dirichlet_boundary, unsigned int q)
 Adds a copy of the specified Dirichlet boundary to the system, corresponding to the adjoint problem defined by Quantity of Interest q.
 
void remove_dirichlet_boundary (const DirichletBoundary &dirichlet_boundary)
 Removes the specified Dirichlet boundary from the system.
 
void remove_adjoint_dirichlet_boundary (const DirichletBoundary &dirichlet_boundary, unsigned int q)
 Removes from the system the specified Dirichlet boundary for the adjoint equation defined by Quantity of interest index q.
 
const DirichletBoundaries * get_dirichlet_boundaries () const
 
DirichletBoundaries * get_dirichlet_boundaries ()
 
bool has_adjoint_dirichlet_boundaries (unsigned int q) const
 
const DirichletBoundaries * get_adjoint_dirichlet_boundaries (unsigned int q) const
 
DirichletBoundaries * get_adjoint_dirichlet_boundaries (unsigned int q)
 
void check_dirichlet_bcid_consistency (const MeshBase &mesh, const DirichletBoundary &boundary) const
 Check that all the ids in dirichlet_bcids are actually present in the mesh.
 
void old_dof_indices (const Elem *const elem, std::vector< dof_id_type > &di, const unsigned int vn=libMesh::invalid_uint) const
 After a mesh is refined and repartitioned it is possible that the _send_list will need to be augmented.
 
void constrain_p_dofs (unsigned int var, const Elem *elem, unsigned int s, unsigned int p)
 Constrains degrees of freedom on side s of element elem which correspond to variable number var and to p refinement levels above p.
 
void reinit (MeshBase &mesh, const std::map< const Node *, std::set< subdomain_id_type > > &constraining_subdomains)
 Reinitialize the underlying data structures conformal to the current mesh.
 
virtual void clear () override
 Free all new memory associated with the object, but restore its original state, with the mesh pointer and any default ghosting.
 
void print_info (std::ostream &os=libMesh::out) const
 Prints summary info about the sparsity bandwidth and constraints.
 
std::string get_info () const
 Gets summary info about the sparsity bandwidth and constraints.
 
unsigned int sys_number () const
 
std::unique_ptr< SparsityPattern::Build > build_sparsity (const MeshBase &mesh, bool calculate_constrained=false, bool use_condensed_system=false) const
 Builds a sparsity pattern for matrices using the current degree-of-freedom numbering and coupling.
 
void should_p_refine (unsigned int g, bool p_refine)
 Set whether the given variable group should be p-refined on a p-refined Elem.
 
bool should_p_refine (unsigned int g) const
 Whether the given variable group should be p-refined.
 
bool should_p_refine_var (unsigned int var) const
 Whether the given variable should be p-refined.
 
void should_p_refine (FEFamily, bool)=delete
 
void should_p_refine (Order, bool)=delete
 
bool should_p_refine (FEFamily) const =delete
 
bool should_p_refine (Order) const =delete
 
void create_static_condensation (MeshBase &mesh, System &system)
 Add a static condensation class.
 
bool has_static_condensation () const
 Checks whether we have static condensation.
 
StaticCondensationDofMap & get_static_condensation ()
 
const StaticCondensationDofMap & get_static_condensation () const
 
void reinit_static_condensation ()
 Calls reinit on the static condensation map if it exists.
 
dof_id_type n_dofs () const
 
dof_id_type n_local_dofs () const
 
dof_id_type first_dof (const processor_id_type proc) const
 
dof_id_type first_dof () const
 
dof_id_type end_dof (const processor_id_type proc) const
 
dof_id_type end_dof () const
 
dof_id_type n_dofs_on_processor (const processor_id_type proc) const
 
dof_id_type n_old_dofs () const
 
dof_id_type first_old_dof (const processor_id_type proc) const
 
dof_id_type first_old_dof () const
 
dof_id_type end_old_dof (const processor_id_type proc) const
 
dof_id_type end_old_dof () const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information.
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out.
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects.
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info().
 
static void disable_print_counter_info ()
 

Public Attributes

CouplingMatrix * _dof_coupling
 Degree of freedom coupling.
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information.
 

Protected Member Functions

std::size_t compute_dof_info (dof_id_type n_local_dofs)
 compute the key degree of freedom information given the local number of degrees of freedom on this process
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter.
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter.
 

Protected Attributes

std::vector< dof_id_type > _first_df
 First DOF index on processor p.
 
std::vector< dof_id_type > _end_df
 Last DOF index (plus 1) on processor p.
 
dof_id_type _n_dfs
 Total number of degrees of freedom.
 
dof_id_type _n_old_dfs
 Total number of degrees of freedom on old dof objects.
 
std::vector< dof_id_type > _first_old_df
 First old DOF index on processor p.
 
std::vector< dof_id_type > _end_old_df
 Last old DOF index (plus 1) on processor p.
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data.
 
static Threads::atomic< unsigned int > _n_objects
 The number of objects.
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting.
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called.
 

Private Types

typedef DofObject *(DofMap::* dofobject_accessor) (MeshBase &mesh, dof_id_type i) const
 A member function type like node_ptr() or elem_ptr().
 
typedef std::set< std::unique_ptr< CouplingMatrix >, Utility::CompareUnderlying > CouplingMatricesSet
 

Private Member Functions

const std::pair< unsigned int, unsigned int > & get_variable_array (unsigned int vi) const
 Retrieve the array variable bounds for a given variable vi.
 
void _dof_indices (const Elem &elem, int p_level, std::vector< dof_id_type > &di, const unsigned int vg, const unsigned int vig, const Node *const *nodes, unsigned int n_nodes, const unsigned int v #ifdef DEBUG, std::size_t &tot_size #endif) const
 Helper function that gets the dof indices on the current element for a non-SCALAR type variable, where the variable is identified by its variable group number vg and its offset vig from the first variable in that group.
 
template<typename FieldDofsFunctor >
void _dof_indices (const Elem &elem, int p_level, std::vector< dof_id_type > &di, const unsigned int vg, const unsigned int vig, const Node *const *nodes, unsigned int n_nodes, const unsigned int v, #ifdef DEBUG std::size_t &tot_size, #endif FieldDofsFunctor field_dofs_functor) const
 As above except a field_dofs_functor must be provided.
 
void _node_dof_indices (const Elem &elem, unsigned int n, const DofObject &obj, std::vector< dof_id_type > &di, const unsigned int vn) const
 Helper function that implements the element-nodal versions of dof_indices and old_dof_indices.
 
void invalidate_dofs (MeshBase &mesh) const
 Invalidates all active DofObject dofs for this system.
 
DofObject * node_ptr (MeshBase &mesh, dof_id_type i) const
 
DofObject * elem_ptr (MeshBase &mesh, dof_id_type i) const
 
template<typename iterator_type >
void set_nonlocal_dof_objects (iterator_type objects_begin, iterator_type objects_end, MeshBase &mesh, dofobject_accessor objects)
 Helper function for distributing dofs in parallel.
 
std::map< const Node *, std::set< subdomain_id_type > > calculate_constraining_subdomains ()
 We may have mesh constraint rows with dependent nodes in one subdomain but dependency nodes in another subdomain, and we may have variables whose subdomain restriction includes the dependent subdomain but not the dependency.
 
void distribute_local_dofs_var_major (dof_id_type &next_free_dof, MeshBase &mesh, const std::map< const Node *, std::set< subdomain_id_type > > &constraining_subdomains)
 Distributes the global degrees of freedom, for dofs on this processor.
 
void distribute_local_dofs_node_major (dof_id_type &next_free_dof, MeshBase &mesh, const std::map< const Node *, std::set< subdomain_id_type > > &constraining_subdomains)
 Distributes the global degrees of freedom for dofs on this processor.
 
void distribute_scalar_dofs (dof_id_type &next_free_dof)
 
void assert_no_nodes_missed (MeshBase &mesh)
 
void add_neighbors_to_send_list (MeshBase &mesh)
 Adds entries to the _send_list vector corresponding to DoFs on elements neighboring the current processor.
 
void build_constraint_matrix (DenseMatrix< Number > &C, std::vector< dof_id_type > &elem_dofs, const bool called_recursively=false) const
 Build the constraint matrix C associated with the element degree of freedom indices elem_dofs.
 
void build_constraint_matrix_and_vector (DenseMatrix< Number > &C, DenseVector< Number > &H, std::vector< dof_id_type > &elem_dofs, int qoi_index=-1, const bool called_recursively=false) const
 Build the constraint matrix C and the forcing vector H associated with the element degree of freedom indices elem_dofs.
 
void find_connected_dofs (std::vector< dof_id_type > &elem_dofs) const
 Finds all the DOFS associated with the element DOFs elem_dofs.
 
void find_connected_dof_objects (std::vector< const DofObject * > &objs) const
 Finds all the DofObjects associated with the set in objs.
 
void add_constraints_to_send_list (const MeshBase &mesh)
 Adds entries to the _send_list vector corresponding to DoFs which are dependencies for constraint equations on the current processor.
 
void process_mesh_constraint_rows (const MeshBase &mesh)
 Adds any spline constraints from the Mesh to our DoF constraints.
 

Static Private Member Functions

static void merge_ghost_functor_outputs (GhostingFunctor::map_type &elements_to_ghost, CouplingMatricesSet &temporary_coupling_matrices, const GhostingFunctorIterator &gf_begin, const GhostingFunctorIterator &gf_end, const MeshBase::const_element_iterator &elems_begin, const MeshBase::const_element_iterator &elems_end, processor_id_type p)
 

Private Attributes

bool _error_on_constraint_loop
 This flag indicates whether or not we do an opt-mode check for the presence of constraint loops, i.e.
 
bool _constrained_sparsity_construction
 This flag indicates whether or not we explicitly take constraint equations into account when computing a sparsity pattern.
 
std::vector< Variable > _variables
 The variables in this system/degree of freedom map.
 
std::vector< VariableGroup > _variable_groups
 The variable groups in this system/degree of freedom map.
 
std::vector< unsigned int > _variable_group_numbers
 The variable group number for each variable.
 
std::unordered_map< unsigned int, unsigned int > _var_to_vg
 A map from variable number to variable group number.
 
std::map< std::string, unsigned int, std::less<> > _variable_numbers
 The variable numbers corresponding to user-specified names, useful for name-based lookups.
 
std::vector< std::pair< unsigned int, unsigned int > > _array_variables
 Array variable information storage.
 
bool _identify_variable_groups = true
 true when VariableGroup structures should be automatically identified, false otherwise.
 
const unsigned int _sys_number
 The number of the system we manage DOFs for.
 
MeshBase & _mesh
 The mesh that system uses.
 
std::vector< SparseMatrix< Number > * > _matrices
 Additional matrices handled by this object.
 
std::vector< dof_id_type > _first_scalar_df
 First DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
 
std::vector< dof_id_type > _send_list
 A list containing all the global DOF indices that affect the solution on my processor.
 
SparsityPattern::AugmentSparsityPattern * _augment_sparsity_pattern
 Function object to call to add extra entries to the sparsity pattern.
 
void(* _extra_sparsity_function )(SparsityPattern::Graph &, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *)
 A function pointer to a function to call to add extra entries to the sparsity pattern.
 
void * _extra_sparsity_context
 A pointer associated with the extra sparsity that can optionally be passed in.
 
AugmentSendList * _augment_send_list
 Function object to call to add extra entries to the send list.
 
void(* _extra_send_list_function )(std::vector< dof_id_type > &, void *)
 A function pointer to a function to call to add extra entries to the send list.
 
void * _extra_send_list_context
 A pointer associated with the extra send list that can optionally be passed in.
 
std::unique_ptr< DefaultCoupling > _default_coupling
 The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern construction.
 
std::unique_ptr< DefaultCoupling > _default_evaluating
 The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction.
 
std::vector< GhostingFunctor * > _algebraic_ghosting_functors
 The list of all GhostingFunctor objects to be used when distributing ghosted vectors.
 
std::vector< GhostingFunctor * > _coupling_functors
 The list of all GhostingFunctor objects to be used when coupling degrees of freedom in matrix sparsity patterns.
 
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
 Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.
 
bool _need_full_sparsity_pattern
 Default false; set to true if any attached matrix requires a full sparsity pattern.
 
bool _need_ghost_constraints
 Default false; set to true if the dependencies of constrained ghost DOFs supported by local elements should also be ghosted.
 
std::unique_ptr< SparsityPattern::Build > _sp
 The sparsity pattern of the global matrix.
 
dof_id_type _n_SCALAR_dofs
 The total number of SCALAR dofs associated to all SCALAR variables.
 
std::vector< dof_id_type > _first_old_scalar_df
 First old DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
 
DofConstraints _dof_constraints
 Data structure containing DOF constraints.
 
DofConstraints _stashed_dof_constraints
 
DofConstraintValueMap _primal_constraint_values
 
AdjointDofConstraintValues _adjoint_constraint_values
 
NodeConstraints _node_constraints
 Data structure containing DofObject constraints.
 
std::unique_ptr< PeriodicBoundaries > _periodic_boundaries
 Data structure containing periodic boundaries.
 
std::unique_ptr< DirichletBoundaries > _dirichlet_boundaries
 Data structure containing Dirichlet functions.
 
std::vector< std::unique_ptr< DirichletBoundaries > > _adjoint_dirichlet_boundaries
 Data structure containing Dirichlet functions.
 
bool _implicit_neighbor_dofs_initialized
 Bools to indicate if we override the –implicit_neighbor_dofs commandline options.
 
bool _implicit_neighbor_dofs
 
bool _verify_dirichlet_bc_consistency
 Flag which determines whether we should do some additional checking of the consistency of the DirichletBoundary objects added by the user.
 
std::unique_ptr< StaticCondensationDofMap > _sc
 Static condensation class.
 

Friends

class SparsityPattern::Build
 

Detailed Description

This class handles the numbering of degrees of freedom on a mesh.

For systems of equations the class supports a fixed number of variables. The degrees of freedom are numbered such that sequential, contiguous blocks belong to distinct processors. This is so that the resulting data structures will work well with parallel linear algebra packages.

Author
Benjamin S. Kirk
Date
2002-2007

Manages the degrees of freedom (DOFs) in a simulation.

Definition at line 179 of file dof_map.h.

Member Typedef Documentation

◆ Counts

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ CouplingMatricesSet

Definition at line 2006 of file dof_map.h.

◆ dofobject_accessor

typedef DofObject *(DofMap::* libMesh::DofMap::dofobject_accessor) (MeshBase &mesh, dof_id_type i) const
private

A member function type like node_ptr() or elem_ptr().

Definition at line 1922 of file dof_map.h.

◆ GhostingFunctorIterator

typedef std::vector<GhostingFunctor*>::const_iterator libMesh::DofMap::GhostingFunctorIterator

Iterator type for coupling and algebraic ghosting functor ranges.

This has changed in the past and may change again; code should use auto or the type here.

Definition at line 322 of file dof_map.h.

Constructor & Destructor Documentation

◆ DofMap()

libMesh::DofMap::DofMap ( const unsigned int  sys_number,
MeshBase &  mesh 
)
explicit

Constructor.

Requires the number of the system for which we will be numbering degrees of freedom & the parent object we are contained in, which defines our communication space.

Definition at line 138 of file dof_map.C.

139 :
140 DofMapBase (mesh.comm()),
141 _dof_coupling(nullptr),
144 _variables(),
147 _sys_number(number),
148 _mesh(mesh),
149 _matrices(),
151 _send_list(),
155 _augment_send_list(nullptr),
158 _default_coupling(std::make_unique<DefaultCoupling>()),
159 _default_evaluating(std::make_unique<DefaultCoupling>()),
163#ifdef LIBMESH_ENABLE_AMR
165#endif
166#ifdef LIBMESH_ENABLE_CONSTRAINTS
171#endif
172#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
174#endif
175#ifdef LIBMESH_ENABLE_PERIODIC
176 , _periodic_boundaries(std::make_unique<PeriodicBoundaries>())
177#endif
178#ifdef LIBMESH_ENABLE_DIRICHLET
179 , _dirichlet_boundaries(std::make_unique<DirichletBoundaries>())
181#endif
185 _sc(nullptr)
186{
187 _matrices.clear();
188
189 _default_coupling->set_mesh(&_mesh);
190 _default_evaluating->set_mesh(&_mesh);
191 _default_evaluating->set_n_levels(1);
192
193#ifdef LIBMESH_ENABLE_PERIODIC
194 _default_coupling->set_periodic_boundaries(_periodic_boundaries.get());
195 _default_evaluating->set_periodic_boundaries(_periodic_boundaries.get());
196#endif
197
200}
DofMapBase(const Parallel::Communicator &comm)
std::vector< unsigned int > _variable_group_numbers
The variable group number for each variable.
Definition dof_map.h:2113
bool _implicit_neighbor_dofs
Definition dof_map.h:2331
bool _verify_dirichlet_bc_consistency
Flag which determines whether we should do some additional checking of the consistency of the Dirichl...
Definition dof_map.h:2343
DofConstraintValueMap _primal_constraint_values
Definition dof_map.h:2289
void * _extra_sparsity_context
A pointer associated with the extra sparsity that can optionally be passed in.
Definition dof_map.h:2183
std::vector< dof_id_type > _send_list
A list containing all the global DOF indices that affect the solution on my processor.
Definition dof_map.h:2166
std::unique_ptr< DirichletBoundaries > _dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition dof_map.h:2315
const unsigned int _sys_number
The number of the system we manage DOFs for.
Definition dof_map.h:2142
std::vector< std::unique_ptr< DirichletBoundaries > > _adjoint_dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition dof_map.h:2321
AugmentSendList * _augment_send_list
Function object to call to add extra entries to the send list.
Definition dof_map.h:2188
std::unique_ptr< DefaultCoupling > _default_evaluating
The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction.
Definition dof_map.h:2214
std::vector< Variable > _variables
The variables in this system/degree of freedom map.
Definition dof_map.h:2103
bool _need_ghost_constraints
Default false; set to true if the dependencies of constrained ghost DOFs supported by local elements ...
Definition dof_map.h:2258
void * _extra_send_list_context
A pointer associated with the extra send list that can optionally be passed in.
Definition dof_map.h:2198
void(* _extra_sparsity_function)(SparsityPattern::Graph &, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *)
A function pointer to a function to call to add extra entries to the sparsity pattern.
Definition dof_map.h:2176
bool _constrained_sparsity_construction
This flag indicates whether or not we explicitly take constraint equations into account when computin...
Definition dof_map.h:2098
NodeConstraints _node_constraints
Data structure containing DofObject constraints.
Definition dof_map.h:2298
AdjointDofConstraintValues _adjoint_constraint_values
Definition dof_map.h:2291
SparsityPattern::AugmentSparsityPattern * _augment_sparsity_pattern
Function object to call to add extra entries to the sparsity pattern.
Definition dof_map.h:2171
dof_id_type _n_SCALAR_dofs
The total number of SCALAR dofs associated to all SCALAR variables.
Definition dof_map.h:2271
std::vector< dof_id_type > _first_old_scalar_df
First old DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
Definition dof_map.h:2279
void add_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor, bool to_mesh=true)
Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors.
Definition dof_map.C:2064
bool _implicit_neighbor_dofs_initialized
Bools to indicate if we override the –implicit_neighbor_dofs commandline options.
Definition dof_map.h:2330
std::vector< SparseMatrix< Number > * > _matrices
Additional matrices handled by this object.
Definition dof_map.h:2154
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
Definition dof_map.h:1748
std::unique_ptr< PeriodicBoundaries > _periodic_boundaries
Data structure containing periodic boundaries.
Definition dof_map.h:2307
std::unique_ptr< DefaultCoupling > _default_coupling
The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern constructio...
Definition dof_map.h:2206
MeshBase & _mesh
The mesh that system uses.
Definition dof_map.h:2147
void(* _extra_send_list_function)(std::vector< dof_id_type > &, void *)
A function pointer to a function to call to add extra entries to the send list.
Definition dof_map.h:2193
std::vector< VariableGroup > _variable_groups
The variable groups in this system/degree of freedom map.
Definition dof_map.h:2108
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices.
Definition dof_map.C:2007
bool _error_on_constraint_loop
This flag indicates whether or not we do an opt-mode check for the presence of constraint loops,...
Definition dof_map.h:2092
std::vector< dof_id_type > _first_scalar_df
First DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
Definition dof_map.h:2160
DofConstraints _stashed_dof_constraints
Definition dof_map.h:2287
DofConstraints _dof_constraints
Data structure containing DOF constraints.
Definition dof_map.h:2287
std::unique_ptr< StaticCondensationDofMap > _sc
Static condensation class.
Definition dof_map.h:2346
bool _need_full_sparsity_pattern
Default false; set to true if any attached matrix requires a full sparsity pattern.
Definition dof_map.h:2252
MeshBase & mesh

References _default_coupling, _default_evaluating, _matrices, _mesh, _periodic_boundaries, add_algebraic_ghosting_functor(), add_coupling_functor(), and libMesh::DofMapBase::clear().

◆ ~DofMap()

libMesh::DofMap::~DofMap ( )

Destructor.

Definition at line 205 of file dof_map.C.

206{
207 this->clear();
208
209 // clear() resets all but the default DofMap-based functors. We
210 // need to remove those from the mesh too before we die.
213}
virtual void clear() override
Free all new memory associated with the object, but restore its original state, with the mesh pointer...
Definition dof_map.C:872
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
Definition mesh_base.C:1101

References _default_coupling, _default_evaluating, _mesh, clear(), and libMesh::MeshBase::remove_ghosting_functor().

Member Function Documentation

◆ _dof_indices() [1/2]

void libMesh::DofMap::_dof_indices ( const Elem &  elem,
int  p_level,
std::vector< dof_id_type > &  di,
const unsigned int  vg,
const unsigned int  vig,
const Node *const *  nodes,
unsigned int  n_nodes,
const unsigned int v #ifdef  DEBUG,
std::size_t &tot_size #  endif 
) const
private

Helper function that gets the dof indices on the current element for a non-SCALAR type variable, where the variable is identified by its variable group number vg and its offset vig from the first variable in that group.

In DEBUG mode, the tot_size parameter will add up the total number of dof indices that should have been added to di, and v will be the variable number corresponding to vg and vig.

Definition at line 2575 of file dof_map.C.

2588{
2589 _dof_indices(elem,
2590 p_level,
2591 di,
2592 vg,
2593 vig,
2594 nodes,
2595 n_nodes,
2596 v,
2597#ifdef DEBUG
2598 tot_size,
2599#endif
2600 [](const Elem &,
2601 unsigned int,
2602 unsigned int,
2603 std::vector<dof_id_type> & functor_di,
2604 const dof_id_type dof) { functor_di.push_back(dof); });
2605}
void _dof_indices(const Elem &elem, int p_level, std::vector< dof_id_type > &di, const unsigned int vg, const unsigned int vig, const Node *const *nodes, unsigned int n_nodes, const unsigned int v #ifdef DEBUG, std::size_t &tot_size #endif) const
Helper function that gets the dof indices on the current element for a non-SCALAR type variable,...
Definition dof_map.C:2575
uint8_t dof_id_type
Definition id_types.h:67
const dof_id_type n_nodes
Definition tecplot_io.C:67

References n_nodes.

Referenced by dof_indices().

◆ _dof_indices() [2/2]

template<typename FieldDofsFunctor >
void libMesh::DofMap::_dof_indices ( const Elem &  elem,
int  p_level,
std::vector< dof_id_type > &  di,
const unsigned int  vg,
const unsigned int  vig,
const Node *const *  nodes,
unsigned int  n_nodes,
const unsigned int  v,
#ifdef DEBUG std::size_t &  tot_size,
#endif FieldDofsFunctor  field_dofs_functor 
) const
private

As above except a field_dofs_functor must be provided.

This method is useful when the caller wants to do more than simply fill a degree of freedom container

Parameters
field_dofs_functorThis functor has the interface: void field_dofs_functor(const Elem & elem, const unsigned int node_num, const unsigned int var_num, std::vector<dof_id_type> & di, const dof_id_type field_dof) where field_dof represents a field degree of freedom to act on and is associated with node_num and var_num. If the degree of freedom is elemental than node_num will be invalid_uint. di is the degree of freedom container provided to the _dof_indices method

Definition at line 2638 of file dof_map.h.

2650{
2651 const VariableGroup & var = this->variable_group(vg);
2652
2653 if (var.active_on_subdomain(elem.subdomain_id()))
2654 {
2655 const ElemType type = elem.type();
2656 const unsigned int sys_num = this->sys_number();
2657#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2658 const bool is_inf = elem.infinite();
2659#endif
2660
2661 const bool extra_hanging_dofs =
2663
2664 FEType fe_type = var.type();
2665
2666 const bool add_p_level = fe_type.p_refinement;
2667
2668#ifdef DEBUG
2669 // The number of dofs per element is non-static for subdivision FE
2670 if (var.type().family == SUBDIVISION)
2671 tot_size += n_nodes;
2672 else
2673 // FIXME: Is the passed-in p_level just elem.p_level()? If so,
2674 // this seems redundant.
2675 tot_size += FEInterface::n_dofs(fe_type, add_p_level*p_level, &elem);
2676#endif
2677
2678 // The total Order is not required when getting the function
2679 // pointer, it is only needed when the function is called (see
2680 // below).
2683
2684 // Get the node-based DOF numbers
2685 for (unsigned int n=0; n != n_nodes; n++)
2686 {
2687 const Node & node = *nodes[n];
2688
2689 // Cache the intermediate lookups that are common to every
2690 // component
2691#ifdef DEBUG
2692 const std::pair<unsigned int, unsigned int>
2693 vg_and_offset = node.var_to_vg_and_offset(sys_num,v);
2694 libmesh_assert_equal_to (vg, vg_and_offset.first);
2695 libmesh_assert_equal_to (vig, vg_and_offset.second);
2696#endif
2697 const unsigned int n_comp = node.n_comp_group(sys_num,vg);
2698
2699 // There is a potential problem with h refinement. Imagine a
2700 // quad9 that has a linear FE on it. Then, on the hanging side,
2701 // it can falsely identify a DOF at the mid-edge node. This is why
2702 // we go through FEInterface instead of node.n_comp() directly.
2703 const unsigned int nc =
2704#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2705 is_inf ?
2706 FEInterface::n_dofs_at_node(fe_type, add_p_level*p_level, &elem, n) :
2707#endif
2708 ndan (type, fe_type.order + add_p_level*p_level, n);
2709
2710 // If this is a non-vertex on a hanging node with extra
2711 // degrees of freedom, we use the non-vertex dofs (which
2712 // come in reverse order starting from the end, to
2713 // simplify p refinement)
2714 if (extra_hanging_dofs && !elem.is_vertex(n))
2715 {
2716 const int dof_offset = n_comp - nc;
2717
2718 // We should never have fewer dofs than necessary on a
2719 // node unless we're getting indices on a parent element,
2720 // and we should never need the indices on such a node
2721 if (dof_offset < 0)
2722 {
2723 libmesh_assert(!elem.active());
2724 di.resize(di.size() + nc, DofObject::invalid_id);
2725 }
2726 else
2727 for (int i=int(n_comp)-1; i>=dof_offset; i--)
2728 {
2729 const dof_id_type d =
2730 node.dof_number(sys_num, vg, vig, i, n_comp);
2731 libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2732 field_dofs_functor(elem, n, v, di, d);
2733 }
2734 }
2735 // If this is a vertex or an element without extra hanging
2736 // dofs, our dofs come in forward order coming from the
2737 // beginning
2738 else
2739 {
2740 // We have a good component index only if it's being
2741 // used on this FE type (nc) *and* it's available on
2742 // this DofObject (n_comp).
2743 const unsigned int good_nc = std::min(n_comp, nc);
2744 for (unsigned int i=0; i!=good_nc; ++i)
2745 {
2746 const dof_id_type d =
2747 node.dof_number(sys_num, vg, vig, i, n_comp);
2748 libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2749 libmesh_assert_less (d, this->n_dofs());
2750 field_dofs_functor(elem, n, v, di, d);
2751 }
2752
2753 // With fewer good component indices than we need, e.g.
2754 // due to subdomain expansion, the remaining expected
2755 // indices are marked invalid.
2756 if (n_comp < nc)
2757 for (unsigned int i=n_comp; i!=nc; ++i)
2758 di.push_back(DofObject::invalid_id);
2759 }
2760 }
2761
2762 // If there are any element-based DOF numbers, get them
2763 const unsigned int nc = FEInterface::n_dofs_per_elem(fe_type, add_p_level*p_level, &elem);
2764
2765 // We should never have fewer dofs than necessary on an
2766 // element unless we're getting indices on a parent element
2767 // (and we should never need those indices) or off-domain for a
2768 // subdomain-restricted variable (where invalid_id is the
2769 // correct thing to return)
2770 if (nc != 0)
2771 {
2772 const unsigned int n_comp = elem.n_comp_group(sys_num,vg);
2773 if (elem.n_systems() > sys_num && nc <= n_comp)
2774 {
2775 for (unsigned int i=0; i<nc; i++)
2776 {
2777 const dof_id_type d =
2778 elem.dof_number(sys_num, vg, vig, i, n_comp);
2779 libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2780
2781 field_dofs_functor(elem, invalid_uint, v, di, d);
2782 }
2783 }
2784 else
2785 {
2786 libmesh_assert(!elem.active() || fe_type.family == LAGRANGE || fe_type.family == SUBDIVISION);
2787 di.resize(di.size() + nc, DofObject::invalid_id);
2788 }
2789 }
2790 }
2791}
dof_id_type n_dofs() const
unsigned int sys_number() const
Definition dof_map.h:2353
const VariableGroup & variable_group(const unsigned int c) const
Definition dof_map.h:2361
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
static n_dofs_at_node_ptr n_dofs_at_node_function(const unsigned int dim, const FEType &fe_t)
unsigned int(* n_dofs_at_node_ptr)(const ElemType, const Order, const unsigned int)
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
static unsigned int n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)
static unsigned int n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
static bool extra_hanging_dofs(const FEType &fe_t)
ElemType
Defines an enum for geometric element types.
libmesh_assert(ctx)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303

References libMesh::Elem::active(), libMesh::Variable::active_on_subdomain(), libMesh::DofObject::dof_number(), libMesh::FEInterface::extra_hanging_dofs(), libMesh::FEType::family, libMesh::Elem::infinite(), libMesh::DofObject::invalid_id, libMesh::invalid_uint, libMesh::Elem::is_vertex(), libMesh::LAGRANGE, libMesh::libmesh_assert(), libMesh::DofObject::n_comp_group(), n_dofs(), libMesh::FEInterface::n_dofs(), libMesh::FEInterface::n_dofs_at_node(), libMesh::FEInterface::n_dofs_at_node_function(), libMesh::FEInterface::n_dofs_per_elem(), n_nodes, libMesh::DofObject::n_systems(), libMesh::FEType::order, libMesh::FEType::p_refinement, libMesh::SUBDIVISION, libMesh::Elem::subdomain_id(), sys_number(), libMesh::Variable::type(), libMesh::Elem::type(), libMesh::DofObject::var_to_vg_and_offset(), and variable_group().

◆ _node_dof_indices()

void libMesh::DofMap::_node_dof_indices ( const Elem &  elem,
unsigned int  n,
const DofObject &  obj,
std::vector< dof_id_type > &  di,
const unsigned int  vn 
) const
private

Helper function that implements the element-nodal versions of dof_indices and old_dof_indices.

Definition at line 2493 of file dof_map.C.

2498{
2499 // Half of this is a cut and paste of _dof_indices code below, but
2500 // duplication actually seems cleaner than creating a helper
2501 // function with a million arguments and hoping the compiler inlines
2502 // it properly into one of our most highly trafficked functions.
2503
2504 // dof_indices() is a relatively light-weight function; the cost of
2505 // the logging code itself is roughly on par with the time required
2506 // to call dof_indices().
2507 // LOG_SCOPE("_node_dof_indices()", "DofMap");
2508
2509 const unsigned int sys_num = this->sys_number();
2510 const auto [vg, vig] =
2511 obj.var_to_vg_and_offset(sys_num,vn);
2512 const unsigned int n_comp = obj.n_comp_group(sys_num,vg);
2513
2514 const VariableGroup & var = this->variable_group(vg);
2515 FEType fe_type = var.type();
2516 const bool extra_hanging_dofs =
2518
2519 const bool add_p_level = fe_type.p_refinement;
2520
2521 // There is a potential problem with h refinement. Imagine a
2522 // quad9 that has a linear FE on it. Then, on the hanging side,
2523 // it can falsely identify a DOF at the mid-edge node. This is why
2524 // we go through FEInterface instead of obj->n_comp() directly.
2525 const unsigned int nc =
2526 FEInterface::n_dofs_at_node(fe_type, &elem, n, add_p_level);
2527
2528 // If this is a non-vertex on a hanging node with extra
2529 // degrees of freedom, we use the non-vertex dofs (which
2530 // come in reverse order starting from the end, to
2531 // simplify p refinement)
2532 if (extra_hanging_dofs && nc && !elem.is_vertex(n))
2533 {
2534 const int dof_offset = n_comp - nc;
2535
2536 // We should never have fewer dofs than necessary on a
2537 // node unless we're getting indices on a parent element,
2538 // and we should never need the indices on such a node
2539 if (dof_offset < 0)
2540 {
2541 libmesh_assert(!elem.active());
2542 di.resize(di.size() + nc, DofObject::invalid_id);
2543 }
2544 else
2545 for (unsigned int i = dof_offset; i != n_comp; ++i)
2546 {
2547 const dof_id_type d =
2548 obj.dof_number(sys_num, vg, vig, i, n_comp);
2549 libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2550 di.push_back(d);
2551 }
2552 }
2553 // If this is a vertex or an element without extra hanging
2554 // dofs, our dofs come in forward order coming from the
2555 // beginning. But we still might not have all those dofs, in cases
2556 // where a subdomain-restricted variable just had its subdomain
2557 // expanded.
2558 else
2559 {
2560 const unsigned int good_nc =
2561 std::min(static_cast<unsigned int>(n_comp), nc);
2562 for (unsigned int i=0; i != good_nc; ++i)
2563 {
2564 const dof_id_type d =
2565 obj.dof_number(sys_num, vg, vig, i, n_comp);
2566 libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2567 di.push_back(d);
2568 }
2569 for (unsigned int i=good_nc; i != nc; ++i)
2570 di.push_back(DofObject::invalid_id);
2571 }
2572}

References libMesh::Elem::active(), libMesh::DofObject::dof_number(), libMesh::Elem::is_vertex(), libMesh::libmesh_assert(), libMesh::DofObject::n_comp_group(), libMesh::FEType::p_refinement, libMesh::Variable::type(), and libMesh::DofObject::var_to_vg_and_offset().

◆ add_adjoint_constraint_row()

void libMesh::DofMap::add_adjoint_constraint_row ( const unsigned int  qoi_index,
const dof_id_type  dof_number,
const DofConstraintRow &  constraint_row,
const Number  constraint_rhs,
const bool  forbid_constraint_overwrite 
)

Adds a copy of the user-defined row to the constraint matrix, using an inhomogeneous right-hand-side for the adjoint constraint equation.

forbid_constraint_overwrite here only tests for overwriting the rhs. This method should only be used when an equivalent constraint (with a potentially different rhs) already exists for the primal problem.

Definition at line 2208 of file dof_map_constraints.C.

2213{
2214 // Optionally allow the user to overwrite constraints. Defaults to false.
2215 if (forbid_constraint_overwrite)
2216 {
2217 libmesh_error_msg_if(!this->is_constrained_dof(dof_number),
2218 "ERROR: DOF " << dof_number << " has no corresponding primal constraint!");
2219#ifndef NDEBUG
2220 // No way to do this without a non-normalized tolerance?
2221
2222 // // If the user passed in more than just the rhs, let's check the
2223 // // coefficients for consistency
2224 // if (!constraint_row.empty())
2225 // {
2226 // DofConstraintRow row = _dof_constraints[dof_number];
2227 // for (const auto & [dof, val] : row)
2228 // libmesh_assert(constraint_row.find(dof)->second == val);
2229 // }
2230 //
2231 // if (_adjoint_constraint_values[qoi_index].find(dof_number) !=
2232 // _adjoint_constraint_values[qoi_index].end())
2233 // libmesh_assert_equal_to(_adjoint_constraint_values[qoi_index][dof_number],
2234 // constraint_rhs);
2235
2236#endif
2237 }
2238
2239 // Creates the map of rhs values if it doesn't already exist; then
2240 // adds the current value to that map
2241
2242 // Store the rhs value in the map
2243 _adjoint_constraint_values[qoi_index].insert_or_assign(dof_number, constraint_rhs);
2244}
bool is_constrained_dof(const dof_id_type dof) const
Definition dof_map.h:2439

References _adjoint_constraint_values, and is_constrained_dof().

◆ add_adjoint_dirichlet_boundary()

void libMesh::DofMap::add_adjoint_dirichlet_boundary ( const DirichletBoundary &  dirichlet_boundary,
unsigned int  q 
)

Adds a copy of the specified Dirichlet boundary to the system, corresponding to the adjoint problem defined by Quantity of Interest q.

Definition at line 5444 of file dof_map_constraints.C.

5446{
5447 unsigned int old_size = cast_int<unsigned int>
5449 for (unsigned int i = old_size; i <= qoi_index; ++i)
5450 _adjoint_dirichlet_boundaries.push_back(std::make_unique<DirichletBoundaries>());
5451
5452 // Make copy of DirichletBoundary, owned by _adjoint_dirichlet_boundaries
5453 _adjoint_dirichlet_boundaries[qoi_index]->push_back
5454 (std::make_unique<DirichletBoundary>(dirichlet_boundary));
5455}

References _adjoint_dirichlet_boundaries.

Referenced by PoissonSystem::init_data(), and SigmaPhysics::init_data().

◆ add_algebraic_ghosting_functor() [1/2]

void libMesh::DofMap::add_algebraic_ghosting_functor ( GhostingFunctor &  evaluable_functor,
bool  to_mesh = true 
)

Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors.

Degrees of freedom on other processors which match the elements and variables returned by these functors will be added to the send_list, and the elements on other processors will be ghosted on a distributed mesh, so that the elements can always be found and the solutions on them will always be evaluable.

GhostingFunctor memory must be managed by the code which calls this function; the GhostingFunctor lifetime is expected to extend until either the functor is removed or the DofMap is destructed.

When to_mesh is true, the coupling_functor is also added to our associated mesh, to ensure that evaluable elements do not get lost during mesh distribution. (if evaluable elements were already lost there's no getting them back after the fact, sorry)

If to_mesh is false, no change to mesh ghosting is made; the Mesh must already have ghosting functor(s) specifying a superset of evaluable_functor or this is a horrible bug.

Definition at line 2064 of file dof_map.C.

2066{
2067 // We used to implicitly support duplicate inserts to std::set
2068#ifdef LIBMESH_ENABLE_DEPRECATED
2070 (std::remove(_algebraic_ghosting_functors.begin(),
2072 &evaluable_functor),
2074#endif
2075
2076 // We shouldn't have two copies of the same functor
2079 &evaluable_functor) ==
2081
2082 _algebraic_ghosting_functors.push_back(&evaluable_functor);
2083 evaluable_functor.set_mesh(&_mesh);
2084 if (to_mesh)
2085 _mesh.add_ghosting_functor(evaluable_functor);
2086}
std::vector< GhostingFunctor * > _algebraic_ghosting_functors
The list of all GhostingFunctor objects to be used when distributing ghosted vectors.
Definition dof_map.h:2227
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition mesh_base.C:1079

References libMesh::libmesh_assert(), and libMesh::GhostingFunctor::set_mesh().

Referenced by add_algebraic_ghosting_functor(), DofMap(), main(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), SlitMeshRefinedSystemTest::setUp(), PointNeighborCouplingTest::testCoupling(), and EquationSystemsTest::testDisableDefaultGhosting().

◆ add_algebraic_ghosting_functor() [2/2]

void libMesh::DofMap::add_algebraic_ghosting_functor ( std::shared_ptr< GhostingFunctor >  evaluable_functor,
bool  to_mesh = true 
)
inline

Adds a functor which can specify algebraic ghosting requirements for use with distributed vectors.

GhostingFunctor memory when using this method is managed by the shared_ptr mechanism.

Definition at line 420 of file dof_map.h.

422 { _shared_functors[evaluable_functor.get()] = evaluable_functor;
423 this->add_algebraic_ghosting_functor(*evaluable_functor, to_mesh); }
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.
Definition dof_map.h:2246

References _shared_functors, and add_algebraic_ghosting_functor().

◆ add_constraint_row() [1/2]

void libMesh::DofMap::add_constraint_row ( const dof_id_type  dof_number,
const DofConstraintRow &  constraint_row,
const bool  forbid_constraint_overwrite = true 
)
inline

Adds a copy of the user-defined row to the constraint matrix, using a homogeneous right-hand-side for the constraint equation.

By default, produces an error if the DOF was already constrained.

Definition at line 1163 of file dof_map.h.

1166 { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const Number constraint_rhs, const bool forbid_constraint_overwrite)
Adds a copy of the user-defined row to the constraint matrix, using an inhomogeneous right-hand-side ...

References add_constraint_row().

◆ add_constraint_row() [2/2]

void libMesh::DofMap::add_constraint_row ( const dof_id_type  dof_number,
const DofConstraintRow &  constraint_row,
const Number  constraint_rhs,
const bool  forbid_constraint_overwrite 
)

Adds a copy of the user-defined row to the constraint matrix, using an inhomogeneous right-hand-side for the constraint equation.

Definition at line 2176 of file dof_map_constraints.C.

2180{
2181 // Optionally allow the user to overwrite constraints. Defaults to false.
2182 libmesh_error_msg_if(forbid_constraint_overwrite && this->is_constrained_dof(dof_number),
2183 "ERROR: DOF " << dof_number << " was already constrained!");
2184
2185 libmesh_assert_less(dof_number, this->n_dofs());
2186
2187 // There is an implied "1" on the diagonal of the constraint row, and the user
2188 // should not try to manually set _any_ value on the diagonal.
2189 libmesh_assert_msg(!constraint_row.count(dof_number),
2190 "Error: constraint_row for dof " << dof_number <<
2191 " should not contain an entry for dof " << dof_number);
2192
2193#ifndef NDEBUG
2194 for (const auto & pr : constraint_row)
2195 libmesh_assert_less(pr.first, this->n_dofs());
2196#endif
2197
2198 // Store the constraint_row in the map
2199 _dof_constraints.insert_or_assign(dof_number, constraint_row);
2200
2201 std::pair<DofConstraintValueMap::iterator, bool> rhs_it =
2202 _primal_constraint_values.emplace(dof_number, constraint_rhs);
2203 if (!rhs_it.second)
2204 rhs_it.first->second = constraint_rhs;
2205}

References _dof_constraints, _primal_constraint_values, is_constrained_dof(), and n_dofs().

Referenced by add_constraint_row(), MyConstraint::constrain(), GhostDofConstraint::constrain(), libMesh::VariationalSmootherConstraint::constrain_node_to_line(), libMesh::VariationalSmootherConstraint::constrain_node_to_plane(), libMesh::VariationalSmootherConstraint::fix_node(), and process_mesh_constraint_rows().

◆ add_constraints_to_send_list()

void libMesh::DofMap::add_constraints_to_send_list ( const MeshBase &  mesh)
private

Adds entries to the _send_list vector corresponding to DoFs which are dependencies for constraint equations on the current processor.

Definition at line 5307 of file dof_map_constraints.C.

5308{
5309 // This function must be run on all processors at once
5310 parallel_object_only();
5311
5312 // Return immediately if there's nothing to gather
5313 if (this->n_processors() == 1)
5314 return;
5315
5316 // We might get to return immediately if none of the processors
5317 // found any constraints
5318 unsigned int has_constraints = !_dof_constraints.empty();
5319 this->comm().max(has_constraints);
5320 if (!has_constraints)
5321 return;
5322
5323 auto add_row = [this](const DofConstraintRow & constraint_row) {
5324 for (const auto & j : constraint_row)
5325 {
5326 dof_id_type constraint_dependency = j.first;
5327
5328 // No point in adding one of our own dofs to the send_list
5329 if (this->local_index(constraint_dependency))
5330 continue;
5331
5332 _send_list.push_back(constraint_dependency);
5333 }
5334 };
5335
5336 // We usually only need dependencies of our own constrained dofs
5337 for (const auto & [constrained_dof, constraint_row] : _dof_constraints)
5338 if (this->local_index(constrained_dof))
5339 add_row(constraint_row);
5340
5341 // If we only need constraint DoFs constraining DoFs which are
5342 // algebraically local, we're done.
5344 return;
5345
5346 // If we use StaticCondensation, though, we may need constraint DoFs
5347 // constraining DoFs which are not local (they're on someone else's
5348 // node) but which are supported on local elements. Let's get those
5349 // too if we have to.
5350 //
5351 // Kokkos-MOOSE also requires that, because it cannot use VecSetValues
5352 // and MatSetValues which can dynamically cache remote entries. Instead,
5353 // it allocates ghost entries in advance based on libMesh send_list and
5354 // accumulates to those, and does the assembly at once. When ghost DOFs
5355 // are constrained, it has to add residual/Jacobian contributions to the
5356 // dependencies of ghost DOFs locally as well.
5357 //
5358 // We'll potentially be hitting the same constrained DoFs from
5359 // multiple directions.
5360 for (auto & elem : mesh.active_local_element_ptr_range())
5361 {
5362 std::vector<dof_id_type> di;
5363 this->dof_indices (elem, di);
5364 for (const auto & dof_id : di)
5365 if (!this->local_index(dof_id))
5366 if (auto pos = _dof_constraints.find(dof_id);
5367 pos != _dof_constraints.end())
5368 add_row(pos->second);
5369 }
5370}
void max(const T &r, T &o, Request &req) const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2203
bool local_index(dof_id_type dof_index) const
Definition dof_map.h:974
bool has_static_condensation() const
Checks whether we have static condensation.
Definition dof_map.h:1804
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
std::map< dof_id_type, Real, std::less< dof_id_type >, Threads::scalable_allocator< std::pair< const dof_id_type, Real > > > DofConstraintRow
A row of the Dof constraint matrix.
Definition dof_map.h:100

References _dof_constraints, _need_ghost_constraints, _send_list, libMesh::ParallelObject::comm(), dof_indices(), has_static_condensation(), local_index(), libMesh::Parallel::Communicator::max(), mesh, and libMesh::ParallelObject::n_processors().

Referenced by process_constraints().

◆ add_coupling_functor() [1/2]

void libMesh::DofMap::add_coupling_functor ( GhostingFunctor &  coupling_functor,
bool  to_mesh = true 
)

Adds a functor which can specify coupling requirements for creation of sparse matrices.

Degree of freedom pairs which match the elements and variables returned by these functors will be added to the sparsity pattern, and the degrees of freedom which live on other processors will be added to the send_list for use on ghosted vectors, and the elements which live on other processors will be ghosted on a distributed mesh.

GhostingFunctor memory must be managed by the code which calls this function; the GhostingFunctor lifetime is expected to extend until either the functor is removed or the DofMap is destructed.

When to_mesh is true, the coupling_functor is also added to our associated mesh, to ensure that coupled elements do not get lost during mesh distribution. (if coupled elements were already lost there's no getting them back after the fact, sorry)

If to_mesh is false, no change to mesh ghosting is made; the Mesh must already have ghosting functor(s) specifying a superset of coupling_functor or this is a horrible bug.

Definition at line 2007 of file dof_map.C.

2009{
2010 // We used to implicitly support duplicate inserts to std::set
2011#ifdef LIBMESH_ENABLE_DEPRECATED
2012 _coupling_functors.erase
2013 (std::remove(_coupling_functors.begin(),
2014 _coupling_functors.end(),
2015 &coupling_functor),
2016 _coupling_functors.end());
2017#endif
2018
2019 // We shouldn't have two copies of the same functor
2020 libmesh_assert(std::find(_coupling_functors.begin(),
2021 _coupling_functors.end(),
2022 &coupling_functor) ==
2023 _coupling_functors.end());
2024
2025 _coupling_functors.push_back(&coupling_functor);
2026 coupling_functor.set_mesh(&_mesh);
2027 if (to_mesh)
2028 _mesh.add_ghosting_functor(coupling_functor);
2029}
std::vector< GhostingFunctor * > _coupling_functors
The list of all GhostingFunctor objects to be used when coupling degrees of freedom in matrix sparsit...
Definition dof_map.h:2240

References libMesh::libmesh_assert(), and libMesh::GhostingFunctor::set_mesh().

Referenced by add_coupling_functor(), DofMap(), NonManifoldCouplingTestBase::init_es(), main(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), EquationSystemsTest::testDisableDefaultGhosting(), and SystemsTest::testDofCouplingWithVarGroups().

◆ add_coupling_functor() [2/2]

void libMesh::DofMap::add_coupling_functor ( std::shared_ptr< GhostingFunctor >  coupling_functor,
bool  to_mesh = true 
)
inline

Adds a functor which can specify coupling requirements for creation of sparse matrices.

GhostingFunctor memory when using this method is managed by the shared_ptr mechanism.

Definition at line 358 of file dof_map.h.

360 { _shared_functors[coupling_functor.get()] = coupling_functor;
361 this->add_coupling_functor(*coupling_functor, to_mesh); }

References _shared_functors, and add_coupling_functor().

◆ add_default_ghosting()

void libMesh::DofMap::add_default_ghosting ( )

Add the default functor(s) for coupling and algebraic ghosting.

User-added ghosting functors will be unaffected.

Definition at line 1998 of file dof_map.C.

1999{
2002}
DefaultCoupling & default_coupling()
Default coupling functor.
Definition dof_map.h:385
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition dof_map.h:447

Referenced by libMesh::EquationSystems::enable_default_ghosting().

◆ add_dirichlet_boundary()

void libMesh::DofMap::add_dirichlet_boundary ( const DirichletBoundary &  dirichlet_boundary)

Adds a copy of the specified Dirichlet boundary to the system.

The constraints implied by DirichletBoundary objects are imposed in the same order in which DirichletBoundary objects are added to the DofMap. When multiple DirichletBoundary objects would impose competing constraints on a given DOF, the first DirichletBoundary to constrain the DOF "wins". This distinction is important when e.g. two surfaces (sidesets) intersect. The nodes on the intersection will be constrained according to whichever sideset's DirichletBoundary object was added to the DofMap first.

Definition at line 5438 of file dof_map_constraints.C.

5439{
5440 _dirichlet_boundaries->push_back(std::make_unique<DirichletBoundary>(dirichlet_boundary));
5441}

References _dirichlet_boundaries.

Referenced by libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs(), assemble_and_solve(), CoupledSystem::init_data(), HeatSystem::init_data(), PoissonSystem::init_data(), NavierSystem::init_data(), ElasticitySystem::init_data(), SimpleRBConstruction::init_data(), ElasticityRBConstruction::init_data(), NonlinearDiffusionSystem::init_data(), SigmaPhysics::init_data(), LaplaceSystem::init_dirichlet_bcs(), main(), set_lid_driven_bcs(), set_poiseuille_bcs(), set_stagnation_bcs(), set_system_parameters(), MeshAssignTest::testMeshMoveAssign(), HeterogeneousNonlinearConstraintTest::testNonzeroDirichletValues(), PeriodicBCTest::testPeriodicBC(), BoundaryInfoTest::testShellFaceConstraints(), DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ add_neighbors_to_send_list()

void libMesh::DofMap::add_neighbors_to_send_list ( MeshBase &  mesh)
private

Adds entries to the _send_list vector corresponding to DoFs on elements neighboring the current processor.

Definition at line 1689 of file dof_map.C.

1690{
1691 LOG_SCOPE("add_neighbors_to_send_list()", "DofMap");
1692
1693 // Return immediately if there's no ghost data
1694 if (this->n_processors() == 1)
1695 return;
1696
1697 const unsigned int n_var = this->n_variables();
1698
1699 MeshBase::const_element_iterator local_elem_it
1700 = mesh.active_local_elements_begin();
1701 const MeshBase::const_element_iterator local_elem_end
1702 = mesh.active_local_elements_end();
1703
1704 GhostingFunctor::map_type elements_to_send;
1705 DofMap::CouplingMatricesSet temporary_coupling_matrices;
1706
1707 // We need to add dofs to the send list if they've been directly
1708 // requested by an algebraic ghosting functor or they've been
1709 // indirectly requested by a coupling functor.
1710 this->merge_ghost_functor_outputs(elements_to_send,
1711 temporary_coupling_matrices,
1714 local_elem_it, local_elem_end, mesh.processor_id());
1715
1716 this->merge_ghost_functor_outputs(elements_to_send,
1717 temporary_coupling_matrices,
1719 this->coupling_functors_end(),
1720 local_elem_it, local_elem_end, mesh.processor_id());
1721
1722 // Making a list of non-zero coupling matrix columns is an
1723 // O(N_var^2) operation. We cache it so we only have to do it once
1724 // per CouplingMatrix and not once per element.
1725 std::map<const CouplingMatrix *, std::vector<unsigned int>>
1726 column_variable_lists;
1727
1728 for (const auto & [partner, ghost_coupling] : elements_to_send)
1729 {
1730 // We asked ghosting functors not to give us local elements
1731 libmesh_assert_not_equal_to
1732 (partner->processor_id(), this->processor_id());
1733
1734 // Loop over any present coupling matrix column variables if we
1735 // have a coupling matrix, or just add all variables to
1736 // send_list if not.
1737 if (ghost_coupling)
1738 {
1739 libmesh_assert_equal_to (ghost_coupling->size(), n_var);
1740
1741 // Try to find a cached list of column variables.
1742 std::map<const CouplingMatrix *, std::vector<unsigned int>>::const_iterator
1743 column_variable_list = column_variable_lists.find(ghost_coupling);
1744
1745 // If we didn't find it, then we need to create it.
1746 if (column_variable_list == column_variable_lists.end())
1747 {
1748 auto inserted_variable_list_pair =
1749 column_variable_lists.emplace(ghost_coupling, std::vector<unsigned int>());
1750 column_variable_list = inserted_variable_list_pair.first;
1751
1752 std::vector<unsigned int> & new_variable_list =
1753 inserted_variable_list_pair.first->second;
1754
1755 std::vector<unsigned char> has_variable(n_var, false);
1756
1757 for (unsigned int vi = 0; vi != n_var; ++vi)
1758 {
1759 ConstCouplingRow ccr(vi, *ghost_coupling);
1760
1761 for (const auto & vj : ccr)
1762 has_variable[vj] = true;
1763 }
1764 for (unsigned int vj = 0; vj != n_var; ++vj)
1765 {
1766 if (has_variable[vj])
1767 new_variable_list.push_back(vj);
1768 }
1769 }
1770
1771 const std::vector<unsigned int> & variable_list =
1772 column_variable_list->second;
1773
1774 for (const auto & vj : variable_list)
1775 {
1776 std::vector<dof_id_type> di;
1777 this->dof_indices (partner, di, vj);
1778
1779 // Insert the remote DOF indices into the send list
1780 for (auto d : di)
1781 if (d != DofObject::invalid_id &&
1782 !this->local_index(d))
1783 {
1784 libmesh_assert_less(d, this->n_dofs());
1785 _send_list.push_back(d);
1786 }
1787 }
1788 }
1789 else
1790 {
1791 std::vector<dof_id_type> di;
1792 this->dof_indices (partner, di);
1793
1794 // Insert the remote DOF indices into the send list
1795 for (const auto & dof : di)
1796 if (dof != DofObject::invalid_id &&
1797 !this->local_index(dof))
1798 {
1799 libmesh_assert_less(dof, this->n_dofs());
1800 _send_list.push_back(dof);
1801 }
1802 }
1803
1804 }
1805
1806 // We're now done with any merged coupling matrices we had to create.
1807 temporary_coupling_matrices.clear();
1808
1809 //-------------------------------------------------------------------------
1810 // Our coupling functors added dofs from neighboring elements to the
1811 // send list, but we may still need to add non-local dofs from local
1812 // elements.
1813 //-------------------------------------------------------------------------
1814
1815 // Loop over the active local elements, adding all active elements
1816 // that neighbor an active local element to the send list.
1817 for ( ; local_elem_it != local_elem_end; ++local_elem_it)
1818 {
1819 const Elem * elem = *local_elem_it;
1820
1821 std::vector<dof_id_type> di;
1822 this->dof_indices (elem, di);
1823
1824 // Insert the remote DOF indices into the send list
1825 for (const auto & dof : di)
1826 if (dof != DofObject::invalid_id &&
1827 !this->local_index(dof))
1828 {
1829 libmesh_assert_less(dof, this->n_dofs());
1830 _send_list.push_back(dof);
1831 }
1832 }
1833}
unsigned int n_variables() const override
Definition dof_map.h:743
GhostingFunctorIterator coupling_functors_begin() const
Beginning of range of coupling functors.
Definition dof_map.h:373
GhostingFunctorIterator coupling_functors_end() const
End of range of coupling functors.
Definition dof_map.h:379
static void merge_ghost_functor_outputs(GhostingFunctor::map_type &elements_to_ghost, CouplingMatricesSet &temporary_coupling_matrices, const GhostingFunctorIterator &gf_begin, const GhostingFunctorIterator &gf_end, const MeshBase::const_element_iterator &elems_begin, const MeshBase::const_element_iterator &elems_end, processor_id_type p)
Definition dof_map.C:1587
std::set< std::unique_ptr< CouplingMatrix >, Utility::CompareUnderlying > CouplingMatricesSet
Definition dof_map.h:2006
GhostingFunctorIterator algebraic_ghosting_functors_end() const
End of range of algebraic ghosting functors.
Definition dof_map.h:441
GhostingFunctorIterator algebraic_ghosting_functors_begin() const
Beginning of range of algebraic ghosting functors.
Definition dof_map.h:435
bool has_variable(std::string_view var) const
Definition dof_map.h:3005
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?

References mesh.

◆ add_periodic_boundary() [1/2]

void libMesh::DofMap::add_periodic_boundary ( const PeriodicBoundaryBase &  boundary,
const PeriodicBoundaryBase &  inverse_boundary 
)

Add a periodic boundary pair.

Parameters
boundary- primary boundary
inverse_boundary- inverse boundary

Definition at line 5566 of file dof_map_constraints.C.

5568{
5569 libmesh_assert_equal_to (boundary.myboundary, inverse_boundary.pairedboundary);
5570 libmesh_assert_equal_to (boundary.pairedboundary, inverse_boundary.myboundary);
5571 libmesh_assert(boundary.get_variables() == inverse_boundary.get_variables());
5572
5573 // See if we already have a periodic boundary associated myboundary...
5574 PeriodicBoundaryBase * existing_boundary =
5575 _periodic_boundaries->boundary(boundary.myboundary);
5576
5577 if (!existing_boundary)
5578 {
5579 // ...if not, clone the inputs and add them to the
5580 // PeriodicBoundaries object.
5581 // These will be cleaned up automatically in the
5582 // _periodic_boundaries destructor.
5583 _periodic_boundaries->emplace(boundary.myboundary, boundary.clone());
5584 _periodic_boundaries->emplace(inverse_boundary.myboundary, inverse_boundary.clone());
5585 }
5586 else
5587 {
5588 // ...otherwise, merge this object's variable IDs with the
5589 // existing boundary object's.
5590 existing_boundary->merge(boundary);
5591
5592 // Do the same merging process for the inverse boundary. The
5593 // inverse had better already exist!
5594 PeriodicBoundaryBase * existing_inverse_boundary =
5595 _periodic_boundaries->boundary(boundary.pairedboundary);
5596 libmesh_assert(existing_inverse_boundary);
5597 existing_inverse_boundary->merge(inverse_boundary);
5598
5599 // If we had to merge different *types* of boundaries then
5600 // something likely has gone wrong.
5601#ifdef LIBMESH_HAVE_RTTI
5602 // typeid needs to be given references, not just pointers, to
5603 // return a derived class name.
5604 libmesh_assert(typeid(boundary) == typeid(*existing_boundary));
5605 libmesh_assert(typeid(inverse_boundary) == typeid(*existing_inverse_boundary));
5606#endif
5607 }
5608}
The base class for defining periodic boundaries.
const std::set< unsigned int > & get_variables() const
Get the set of variables for this periodic boundary condition.
boundary_id_type myboundary
The boundary ID of this boundary and its counterpart.
void merge(const PeriodicBoundaryBase &pb)
virtual std::unique_ptr< PeriodicBoundaryBase > clone(TransformationType t=FORWARD) const =0
If we want the DofMap to be able to make copies of references and store them in the underlying map,...

References _periodic_boundaries, libMesh::PeriodicBoundaryBase::clone(), libMesh::PeriodicBoundaryBase::get_variables(), libMesh::libmesh_assert(), libMesh::PeriodicBoundaryBase::merge(), libMesh::PeriodicBoundaryBase::myboundary, and libMesh::PeriodicBoundaryBase::pairedboundary.

◆ add_periodic_boundary() [2/2]

void libMesh::DofMap::add_periodic_boundary ( const PeriodicBoundaryBase &  periodic_boundary)

Adds a copy of the specified periodic boundary to the system.

Definition at line 5558 of file dof_map_constraints.C.

5559{
5560 auto inverse_boundary = periodic_boundary.clone(PeriodicBoundaryBase::INVERSE);
5561 this->add_periodic_boundary(periodic_boundary, *inverse_boundary);
5562}
void add_periodic_boundary(const PeriodicBoundaryBase &periodic_boundary)
Adds a copy of the specified periodic boundary to the system.

References add_periodic_boundary(), libMesh::PeriodicBoundaryBase::clone(), and libMesh::PeriodicBoundaryBase::INVERSE.

Referenced by add_periodic_boundary(), Biharmonic::JR::JR(), main(), and PeriodicBCTest::testPeriodicBC().

◆ add_variable()

unsigned int libMesh::DofMap::add_variable ( System &  sys,
std::string_view  var,
const FEType &  type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)

Adds the variable var to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions

Returns
The index number for the new variable.

Definition at line 3148 of file dof_map.C.

3152{
3153 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
3154
3155 libmesh_assert(this->comm().verify(std::string(var)));
3156 libmesh_assert(this->comm().verify(type));
3157 libmesh_assert(this->comm().verify((active_subdomains == nullptr)));
3158
3159 if (active_subdomains)
3160 libmesh_assert(this->comm().verify(active_subdomains->size()));
3161
3162 // Make sure the variable isn't there already
3163 // or if it is, that it's the type we want
3164 for (auto v : make_range(this->n_vars()))
3165 if (this->variable_name(v) == var)
3166 {
3167 if (this->variable_type(v) == type)
3168 {
3169 // Check whether the existing variable's active subdomains also matches
3170 // the incoming variable's active subdomains. If they don't match, then
3171 // either it is an error by the user or the user is trying to change the
3172 // subdomain restriction after the variable has already been added, which
3173 // is not supported.
3174 const Variable & existing_var = this->variable(v);
3175
3176 // Check whether active_subdomains is not provided/empty and the existing_var is
3177 // implicitly_active()
3178 bool check1 = (!active_subdomains || active_subdomains->empty()) &&
3179 existing_var.implicitly_active();
3180
3181 // Check if the provided active_subdomains is equal to the existing_var's
3182 // active_subdomains
3183 bool check2 =
3184 (active_subdomains && (*active_subdomains == existing_var.active_subdomains()));
3185
3186 // If either of these checks passed, then we already have this variable
3187 if (check1 || check2)
3188 return _variables[v].number();
3189 }
3190
3191 libmesh_error_msg("ERROR: incompatible variable "
3192 << var << " has already been added for this system!");
3193 }
3194
3195 libmesh_assert(!sys.is_initialized());
3196
3197 if (this->n_variable_groups())
3198 {
3199 // Optimize for VariableGroups here - if the user is adding multiple
3200 // variables of the same FEType and subdomain restriction, catch
3201 // that here and add them as members of the same VariableGroup.
3202 //
3203 // start by setting this flag to whatever the user has requested
3204 // and then consider the conditions which should negate it.
3205 bool should_be_in_vg = this->identify_variable_groups();
3206
3207 VariableGroup & vg = _variable_groups.back();
3208
3209 // get a pointer to their subdomain restriction, if any.
3210 const std::set<subdomain_id_type> * const their_active_subdomains(
3211 vg.implicitly_active() ? nullptr : &vg.active_subdomains());
3212
3213 // Different types?
3214 if (vg.type() != type)
3215 should_be_in_vg = false;
3216
3217 // they are restricted, we aren't?
3218 if (their_active_subdomains &&
3219 (!active_subdomains || (active_subdomains && active_subdomains->empty())))
3220 should_be_in_vg = false;
3221
3222 // they aren't restricted, we are?
3223 if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
3224 should_be_in_vg = false;
3225
3226 if (their_active_subdomains && active_subdomains)
3227 // restricted to different sets?
3228 if (*their_active_subdomains != *active_subdomains)
3229 should_be_in_vg = false;
3230
3231 // OK, after all that, append the variable to the vg if none of the conditions
3232 // were violated
3233 if (should_be_in_vg)
3234 {
3235 const unsigned int vn = this->n_vars();
3236
3237 std::string varstr(var);
3238
3239 _variable_numbers[varstr] = vn;
3240 vg.append(std::move(varstr));
3241 _variables.push_back(vg(vg.n_variables() - 1));
3242 const unsigned int vgn = _variable_groups.size() - 1;
3243 _variable_group_numbers.push_back(vgn);
3244 _var_to_vg.emplace(vn, vgn);
3245
3246 return vn;
3247 }
3248 }
3249
3250 // otherwise, fall back to adding a single variable group
3251 return this->add_variables(
3252 sys, std::vector<std::string>(1, std::string(var)), type, active_subdomains);
3253}
unsigned int n_variable_groups() const
Definition dof_map.h:740
std::unordered_map< unsigned int, unsigned int > _var_to_vg
A map from variable number to variable group number.
Definition dof_map.h:2118
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups.
Definition dof_map.h:2124
bool identify_variable_groups() const
Definition dof_map.h:2970
unsigned int add_variables(System &sys, const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variables vars to the list of variables for this system.
Definition dof_map.C:3255
unsigned int n_vars() const
Definition dof_map.h:2956
const FEType & variable_type(const unsigned int i) const
Definition dof_map.h:2401
const Variable & variable(const unsigned int c) const override
Definition dof_map.h:2371
const std::string & variable_name(const unsigned int i) const
Definition dof_map.h:2962
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176

References libMesh::Variable::active_subdomains(), libMesh::VariableGroup::append(), libMesh::Variable::implicitly_active(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::VariableGroup::n_variables(), n_vars, and libMesh::Variable::type().

Referenced by libMesh::System::add_variable().

◆ add_variable_array()

unsigned int libMesh::DofMap::add_variable_array ( System &  sys,
const std::vector< std::string > &  vars,
const FEType &  type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)

Adds variables vars to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that the vars have no subdomain restrictions. This API will end up calling this->add_variables(). However, we will additionally store data that can be leveraged by the DofMap to build degrees of freedom containers corresponding to all the variables in this variable array

An 'array variable' is simply a sequence of contiguous variable numbers defined by pair where the first member of the pair is the first number in the variable sequence and the second member of the pair is the number of the last variable in the sequence plus one. Array variables may be used in tandem with variable grouping by downstream code to build optimized physics kernels since each variable in the array will have the same shape functions.

Returns
The index number for the last of the new variables.

Definition at line 3379 of file dof_map.C.

3383{
3384 const unsigned int count = cast_int<unsigned int>(vars.size());
3385 const unsigned int last_var = this->add_variables(sys, vars, type, active_subdomains);
3386 const unsigned int first_var = last_var + 1 - count;
3387 _array_variables.push_back({first_var, first_var + count});
3388 return last_var;
3389}
std::vector< std::pair< unsigned int, unsigned int > > _array_variables
Array variable information storage.
Definition dof_map.h:2131

Referenced by libMesh::System::add_variable_array().

◆ add_variables()

unsigned int libMesh::DofMap::add_variables ( System &  sys,
const std::vector< std::string > &  vars,
const FEType &  type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)

Adds the variables vars to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that the vars have no subdomain restrictions

Returns
The index number for the last of the new variables.

Definition at line 3255 of file dof_map.C.

3259{
3260 parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
3261
3262 libmesh_assert(!sys.is_initialized());
3263
3264 libmesh_assert(this->comm().verify(vars.size()));
3265 libmesh_assert(this->comm().verify(type));
3266 libmesh_assert(this->comm().verify((active_subdomains == nullptr)));
3267
3268 if (active_subdomains)
3269 libmesh_assert(this->comm().verify(active_subdomains->size()));
3270
3271 // Make sure the variable isn't there already
3272 // or if it is, that it's the type we want
3273 for (auto ovar : vars)
3274 {
3275 libmesh_assert(this->comm().verify(ovar));
3276
3277 for (auto v : make_range(this->n_vars()))
3278 if (this->variable_name(v) == ovar)
3279 {
3280 if (this->variable_type(v) == type)
3281 return _variables[v].number();
3282
3283 libmesh_error_msg("ERROR: incompatible variable "
3284 << ovar << " has already been added for this system!");
3285 }
3286 }
3287
3288 if (this->n_variable_groups())
3289 {
3290 // Optimize for VariableGroups here - if the user is adding multiple
3291 // variables of the same FEType and subdomain restriction, catch
3292 // that here and add them as members of the same VariableGroup.
3293 //
3294 // start by setting this flag to whatever the user has requested
3295 // and then consider the conditions which should negate it.
3296 bool should_be_in_vg = this->identify_variable_groups();
3297
3298 VariableGroup & vg = _variable_groups.back();
3299
3300 // get a pointer to their subdomain restriction, if any.
3301 const std::set<subdomain_id_type> * const their_active_subdomains(
3302 vg.implicitly_active() ? nullptr : &vg.active_subdomains());
3303
3304 // Different types?
3305 if (vg.type() != type)
3306 should_be_in_vg = false;
3307
3308 // they are restricted, we aren't?
3309 if (their_active_subdomains &&
3310 (!active_subdomains || (active_subdomains && active_subdomains->empty())))
3311 should_be_in_vg = false;
3312
3313 // they aren't restricted, we are?
3314 if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
3315 should_be_in_vg = false;
3316
3317 if (their_active_subdomains && active_subdomains)
3318 // restricted to different sets?
3319 if (*their_active_subdomains != *active_subdomains)
3320 should_be_in_vg = false;
3321
3322 // If after all that none of the conditions were violated,
3323 // append the variables to the vg and we're done
3324 if (should_be_in_vg)
3325 {
3326 unsigned int vn = this->n_vars();
3327 const unsigned int vgn = _variable_groups.size() - 1;
3328
3329 for (auto ovar : vars)
3330 {
3331 vn = this->n_vars();
3332
3333 vg.append(ovar);
3334
3335 _variables.push_back(vg(vg.n_variables() - 1));
3336 _variable_numbers[ovar] = vn;
3337 _variable_group_numbers.push_back(vgn);
3338 _var_to_vg.emplace(vn, vgn);
3339 }
3340 return vn;
3341 }
3342 }
3343
3344 const unsigned int curr_n_vars = this->n_vars();
3345
3346 const unsigned int next_first_component = this->n_components(sys.get_mesh());
3347
3348 // We weren't able to add to an existing variable group, so
3349 // add a new variable group to the list
3350 _variable_groups.push_back(
3351 (active_subdomains == nullptr)
3352 ? VariableGroup(&sys, vars, curr_n_vars, next_first_component, type)
3353 : VariableGroup(&sys, vars, curr_n_vars, next_first_component, type, *active_subdomains));
3354
3355 const VariableGroup & vg(_variable_groups.back());
3356 const unsigned int vgn = _variable_groups.size() - 1;
3357
3358 // Add each component of the group individually
3359 for (auto v : make_range(vars.size()))
3360 {
3361 const unsigned int vn = curr_n_vars + v;
3362 _variables.push_back(vg(v));
3363 _variable_numbers[vars[v]] = vn;
3364 _variable_group_numbers.push_back(vgn);
3365 _var_to_vg.emplace(vn, vgn);
3366 }
3367
3368 libmesh_assert_equal_to((curr_n_vars + vars.size()), this->n_vars());
3369
3370 // BSK - Defer this now to System::init_data() so we can detect
3371 // VariableGroups 12/28/2012
3372 // // Add the variable group to the _dof_map
3373 // _dof_map->add_variable_group (vg);
3374
3375 // Return the number of the new variable
3376 return cast_int<unsigned int>(curr_n_vars + vars.size() - 1);
3377}
unsigned int n_components(const MeshBase &mesh) const
Definition dof_map.h:2982

References libMesh::Variable::active_subdomains(), libMesh::VariableGroup::append(), libMesh::System::get_mesh(), libMesh::Variable::implicitly_active(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::VariableGroup::n_variables(), n_vars, and libMesh::Variable::type().

Referenced by libMesh::System::add_variables().

◆ algebraic_ghosting_functors_begin()

GhostingFunctorIterator libMesh::DofMap::algebraic_ghosting_functors_begin ( ) const
inline

Beginning of range of algebraic ghosting functors.

Definition at line 435 of file dof_map.h.

436 { return _algebraic_ghosting_functors.begin(); }

References _algebraic_ghosting_functors.

◆ algebraic_ghosting_functors_end()

GhostingFunctorIterator libMesh::DofMap::algebraic_ghosting_functors_end ( ) const
inline

End of range of algebraic ghosting functors.

Definition at line 441 of file dof_map.h.

442 { return _algebraic_ghosting_functors.end(); }

References _algebraic_ghosting_functors.

◆ all_semilocal_indices()

bool libMesh::DofMap::all_semilocal_indices ( const std::vector< dof_id_type > &  dof_indices) const
Returns
true if all degree of freedom indices in dof_indices are either local indices or in the send_list.
Note
This is an O(logN) operation for a send_list of size N; we don't cache enough information for O(1) right now.

Definition at line 2662 of file dof_map.C.

2663{
2664 // We're all semilocal unless we find a counterexample
2665 for (const auto & di : dof_indices_in)
2666 if (!this->semilocal_index(di))
2667 return false;
2668
2669 return true;
2670}
bool semilocal_index(dof_id_type dof_index) const
Definition dof_map.C:2646

◆ allgather_recursive_constraints()

void libMesh::DofMap::allgather_recursive_constraints ( MeshBase &  mesh)

Gathers constraint equation dependencies from other processors.

Definition at line 3673 of file dof_map_constraints.C.

3674{
3675 // This function must be run on all processors at once
3676 parallel_object_only();
3677
3678 // Return immediately if there's nothing to gather
3679 if (this->n_processors() == 1)
3680 return;
3681
3682 // We might get to return immediately if none of the processors
3683 // found any constraints
3684 unsigned int has_constraints = !_dof_constraints.empty()
3685#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
3686 || !_node_constraints.empty()
3687#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
3688 ;
3689 this->comm().max(has_constraints);
3690 if (!has_constraints)
3691 return;
3692
3693 // If we have heterogeneous adjoint constraints we need to
3694 // communicate those too.
3695 const unsigned int max_qoi_num =
3697 0 : _adjoint_constraint_values.rbegin()->first+1;
3698
3699#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
3700 // We may need to send nodes ahead of data about them
3701 std::vector<Parallel::Request> packed_range_sends;
3702
3703 // We may be receiving packed_range sends out of order with
3704 // parallel_sync tags, so make sure they're received correctly.
3705 Parallel::MessageTag range_tag = this->comm().get_unique_tag();
3706
3707 // We only need to do these sends on a distributed mesh
3708 const bool dist_mesh = !mesh.is_serial();
3709#endif
3710
3711 // We might have calculated constraints for constrained dofs
3712 // which have support on other processors.
3713 // Push these out first.
3714 {
3715 std::map<processor_id_type, std::set<dof_id_type>> pushed_ids;
3716
3717#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
3718 std::map<processor_id_type, std::set<dof_id_type>> pushed_node_ids;
3719#endif
3720
3721 const unsigned int sys_num = this->sys_number();
3722
3723 // Collect the constraints to push to each processor
3724 for (auto & elem : as_range(mesh.active_not_local_elements_begin(),
3725 mesh.active_not_local_elements_end()))
3726 {
3727 const unsigned short n_nodes = elem->n_nodes();
3728
3729 // Just checking dof_indices on the foreign element isn't
3730 // enough. Consider a central hanging node between a coarse
3731 // Q2/Q1 element and its finer neighbors on a higher-ranked
3732 // processor. The coarse element's processor will own the node,
3733 // and will thereby own the pressure dof on that node, despite
3734 // the fact that that pressure dof doesn't directly exist on the
3735 // coarse element!
3736 //
3737 // So, we loop through dofs manually.
3738
3739 {
3740 const unsigned int n_vars = elem->n_vars(sys_num);
3741 for (unsigned int v=0; v != n_vars; ++v)
3742 {
3743 const unsigned int n_comp = elem->n_comp(sys_num,v);
3744 for (unsigned int c=0; c != n_comp; ++c)
3745 {
3746 const unsigned int id =
3747 elem->dof_number(sys_num,v,c);
3748 if (this->is_constrained_dof(id))
3749 pushed_ids[elem->processor_id()].insert(id);
3750 }
3751 }
3752 }
3753
3754 for (unsigned short n = 0; n != n_nodes; ++n)
3755 {
3756 const Node & node = elem->node_ref(n);
3757 const unsigned int n_vars = node.n_vars(sys_num);
3758 for (unsigned int v=0; v != n_vars; ++v)
3759 {
3760 const unsigned int n_comp = node.n_comp(sys_num,v);
3761 for (unsigned int c=0; c != n_comp; ++c)
3762 {
3763 const unsigned int id =
3764 node.dof_number(sys_num,v,c);
3765 if (this->is_constrained_dof(id))
3766 pushed_ids[elem->processor_id()].insert(id);
3767 }
3768 }
3769 }
3770
3771#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
3772 for (unsigned short n = 0; n != n_nodes; ++n)
3773 if (this->is_constrained_node(elem->node_ptr(n)))
3774 pushed_node_ids[elem->processor_id()].insert(elem->node_id(n));
3775#endif
3776 }
3777
3778 // Rewrite those id sets as vectors for sending and receiving,
3779 // then find the corresponding data for each id, then push it all.
3780 std::map<processor_id_type, std::vector<dof_id_type>>
3781 pushed_id_vecs, received_id_vecs;
3782 for (auto & p : pushed_ids)
3783 pushed_id_vecs[p.first].assign(p.second.begin(), p.second.end());
3784
3785 std::map<processor_id_type, std::vector<std::vector<std::pair<dof_id_type,Real>>>>
3786 pushed_keys_vals, received_keys_vals;
3787 std::map<processor_id_type, std::vector<std::vector<Number>>> pushed_rhss, received_rhss;
3788 for (auto & p : pushed_id_vecs)
3789 {
3790 auto & keys_vals = pushed_keys_vals[p.first];
3791 keys_vals.reserve(p.second.size());
3792
3793 auto & rhss = pushed_rhss[p.first];
3794 rhss.reserve(p.second.size());
3795 for (auto & pushed_id : p.second)
3796 {
3797 const DofConstraintRow & row = _dof_constraints[pushed_id];
3798 keys_vals.emplace_back(row.begin(), row.end());
3799
3800 rhss.push_back(std::vector<Number>(max_qoi_num+1));
3801 std::vector<Number> & rhs = rhss.back();
3802 DofConstraintValueMap::const_iterator rhsit =
3803 _primal_constraint_values.find(pushed_id);
3804 rhs[max_qoi_num] =
3805 (rhsit == _primal_constraint_values.end()) ?
3806 0 : rhsit->second;
3807 for (unsigned int q = 0; q != max_qoi_num; ++q)
3808 {
3809 AdjointDofConstraintValues::const_iterator adjoint_map_it =
3811
3812 if (adjoint_map_it == _adjoint_constraint_values.end())
3813 continue;
3814
3815 const DofConstraintValueMap & constraint_map =
3816 adjoint_map_it->second;
3817
3818 DofConstraintValueMap::const_iterator adj_rhsit =
3819 constraint_map.find(pushed_id);
3820
3821 rhs[q] =
3822 (adj_rhsit == constraint_map.end()) ?
3823 0 : adj_rhsit->second;
3824 }
3825 }
3826 }
3827
3828 auto ids_action_functor =
3829 [& received_id_vecs]
3830 (processor_id_type pid,
3831 const std::vector<dof_id_type> & data)
3832 {
3833 received_id_vecs[pid] = data;
3834 };
3835
3837 (this->comm(), pushed_id_vecs, ids_action_functor);
3838
3839 auto keys_vals_action_functor =
3840 [& received_keys_vals]
3841 (processor_id_type pid,
3842 const std::vector<std::vector<std::pair<dof_id_type,Real>>> & data)
3843 {
3844 received_keys_vals[pid] = data;
3845 };
3846
3848 (this->comm(), pushed_keys_vals, keys_vals_action_functor);
3849
3850 auto rhss_action_functor =
3851 [& received_rhss]
3852 (processor_id_type pid,
3853 const std::vector<std::vector<Number>> & data)
3854 {
3855 received_rhss[pid] = data;
3856 };
3857
3859 (this->comm(), pushed_rhss, rhss_action_functor);
3860
3861 // Now we have all the DofConstraint rows and rhs values received
3862 // from others, so add the DoF constraints that we've been sent
3863
3864#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
3865 std::map<processor_id_type, std::vector<dof_id_type>>
3866 pushed_node_id_vecs, received_node_id_vecs;
3867 for (auto & p : pushed_node_ids)
3868 pushed_node_id_vecs[p.first].assign(p.second.begin(), p.second.end());
3869
3870 std::map<processor_id_type, std::vector<std::vector<std::pair<dof_id_type,Real>>>>
3871 pushed_node_keys_vals, received_node_keys_vals;
3872 std::map<processor_id_type, std::vector<Point>> pushed_offsets, received_offsets;
3873
3874 for (auto & p : pushed_node_id_vecs)
3875 {
3876 const processor_id_type pid = p.first;
3877
3878 // FIXME - this could be an unordered set, given a
3879 // hash<pointers> specialization
3880 std::set<const Node *> nodes_requested;
3881
3882 auto & node_keys_vals = pushed_node_keys_vals[pid];
3883 node_keys_vals.reserve(p.second.size());
3884
3885 auto & offsets = pushed_offsets[pid];
3886 offsets.reserve(p.second.size());
3887
3888 for (auto & pushed_node_id : p.second)
3889 {
3890 const Node * node = mesh.node_ptr(pushed_node_id);
3891 NodeConstraintRow & row = _node_constraints[node].first;
3892 const std::size_t row_size = row.size();
3893 node_keys_vals.push_back
3894 (std::vector<std::pair<dof_id_type,Real>>());
3895 std::vector<std::pair<dof_id_type,Real>> & this_node_kv =
3896 node_keys_vals.back();
3897 this_node_kv.reserve(row_size);
3898 for (const auto & j : row)
3899 {
3900 this_node_kv.emplace_back(j.first->id(), j.second);
3901
3902 // If we're not sure whether our send
3903 // destination already has this node, let's give
3904 // it a copy.
3905 if (j.first->processor_id() != pid && dist_mesh)
3906 nodes_requested.insert(j.first);
3907 }
3908
3909 offsets.push_back(_node_constraints[node].second);
3910
3911 }
3912
3913 // Constraining nodes might not even exist on our
3914 // correspondant's subset of a distributed mesh, so let's
3915 // make them exist.
3916 if (dist_mesh)
3917 {
3918 packed_range_sends.push_back(Parallel::Request());
3919 this->comm().send_packed_range
3920 (pid, &mesh, nodes_requested.begin(), nodes_requested.end(),
3921 packed_range_sends.back(), range_tag);
3922 }
3923 }
3924
3925 auto node_ids_action_functor =
3926 [& received_node_id_vecs]
3927 (processor_id_type pid,
3928 const std::vector<dof_id_type> & data)
3929 {
3930 received_node_id_vecs[pid] = data;
3931 };
3932
3934 (this->comm(), pushed_node_id_vecs, node_ids_action_functor);
3935
3936 auto node_keys_vals_action_functor =
3937 [& received_node_keys_vals]
3938 (processor_id_type pid,
3939 const std::vector<std::vector<std::pair<dof_id_type,Real>>> & data)
3940 {
3941 received_node_keys_vals[pid] = data;
3942 };
3943
3945 (this->comm(), pushed_node_keys_vals,
3946 node_keys_vals_action_functor);
3947
3948 auto node_offsets_action_functor =
3949 [& received_offsets]
3950 (processor_id_type pid,
3951 const std::vector<Point> & data)
3952 {
3953 received_offsets[pid] = data;
3954 };
3955
3957 (this->comm(), pushed_offsets, node_offsets_action_functor);
3958
3959#endif
3960
3961 // Add all the dof constraints that I've been sent
3962 for (auto & [pid, pushed_ids_to_me] : received_id_vecs)
3963 {
3964 libmesh_assert(received_keys_vals.count(pid));
3965 libmesh_assert(received_rhss.count(pid));
3966 const auto & pushed_keys_vals_to_me = received_keys_vals.at(pid);
3967 const auto & pushed_rhss_to_me = received_rhss.at(pid);
3968
3969 libmesh_assert_equal_to (pushed_ids_to_me.size(),
3970 pushed_keys_vals_to_me.size());
3971 libmesh_assert_equal_to (pushed_ids_to_me.size(),
3972 pushed_rhss_to_me.size());
3973
3974 for (auto i : index_range(pushed_ids_to_me))
3975 {
3976 dof_id_type constrained = pushed_ids_to_me[i];
3977
3978 // If we don't already have a constraint for this dof,
3979 // add the one we were sent
3980 if (!this->is_constrained_dof(constrained))
3981 {
3982 DofConstraintRow & row = _dof_constraints[constrained];
3983 for (auto & kv : pushed_keys_vals_to_me[i])
3984 {
3985 libmesh_assert_less(kv.first, this->n_dofs());
3986 row[kv.first] = kv.second;
3987 }
3988
3989 const Number primal_rhs = pushed_rhss_to_me[i][max_qoi_num];
3990
3991 if (libmesh_isnan(primal_rhs))
3992 libmesh_assert(pushed_keys_vals_to_me[i].empty());
3993
3994 if (primal_rhs != Number(0))
3995 _primal_constraint_values[constrained] = primal_rhs;
3996 else
3997 _primal_constraint_values.erase(constrained);
3998
3999 for (unsigned int q = 0; q != max_qoi_num; ++q)
4000 {
4001 AdjointDofConstraintValues::iterator adjoint_map_it =
4003
4004 const Number adj_rhs = pushed_rhss_to_me[i][q];
4005
4006 if ((adjoint_map_it == _adjoint_constraint_values.end()) &&
4007 adj_rhs == Number(0))
4008 continue;
4009
4010 if (adjoint_map_it == _adjoint_constraint_values.end())
4011 adjoint_map_it = _adjoint_constraint_values.emplace
4012 (q, DofConstraintValueMap()).first;
4013
4014 DofConstraintValueMap & constraint_map =
4015 adjoint_map_it->second;
4016
4017 if (adj_rhs != Number(0))
4018 constraint_map[constrained] = adj_rhs;
4019 else
4020 constraint_map.erase(constrained);
4021 }
4022 }
4023 }
4024 }
4025
4026#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
4027 // Add all the node constraints that I've been sent
4028 for (auto & [pid, pushed_node_ids_to_me] : received_node_id_vecs)
4029 {
4030 // Before we act on any new constraint rows, we may need to
4031 // make sure we have all the nodes involved!
4032 if (dist_mesh)
4035 (Node**)nullptr, range_tag);
4036
4037 libmesh_assert(received_node_keys_vals.count(pid));
4038 libmesh_assert(received_offsets.count(pid));
4039 const auto & pushed_node_keys_vals_to_me = received_node_keys_vals.at(pid);
4040 const auto & pushed_offsets_to_me = received_offsets.at(pid);
4041
4042 libmesh_assert_equal_to (pushed_node_ids_to_me.size(),
4043 pushed_node_keys_vals_to_me.size());
4044 libmesh_assert_equal_to (pushed_node_ids_to_me.size(),
4045 pushed_offsets_to_me.size());
4046
4047 for (auto i : index_range(pushed_node_ids_to_me))
4048 {
4049 dof_id_type constrained_id = pushed_node_ids_to_me[i];
4050
4051 // If we don't already have a constraint for this node,
4052 // add the one we were sent
4053 const Node * constrained = mesh.node_ptr(constrained_id);
4054 if (!this->is_constrained_node(constrained))
4055 {
4056 NodeConstraintRow & row = _node_constraints[constrained].first;
4057 for (auto & kv : pushed_node_keys_vals_to_me[i])
4058 {
4059 const Node * key_node = mesh.node_ptr(kv.first);
4060 libmesh_assert(key_node);
4061 row[key_node] = kv.second;
4062 }
4063 _node_constraints[constrained].second = pushed_offsets_to_me[i];
4064 }
4065 }
4066 }
4067#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
4068 }
4069
4070 // Now start checking for any other constraints we need
4071 // to know about, requesting them recursively.
4072
4073 // Create sets containing the DOFs and nodes we already depend on
4074 typedef std::set<dof_id_type> DoF_RCSet;
4075 DoF_RCSet unexpanded_dofs;
4076
4077 for (const auto & i : _dof_constraints)
4078 unexpanded_dofs.insert(i.first);
4079
4080 // Gather all the dof constraints we need
4081 this->gather_constraints(mesh, unexpanded_dofs, false);
4082
4083 // Gather all the node constraints we need
4084#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
4085 typedef std::set<const Node *> Node_RCSet;
4086 Node_RCSet unexpanded_nodes;
4087
4088 for (const auto & i : _node_constraints)
4089 unexpanded_nodes.insert(i.first);
4090
4091 // We have to keep recursing while the unexpanded set is
4092 // nonempty on *any* processor
4093 bool unexpanded_set_nonempty = !unexpanded_nodes.empty();
4094 this->comm().max(unexpanded_set_nonempty);
4095
4096 while (unexpanded_set_nonempty)
4097 {
4098 // Let's make sure we don't lose sync in this loop.
4099 parallel_object_only();
4100
4101 // Request sets
4102 Node_RCSet node_request_set;
4103
4104 // Request sets to send to each processor
4105 std::map<processor_id_type, std::vector<dof_id_type>>
4106 requested_node_ids;
4107
4108 // And the sizes of each
4109 std::map<processor_id_type, dof_id_type> node_ids_on_proc;
4110
4111 // Fill (and thereby sort and uniq!) the main request sets
4112 for (const auto & i : unexpanded_nodes)
4113 {
4115 for (const auto & j : row)
4116 {
4117 const Node * const node = j.first;
4118 libmesh_assert(node);
4119
4120 // If it's non-local and we haven't already got a
4121 // constraint for it, we might need to ask for one
4122 if ((node->processor_id() != this->processor_id()) &&
4123 !_node_constraints.count(node))
4124 node_request_set.insert(node);
4125 }
4126 }
4127
4128 // Clear the unexpanded constraint sets; we're about to expand
4129 // them
4130 unexpanded_nodes.clear();
4131
4132 // Count requests by processor
4133 for (const auto & node : node_request_set)
4134 {
4135 libmesh_assert(node);
4136 libmesh_assert_less (node->processor_id(), this->n_processors());
4137 node_ids_on_proc[node->processor_id()]++;
4138 }
4139
4140 for (auto pair : node_ids_on_proc)
4141 requested_node_ids[pair.first].reserve(pair.second);
4142
4143 // Prepare each processor's request set
4144 for (const auto & node : node_request_set)
4145 requested_node_ids[node->processor_id()].push_back(node->id());
4146
4147 typedef std::vector<std::pair<dof_id_type, Real>> row_datum;
4148
4149 auto node_row_gather_functor =
4150 [this,
4151 & mesh,
4152 dist_mesh,
4153 & packed_range_sends,
4154 & range_tag]
4155 (processor_id_type pid,
4156 const std::vector<dof_id_type> & ids,
4157 std::vector<row_datum> & data)
4158 {
4159 // FIXME - this could be an unordered set, given a
4160 // hash<pointers> specialization
4161 std::set<const Node *> nodes_requested;
4162
4163 // Fill those requests
4164 const std::size_t query_size = ids.size();
4165
4166 data.resize(query_size);
4167 for (std::size_t i=0; i != query_size; ++i)
4168 {
4169 dof_id_type constrained_id = ids[i];
4170 const Node * constrained_node = mesh.node_ptr(constrained_id);
4171 if (_node_constraints.count(constrained_node))
4172 {
4173 const NodeConstraintRow & row = _node_constraints[constrained_node].first;
4174 std::size_t row_size = row.size();
4175 data[i].reserve(row_size);
4176 for (const auto & j : row)
4177 {
4178 const Node * node = j.first;
4179 data[i].emplace_back(node->id(), j.second);
4180
4181 // If we're not sure whether our send
4182 // destination already has this node, let's give
4183 // it a copy.
4184 if (node->processor_id() != pid && dist_mesh)
4185 nodes_requested.insert(node);
4186
4187 // We can have 0 nodal constraint
4188 // coefficients, where no Lagrange constraint
4189 // exists but non-Lagrange basis constraints
4190 // might.
4191 // libmesh_assert(j.second);
4192 }
4193 }
4194 else
4195 {
4196 // We have to distinguish "constraint with no
4197 // constraining nodes" (e.g. due to user node
4198 // constraint equations) from "no constraint".
4199 // We'll use invalid_id for the latter.
4200 data[i].emplace_back(DofObject::invalid_id, Real(0));
4201 }
4202 }
4203
4204 // Constraining nodes might not even exist on our
4205 // correspondant's subset of a distributed mesh, so let's
4206 // make them exist.
4207 if (dist_mesh)
4208 {
4209 packed_range_sends.push_back(Parallel::Request());
4210 this->comm().send_packed_range
4211 (pid, &mesh, nodes_requested.begin(), nodes_requested.end(),
4212 packed_range_sends.back(), range_tag);
4213 }
4214 };
4215
4216 typedef Point node_rhs_datum;
4217
4218 auto node_rhs_gather_functor =
4219 [this,
4220 & mesh]
4222 const std::vector<dof_id_type> & ids,
4223 std::vector<node_rhs_datum> & data)
4224 {
4225 // Fill those requests
4226 const std::size_t query_size = ids.size();
4227
4228 data.resize(query_size);
4229 for (std::size_t i=0; i != query_size; ++i)
4230 {
4231 dof_id_type constrained_id = ids[i];
4232 const Node * constrained_node = mesh.node_ptr(constrained_id);
4233 if (_node_constraints.count(constrained_node))
4234 data[i] = _node_constraints[constrained_node].second;
4235 else
4236 data[i](0) = std::numeric_limits<Real>::quiet_NaN();
4237 }
4238 };
4239
4240 auto node_row_action_functor =
4241 [this,
4242 & mesh,
4243 dist_mesh,
4244 & range_tag,
4245 & unexpanded_nodes]
4246 (processor_id_type pid,
4247 const std::vector<dof_id_type> & ids,
4248 const std::vector<row_datum> & data)
4249 {
4250 // Before we act on any new constraint rows, we may need to
4251 // make sure we have all the nodes involved!
4252 if (dist_mesh)
4255 (Node**)nullptr, range_tag);
4256
4257 // Add any new constraint rows we've found
4258 const std::size_t query_size = ids.size();
4259
4260 for (std::size_t i=0; i != query_size; ++i)
4261 {
4262 const dof_id_type constrained_id = ids[i];
4263
4264 // An empty row is an constraint with an empty row; for
4265 // no constraint we use a "no row" placeholder
4266 if (data[i].empty())
4267 {
4268 const Node * constrained_node = mesh.node_ptr(constrained_id);
4269 NodeConstraintRow & row = _node_constraints[constrained_node].first;
4270 row.clear();
4271 }
4272 else if (data[i][0].first != DofObject::invalid_id)
4273 {
4274 const Node * constrained_node = mesh.node_ptr(constrained_id);
4275 NodeConstraintRow & row = _node_constraints[constrained_node].first;
4276 row.clear();
4277 for (auto & pair : data[i])
4278 {
4279 const Node * key_node =
4280 mesh.node_ptr(pair.first);
4281 libmesh_assert(key_node);
4282 row[key_node] = pair.second;
4283 }
4284
4285 // And prepare to check for more recursive constraints
4286 unexpanded_nodes.insert(constrained_node);
4287 }
4288 }
4289 };
4290
4291 auto node_rhs_action_functor =
4292 [this,
4293 & mesh]
4295 const std::vector<dof_id_type> & ids,
4296 const std::vector<node_rhs_datum> & data)
4297 {
4298 // Add rhs data for any new node constraint rows we've found
4299 const std::size_t query_size = ids.size();
4300
4301 for (std::size_t i=0; i != query_size; ++i)
4302 {
4303 dof_id_type constrained_id = ids[i];
4304 const Node * constrained_node = mesh.node_ptr(constrained_id);
4305
4306 if (!libmesh_isnan(data[i](0)))
4307 _node_constraints[constrained_node].second = data[i];
4308 else
4309 _node_constraints.erase(constrained_node);
4310 }
4311 };
4312
4313 // Now request node constraint rows from other processors
4314 row_datum * node_row_ex = nullptr;
4316 (this->comm(), requested_node_ids, node_row_gather_functor,
4317 node_row_action_functor, node_row_ex);
4318
4319 // And request node constraint right hand sides from other procesors
4320 node_rhs_datum * node_rhs_ex = nullptr;
4322 (this->comm(), requested_node_ids, node_rhs_gather_functor,
4323 node_rhs_action_functor, node_rhs_ex);
4324
4325
4326 // We have to keep recursing while the unexpanded set is
4327 // nonempty on *any* processor
4328 unexpanded_set_nonempty = !unexpanded_nodes.empty();
4329 this->comm().max(unexpanded_set_nonempty);
4330 }
4331 Parallel::wait(packed_range_sends);
4332#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
4333}
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
void receive_packed_range(const unsigned int dest_processor_id, Context *context, OutputIter out, const T *output_type, const MessageTag &tag=any_tag) const
void send_packed_range(const unsigned int dest_processor_id, const Context *context, Iter range_begin, const Iter range_end, const MessageTag &tag=no_tag, std::size_t approx_buffer_size=1000000) const
Storage for DofConstraint right hand sides for a particular problem.
Definition dof_map.h:124
void gather_constraints(MeshBase &mesh, std::set< dof_id_type > &unexpanded_dofs, bool look_for_constrainees)
Helper function for querying about constraint equations on other processors.
bool is_constrained_node(const Node *node) const
Definition dof_map.h:2423
unsigned int n_comp(const unsigned int s, const unsigned int var) const
Definition dof_object.h:992
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
processor_id_type processor_id() const
Definition dof_object.h:895
dof_id_type id() const
Definition dof_object.h:833
unsigned int n_vars(const unsigned int s, const unsigned int vg) const
Definition dof_object.h:957
virtual bool is_serial() const
Definition mesh_base.h:357
virtual const Node * node_ptr(const dof_id_type i) const =0
A Node is like a Point, but with more information.
Definition node.h:55
processor_id_type processor_id() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
void pull_parallel_vector_data(const Communicator &comm, const MapToVectors &queries, GatherFunctor &gather_data, const ActionFunctor &act_on_data, const datum *example)
Status wait(Request &r)
void push_parallel_vector_data(const Communicator &comm, MapToVectors &&data, const ActionFunctor &act_on_data)
LIBMESH_DEVICE_INLINE ResultVector row(const TensorLike &T_in, const unsigned int row_index)
std::map< const Node *, Real, std::less< const Node * >, Threads::scalable_allocator< std::pair< const Node *const, Real > > > NodeConstraintRow
A row of the Node constraint mapping.
Definition dof_map.h:148
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
LIBMESH_DEVICE_INLINE bool libmesh_isnan(T x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104

References _adjoint_constraint_values, _dof_constraints, _node_constraints, _primal_constraint_values, libMesh::as_range(), libMesh::ParallelObject::comm(), libMesh::DofObject::dof_number(), gather_constraints(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::DofObject::invalid_id, is_constrained_dof(), is_constrained_node(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::libmesh_isnan(), libMesh::Parallel::Communicator::max(), mesh, libMesh::DofObject::n_comp(), libMesh::Elem::n_nodes(), n_nodes, libMesh::ParallelObject::n_processors(), n_vars(), libMesh::DofObject::n_vars(), libMesh::Elem::node_id(), libMesh::MeshBase::node_ptr(), libMesh::Elem::node_ptr(), libMesh::Elem::node_ref(), libMesh::DofObject::processor_id(), TIMPI::pull_parallel_vector_data(), TIMPI::push_parallel_vector_data(), libMesh::Real, libMesh::Parallel::Communicator::receive_packed_range(), libMesh::Parallel::Communicator::send_packed_range(), sys_number(), and TIMPI::wait().

Referenced by process_constraints().

◆ array_dof_indices() [1/3]

template<typename DofIndicesFunctor >
void libMesh::DofMap::array_dof_indices ( const DofIndicesFunctor &  functor,
std::vector< dof_id_type > &  di,
const unsigned int  vn 
) const

Definition at line 2909 of file dof_map.h.

2912{
2913 const auto [begin, end] = this->get_variable_array(vn);
2914 functor(di, begin);
2915
2916 const unsigned int count = end - begin;
2917 // We make count, which could be >> ntest, the inner index in hopes of vectorization
2918 if (count > 1)
2919 {
2920 const dof_id_type component_size = di.size();
2921 di.resize(count * component_size);
2922
2923 const auto pack_container = [&di,
2924 component_size](const unsigned int j,
2925 const std::vector<dof_id_type> & j_dof_indices,
2926 const unsigned int stride) {
2927 if (&j_dof_indices != &di)
2928 libmesh_assert(j_dof_indices.size() == component_size);
2929 for (const auto i : make_range(component_size))
2930 di[j * component_size + i] = j_dof_indices[i] + stride * j;
2931 };
2932 pack_container(0, di, 0);
2933
2934 const auto & fe_type = _variable_groups[libmesh_map_find(_var_to_vg, vn)].type();
2935 if (const bool lagrange = fe_type.family == LAGRANGE;
2936 lagrange || (FEInterface::get_continuity(fe_type) == DISCONTINUOUS))
2937 {
2938 const auto stride = lagrange ? 1 : component_size;
2939 for (const auto j : make_range((unsigned int)1, count))
2940 pack_container(j, di, stride);
2941 }
2942 else
2943 {
2944 static thread_local std::vector<dof_id_type> work_dof_indices;
2945 unsigned int j = 1;
2946 for (const auto i : make_range(begin + 1, end))
2947 {
2948 functor(work_dof_indices, i);
2949 pack_container(j++, work_dof_indices, 0);
2950 }
2951 }
2952 }
2953}
void ErrorVector unsigned int
const std::pair< unsigned int, unsigned int > & get_variable_array(unsigned int vi) const
Retrieve the array variable bounds for a given variable vi.
Definition dof_map.h:2892
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType's FEContinuity based on the underlying FEFamily and potentially the Order,...

References _var_to_vg, _variable_groups, libMesh::DISCONTINUOUS, libMesh::FEInterface::get_continuity(), get_variable_array(), libMesh::LAGRANGE, libMesh::libmesh_assert(), and libMesh::make_range().

◆ array_dof_indices() [2/3]

void libMesh::DofMap::array_dof_indices ( const Elem *const  elem,
std::vector< dof_id_type > &  di,
const unsigned int  vn,
int  p_level = -12345 
) const

Fills the vector di with the global degree of freedom indices for the element.

This will aggregate all the degrees of the freedom from the variable array that vn is a member of, and potentially for a non-default element p refinement level

Definition at line 2341 of file dof_map.C.

2345{
2346 auto dof_indices_functor = [elem, p_level, this](std::vector<dof_id_type> & functor_di,
2347 const unsigned int functor_vn) {
2348 this->dof_indices(elem, functor_di, functor_vn, p_level);
2349 };
2350 this->array_dof_indices(dof_indices_functor, di, vn);
2351}
void array_dof_indices(const Elem *const elem, std::vector< dof_id_type > &di, const unsigned int vn, int p_level=-12345) const
Fills the vector di with the global degree of freedom indices for the element.
Definition dof_map.C:2341

◆ array_dof_indices() [3/3]

void libMesh::DofMap::array_dof_indices ( const Node *const  node,
std::vector< dof_id_type > &  di,
const unsigned int  vn 
) const

Definition at line 2353 of file dof_map.C.

2356{
2357 auto dof_indices_functor = [node, this](std::vector<dof_id_type> & functor_di,
2358 const unsigned int functor_vn) {
2359 this->dof_indices(node, functor_di, functor_vn);
2360 };
2361 this->array_dof_indices(dof_indices_functor, di, vn);
2362}

◆ assert_no_nodes_missed()

void libMesh::DofMap::assert_no_nodes_missed ( MeshBase &  mesh)
private

Definition at line 1565 of file dof_map.C.

1566{
1567 MeshTools::libmesh_assert_valid_procids<Node>(mesh);
1568
1569 for (auto & node : mesh.local_node_ptr_range())
1570 {
1571 unsigned int n_var_g = node->n_var_groups(this->sys_number());
1572 for (unsigned int vg=0; vg != n_var_g; ++vg)
1573 {
1574 unsigned int n_comp_g =
1575 node->n_comp_group(this->sys_number(), vg);
1576 dof_id_type my_first_dof = n_comp_g ?
1577 node->vg_dof_base(this->sys_number(), vg) : 0;
1578 libmesh_assert_not_equal_to (my_first_dof, DofObject::invalid_id);
1579 }
1580 }
1581}

References mesh.

◆ attach_extra_send_list_function()

void libMesh::DofMap::attach_extra_send_list_function ( void(*)(std::vector< dof_id_type > &, void *)  func,
void *  context = nullptr 
)
inline

Attach a function pointer to use as a callback to populate the send_list with extra entries.

Definition at line 497 of file dof_map.h.

References _extra_send_list_context, and _extra_send_list_function.

◆ attach_extra_send_list_object()

void libMesh::DofMap::attach_extra_send_list_object ( DofMap::AugmentSendList &  asl)
inline

Attach an object to populate the send_list with extra entries.

This should only add to the send list, but no checking is done to enforce this behavior.

This is an advanced function... use at your own peril!

Definition at line 488 of file dof_map.h.

489 {
490 _augment_send_list = &asl;
491 }

References _augment_send_list.

◆ attach_extra_sparsity_function()

void libMesh::DofMap::attach_extra_sparsity_function ( void(*)(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *)  func,
void *  context = nullptr 
)
inline

Attach a function pointer to use as a callback to populate the sparsity pattern with extra entries.

Care must be taken that when adding entries they are sorted into the Rows

Further, you must modify n_nz and n_oz properly!

This is an advanced function... use at your own peril!

Definition at line 474 of file dof_map.h.

References _extra_sparsity_context, and _extra_sparsity_function.

◆ attach_extra_sparsity_object()

void libMesh::DofMap::attach_extra_sparsity_object ( SparsityPattern::AugmentSparsityPattern &  asp)
inline

Attach an object to use to populate the sparsity pattern with extra entries.

Care must be taken that when adding entries they are sorted into the Rows

Further, you must modify n_nz and n_oz properly!

This is an advanced function... use at your own peril!

Definition at line 459 of file dof_map.h.

460 {
462 }

References _augment_sparsity_pattern.

◆ attach_matrix()

void libMesh::DofMap::attach_matrix ( SparseMatrix< Number > &  matrix)

Additional matrices may be attached to this DofMap.

They are initialized to the same sparsity structure as the major matrix.

Definition at line 241 of file dof_map.C.

242{
243 parallel_object_only();
244
245 // We shouldn't be trying to re-attach the same matrices repeatedly
246 libmesh_assert (std::find(_matrices.begin(), _matrices.end(),
247 &matrix) == _matrices.end());
248
249 _matrices.push_back(&matrix);
250
251 this->update_sparsity_pattern(matrix);
252
253 if (matrix.need_full_sparsity_pattern())
255}
void update_sparsity_pattern(SparseMatrix< Number > &matrix) const
Additional matrices may be be temporarily initialized by this DofMap.
Definition dof_map.C:270
virtual bool need_full_sparsity_pattern() const

References _matrices, _need_full_sparsity_pattern, libMesh::libmesh_assert(), libMesh::SparseMatrix< T >::need_full_sparsity_pattern(), and update_sparsity_pattern().

Referenced by libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::ClawSystem::init_data(), libMesh::System::init_matrices(), and libMesh::System::late_matrix_init().

◆ block_size()

unsigned int libMesh::DofMap::block_size ( ) const
inline
Returns
The block size, if the variables are amenable to block storage. Otherwise 1. This routine was originally designed to enable a blocked storage, but it turns out this information is still super useful for solvers even when we do not use the blocked storage (e.g., MATMPIBAIJ in PETSc). For example (in PCHMG), for a system of PDEs, to construct an efficient multilevel preconditioner, we coarsen the matrix of one single PDE instead of the entire huge matrix. In order to accomplish this, we need to know many PDEs we have. Another use case, the fieldsplit preconditioner can be constructed in place with this info without involving any user efforts.

Definition at line 773 of file dof_map.h.

774 {
775 return (this->has_blocked_representation() ? this->n_variables() : 1);
776 }
bool has_blocked_representation() const
Definition dof_map.h:756

References has_blocked_representation(), and n_variables().

◆ build_constraint_matrix()

void libMesh::DofMap::build_constraint_matrix ( DenseMatrix< Number > &  C,
std::vector< dof_id_type > &  elem_dofs,
const bool  called_recursively = false 
) const
private

Build the constraint matrix C associated with the element degree of freedom indices elem_dofs.

The optional parameter called_recursively should be left at the default value false. This is used to handle the special case of an element's degrees of freedom being constrained in terms of other, local degrees of freedom. The usual case is for an elements DOFs to be constrained by some other, external DOFs.

Definition at line 3429 of file dof_map_constraints.C.

3432{
3433 LOG_SCOPE_IF("build_constraint_matrix()", "DofMap", !called_recursively);
3434
3435 // Create a set containing the DOFs we already depend on
3436 typedef std::set<dof_id_type> RCSet;
3437 RCSet dof_set;
3438
3439 bool we_have_constraints = false;
3440
3441 // Next insert any other dofs the current dofs might be constrained
3442 // in terms of. Note that in this case we may not be done: Those
3443 // may in turn depend on others. So, we need to repeat this process
3444 // in that case until the system depends only on unconstrained
3445 // degrees of freedom.
3446 for (const auto & dof : elem_dofs)
3447 if (this->is_constrained_dof(dof))
3448 {
3449 we_have_constraints = true;
3450
3451 // If the DOF is constrained
3452 DofConstraints::const_iterator
3453 pos = _dof_constraints.find(dof);
3454
3455 libmesh_assert (pos != _dof_constraints.end());
3456
3457 const DofConstraintRow & constraint_row = pos->second;
3458
3459 // Constraint rows in p refinement may be empty
3460 //libmesh_assert (!constraint_row.empty());
3461
3462 for (const auto & item : constraint_row)
3463 dof_set.insert (item.first);
3464 }
3465
3466 // May be safe to return at this point
3467 // (but remember to stop the perflog)
3468 if (!we_have_constraints)
3469 return;
3470
3471 for (const auto & dof : elem_dofs)
3472 dof_set.erase (dof);
3473
3474 // If we added any DOFS then we need to do this recursively.
3475 // It is possible that we just added a DOF that is also
3476 // constrained!
3477 //
3478 // Also, we need to handle the special case of an element having DOFs
3479 // constrained in terms of other, local DOFs
3480 if (!dof_set.empty() || // case 1: constrained in terms of other DOFs
3481 !called_recursively) // case 2: constrained in terms of our own DOFs
3482 {
3483 const unsigned int old_size =
3484 cast_int<unsigned int>(elem_dofs.size());
3485
3486 // Add new dependency dofs to the end of the current dof set
3487 elem_dofs.insert(elem_dofs.end(),
3488 dof_set.begin(), dof_set.end());
3489
3490 // Now we can build the constraint matrix.
3491 // Note that resize also zeros for a DenseMatrix<Number>.
3492 C.resize (old_size,
3493 cast_int<unsigned int>(elem_dofs.size()));
3494
3495 // Create the C constraint matrix.
3496 for (unsigned int i=0; i != old_size; i++)
3497 if (this->is_constrained_dof(elem_dofs[i]))
3498 {
3499 // If the DOF is constrained
3500 DofConstraints::const_iterator
3501 pos = _dof_constraints.find(elem_dofs[i]);
3502
3503 libmesh_assert (pos != _dof_constraints.end());
3504
3505 const DofConstraintRow & constraint_row = pos->second;
3506
3507 // p refinement creates empty constraint rows
3508 // libmesh_assert (!constraint_row.empty());
3509
3510 for (const auto & item : constraint_row)
3511 for (unsigned int j=0,
3512 n_elem_dofs = cast_int<unsigned int>(elem_dofs.size());
3513 j != n_elem_dofs; j++)
3514 if (elem_dofs[j] == item.first)
3515 C(i,j) = item.second;
3516 }
3517 else
3518 {
3519 C(i,i) = 1.;
3520 }
3521
3522 // May need to do this recursively. It is possible
3523 // that we just replaced a constrained DOF with another
3524 // constrained DOF.
3526
3527 this->build_constraint_matrix (Cnew, elem_dofs, true);
3528
3529 if ((C.n() == Cnew.m()) &&
3530 (Cnew.n() == elem_dofs.size())) // If the constraint matrix
3531 C.right_multiply(Cnew); // is constrained...
3532
3533 libmesh_assert_equal_to (C.n(), elem_dofs.size());
3534 }
3535}
Defines a dense matrix for use in Finite Element-type computations.
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
virtual void right_multiply(const DenseMatrixBase< T > &M2) override final
Performs the operation: (*this) <- (*this) * M3.
void build_constraint_matrix(DenseMatrix< Number > &C, std::vector< dof_id_type > &elem_dofs, const bool called_recursively=false) const
Build the constraint matrix C associated with the element degree of freedom indices elem_dofs.
Tnew cast_int(Told oldvar)

References _dof_constraints, build_constraint_matrix(), is_constrained_dof(), libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::m(), libMesh::DenseMatrixBase< T >::n(), libMesh::DenseMatrix< T >::resize(), and libMesh::DenseMatrix< T >::right_multiply().

Referenced by build_constraint_matrix(), constrain_element_residual(), and max_constraint_error().

◆ build_constraint_matrix_and_vector()

void libMesh::DofMap::build_constraint_matrix_and_vector ( DenseMatrix< Number > &  C,
DenseVector< Number > &  H,
std::vector< dof_id_type > &  elem_dofs,
int  qoi_index = -1,
const bool  called_recursively = false 
) const
private

Build the constraint matrix C and the forcing vector H associated with the element degree of freedom indices elem_dofs.

The optional parameter called_recursively should be left at the default value false. This is used to handle the special case of an element's degrees of freedom being constrained in terms of other, local degrees of freedom. The usual case is for an elements DOFs to be constrained by some other, external DOFs and/or Dirichlet conditions.

The forcing vector will depend on which solution's heterogeneous constraints are being applied. For the default qoi_index this will be the primal solution; for qoi_index >= 0 the corresponding adjoint solution's constraints will be used.

Definition at line 3539 of file dof_map_constraints.C.

3544{
3545 LOG_SCOPE_IF("build_constraint_matrix_and_vector()", "DofMap", !called_recursively);
3546
3547 // Create a set containing the DOFs we already depend on
3548 typedef std::set<dof_id_type> RCSet;
3549 RCSet dof_set;
3550
3551 bool we_have_constraints = false;
3552
3553 // Next insert any other dofs the current dofs might be constrained
3554 // in terms of. Note that in this case we may not be done: Those
3555 // may in turn depend on others. So, we need to repeat this process
3556 // in that case until the system depends only on unconstrained
3557 // degrees of freedom.
3558 for (const auto & dof : elem_dofs)
3559 if (this->is_constrained_dof(dof))
3560 {
3561 we_have_constraints = true;
3562
3563 // If the DOF is constrained
3564 DofConstraints::const_iterator
3565 pos = _dof_constraints.find(dof);
3566
3567 libmesh_assert (pos != _dof_constraints.end());
3568
3569 const DofConstraintRow & constraint_row = pos->second;
3570
3571 // Constraint rows in p refinement may be empty
3572 //libmesh_assert (!constraint_row.empty());
3573
3574 for (const auto & item : constraint_row)
3575 dof_set.insert (item.first);
3576 }
3577
3578 // May be safe to return at this point
3579 // (but remember to stop the perflog)
3580 if (!we_have_constraints)
3581 return;
3582
3583 for (const auto & dof : elem_dofs)
3584 dof_set.erase (dof);
3585
3586 // If we added any DOFS then we need to do this recursively.
3587 // It is possible that we just added a DOF that is also
3588 // constrained!
3589 //
3590 // Also, we need to handle the special case of an element having DOFs
3591 // constrained in terms of other, local DOFs
3592 if (!dof_set.empty() || // case 1: constrained in terms of other DOFs
3593 !called_recursively) // case 2: constrained in terms of our own DOFs
3594 {
3595 const DofConstraintValueMap * rhs_values = nullptr;
3596 if (qoi_index < 0)
3597 rhs_values = &_primal_constraint_values;
3598 else if (auto it = _adjoint_constraint_values.find(qoi_index);
3599 it != _adjoint_constraint_values.end())
3600 rhs_values = &it->second;
3601
3602 const unsigned int old_size =
3603 cast_int<unsigned int>(elem_dofs.size());
3604
3605 // Add new dependency dofs to the end of the current dof set
3606 elem_dofs.insert(elem_dofs.end(),
3607 dof_set.begin(), dof_set.end());
3608
3609 // Now we can build the constraint matrix and vector.
3610 // Note that resize also zeros for a DenseMatrix and DenseVector
3611 C.resize (old_size,
3612 cast_int<unsigned int>(elem_dofs.size()));
3613 H.resize (old_size);
3614
3615 // Create the C constraint matrix.
3616 for (unsigned int i=0; i != old_size; i++)
3617 if (this->is_constrained_dof(elem_dofs[i]))
3618 {
3619 // If the DOF is constrained
3620 DofConstraints::const_iterator
3621 pos = _dof_constraints.find(elem_dofs[i]);
3622
3623 libmesh_assert (pos != _dof_constraints.end());
3624
3625 const DofConstraintRow & constraint_row = pos->second;
3626
3627 // p refinement creates empty constraint rows
3628 // libmesh_assert (!constraint_row.empty());
3629
3630 for (const auto & item : constraint_row)
3631 for (unsigned int j=0,
3632 n_elem_dofs = cast_int<unsigned int>(elem_dofs.size());
3633 j != n_elem_dofs; j++)
3634 if (elem_dofs[j] == item.first)
3635 C(i,j) = item.second;
3636
3637 if (rhs_values)
3638 {
3639 if (const auto rhsit = rhs_values->find(elem_dofs[i]);
3640 rhsit != rhs_values->end())
3641 H(i) = rhsit->second;
3642 }
3643 }
3644 else
3645 {
3646 C(i,i) = 1.;
3647 }
3648
3649 // May need to do this recursively. It is possible
3650 // that we just replaced a constrained DOF with another
3651 // constrained DOF.
3654
3655 this->build_constraint_matrix_and_vector (Cnew, Hnew, elem_dofs,
3656 qoi_index, true);
3657
3658 if ((C.n() == Cnew.m()) && // If the constraint matrix
3659 (Cnew.n() == elem_dofs.size())) // is constrained...
3660 {
3661 // If x = Cy + h and y = Dz + g
3662 // Then x = (CD)z + (Cg + h)
3663 C.vector_mult_add(H, 1, Hnew);
3664
3665 C.right_multiply(Cnew);
3666 }
3667
3668 libmesh_assert_equal_to (C.n(), elem_dofs.size());
3669 }
3670}
void vector_mult_add(DenseVector< T > &dest, const T factor, const DenseVector< T > &arg) const
Performs the scaled matrix-vector multiplication, dest += factor * (*this) * arg.
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
void build_constraint_matrix_and_vector(DenseMatrix< Number > &C, DenseVector< Number > &H, std::vector< dof_id_type > &elem_dofs, int qoi_index=-1, const bool called_recursively=false) const
Build the constraint matrix C and the forcing vector H associated with the element degree of freedom ...

References _adjoint_constraint_values, _dof_constraints, _primal_constraint_values, build_constraint_matrix_and_vector(), is_constrained_dof(), libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::m(), libMesh::DenseMatrixBase< T >::n(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::DenseMatrix< T >::right_multiply(), and libMesh::DenseMatrix< T >::vector_mult_add().

Referenced by build_constraint_matrix_and_vector(), heterogeneously_constrain_element_jacobian_and_residual(), and heterogeneously_constrain_element_residual().

◆ build_sparsity()

std::unique_ptr< SparsityPattern::Build > libMesh::DofMap::build_sparsity ( const MeshBase &  mesh,
bool  calculate_constrained = false,
bool  use_condensed_system = false 
) const

Builds a sparsity pattern for matrices using the current degree-of-freedom numbering and coupling.

By default, ignores constraint equations, for build speed; this is valid for the combination of !need_full_sparsity_pattern and constraints which only come from periodic boundary conditions and adaptive mesh refinement, where matrix constraint adds some matrix entries but removes equally many (or more) other entries.

Can be told to calculate sparsity for the constrained matrix, which may be necessary in the case of spline control node constraints or sufficiently many user constraints.

Definition at line 63 of file dof_map.C.

66{
67 libmesh_assert (mesh.is_prepared());
68
69 LOG_SCOPE("build_sparsity()", "DofMap");
70
71 // Compute the sparsity structure of the global matrix. This can be
72 // fed into a PetscMatrixBase to allocate exactly the number of nonzeros
73 // necessary to store the matrix. This algorithm should be linear
74 // in the (# of elements)*(# nodes per element)
75
76 // We can be more efficient in the threaded sparsity pattern assembly
77 // if we don't need the exact pattern. For some sparse matrix formats
78 // a good upper bound will suffice.
79
80 // See if we need to include sparsity pattern entries for coupling
81 // between neighbor dofs
82 bool implicit_neighbor_dofs = this->use_coupled_neighbor_dofs(mesh);
83
84 const StaticCondensationDofMap * sc = nullptr;
85 if (use_condensed_system)
86 {
88 sc = _sc.get();
89 }
90
91 // We can compute the sparsity pattern in parallel on multiple
92 // threads. The goal is for each thread to compute the full sparsity
93 // pattern for a subset of elements. These sparsity patterns can
94 // be efficiently merged in the SparsityPattern::Build::join()
95 // method, especially if there is not too much overlap between them.
96 // Even better, if the full sparsity pattern is not needed then
97 // the number of nonzeros per row can be estimated from the
98 // sparsity patterns created on each thread.
99 auto sp = std::make_unique<SparsityPattern::Build>
100 (*this,
101 this->_dof_coupling,
102 this->_coupling_functors,
103 implicit_neighbor_dofs,
105 calculate_constrained,
106 sc);
107
108 Threads::parallel_reduce (ConstElemRange (mesh.active_local_elements_begin(),
109 mesh.active_local_elements_end()), *sp);
110
111 sp->parallel_sync();
112
113 libmesh_assert_equal_to (sp->get_sparsity_pattern().size(), this->n_local_dofs());
114
115 // Check to see if we have any extra stuff to add to the sparsity_pattern
117 {
119 {
120 libmesh_here();
121 libMesh::out << "WARNING: You have specified both an extra sparsity function and object.\n"
122 << " Are you sure this is what you meant to do??"
123 << std::endl;
124 }
125
126 sp->apply_extra_sparsity_function(_extra_sparsity_function,
128 }
129
131 sp->apply_extra_sparsity_object(*_augment_sparsity_pattern);
132
133 return sp;
134}
bool use_coupled_neighbor_dofs(const MeshBase &mesh) const
Tells other library functions whether or not this problem includes coupling between dofs in neighbori...
Definition dof_map.C:1905
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided reduction operation in parallel on the specified range.
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition elem_range.h:34
OStreamProxy out

References _augment_sparsity_pattern, _coupling_functors, _dof_coupling, _extra_sparsity_context, _extra_sparsity_function, _need_full_sparsity_pattern, _sc, has_static_condensation(), libMesh::libmesh_assert(), mesh, libMesh::out, libMesh::Threads::parallel_reduce(), and use_coupled_neighbor_dofs().

Referenced by process_mesh_constraint_rows(), libMesh::StaticCondensationDofMap::reinit(), and libMesh::System::solve_for_unconstrained_dofs().

◆ calculate_constraining_subdomains()

std::map< const Node *, std::set< subdomain_id_type > > libMesh::DofMap::calculate_constraining_subdomains ( )
private

We may have mesh constraint rows with dependent nodes in one subdomain but dependency nodes in another subdomain, and we may have variables whose subdomain restriction includes the dependent subdomain but not the dependency.

In those cases we need to place degrees of freedom on dependency nodes anyway.

The set value for node n will include all subdomain ids of elements with nodes in subdomains constrained by n.

We use a map<set> rather than a multimap here because we expect to be inserting the same subdomain multiple times and we don't need duplicate values.

Definition at line 1258 of file dof_map.C.

1259{
1260 std::map<const Node *, std::set<subdomain_id_type>> constraining_subdomains;
1261 const auto & constraint_rows = _mesh.get_constraint_rows();
1262
1263 // We can't just loop over constraint rows here because we need
1264 // element subdomain ids for the constrained nodes, but we don't
1265 // want an extra loop if there are no constraint rows.
1266 if (!constraint_rows.empty())
1267 for (auto & elem : _mesh.active_element_ptr_range())
1268 {
1269 const subdomain_id_type sbdid = elem->subdomain_id();
1270
1271 for (const Node & node : elem->node_ref_range())
1272 {
1273 if (auto it = constraint_rows.find(&node);
1274 it != constraint_rows.end())
1275 {
1276 for (const auto & [pr, val] : it->second)
1277 {
1278 const Node * spline_node =
1279 pr.first->node_ptr(pr.second);
1280
1281 constraining_subdomains[spline_node].insert(sbdid);
1282 }
1283 }
1284 }
1285 }
1286
1287 return constraining_subdomains;
1288}
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
Definition mesh_base.h:1940
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all....
Definition id_types.h:43

◆ check_dirichlet_bcid_consistency()

void libMesh::DofMap::check_dirichlet_bcid_consistency ( const MeshBase &  mesh,
const DirichletBoundary &  boundary 
) const

Check that all the ids in dirichlet_bcids are actually present in the mesh.

If not, this will throw an error.

Definition at line 5520 of file dof_map_constraints.C.

5522{
5523 const std::set<boundary_id_type>& mesh_side_bcids =
5525 const std::set<boundary_id_type>& mesh_edge_bcids =
5527 const std::set<boundary_id_type>& mesh_node_bcids =
5529 const std::set<boundary_id_type>& dbc_bcids = boundary.b;
5530
5531 // DirichletBoundary id sets should be consistent across all ranks
5532 libmesh_assert(mesh.comm().verify(dbc_bcids.size()));
5533
5534 for (const auto & bc_id : dbc_bcids)
5535 {
5536 // DirichletBoundary id sets should be consistent across all ranks
5537 libmesh_assert(mesh.comm().verify(bc_id));
5538
5539 bool found_bcid = (mesh_side_bcids.find(bc_id) != mesh_side_bcids.end() ||
5540 mesh_edge_bcids.find(bc_id) != mesh_edge_bcids.end() ||
5541 mesh_node_bcids.find(bc_id) != mesh_node_bcids.end());
5542
5543 // On a distributed mesh, boundary id sets may *not* be
5544 // consistent across all ranks, since not all ranks see all
5545 // boundaries
5546 mesh.comm().max(found_bcid);
5547
5548 libmesh_error_msg_if(!found_bcid,
5549 "Could not find Dirichlet boundary id " << bc_id << " in mesh!");
5550 }
5551}
timpi_pure bool verify(const T &r) const
const std::set< boundary_id_type > & get_edge_boundary_ids() const
const std::set< boundary_id_type > & get_boundary_ids() const
const std::set< boundary_id_type > & get_node_boundary_ids() const
std::set< boundary_id_type > b
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170

References libMesh::DirichletBoundary::b, libMesh::ParallelObject::comm(), libMesh::BoundaryInfo::get_boundary_ids(), libMesh::MeshBase::get_boundary_info(), libMesh::BoundaryInfo::get_edge_boundary_ids(), libMesh::BoundaryInfo::get_node_boundary_ids(), libMesh::libmesh_assert(), libMesh::Parallel::Communicator::max(), mesh, and libMesh::Parallel::Communicator::verify().

Referenced by create_dof_constraints().

◆ check_for_constraint_loops()

void libMesh::DofMap::check_for_constraint_loops ( )

Definition at line 4505 of file dof_map_constraints.C.

4506{
4507 // Create a set containing the DOFs we already depend on
4508 typedef std::set<dof_id_type> RCSet;
4509 RCSet unexpanded_set;
4510
4511 // Use dof_constraints_copy in this method so that we don't
4512 // mess with _dof_constraints.
4513 DofConstraints dof_constraints_copy = _dof_constraints;
4514
4515 for (const auto & i : dof_constraints_copy)
4516 unexpanded_set.insert(i.first);
4517
4518 while (!unexpanded_set.empty())
4519 for (RCSet::iterator i = unexpanded_set.begin();
4520 i != unexpanded_set.end(); /* nothing */)
4521 {
4522 // If the DOF is constrained
4523 DofConstraints::iterator
4524 pos = dof_constraints_copy.find(*i);
4525
4526 libmesh_assert (pos != dof_constraints_copy.end());
4527
4528 DofConstraintRow & constraint_row = pos->second;
4529
4530 // Comment out "rhs" parts of this method copied from process_constraints
4531 // DofConstraintValueMap::iterator rhsit =
4532 // _primal_constraint_values.find(*i);
4533 // Number constraint_rhs = (rhsit == _primal_constraint_values.end()) ?
4534 // 0 : rhsit->second;
4535
4536 std::vector<dof_id_type> constraints_to_expand;
4537
4538 for (const auto & item : constraint_row)
4539 if (item.first != *i && this->is_constrained_dof(item.first))
4540 {
4541 unexpanded_set.insert(item.first);
4542 constraints_to_expand.push_back(item.first);
4543 }
4544
4545 for (const auto & expandable : constraints_to_expand)
4546 {
4547 const Real this_coef = constraint_row[expandable];
4548
4549 DofConstraints::const_iterator
4550 subpos = dof_constraints_copy.find(expandable);
4551
4552 libmesh_assert (subpos != dof_constraints_copy.end());
4553
4554 const DofConstraintRow & subconstraint_row = subpos->second;
4555
4556 for (const auto & item : subconstraint_row)
4557 {
4558 libmesh_error_msg_if(item.first == expandable, "Constraint loop detected");
4559
4560 constraint_row[item.first] += item.second * this_coef;
4561 }
4562
4563 // Comment out "rhs" parts of this method copied from process_constraints
4564 // DofConstraintValueMap::const_iterator subrhsit =
4565 // _primal_constraint_values.find(expandable);
4566 // if (subrhsit != _primal_constraint_values.end())
4567 // constraint_rhs += subrhsit->second * this_coef;
4568
4569 constraint_row.erase(expandable);
4570 }
4571
4572 // Comment out "rhs" parts of this method copied from process_constraints
4573 // if (rhsit == _primal_constraint_values.end())
4574 // {
4575 // if (constraint_rhs != Number(0))
4576 // _primal_constraint_values[*i] = constraint_rhs;
4577 // else
4578 // _primal_constraint_values.erase(*i);
4579 // }
4580 // else
4581 // {
4582 // if (constraint_rhs != Number(0))
4583 // rhsit->second = constraint_rhs;
4584 // else
4585 // _primal_constraint_values.erase(rhsit);
4586 // }
4587
4588 if (constraints_to_expand.empty())
4589 i = unexpanded_set.erase(i);
4590 else
4591 ++i;
4592 }
4593}
The constraint matrix storage format.
Definition dof_map.h:112

References _dof_constraints, libMesh::libmesh_assert(), and libMesh::Real.

Referenced by check_for_cyclic_constraints(), and process_constraints().

◆ check_for_cyclic_constraints()

void libMesh::DofMap::check_for_cyclic_constraints ( )

Throw an error if we detect any constraint loops, i.e.

A -> B -> C -> A that is, "dof A is constrained in terms of dof B which is constrained in terms of dof C which is constrained in terms of dof A", since these are not supported by libMesh and give erroneous results if they are present.

Note
The original "cyclic constraint" terminology was unfortunate since the word cyclic is used by some software to indicate an actual type of rotational/angular constraint and not (as here) a cyclic graph. The former nomenclature will eventually be deprecated in favor of "constraint loop".

Definition at line 4499 of file dof_map_constraints.C.

4500{
4501 // Eventually make this officially libmesh_deprecated();
4503}

References check_for_constraint_loops().

◆ clear()

void libMesh::DofMap::clear ( )
overridevirtual

Free all new memory associated with the object, but restore its original state, with the mesh pointer and any default ghosting.

Reimplemented from libMesh::DofMapBase.

Definition at line 872 of file dof_map.C.

873{
875
876 // we don't want to clear
877 // the coupling matrix!
878 // It should not change...
879 //_dof_coupling->clear();
880 //
881 // But it would be inconsistent to leave our coupling settings
882 // through a clear()...
883 _dof_coupling = nullptr;
884
885 // Reset ghosting functor statuses
886 {
887 for (const auto & gf : _coupling_functors)
888 {
889 libmesh_assert(gf);
891 }
892 this->_coupling_functors.clear();
893
894 // Go back to default coupling
895
896 _default_coupling->set_dof_coupling(this->_dof_coupling);
897 _default_coupling->set_n_levels(this->use_coupled_neighbor_dofs(this->_mesh));
898
900 }
901
902
903 {
904 for (const auto & gf : _algebraic_ghosting_functors)
905 {
906 libmesh_assert(gf);
908 }
909 this->_algebraic_ghosting_functors.clear();
910
911 // Go back to default send_list generation
912
913 // _default_evaluating->set_dof_coupling(this->_dof_coupling);
914 _default_evaluating->set_n_levels(1);
916 }
917
918 this->_shared_functors.clear();
919
920 _variables.clear();
921 _variable_groups.clear();
922 _var_to_vg.clear();
924 _array_variables.clear();
925 _first_scalar_df.clear();
926 this->clear_send_list();
927 this->clear_sparsity();
930
931#ifdef LIBMESH_ENABLE_AMR
932
933 _dof_constraints.clear();
937 _n_old_dfs = 0;
938 _first_old_df.clear();
939 _end_old_df.clear();
940 _first_old_scalar_df.clear();
941
942#endif
943
944 _matrices.clear();
945 if (_sc)
946 _sc->clear();
947}
dof_id_type _n_old_dfs
Total number of degrees of freedom on old dof objects.
std::vector< dof_id_type > _first_old_df
First old DOF index on processor p.
virtual void clear()
std::vector< dof_id_type > _end_old_df
Last old DOF index (plus 1) on processor p.
void clear_sparsity()
Clears the sparsity pattern.
Definition dof_map.C:1983
void clear_send_list()
Clears the _send_list vector.
Definition dof_map.h:514

References libMesh::libmesh_assert().

Referenced by libMesh::DistributedMesh::clear(), libMesh::ReplicatedMesh::clear(), and ~DofMap().

◆ clear_send_list()

void libMesh::DofMap::clear_send_list ( )
inline

Clears the _send_list vector.

This should be done in order to completely rebuild the send_list from scratch rather than merely adding to the existing send_list.

Definition at line 514 of file dof_map.h.

515 {
516 _send_list.clear();
517 }

References _send_list.

◆ clear_sparsity()

void libMesh::DofMap::clear_sparsity ( )

Clears the sparsity pattern.

Definition at line 1983 of file dof_map.C.

1984{
1985 _sp.reset();
1986}
std::unique_ptr< SparsityPattern::Build > _sp
The sparsity pattern of the global matrix.
Definition dof_map.h:2265

Referenced by libMesh::System::reinit(), and OverlappingCouplingGhostingTest::run_sparsity_pattern_test().

◆ comm()

const Parallel::Communicator & libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 97 of file parallel_object.h.

98 { return _communicator; }
const Parallel::Communicator & _communicator

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), allgather_recursive_constraints(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::BoundaryInfo::build_side_list_from_node_list(), libMesh::MeshBase::cache_elem_data(), centroid_l2_error(), check_dirichlet_bcid_consistency(), libMesh::MeshTetInterface::check_hull_integrity(), MeshInputTest::checkHexPrismPolyhedron(), libMesh::MeshBase::complete_preparation(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), computed_sparsity_already(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), PetscSolverConfiguration::configure_solver(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::CondensedEigenSystem::copy_super_to_sub(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshBase::count_constraint_rows(), libMesh::MeshTools::create_bounding_box(), create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::PetscMatrix< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::MeshBase::detect_interior_parents(), libMesh::RBEIMEvaluation::distribute_bfs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::SmoothnessEstimator::estimate_smoothness(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::RBEIMConstruction::get_random_point(), libMesh::MeshTetInterface::improve_hull_integrity(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::StaticCondensation::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::LocationMap< T >::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), ElasticitySystem::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::Modification::interpolate_surface(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), n_constrained_dofs(), n_dofs(), n_dofs_per_processor(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::PetscVector< T >::operator=(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), MeshGenerationTest::polyhedronTetNeighbor(), LaplaceSystem::postprocess(), PoissonSystem::postprocess(), libMesh::MeshBase::print_constraint_rows(), print_dof_constraints(), process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::XdrIO::read(), libMesh::Nemesis_IO::read(), FEMParameters::read(), libMesh::EquationSystems::read(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), MeshFunctionTest::read_variable_info_from_output_data(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::BoundaryInfo::remove_edge_id(), libMesh::BoundaryInfo::remove_node_id(), libMesh::BoundaryInfo::remove_shellface_id(), libMesh::BoundaryInfo::remove_side_id(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::NoxNonlinearSolver< Number >::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshBase::sync_subdomain_name_map(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolygonTest::test_write_and_read_pentagon(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), MeshGenerationTest::testBuildCube(), BoundaryInfoTest::testBuildSideListFromNodeListThinMesh(), CheckpointIOTest::testC0PolygonCheckpoint(), VolumeTest::testC0PolygonMethods(), CheckpointIOTest::testC0PolyhedronCheckpoint(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriEdge3ToTri7CenterFixup(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectScalarCoarsening(), BoundaryInfoTest::testRenumber(), BoundaryInfoTest::testSelectiveRenumber(), BoundaryMeshSubdomainTest::testSingleSubdomain(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_assembly(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

◆ compute_dof_info()

std::size_t libMesh::DofMapBase::compute_dof_info ( dof_id_type  n_local_dofs)
protectedinherited

compute the key degree of freedom information given the local number of degrees of freedom on this process

Returns
The total number of DOFs for the System, summed across all procs.

Referenced by libMesh::StaticCondensationDofMap::reinit().

◆ compute_sparsity()

void libMesh::DofMap::compute_sparsity ( const MeshBase &  mesh)

Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear Algebra packages for preallocation of sparse matrices.

Definition at line 1962 of file dof_map.C.

1963{
1965
1966 // It is possible that some \p SparseMatrix implementations want to
1967 // see the sparsity pattern before we throw it away. If so, we
1968 // share a view of its arrays, and we pass it in to the matrices.
1969 for (const auto & mat : _matrices)
1970 {
1971 mat->attach_sparsity_pattern (*_sp);
1973 mat->update_sparsity_pattern (_sp->get_sparsity_pattern());
1974 }
1975 // If we don't need the full sparsity pattern anymore, free the
1976 // parts of it we don't need.
1978 _sp->clear_full_sparsity();
1979}
std::unique_ptr< SparsityPattern::Build > build_sparsity(const MeshBase &mesh, bool calculate_constrained=false, bool use_condensed_system=false) const
Builds a sparsity pattern for matrices using the current degree-of-freedom numbering and coupling.
Definition dof_map.C:63

References mesh.

Referenced by libMesh::System::init_matrices(), libMesh::System::reinit(), and OverlappingCouplingGhostingTest::run_sparsity_pattern_test().

◆ computed_sparsity_already()

bool libMesh::DofMap::computed_sparsity_already ( ) const

Returns true iff a sparsity pattern has already been computed.

Definition at line 259 of file dof_map.C.

260{
262 (!_sp->get_n_nz().empty() ||
263 !_sp->get_n_oz().empty());
264 this->comm().max(computed_sparsity_already);
266}
bool computed_sparsity_already() const
Returns true iff a sparsity pattern has already been computed.
Definition dof_map.C:259

References _sp, libMesh::ParallelObject::comm(), computed_sparsity_already(), and libMesh::Parallel::Communicator::max().

Referenced by computed_sparsity_already(), libMesh::System::solve_for_unconstrained_dofs(), and update_sparsity_pattern().

◆ constrain_element_dyad_matrix()

void libMesh::DofMap::constrain_element_dyad_matrix ( DenseVector< Number > &  v,
DenseVector< Number > &  w,
std::vector< dof_id_type > &  row_dofs,
bool  asymmetric_constraint_rows = true 
) const
inline

Constrains a dyadic element matrix B = v w'.

This method requires the element matrix to be square, in which case the elem_dofs correspond to the global DOF indices of both the rows and columns of the element matrix. For this case the rows and columns of the matrix necessarily correspond to variables of the same approximation order.

Definition at line 2524 of file dof_map.h.

2527 {}

Referenced by assemble().

◆ constrain_element_matrix() [1/2]

void libMesh::DofMap::constrain_element_matrix ( DenseMatrix< Number > &  matrix,
std::vector< dof_id_type > &  elem_dofs,
bool  asymmetric_constraint_rows = true 
) const
inline

Constrains the element matrix.

This method requires the element matrix to be square, in which case the elem_dofs correspond to the global DOF indices of both the rows and columns of the element matrix. For this case the rows and columns of the matrix necessarily correspond to variables of the same approximation order.

If asymmetric_constraint_rows is set to true (as it is by default), constraint row equations will be reinforced in a way which breaks matrix symmetry but makes inexact linear solver solutions more likely to satisfy hanging node constraints.

Definition at line 2498 of file dof_map.h.

2500 {}

Referenced by libMesh::ClawSystem::assemble_advection_matrices(), assemble_mass(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_matrices(), assemble_SchroedingerEquation(), LargeDeformationElasticity::jacobian(), and Biharmonic::JR::residual_and_jacobian().

◆ constrain_element_matrix() [2/2]

void libMesh::DofMap::constrain_element_matrix ( DenseMatrix< Number > &  matrix,
std::vector< dof_id_type > &  row_dofs,
std::vector< dof_id_type > &  col_dofs,
bool  asymmetric_constraint_rows = true 
) const
inline

Constrains the element matrix.

This method allows the element matrix to be non-square, in which case the row_dofs and col_dofs may be of different size and correspond to variables approximated in different spaces.

Definition at line 2502 of file dof_map.h.

2505 {}

◆ constrain_element_matrix_and_vector()

void libMesh::DofMap::constrain_element_matrix_and_vector ( DenseMatrix< Number > &  matrix,
DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
bool  asymmetric_constraint_rows = true 
) const
inline

Constrains the element matrix and vector.

This method requires the element matrix to be square, in which case the elem_dofs correspond to the global DOF indices of both the rows and columns of the element matrix. For this case the rows and columns of the matrix necessarily correspond to variables of the same approximation order.

Definition at line 2511 of file dof_map.h.

2514 {}

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector(), LinearElasticity::assemble(), assemble(), assemble(), AssembleOptimization::assemble_A_and_F(), assemble_cd(), assemble_cd(), assemble_elasticity(), assemble_poisson(), assemble_shell(), assemble_stokes(), and LinearElasticityWithContact::residual_and_jacobian().

◆ constrain_element_residual()

void libMesh::DofMap::constrain_element_residual ( DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
NumericVector< Number > &  solution_local 
) const

Constrains the element residual.

The element Jacobian is square, and the elem_dofs should correspond to the global DOF indices of both the rows and columns of the element matrix, and the dof constraint should not include any heterogeneous terms.

The residual-constraining version of this method creates linear systems in which heterogeneously constrained degrees of freedom create non-zero residual terms when not at their correct offset values, as would be appropriate for finding a solution to a nonlinear problem in a quasi-Newton solve.

The solution vector passed in should be a serialized or ghosted primal solution

Definition at line 2758 of file dof_map_constraints.C.

2762{
2763 libmesh_assert_equal_to (elem_dofs.size(), rhs.size());
2764
2765 libmesh_assert (solution_local.type() == SERIAL ||
2766 solution_local.type() == GHOSTED);
2767
2768 // check for easy return
2769 if (this->_dof_constraints.empty())
2770 return;
2771
2772 // The constrained RHS is built up as C^T F
2774
2775 this->build_constraint_matrix (C, elem_dofs);
2776
2777 LOG_SCOPE("cnstrn_elem_residual()", "DofMap");
2778
2779 // It is possible that the matrix is not constrained at all.
2780 if (C.n() != elem_dofs.size())
2781 return;
2782
2783 // Compute the matrix-vector product C^T F
2784 DenseVector<Number> old_rhs(rhs);
2785 C.vector_mult_transpose(rhs, old_rhs);
2786
2787 for (unsigned int i=0,
2788 n_elem_dofs = cast_int<unsigned int>(elem_dofs.size());
2789 i != n_elem_dofs; i++)
2790 {
2791 const dof_id_type dof_id = elem_dofs[i];
2792
2793 if (auto pos = _dof_constraints.find(dof_id);
2794 pos != _dof_constraints.end())
2795 {
2796 // This will put a nonsymmetric entry in the constraint
2797 // row to ensure that the linear system produces the
2798 // correct value for the constrained DOF.
2799 const DofConstraintRow & constraint_row = pos->second;
2800
2801 Number & rhs_val = rhs(i);
2802 rhs_val = 0;
2803 for (const auto & [constraining_dof, coef] : constraint_row)
2804 rhs_val -= coef * solution_local(constraining_dof);
2805 rhs_val += solution_local(dof_id);
2806 }
2807 }
2808}
void vector_mult_transpose(DenseVector< T > &dest, const DenseVector< T > &arg) const
Performs the matrix-vector multiplication, dest := (*this)^T * arg.
virtual unsigned int size() const override final
ParallelType type() const

References _dof_constraints, build_constraint_matrix(), libMesh::GHOSTED, libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::n(), libMesh::SERIAL, libMesh::DenseVector< T >::size(), libMesh::NumericVector< T >::type(), and libMesh::DenseMatrix< T >::vector_mult_transpose().

◆ constrain_element_vector()

void libMesh::DofMap::constrain_element_vector ( DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  dofs,
bool  asymmetric_constraint_rows = true 
) const
inline

Constrains the element vector.

Definition at line 2507 of file dof_map.h.

2509 {}

Referenced by LargeDeformationElasticity::residual(), Biharmonic::JR::residual_and_jacobian(), and InfFERadialTest::testRefinement().

◆ constrain_nothing()

void libMesh::DofMap::constrain_nothing ( std::vector< dof_id_type > &  dofs) const
inline

Does not actually constrain anything, but modifies dofs in the same way as any of the constrain functions would do, i.e.

adds those dofs in terms of which any of the existing dofs is constrained.

Definition at line 2529 of file dof_map.h.

2529{}

◆ constrain_p_dofs()

void libMesh::DofMap::constrain_p_dofs ( unsigned int  var,
const Elem *  elem,
unsigned int  s,
unsigned int  p 
)

Constrains degrees of freedom on side s of element elem which correspond to variable number var and to p refinement levels above p.

Definition at line 5379 of file dof_map_constraints.C.

5383{
5384 // We're constraining dofs on elem which correspond to p refinement
5385 // levels above p - this only makes sense if elem's p refinement
5386 // level is above p.
5387 libmesh_assert_greater (elem->p_level(), p);
5388 libmesh_assert_less (s, elem->n_sides());
5389
5390 const unsigned int sys_num = this->sys_number();
5391 FEType fe_type = this->variable_type(var);
5392
5393 const unsigned int n_nodes = elem->n_nodes();
5394 for (unsigned int n = 0; n != n_nodes; ++n)
5395 if (elem->is_node_on_side(n, s))
5396 {
5397 const Node & node = elem->node_ref(n);
5398 const unsigned int low_nc =
5399 FEInterface::n_dofs_at_node (fe_type, p, elem, n);
5400 const unsigned int high_nc =
5401 FEInterface::n_dofs_at_node (fe_type, elem, n);
5402
5403 // since we may be running this method concurrently
5404 // on multiple threads we need to acquire a lock
5405 // before modifying the _dof_constraints object.
5406 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
5407
5408 if (elem->is_vertex(n))
5409 {
5410 // Add "this is zero" constraint rows for high p vertex
5411 // dofs
5412 for (unsigned int i = low_nc; i != high_nc; ++i)
5413 {
5414 _dof_constraints[node.dof_number(sys_num,var,i)].clear();
5415 _primal_constraint_values.erase(node.dof_number(sys_num,var,i));
5416 }
5417 }
5418 else
5419 {
5420 const unsigned int total_dofs = node.n_comp(sys_num, var);
5421 libmesh_assert_greater_equal (total_dofs, high_nc);
5422 // Add "this is zero" constraint rows for high p
5423 // non-vertex dofs, which are numbered in reverse
5424 for (unsigned int j = low_nc; j != high_nc; ++j)
5425 {
5426 const unsigned int i = total_dofs - j - 1;
5427 _dof_constraints[node.dof_number(sys_num,var,i)].clear();
5428 _primal_constraint_values.erase(node.dof_number(sys_num,var,i));
5429 }
5430 }
5431 }
5432}
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
const Node & node_ref(const unsigned int i) const
Definition elem.h:2659
virtual unsigned int n_nodes() const =0
virtual bool is_vertex(const unsigned int i) const =0
virtual unsigned int n_sides() const =0
unsigned int p_level() const
Definition elem.h:3246
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition threads.C:30

References _dof_constraints, _primal_constraint_values, libMesh::DofObject::dof_number(), libMesh::Elem::is_node_on_side(), libMesh::Elem::is_vertex(), libMesh::DofObject::n_comp(), libMesh::FEInterface::n_dofs_at_node(), libMesh::Elem::n_nodes(), n_nodes, libMesh::Elem::n_sides(), libMesh::Elem::node_ref(), libMesh::Elem::p_level(), libMesh::Threads::spin_mtx, sys_number(), and variable_type().

Referenced by libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), and libMesh::FEGenericBase< OutputType >::compute_proj_constraints().

◆ constrained_sparsity_construction()

bool libMesh::DofMap::constrained_sparsity_construction ( )
inline

Returns true iff the current policy when constructing sparsity patterns is to explicitly account for sparsity entries created by constraint matrix pre- and post- application.

Definition at line 2579 of file dof_map.h.

2580{
2581#ifdef LIBMESH_ENABLE_CONSTRAINTS
2583#else
2584 return true;
2585#endif
2586}

References _constrained_sparsity_construction.

◆ constraint_rows_begin()

DofConstraints::const_iterator libMesh::DofMap::constraint_rows_begin ( ) const
inline
Returns
An iterator pointing to the first DoF constraint row.

Definition at line 1171 of file dof_map.h.

1172 { return _dof_constraints.begin(); }

References _dof_constraints.

◆ constraint_rows_end()

DofConstraints::const_iterator libMesh::DofMap::constraint_rows_end ( ) const
inline
Returns
An iterator pointing just past the last DoF constraint row.

Definition at line 1177 of file dof_map.h.

1178 { return _dof_constraints.end(); }

References _dof_constraints.

◆ coupling_functors_begin()

GhostingFunctorIterator libMesh::DofMap::coupling_functors_begin ( ) const
inline

Beginning of range of coupling functors.

Definition at line 373 of file dof_map.h.

374 { return _coupling_functors.begin(); }

References _coupling_functors.

Referenced by libMesh::SparsityPattern::Build::operator()(), and scatter_constraints().

◆ coupling_functors_end()

GhostingFunctorIterator libMesh::DofMap::coupling_functors_end ( ) const
inline

End of range of coupling functors.

Definition at line 379 of file dof_map.h.

380 { return _coupling_functors.end(); }

References _coupling_functors.

Referenced by libMesh::SparsityPattern::Build::operator()(), and scatter_constraints().

◆ create_dof_constraints()

void libMesh::DofMap::create_dof_constraints ( const MeshBase &  mesh,
Real  time = 0 
)

Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary objects and on non-conforming interface in adapted meshes.

A time is specified for use in building time-dependent Dirichlet constraints.

Definition at line 1736 of file dof_map_constraints.C.

1737{
1738 parallel_object_only();
1739
1740 LOG_SCOPE("create_dof_constraints()", "DofMap");
1741
1743
1744 // The user might have set boundary conditions after the mesh was
1745 // prepared; we should double-check that those boundary conditions
1746 // are still consistent.
1747#ifdef DEBUG
1749#endif
1750
1751 // We might get constraint equations from AMR hanging nodes in
1752 // 2D/3D, or from spline constraint rows or boundary conditions in
1753 // any dimension
1754 const bool possible_local_constraints = false
1755 || !mesh.n_elem()
1757#ifdef LIBMESH_ENABLE_AMR
1758 || mesh.mesh_dimension() > 1
1759#endif
1760#ifdef LIBMESH_ENABLE_PERIODIC
1761 || !_periodic_boundaries->empty()
1762#endif
1763#ifdef LIBMESH_ENABLE_DIRICHLET
1764 || !_dirichlet_boundaries->empty()
1765#endif
1766 ;
1767
1768 // Even if we don't have constraints, another processor might.
1769 bool possible_global_constraints = possible_local_constraints;
1770#if defined(LIBMESH_ENABLE_PERIODIC) || defined(LIBMESH_ENABLE_DIRICHLET) || defined(LIBMESH_ENABLE_AMR)
1771 libmesh_assert(this->comm().verify(mesh.is_serial()));
1772
1773 this->comm().max(possible_global_constraints);
1774#endif
1775
1776 // Recalculate dof constraints from scratch. (Or just clear them,
1777 // if the user has just deleted their last dirichlet/periodic/user
1778 // constraint)
1779 // Note: any _stashed_dof_constraints are not cleared as it
1780 // may be the user's intention to restore them later.
1781#ifdef LIBMESH_ENABLE_CONSTRAINTS
1782 _dof_constraints.clear();
1785#endif
1786#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1787 _node_constraints.clear();
1788#endif
1789
1790 if (!possible_global_constraints)
1791 return;
1792
1793 // Here we build the hanging node constraints. This is done
1794 // by enforcing the condition u_a = u_b along hanging sides.
1795 // u_a = u_b is collocated at the nodes of side a, which gives
1796 // one row of the constraint matrix.
1797
1798 // Processors only compute their local constraints
1799 ConstElemRange range (mesh.local_elements_begin(),
1800 mesh.local_elements_end());
1801
1802 // Global computation fails if we're using a FEMFunctionBase BC on a
1803 // ReplicatedMesh in parallel
1804 // ConstElemRange range (mesh.elements_begin(),
1805 // mesh.elements_end());
1806
1807 // compute_periodic_constraints requires a point_locator() from our
1808 // Mesh, but point_locator() construction is parallel and threaded.
1809 // Rather than nest threads within threads we'll make sure it's
1810 // preconstructed.
1811#ifdef LIBMESH_ENABLE_PERIODIC
1812 bool need_point_locator = !_periodic_boundaries->empty() && !range.empty();
1813
1814 this->comm().max(need_point_locator);
1815
1816 if (need_point_locator)
1818#endif
1819
1820#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1821 Threads::parallel_for (range,
1822 ComputeNodeConstraints (_node_constraints,
1823#ifdef LIBMESH_ENABLE_PERIODIC
1825#endif
1826 mesh));
1827#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1828
1829
1830 // Look at all the variables in the system. Reset the element
1831 // range at each iteration -- there is no need to reconstruct it.
1832 const auto n_vars = this->n_variables();
1833 for (unsigned int variable_number=0; variable_number<n_vars;
1834 ++variable_number, range.reset())
1835 Threads::parallel_for (range,
1836 ComputeConstraints (_dof_constraints,
1837 *this,
1838#ifdef LIBMESH_ENABLE_PERIODIC
1840#endif
1841 mesh,
1843
1844#ifdef LIBMESH_ENABLE_DIRICHLET
1845
1846 if (!_dirichlet_boundaries->empty())
1847 {
1848 // Sanity check that the boundary ids associated with the
1849 // DirichletBoundary objects are actually present in the
1850 // mesh. We do this check by default, but in cases where you
1851 // intentionally add "inconsistent but valid" DirichletBoundary
1852 // objects in parallel, this check can deadlock since it does a
1853 // collective communication internally. In that case it is
1854 // possible to disable this check by setting the flag to false.
1856 for (const auto & dirichlet : *_dirichlet_boundaries)
1857 this->check_dirichlet_bcid_consistency(mesh, *dirichlet);
1858
1859 // Threaded loop over local over elems applying all Dirichlet BCs
1861 (range,
1862 ConstrainDirichlet(*this, mesh, time, *_dirichlet_boundaries,
1863 AddPrimalConstraint(*this)));
1864
1865 // Threaded loop over local over elems per QOI applying all adjoint
1866 // Dirichlet BCs. Note that the ConstElemRange is reset before each
1867 // execution of Threads::parallel_for().
1868
1869 for (auto qoi_index : index_range(_adjoint_dirichlet_boundaries))
1870 {
1871 const DirichletBoundaries & adb_q =
1872 *(_adjoint_dirichlet_boundaries[qoi_index]);
1873
1874 if (!adb_q.empty())
1876 (range.reset(),
1877 ConstrainDirichlet(*this, mesh, time, adb_q,
1878 AddAdjointConstraint(*this, qoi_index)));
1879 }
1880 }
1881
1882#endif // LIBMESH_ENABLE_DIRICHLET
1883
1884 // Handle spline node constraints last, so we can try to move
1885 // existing constraints onto the spline basis if necessary.
1886 this->process_mesh_constraint_rows(mesh);
1887}
We're using a class instead of a typedef to allow forward declarations and future flexibility.
void check_dirichlet_bcid_consistency(const MeshBase &mesh, const DirichletBoundary &boundary) const
Check that all the ids in dirichlet_bcids are actually present in the mesh.
void process_mesh_constraint_rows(const MeshBase &mesh)
Adds any spline constraints from the Mesh to our DoF constraints.
unsigned int variable_number(std::string_view var) const
Definition dof_map.h:3010
bool is_prepared() const
Definition mesh_base.C:1065
unsigned int mesh_dimension() const
Definition mesh_base.C:435
virtual dof_id_type n_elem() const =0
dof_id_type n_constraint_rows() const
Returns how many total constraint rows we have.
Definition mesh_base.h:2691
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1848
The StoredRange class defines a contiguous, divisible set of objects.
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.

References _adjoint_constraint_values, _adjoint_dirichlet_boundaries, _dirichlet_boundaries, _dof_constraints, _node_constraints, _periodic_boundaries, _primal_constraint_values, _verify_dirichlet_bc_consistency, check_dirichlet_bcid_consistency(), libMesh::ParallelObject::comm(), libMesh::StoredRange< iterator_type, object_type >::empty(), libMesh::index_range(), libMesh::MeshBase::is_prepared(), libMesh::MeshBase::is_serial(), libMesh::libmesh_assert(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::Parallel::Communicator::max(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_constraint_rows(), libMesh::MeshBase::n_elem(), n_variables(), n_vars(), libMesh::Threads::parallel_for(), process_mesh_constraint_rows(), libMesh::StoredRange< iterator_type, object_type >::reset(), libMesh::MeshBase::sub_point_locator(), and variable_number().

Referenced by libMesh::System::reinit_constraints().

◆ create_static_condensation()

void libMesh::DofMap::create_static_condensation ( MeshBase &  mesh,
System &  system 
)

Add a static condensation class.

Definition at line 3137 of file dof_map.C.

3138{
3139 _sc = std::make_unique<StaticCondensationDofMap>(mesh, sys, *this);
3140}

References mesh.

◆ default_algebraic_ghosting()

DefaultCoupling & libMesh::DofMap::default_algebraic_ghosting ( )
inline

Default algebraic ghosting functor.

Definition at line 447 of file dof_map.h.

447{ return *_default_evaluating; }

References _default_evaluating.

Referenced by DefaultCouplingTest::testCoupling(), and PointNeighborCouplingTest::testCoupling().

◆ default_coupling()

DefaultCoupling & libMesh::DofMap::default_coupling ( )
inline

Default coupling functor.

Definition at line 385 of file dof_map.h.

385{ return *_default_coupling; }

References _default_coupling.

Referenced by PointNeighborCouplingTest::testCoupling().

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

101{
102 _enable_print_counter = false;
103 return;
104}
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called.

References libMesh::ReferenceCounter::_enable_print_counter.

◆ distribute_dofs()

std::size_t libMesh::DofMap::distribute_dofs ( MeshBase &  mesh)

Distribute dofs on the current mesh.

Also builds the send list for processor proc_id, which defaults to 0 for ease of use in serial applications.

Returns
The total number of DOFs for the System, summed across all procs.

Definition at line 951 of file dof_map.C.

952{
953 // This function must be run on all processors at once
954 parallel_object_only();
955
956 // Log how long it takes to distribute the degrees of freedom
957 LOG_SCOPE("distribute_dofs()", "DofMap");
958
959 libmesh_assert (mesh.is_prepared());
960
961 const processor_id_type proc_id = this->processor_id();
962#ifndef NDEBUG
963 const processor_id_type n_proc = this->n_processors();
964#endif
965
966 // libmesh_assert_greater (this->n_variables(), 0);
967 libmesh_assert_less (proc_id, n_proc);
968
969 // Data structure to ensure we can correctly combine
970 // subdomain-restricted variables with constraining nodes from
971 // different subdomains
972 const std::map<const Node *, std::set<subdomain_id_type>>
973 constraining_subdomains =
975
976 // re-init in case the mesh has changed
977 this->reinit(mesh,
978 constraining_subdomains);
979
980 // By default distribute variables in a
981 // var-major fashion, but allow run-time
982 // specification
983 bool node_major_dofs = libMesh::on_command_line ("--node-major-dofs");
984
985 // The DOF counter, will be incremented as we encounter
986 // new degrees of freedom
987 dof_id_type next_free_dof = 0;
988
989 // Clear the send list before we rebuild it
990 this->clear_send_list();
991
992 // Set temporary DOF indices on this processor
993 if (node_major_dofs)
995 (next_free_dof, mesh, constraining_subdomains);
996 else
998 (next_free_dof, mesh, constraining_subdomains);
999
1000 // Get DOF counts on all processors
1001 const auto n_dofs = this->compute_dof_info(next_free_dof);
1002
1003 // Clear all the current DOF indices
1004 // (distribute_dofs expects them cleared!)
1005 this->invalidate_dofs(mesh);
1006
1007 next_free_dof = _first_df[proc_id];
1008
1009 // Set permanent DOF indices on this processor
1010 if (node_major_dofs)
1012 (next_free_dof, mesh, constraining_subdomains);
1013 else
1015 (next_free_dof, mesh, constraining_subdomains);
1016
1017 libmesh_assert_equal_to (next_free_dof, _end_df[proc_id]);
1018
1019 //------------------------------------------------------------
1020 // At this point, all n_comp and dof_number values on local
1021 // DofObjects should be correct, but a DistributedMesh might have
1022 // incorrect values on non-local DofObjects. Let's request the
1023 // correct values from each other processor.
1024
1025 if (this->n_processors() > 1)
1026 {
1027 this->set_nonlocal_dof_objects(mesh.nodes_begin(),
1028 mesh.nodes_end(),
1030
1031 this->set_nonlocal_dof_objects(mesh.elements_begin(),
1032 mesh.elements_end(),
1034 }
1035
1036#ifdef DEBUG
1037 {
1038 const unsigned int
1039 sys_num = this->sys_number();
1040
1041 // Processors should all agree on DoF ids for the newly numbered
1042 // system.
1044
1045 // DoF processor ids should match DofObject processor ids
1046 for (auto & node : mesh.node_ptr_range())
1047 {
1048 DofObject const * const dofobj = node;
1049 const processor_id_type obj_proc_id = dofobj->processor_id();
1050
1051 for (auto v : make_range(dofobj->n_vars(sys_num)))
1052 for (auto c : make_range(dofobj->n_comp(sys_num,v)))
1053 {
1054 const dof_id_type dofid = dofobj->dof_number(sys_num,v,c);
1055 libmesh_assert_greater_equal (dofid, this->first_dof(obj_proc_id));
1056 libmesh_assert_less (dofid, this->end_dof(obj_proc_id));
1057 }
1058 }
1059
1060 for (auto & elem : mesh.element_ptr_range())
1061 {
1062 DofObject const * const dofobj = elem;
1063 const processor_id_type obj_proc_id = dofobj->processor_id();
1064
1065 for (auto v : make_range(dofobj->n_vars(sys_num)))
1066 for (auto c : make_range(dofobj->n_comp(sys_num,v)))
1067 {
1068 const dof_id_type dofid = dofobj->dof_number(sys_num,v,c);
1069 libmesh_assert_greater_equal (dofid, this->first_dof(obj_proc_id));
1070 libmesh_assert_less (dofid, this->end_dof(obj_proc_id));
1071 }
1072 }
1073 }
1074#endif
1075
1076 // start finding SCALAR degrees of freedom
1077#ifdef LIBMESH_ENABLE_AMR
1079#endif
1080 _first_scalar_df.clear();
1082 dof_id_type current_SCALAR_dof_index = n_dofs - n_SCALAR_dofs();
1083
1084 // Calculate and cache the initial DoF indices for SCALAR variables.
1085 // This is an O(N_vars) calculation so we want to do it once per
1086 // renumbering rather than once per SCALAR_dof_indices() call
1087
1088 for (auto v : make_range(this->n_variables()))
1089 if (this->variable(v).type().family == SCALAR)
1090 {
1091 _first_scalar_df[v] = current_SCALAR_dof_index;
1092 current_SCALAR_dof_index += this->variable(v).type().order.get_order();
1093 }
1094
1095 // Allow our GhostingFunctor objects to reinit if necessary
1096 for (const auto & gf : _algebraic_ghosting_functors)
1097 {
1098 libmesh_assert(gf);
1099 gf->dofmap_reinit();
1100 }
1101
1102 for (const auto & gf : _coupling_functors)
1103 {
1104 libmesh_assert(gf);
1105 gf->dofmap_reinit();
1106 }
1107
1108 // Note that in the add_neighbors_to_send_list nodes on processor
1109 // boundaries that are shared by multiple elements are added for
1110 // each element.
1112
1113 // Here we used to clean up that data structure; now System and
1114 // EquationSystems call that for us, after we've added constraint
1115 // dependencies to the send_list too.
1116 // this->sort_send_list ();
1117
1118 return n_dofs;
1119}
std::size_t compute_dof_info(dof_id_type n_local_dofs)
compute the key degree of freedom information given the local number of degrees of freedom on this pr...
std::vector< dof_id_type > _end_df
Last DOF index (plus 1) on processor p.
dof_id_type end_dof() const
std::vector< dof_id_type > _first_df
First DOF index on processor p.
dof_id_type first_dof() const
void reinit(MeshBase &mesh, const std::map< const Node *, std::set< subdomain_id_type > > &constraining_subdomains)
Reinitialize the underlying data structures conformal to the current mesh.
Definition dof_map.C:470
void set_nonlocal_dof_objects(iterator_type objects_begin, iterator_type objects_end, MeshBase &mesh, dofobject_accessor objects)
Helper function for distributing dofs in parallel.
Definition dof_map.C:319
void distribute_local_dofs_var_major(dof_id_type &next_free_dof, MeshBase &mesh, const std::map< const Node *, std::set< subdomain_id_type > > &constraining_subdomains)
Distributes the global degrees of freedom, for dofs on this processor.
Definition dof_map.C:1420
std::map< const Node *, std::set< subdomain_id_type > > calculate_constraining_subdomains()
We may have mesh constraint rows with dependent nodes in one subdomain but dependency nodes in anothe...
Definition dof_map.C:1258
void distribute_local_dofs_node_major(dof_id_type &next_free_dof, MeshBase &mesh, const std::map< const Node *, std::set< subdomain_id_type > > &constraining_subdomains)
Distributes the global degrees of freedom for dofs on this processor.
Definition dof_map.C:1292
DofObject * node_ptr(MeshBase &mesh, dof_id_type i) const
Definition dof_map.C:304
DofObject * elem_ptr(MeshBase &mesh, dof_id_type i) const
Definition dof_map.C:311
void add_neighbors_to_send_list(MeshBase &mesh)
Adds entries to the _send_list vector corresponding to DoFs on elements neighboring the current proce...
Definition dof_map.C:1689
dof_id_type n_SCALAR_dofs() const
Definition dof_map.h:793
void invalidate_dofs(MeshBase &mesh) const
Invalidates all active DofObject dofs for this system.
Definition dof_map.C:857
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
Definition fe_type.h:203
int get_order() const
Explicitly request the order as an int.
Definition fe_type.h:80
const FEType & type() const
Definition variable.h:144
void libmesh_assert_valid_dof_ids(const MeshBase &mesh, unsigned int sysnum=libMesh::invalid_uint)
A function for verifying that degree of freedom indexing matches across processors.
bool on_command_line(std::string arg)
Definition libmesh.C:934

References libMesh::DofObject::dof_number(), libMesh::libmesh_assert(), libMesh::make_range(), mesh, libMesh::DofObject::n_comp(), libMesh::DofObject::n_vars(), libMesh::on_command_line(), libMesh::DofObject::processor_id(), and libMesh::SCALAR.

Referenced by libMesh::EquationSystems::allgather(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::EquationSystems::reinit_solutions(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), and SystemsTest::testProjectMatrix3D().

◆ distribute_local_dofs_node_major()

void libMesh::DofMap::distribute_local_dofs_node_major ( dof_id_type &  next_free_dof,
MeshBase &  mesh,
const std::map< const Node *, std::set< subdomain_id_type > > &  constraining_subdomains 
)
private

Distributes the global degrees of freedom for dofs on this processor.

In this format all the degrees of freedom at a node/element are in contiguous blocks. Starts at index next_free_dof, and increments it to the post-final index. If build_send_list is true, builds the send list. If false, clears and reserves the send list.

Uses the provided constraining_subdomains map from calculate_constraining_subdomains() to ensure allocation of all DoFs on constraining nodes.

Note
The degrees of freedom for a given variable are not in contiguous blocks, as in the case of distribute_local_dofs_var_major.

Definition at line 1291 of file dof_map.C.

1296{
1297 const unsigned int sys_num = this->sys_number();
1298 const unsigned int n_var_groups = this->n_variable_groups();
1299
1300 // This is the common case and we want to optimize for it
1301 const bool constraining_subdomains_empty =
1302 constraining_subdomains.empty();
1303
1304 // Our numbering here must be kept consistent with the numbering
1305 // scheme assumed by DofMap::local_variable_indices!
1306
1307 //-------------------------------------------------------------------------
1308 // First count and assign temporary numbers to local dofs
1309 for (auto & elem : mesh.active_local_element_ptr_range())
1310 {
1311 // Only number dofs connected to active
1312 // elements on this processor.
1313 const unsigned int n_nodes = elem->n_nodes();
1314
1315 const subdomain_id_type sbdid = elem->subdomain_id();
1316
1317 // First number the nodal DOFS
1318 for (unsigned int n=0; n<n_nodes; n++)
1319 {
1320 Node & node = elem->node_ref(n);
1321
1322 for (unsigned vg=0; vg<n_var_groups; vg++)
1323 {
1324 const VariableGroup & vg_description(this->variable_group(vg));
1325
1326 if (vg_description.type().family == SCALAR)
1327 continue;
1328
1329 bool active_on_node =
1330 vg_description.active_on_subdomain(sbdid);
1331
1332 // Are we at least active indirectly here?
1333 if (!active_on_node && !constraining_subdomains_empty)
1334 if (auto it = constraining_subdomains.find(&node);
1335 it != constraining_subdomains.end())
1336 for (auto s : it->second)
1337 if (vg_description.active_on_subdomain(s))
1338 {
1339 active_on_node = true;
1340 break;
1341 }
1342
1343 if (active_on_node)
1344 {
1345 // assign dof numbers (all at once) if this is
1346 // our node and if they aren't already there
1347 if ((node.n_comp_group(sys_num,vg) > 0) &&
1348 (node.processor_id() == this->processor_id()) &&
1349 (node.vg_dof_base(sys_num,vg) ==
1351 {
1352 node.set_vg_dof_base(sys_num, vg,
1353 next_free_dof);
1354 next_free_dof += (vg_description.n_variables()*
1355 node.n_comp_group(sys_num,vg));
1356 //node.debug_buffer();
1357 }
1358 }
1359 }
1360 }
1361
1362 // Now number the element DOFS
1363 for (unsigned vg=0; vg<n_var_groups; vg++)
1364 {
1365 const VariableGroup & vg_description(this->variable_group(vg));
1366
1367 if ((vg_description.type().family != SCALAR) &&
1368 (vg_description.active_on_subdomain(elem->subdomain_id())))
1369 if (elem->n_comp_group(sys_num,vg) > 0)
1370 {
1371 libmesh_assert_equal_to (elem->vg_dof_base(sys_num,vg),
1373
1374 elem->set_vg_dof_base(sys_num,
1375 vg,
1376 next_free_dof);
1377
1378 next_free_dof += (vg_description.n_variables()*
1379 elem->n_comp_group(sys_num,vg));
1380 }
1381 }
1382 } // done looping over elements
1383
1384
1385 // we may have missed assigning DOFs to nodes that we own
1386 // but to which we have no connected elements matching our
1387 // variable restriction criterion. this will happen, for example,
1388 // if variable V is restricted to subdomain S. We may not own
1389 // any elements which live in S, but we may own nodes which are
1390 // *connected* to elements which do. in this scenario these nodes
1391 // will presently have unnumbered DOFs. we need to take care of
1392 // them here since we own them and no other processor will touch them.
1393 for (auto & node : mesh.local_node_ptr_range())
1394 for (unsigned vg=0; vg<n_var_groups; vg++)
1395 {
1396 const VariableGroup & vg_description(this->variable_group(vg));
1397
1398 if (node->n_comp_group(sys_num,vg))
1399 if (node->vg_dof_base(sys_num,vg) == DofObject::invalid_id)
1400 {
1401 node->set_vg_dof_base (sys_num,
1402 vg,
1403 next_free_dof);
1404
1405 next_free_dof += (vg_description.n_variables()*
1406 node->n_comp(sys_num,vg));
1407 }
1408 }
1409
1410 this->distribute_scalar_dofs(next_free_dof);
1411
1412#ifdef DEBUG
1414#endif // DEBUG
1415}
void distribute_scalar_dofs(dof_id_type &next_free_dof)
Definition dof_map.C:1541
void assert_no_nodes_missed(MeshBase &mesh)
Definition dof_map.C:1565

References libMesh::Variable::active_on_subdomain(), libMesh::FEType::family, mesh, libMesh::DofObject::n_comp_group(), n_nodes, libMesh::VariableGroup::n_variables(), libMesh::DofObject::processor_id(), libMesh::SCALAR, libMesh::DofObject::set_vg_dof_base(), libMesh::Variable::type(), and libMesh::DofObject::vg_dof_base().

◆ distribute_local_dofs_var_major()

void libMesh::DofMap::distribute_local_dofs_var_major ( dof_id_type &  next_free_dof,
MeshBase &  mesh,
const std::map< const Node *, std::set< subdomain_id_type > > &  constraining_subdomains 
)
private

Distributes the global degrees of freedom, for dofs on this processor.

In this format the local degrees of freedom are in a contiguous block for each variable in the system. Starts at index next_free_dof, and increments it to the post-final index.

Uses the provided constraining_subdomains map from calculate_constraining_subdomains() to ensure allocation of all DoFs on constraining nodes.

Definition at line 1419 of file dof_map.C.

1424{
1425 const unsigned int sys_num = this->sys_number();
1426 const unsigned int n_var_groups = this->n_variable_groups();
1427
1428 // This is the common case and we want to optimize for it
1429 const bool constraining_subdomains_empty =
1430 constraining_subdomains.empty();
1431
1432 // Our numbering here must be kept consistent with the numbering
1433 // scheme assumed by DofMap::local_variable_indices!
1434
1435 //-------------------------------------------------------------------------
1436 // First count and assign temporary numbers to local dofs
1437 for (unsigned vg=0; vg<n_var_groups; vg++)
1438 {
1439 const VariableGroup & vg_description(this->variable_group(vg));
1440
1441 const unsigned int n_vars_in_group = vg_description.n_variables();
1442
1443 // Skip the SCALAR dofs
1444 if (vg_description.type().family == SCALAR)
1445 continue;
1446
1447 for (auto & elem : mesh.active_local_element_ptr_range())
1448 {
1449 // Only number dofs connected to active elements on this
1450 // processor and only for variables which are active on on
1451 // this element's subdomain or which are active on the
1452 // subdomain of a node constrained by this node.
1453 const bool active_on_elem =
1454 vg_description.active_on_subdomain(elem->subdomain_id());
1455
1456 // If there's no way we're active on this element then we're
1457 // done
1458 if (!active_on_elem && constraining_subdomains_empty)
1459 continue;
1460
1461 const unsigned int n_nodes = elem->n_nodes();
1462
1463 // First number the nodal DOFS
1464 for (unsigned int n=0; n<n_nodes; n++)
1465 {
1466 Node & node = elem->node_ref(n);
1467
1468 bool active_on_node = active_on_elem;
1469 if (!active_on_node)
1470 if (auto it = constraining_subdomains.find(&node);
1471 it != constraining_subdomains.end())
1472 for (auto s : it->second)
1473 if (vg_description.active_on_subdomain(s))
1474 {
1475 active_on_node = true;
1476 break;
1477 }
1478
1479 if (!active_on_node)
1480 continue;
1481
1482 // assign dof numbers (all at once) if this is
1483 // our node and if they aren't already there
1484 if ((node.n_comp_group(sys_num,vg) > 0) &&
1485 (node.processor_id() == this->processor_id()) &&
1486 (node.vg_dof_base(sys_num,vg) ==
1488 {
1489 node.set_vg_dof_base(sys_num, vg, next_free_dof);
1490
1491 next_free_dof += (n_vars_in_group*
1492 node.n_comp_group(sys_num,vg));
1493 }
1494 }
1495
1496 // Now number the element DOFS
1497 if (elem->n_comp_group(sys_num,vg) > 0)
1498 {
1499 libmesh_assert_equal_to (elem->vg_dof_base(sys_num,vg),
1501
1502 elem->set_vg_dof_base(sys_num,
1503 vg,
1504 next_free_dof);
1505
1506 next_free_dof += (n_vars_in_group*
1507 elem->n_comp_group(sys_num,vg));
1508 }
1509 } // end loop on elements
1510
1511 // we may have missed assigning DOFs to nodes that we own
1512 // but to which we have no connected elements matching our
1513 // variable restriction criterion. this will happen, for example,
1514 // if variable V is restricted to subdomain S. We may not own
1515 // any elements which live in S, but we may own nodes which are
1516 // *connected* to elements which do. in this scenario these nodes
1517 // will presently have unnumbered DOFs. we need to take care of
1518 // them here since we own them and no other processor will touch them.
1519 for (auto & node : mesh.local_node_ptr_range())
1520 if (node->n_comp_group(sys_num,vg))
1521 if (node->vg_dof_base(sys_num,vg) == DofObject::invalid_id)
1522 {
1523 node->set_vg_dof_base (sys_num,
1524 vg,
1525 next_free_dof);
1526
1527 next_free_dof += (n_vars_in_group*
1528 node->n_comp_group(sys_num,vg));
1529 }
1530 } // end loop on variable groups
1531
1532 this->distribute_scalar_dofs(next_free_dof);
1533
1534#ifdef DEBUG
1536#endif
1537}

References libMesh::Variable::active_on_subdomain(), libMesh::FEType::family, mesh, libMesh::DofObject::n_comp_group(), n_nodes, libMesh::VariableGroup::n_variables(), libMesh::DofObject::processor_id(), libMesh::SCALAR, libMesh::DofObject::set_vg_dof_base(), libMesh::Variable::type(), and libMesh::DofObject::vg_dof_base().

◆ distribute_scalar_dofs()

void libMesh::DofMap::distribute_scalar_dofs ( dof_id_type &  next_free_dof)
private

Definition at line 1541 of file dof_map.C.

1542{
1543 this->_n_SCALAR_dofs = 0;
1544 for (auto vg : make_range(this->n_variable_groups()))
1545 {
1546 const VariableGroup & vg_description(this->variable_group(vg));
1547
1548 if (vg_description.type().family == SCALAR)
1549 {
1550 this->_n_SCALAR_dofs += (vg_description.n_variables()*
1551 vg_description.type().order.get_order());
1552 continue;
1553 }
1554 }
1555
1556 // Only increment next_free_dof if we're on the processor
1557 // that holds this SCALAR variable
1558 if (this->processor_id() == (this->n_processors()-1))
1559 next_free_dof += _n_SCALAR_dofs;
1560}

References libMesh::FEType::family, libMesh::OrderWrapper::get_order(), libMesh::make_range(), libMesh::VariableGroup::n_variables(), libMesh::FEType::order, libMesh::SCALAR, and libMesh::Variable::type().

◆ dof_indices() [1/6]

void libMesh::DofMap::dof_indices ( const Elem &  elem,
unsigned int  n,
std::vector< dof_id_type > &  di,
const unsigned int  vn 
) const

Appends to the vector di the global degree of freedom indices for elem.node_ref(n), for one variable vn.

On hanging nodes with both vertex and non-vertex DoFs, only those indices which are directly supported on elem are included.

Definition at line 2468 of file dof_map.C.

2472{
2473 this->_node_dof_indices(elem, n, elem.node_ref(n), di, vn);
2474}
void _node_dof_indices(const Elem &elem, unsigned int n, const DofObject &obj, std::vector< dof_id_type > &di, const unsigned int vn) const
Helper function that implements the element-nodal versions of dof_indices and old_dof_indices.
Definition dof_map.C:2493

References libMesh::Elem::node_ref().

◆ dof_indices() [2/6]

void libMesh::DofMap::dof_indices ( const Elem *const  elem,
std::vector< dof_id_type > &  di 
) const

Definition at line 2203 of file dof_map.C.

2205{
2206 // We now allow elem==nullptr to request just SCALAR dofs
2207 // libmesh_assert(elem);
2208
2209 // If we are asking for current indices on an element, it ought to
2210 // be an active element (or a temporary side, which also thinks it's
2211 // active)
2212 libmesh_assert(!elem || elem->active());
2213
2214 // dof_indices() is a relatively light-weight function that is
2215 // called millions of times in normal codes. Therefore, it is not a
2216 // good candidate for logging, since the cost of the logging code
2217 // itself is roughly on par with the time required to call
2218 // dof_indices().
2219 // LOG_SCOPE("dof_indices()", "DofMap");
2220
2221 // Clear the DOF indices vector
2222 di.clear();
2223
2224 const unsigned int n_var_groups = this->n_variable_groups();
2225
2226#ifdef DEBUG
2227 // Check that sizes match in DEBUG mode
2228 std::size_t tot_size = 0;
2229#endif
2230
2231 if (elem && elem->type() == TRI3SUBDIVISION)
2232 {
2233 // Subdivision surface FE require the 1-ring around elem
2234 const Tri3Subdivision * sd_elem = static_cast<const Tri3Subdivision *>(elem);
2235
2236 // Ghost subdivision elements have no real dofs
2237 if (!sd_elem->is_ghost())
2238 {
2239 // Determine the nodes contributing to element elem
2240 std::vector<const Node *> elem_nodes;
2241 MeshTools::Subdivision::find_one_ring(sd_elem, elem_nodes);
2242
2243 // Get the dof numbers
2244 for (unsigned int vg=0; vg<n_var_groups; vg++)
2245 {
2246 const VariableGroup & var = this->variable_group(vg);
2247 const unsigned int vars_in_group = var.n_variables();
2248
2249 if (var.type().family == SCALAR &&
2250 var.active_on_subdomain(elem->subdomain_id()))
2251 {
2252 for (unsigned int vig=0; vig != vars_in_group; ++vig)
2253 {
2254#ifdef DEBUG
2255 tot_size += var.type().order;
2256#endif
2257 std::vector<dof_id_type> di_new;
2258 this->SCALAR_dof_indices(di_new,var.number(vig));
2259 di.insert( di.end(), di_new.begin(), di_new.end());
2260 }
2261 }
2262 else
2263 for (unsigned int vig=0; vig != vars_in_group; ++vig)
2264 {
2265 _dof_indices(*elem, elem->p_level(), di, vg, vig,
2266 elem_nodes.data(),
2267 cast_int<unsigned int>(elem_nodes.size()),
2268 var.number(vig)
2269#ifdef DEBUG
2270 , tot_size
2271#endif
2272 );
2273 }
2274 }
2275 }
2276
2277 return;
2278 }
2279
2280 // Get the dof numbers for each variable
2281 const unsigned int n_nodes = elem ? elem->n_nodes() : 0;
2282 for (unsigned int vg=0; vg<n_var_groups; vg++)
2283 {
2284 const VariableGroup & var = this->variable_group(vg);
2285 const unsigned int vars_in_group = var.n_variables();
2286
2287 if (var.type().family == SCALAR &&
2288 (!elem ||
2289 var.active_on_subdomain(elem->subdomain_id())))
2290 {
2291 for (unsigned int vig=0; vig != vars_in_group; ++vig)
2292 {
2293#ifdef DEBUG
2294 tot_size += var.type().order;
2295#endif
2296 std::vector<dof_id_type> di_new;
2297 this->SCALAR_dof_indices(di_new,var.number(vig));
2298 di.insert( di.end(), di_new.begin(), di_new.end());
2299 }
2300 }
2301 else if (elem)
2302 for (unsigned int vig=0; vig != vars_in_group; ++vig)
2303 {
2304 _dof_indices(*elem, elem->p_level(), di, vg, vig,
2305 elem->get_nodes(), n_nodes, var.number(vig)
2306#ifdef DEBUG
2307 , tot_size
2308#endif
2309 );
2310 }
2311 }
2312
2313#ifdef DEBUG
2314 libmesh_assert_equal_to (tot_size, di.size());
2315#endif
2316}
void SCALAR_dof_indices(std::vector< dof_id_type > &di, const unsigned int vn, const bool old_dofs=false) const
Fills the vector di with the global degree of freedom indices corresponding to the SCALAR variable vn...
Definition dof_map.C:2607
void find_one_ring(const Tri3Subdivision *elem, std::vector< const Node * > &nodes)
Determines the 1-ring of element elem, and writes it to the nodes vector.

References libMesh::Elem::active(), libMesh::Variable::active_on_subdomain(), libMesh::FEType::family, libMesh::Elem::get_nodes(), libMesh::Tri3Subdivision::is_ghost(), libMesh::libmesh_assert(), libMesh::Elem::n_nodes(), n_nodes, libMesh::VariableGroup::n_variables(), libMesh::VariableGroup::number(), libMesh::FEType::order, libMesh::Elem::p_level(), libMesh::SCALAR, libMesh::Elem::subdomain_id(), libMesh::TRI3SUBDIVISION, libMesh::Variable::type(), and libMesh::Elem::type().

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::MeshFunction::_gradient_on_elem(), add_constraints_to_send_list(), libMesh::HPCoarsenTest::add_projection(), LinearElasticity::assemble(), assemble(), assemble(), AssembleOptimization::assemble_A_and_F(), libMesh::ClawSystem::assemble_advection_matrices(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), assemble_cd(), assemble_cd(), assemble_elasticity(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), assemble_mass(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_matrices(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_shell(), assemble_stokes(), assemble_wave(), Biharmonic::JR::bounds(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), compute_enriched_soln(), compute_jacobian(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEGenericBase< OutputType >::compute_proj_constraints(), compute_residual(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), libMesh::MeshFunction::discontinuous_value(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::DTKEvaluator::evaluate(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::MeshFunction::hessian(), libMesh::InfFE< Dim, T_radial, T_map >::inf_compute_constraints(), libMesh::SystemSubsetBySubdomain::init(), LargeDeformationElasticity::jacobian(), libMesh::HDGProblem::jacobian(), libMesh::System::local_dof_indices(), max_constraint_error(), LinearElasticityWithContact::move_mesh(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::MeshFunction::operator()(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), process_mesh_constraint_rows(), libMesh::StaticCondensationDofMap::reinit(), LargeDeformationElasticity::residual(), libMesh::HDGProblem::residual(), LinearElasticityWithContact::residual_and_jacobian(), Biharmonic::JR::residual_and_jacobian(), scatter_constraints(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), FETestBase< order, family, elem_type, build_nx, CaseName >::setUp(), SolidSystem::side_time_derivative(), libMesh::System::solve_for_unconstrained_dofs(), libMesh::SparsityPattern::Build::sorted_connected_dofs(), FEOrientationTestBase< order, family >::test_conformity_across_sides(), ProjectSolutionTest::test_partial_project_solution(), MixedDimensionMeshTest::testDofOrdering(), MixedDimensionRefinedMeshTest::testDofOrdering(), MixedDimensionNonUniformRefinement::testDofOrdering(), MixedDimensionNonUniformRefinementTriangle::testDofOrdering(), MixedDimensionNonUniformRefinement3D::testDofOrdering(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), DofMapTest::testGhostConstraintSendList(), InfFERadialTest::testRefinement(), BoundaryInfoTest::testShellFaceConstraints(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), NonManifoldGhostingFunctorTest::verify_send_list_entries_helper(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

◆ dof_indices() [3/6]

void libMesh::DofMap::dof_indices ( const Elem *const  elem,
std::vector< dof_id_type > &  di,
const unsigned int  vn,
int  p_level = -12345 
) const
overridevirtual

Fills the vector di with the global degree of freedom indices for the element.

For one variable, and potentially for a non-default element p refinement level

Implements libMesh::DofMapBase.

Definition at line 2319 of file dof_map.C.

2323{
2325 elem,
2326 di,
2327 vn,
2328 [](const Elem &,
2329 std::vector<dof_id_type> & dof_indices,
2330 const std::vector<dof_id_type> & scalar_dof_indices) {
2331 dof_indices.insert(dof_indices.end(), scalar_dof_indices.begin(), scalar_dof_indices.end());
2332 },
2333 [](const Elem &,
2334 unsigned int,
2335 unsigned int,
2336 std::vector<dof_id_type> & dof_indices,
2337 const dof_id_type dof) { dof_indices.push_back(dof); },
2338 p_level);
2339}

References int.

◆ dof_indices() [4/6]

template<typename ScalarDofsFunctor , typename FieldDofsFunctor >
void libMesh::DofMap::dof_indices ( const Elem *const  elem,
std::vector< dof_id_type > &  di,
const unsigned int  vn,
ScalarDofsFunctor  scalar_dofs_functor,
FieldDofsFunctor  field_dofs_functor,
int  p_level = -12345 
) const

Retrieves degree of freedom indices for a given elem and then performs actions for these indices defined by the user-provided functors scalar_dofs_functor and field_dofs_functor.

This API is useful when a user wants to do more than simply fill a degree of freedom container

Parameters
elemThe element to get degrees of freedom for
diA container for degrees of freedom. It is up to the provided functors how this gets filled
vnThe variable number to retrieve degrees of freedom for
scalar_dofs_functorThe functor that acts on scalar degrees of freedom. This functor has the interface: void scalar_dofs_functor(const Elem & elem, std::vector<dof_id_type> & di, const std::vector<dof_id_type> & scalar_dof_indices) where di is the degree of freedom container described above and scalar_dof_indices are the scalar dof indices available to elem
field_dofs_functorThe functor that acts on "field" (e.g. non-scalar, non-global) degrees of freedom. This functor has the interface: void field_dofs_functor(const Elem & elem, const unsigned int node_num, const unsigned int var_num, std::vector<dof_id_type> & di, const dof_id_type field_dof) where field_dof represents a field degree of freedom to act on and is associated with node_num and var_num. If the degree of freedom is elemental than node_num will be invalid_uint. di is again the degree of freedom container provided above

Definition at line 2796 of file dof_map.h.

2802{
2803 // We now allow elem==nullptr to request just SCALAR dofs
2804 // libmesh_assert(elem);
2805
2806 // dof_indices() is a relatively light-weight function that is
2807 // called millions of times in normal codes. Therefore, it is not a
2808 // good candidate for logging, since the cost of the logging code
2809 // itself is roughly on par with the time required to call
2810 // dof_indices().
2811 // LOG_SCOPE("dof_indices()", "DofMap");
2812
2813 // Clear the DOF indices vector
2814 di.clear();
2815
2816 // Use the default p refinement level?
2817 if (p_level == -12345)
2818 p_level = elem ? elem->p_level() : 0;
2819
2820 const unsigned int vg = this->_variable_group_numbers[vn];
2821 const VariableGroup & var = this->variable_group(vg);
2822 const unsigned int vig = vn - var.number();
2823
2824#ifdef DEBUG
2825 // Check that sizes match in DEBUG mode
2826 std::size_t tot_size = 0;
2827#endif
2828
2829 if (elem && elem->type() == TRI3SUBDIVISION)
2830 {
2831 // Subdivision surface FE require the 1-ring around elem
2832 const Tri3Subdivision * sd_elem = static_cast<const Tri3Subdivision *>(elem);
2833
2834 // Ghost subdivision elements have no real dofs
2835 if (!sd_elem->is_ghost())
2836 {
2837 // Determine the nodes contributing to element elem
2838 std::vector<const Node *> elem_nodes;
2839 MeshTools::Subdivision::find_one_ring(sd_elem, elem_nodes);
2840
2841 _dof_indices(*elem, p_level, di, vg, vig, elem_nodes.data(),
2842 cast_int<unsigned int>(elem_nodes.size()), vn,
2843#ifdef DEBUG
2844 tot_size,
2845#endif
2846 field_dofs_functor);
2847 }
2848
2849 return;
2850 }
2851
2852 // Get the dof numbers
2853 if (var.type().family == SCALAR &&
2854 (!elem ||
2855 var.active_on_subdomain(elem->subdomain_id())))
2856 {
2857#ifdef DEBUG
2858 tot_size += var.type().order;
2859#endif
2860 std::vector<dof_id_type> di_new;
2861 this->SCALAR_dof_indices(di_new,vn);
2862 scalar_dofs_functor(*elem, di, di_new);
2863 }
2864 else if (elem)
2865 _dof_indices(*elem, p_level, di, vg, vig, elem->get_nodes(),
2866 elem->n_nodes(), vn,
2867#ifdef DEBUG
2868 tot_size,
2869#endif
2870 field_dofs_functor);
2871
2872#ifdef DEBUG
2873 libmesh_assert_equal_to (tot_size, di.size());
2874#endif
2875}

References _dof_indices(), _variable_group_numbers, libMesh::Variable::active_on_subdomain(), libMesh::FEType::family, libMesh::MeshTools::Subdivision::find_one_ring(), libMesh::Elem::get_nodes(), libMesh::Tri3Subdivision::is_ghost(), libMesh::Elem::n_nodes(), libMesh::VariableGroup::number(), libMesh::FEType::order, libMesh::Elem::p_level(), libMesh::SCALAR, SCALAR_dof_indices(), libMesh::Elem::subdomain_id(), libMesh::TRI3SUBDIVISION, libMesh::Variable::type(), libMesh::Elem::type(), and variable_group().

◆ dof_indices() [5/6]

void libMesh::DofMap::dof_indices ( const Node *const  node,
std::vector< dof_id_type > &  di 
) const

Fills the vector di with the global degree of freedom indices for the node.

Definition at line 2364 of file dof_map.C.

2366{
2367 // We allow node==nullptr to request just SCALAR dofs
2368 // libmesh_assert(elem);
2369
2370 // dof_indices() is a relatively light-weight function that is
2371 // called millions of times in normal codes. Therefore, it is not a
2372 // good candidate for logging, since the cost of the logging code
2373 // itself is roughly on par with the time required to call
2374 // dof_indices().
2375 // LOG_SCOPE("dof_indices(Node)", "DofMap");
2376
2377 // Clear the DOF indices vector
2378 di.clear();
2379
2380 const unsigned int n_var_groups = this->n_variable_groups();
2381 const unsigned int sys_num = this->sys_number();
2382
2383 // Get the dof numbers
2384 for (unsigned int vg=0; vg<n_var_groups; vg++)
2385 {
2386 const VariableGroup & var = this->variable_group(vg);
2387 const unsigned int vars_in_group = var.n_variables();
2388
2389 if (var.type().family == SCALAR)
2390 {
2391 for (unsigned int vig=0; vig != vars_in_group; ++vig)
2392 {
2393 std::vector<dof_id_type> di_new;
2394 this->SCALAR_dof_indices(di_new,var.number(vig));
2395 di.insert( di.end(), di_new.begin(), di_new.end());
2396 }
2397 }
2398 else
2399 {
2400 const int n_comp = node->n_comp_group(sys_num,vg);
2401 for (unsigned int vig=0; vig != vars_in_group; ++vig)
2402 {
2403 for (int i=0; i != n_comp; ++i)
2404 {
2405 const dof_id_type d =
2406 node->dof_number(sys_num, vg, vig, i, n_comp);
2407 libmesh_assert_not_equal_to
2409 di.push_back(d);
2410 }
2411 }
2412 }
2413 }
2414}

References libMesh::DofObject::dof_number(), libMesh::FEType::family, libMesh::DofObject::n_comp_group(), libMesh::VariableGroup::n_variables(), libMesh::VariableGroup::number(), libMesh::SCALAR, and libMesh::Variable::type().

◆ dof_indices() [6/6]

void libMesh::DofMap::dof_indices ( const Node *const  node,
std::vector< dof_id_type > &  di,
const unsigned int  vn 
) const
overridevirtual

Fills the vector di with the global degree of freedom indices for the node, for one variable vn.

Implements libMesh::DofMapBase.

Definition at line 2417 of file dof_map.C.

2420{
2421 if (vn == libMesh::invalid_uint)
2422 {
2423 this->dof_indices(node, di);
2424 return;
2425 }
2426
2427 // We allow node==nullptr to request just SCALAR dofs
2428 // libmesh_assert(elem);
2429
2430 // dof_indices() is a relatively light-weight function that is
2431 // called millions of times in normal codes. Therefore, it is not a
2432 // good candidate for logging, since the cost of the logging code
2433 // itself is roughly on par with the time required to call
2434 // dof_indices().
2435 // LOG_SCOPE("dof_indices(Node)", "DofMap");
2436
2437 // Clear the DOF indices vector
2438 di.clear();
2439
2440 const unsigned int sys_num = this->sys_number();
2441
2442 // Get the dof numbers
2443 const unsigned int vg = this->_variable_group_numbers[vn];
2444 const VariableGroup & var = this->variable_group(vg);
2445
2446 if (var.type().family == SCALAR)
2447 {
2448 std::vector<dof_id_type> di_new;
2449 this->SCALAR_dof_indices(di_new,vn);
2450 di.insert( di.end(), di_new.begin(), di_new.end());
2451 }
2452 else
2453 {
2454 const unsigned int vig = vn - var.number();
2455 const int n_comp = node->n_comp_group(sys_num,vg);
2456 for (int i=0; i != n_comp; ++i)
2457 {
2458 const dof_id_type d =
2459 node->dof_number(sys_num, vg, vig, i, n_comp);
2460 libmesh_assert_not_equal_to
2462 di.push_back(d);
2463 }
2464 }
2465}

References libMesh::DofObject::dof_number(), libMesh::FEType::family, libMesh::invalid_uint, libMesh::DofObject::n_comp_group(), libMesh::VariableGroup::number(), libMesh::SCALAR, and libMesh::Variable::type().

◆ dof_owner()

processor_id_type libMesh::DofMap::dof_owner ( const dof_id_type  dof) const
inline
Returns
The processor id that owns the dof index dof

Definition at line 822 of file dof_map.h.

823 { std::vector<dof_id_type>::const_iterator ub =
824 std::upper_bound(_end_df.begin(), _end_df.end(), dof);
825 libmesh_assert (ub != _end_df.end());
826 return cast_int<processor_id_type>(ub - _end_df.begin());
827 }

References libMesh::DofMapBase::_end_df, and libMesh::libmesh_assert().

Referenced by libMesh::StaticCondensationDofMap::add_uncondensed_dof(), libMesh::PetscDMWrapper::build_sf(), and DofMapTest::testDofOwner().

◆ elem_ptr()

DofObject * libMesh::DofMap::elem_ptr ( MeshBase &  mesh,
dof_id_type  i 
) const
private
Returns
The Elem pointer with index i from the mesh.

Definition at line 311 of file dof_map.C.

312{
313 return mesh.elem_ptr(i);
314}

References mesh.

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info().

Enabled by default.

Definition at line 94 of file reference_counter.C.

95{
97 return;
98}

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

◆ end_dof() [1/2]

dof_id_type libMesh::DofMapBase::end_dof ( ) const
inlineinherited

◆ end_dof() [2/2]

dof_id_type libMesh::DofMapBase::end_dof ( const processor_id_type  proc) const
inlineinherited

◆ end_old_dof() [1/2]

dof_id_type libMesh::DofMapBase::end_old_dof ( ) const
inlineinherited

Definition at line 140 of file dof_map_base.h.

140{ return this->end_old_dof(this->processor_id()); }
dof_id_type end_old_dof() const

References libMesh::DofMapBase::end_old_dof(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::DofMapBase::end_old_dof().

◆ end_old_dof() [2/2]

dof_id_type libMesh::DofMapBase::end_old_dof ( const processor_id_type  proc) const
inlineinherited
Returns
The first old dof index that is after all indices local to processor proc.

Analogous to the end() member function of STL containers.

Definition at line 210 of file dof_map_base.h.

211{
212 libmesh_assert_less(proc, _end_old_df.size());
213 return _end_old_df[proc];
214}

References libMesh::DofMapBase::_end_old_df.

Referenced by libMesh::PetscDMWrapper::init_petscdm(), libMesh::BuildProjectionList::operator()(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), and SystemsTest::testProjectMatrix3D().

◆ enforce_adjoint_constraints_exactly()

void libMesh::DofMap::enforce_adjoint_constraints_exactly ( NumericVector< Number > &  v,
unsigned int  q 
) const
inline

Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the mesh for quantity fo interest q.

For homogeneous constraints, use enforce_constraints_exactly instead

Definition at line 2535 of file dof_map.h.

2536 {}

Referenced by libMesh::ImplicitSystem::adjoint_solve(), and libMesh::AdjointRefinementEstimator::estimate_error().

◆ enforce_constraints_exactly()

void libMesh::DofMap::enforce_constraints_exactly ( const System &  system,
NumericVector< Number > *  v = nullptr,
bool  homogeneous = false 
) const
inline

Constrains the numeric vector v, which represents a solution defined on the mesh.

This may need to be used after a linear solve, if your linear solver's solutions do not satisfy your DoF constraints to a tight enough tolerance.

If v == nullptr, the system solution vector is constrained

If homogeneous == true, heterogeneous constraints are enforced as if they were homogeneous. This might be appropriate for e.g. a vector representing a difference between two heterogeneously-constrained solutions.

Definition at line 2531 of file dof_map.h.

2533 {}

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::CondensedEigenSystem::get_eigenpair(), main(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ enforce_constraints_on_jacobian()

void libMesh::DofMap::enforce_constraints_on_jacobian ( const NonlinearImplicitSystem &  system,
SparseMatrix< Number > *  jac 
) const
inline

Definition at line 2545 of file dof_map.h.

2547 {}

◆ enforce_constraints_on_residual()

void libMesh::DofMap::enforce_constraints_on_residual ( const NonlinearImplicitSystem &  system,
NumericVector< Number > *  rhs,
NumericVector< Number > const *  solution,
bool  homogeneous = true 
) const
inline

Definition at line 2539 of file dof_map.h.

2543 {}

◆ extract_local_vector()

void libMesh::DofMap::extract_local_vector ( const NumericVector< Number > &  Ug,
const std::vector< dof_id_type > &  dof_indices,
DenseVectorBase< Number > &  Ue 
) const

Builds the local element vector Ue from the global vector Ug, accounting for any constrained degrees of freedom.

For an element without constrained degrees of freedom this is the trivial mapping \( Ue[i] = Ug[dof_indices[i]] \)

Note
The user must ensure that the element vector Ue is properly sized when calling this method. This is because there is no resize() method in the DenseVectorBase<> class.

Definition at line 2121 of file dof_map.C.

2124{
2125 const unsigned int n_original_dofs = dof_indices_in.size();
2126
2127#ifdef LIBMESH_ENABLE_AMR
2128
2129 // Trivial mapping
2130 libmesh_assert_equal_to (dof_indices_in.size(), Ue.size());
2131 bool has_constrained_dofs = false;
2132
2133 for (unsigned int il=0; il != n_original_dofs; ++il)
2134 {
2135 const dof_id_type ig = dof_indices_in[il];
2136
2137 if (this->is_constrained_dof (ig)) has_constrained_dofs = true;
2138
2139 libmesh_assert_less (ig, Ug.size());
2140
2141 Ue.el(il) = Ug(ig);
2142 }
2143
2144 // If the element has any constrained DOFs then we need
2145 // to account for them in the mapping. This will handle
2146 // the case that the input vector is not constrained.
2147 if (has_constrained_dofs)
2148 {
2149 // Copy the input DOF indices.
2150 std::vector<dof_id_type> constrained_dof_indices(dof_indices_in);
2151
2152 DenseMatrix<Number> C;
2153 DenseVector<Number> H;
2154
2155 this->build_constraint_matrix_and_vector (C, H, constrained_dof_indices);
2156
2157 libmesh_assert_equal_to (dof_indices_in.size(), C.m());
2158 libmesh_assert_equal_to (constrained_dof_indices.size(), C.n());
2159
2160 // zero-out Ue
2161 Ue.zero();
2162
2163 // compute Ue = C Ug, with proper mapping.
2164 for (unsigned int i=0; i != n_original_dofs; i++)
2165 {
2166 Ue.el(i) = H(i);
2167
2168 const unsigned int n_constrained =
2169 cast_int<unsigned int>(constrained_dof_indices.size());
2170 for (unsigned int j=0; j<n_constrained; j++)
2171 {
2172 const dof_id_type jg = constrained_dof_indices[j];
2173
2174 // If Ug is a serial or ghosted vector, then this assert is
2175 // overzealous. If Ug is a parallel vector, then this assert
2176 // is redundant.
2177 // libmesh_assert ((jg >= Ug.first_local_index()) &&
2178 // (jg < Ug.last_local_index()));
2179
2180 Ue.el(i) += C(i,j)*Ug(jg);
2181 }
2182 }
2183 }
2184
2185#else
2186
2187 // Trivial mapping
2188
2189 libmesh_assert_equal_to (n_original_dofs, Ue.size());
2190
2191 for (unsigned int il=0; il<n_original_dofs; il++)
2192 {
2193 const dof_id_type ig = dof_indices_in[il];
2194
2195 libmesh_assert ((ig >= Ug.first_local_index()) && (ig < Ug.last_local_index()));
2196
2197 Ue.el(il) = Ug(ig);
2198 }
2199
2200#endif
2201}
virtual void zero()=0
Set every element in the vector to 0.
virtual T el(const unsigned int i) const =0
virtual unsigned int size() const =0
virtual numeric_index_type last_local_index() const =0
virtual numeric_index_type size() const =0
virtual numeric_index_type first_local_index() const =0

References libMesh::DenseVectorBase< T >::el(), libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::m(), libMesh::DenseMatrixBase< T >::n(), libMesh::DenseVectorBase< T >::size(), libMesh::NumericVector< T >::size(), and libMesh::DenseVectorBase< T >::zero().

◆ find_connected_dof_objects()

void libMesh::DofMap::find_connected_dof_objects ( std::vector< const DofObject * > &  objs) const
private

Finds all the DofObjects associated with the set in objs.

This will account for off-element couplings via hanging nodes.

◆ find_connected_dofs()

void libMesh::DofMap::find_connected_dofs ( std::vector< dof_id_type > &  elem_dofs) const
private

Finds all the DOFS associated with the element DOFs elem_dofs.

This will account for off-element couplings via hanging nodes.

Definition at line 2917 of file dof_map.C.

2918{
2919 typedef std::set<dof_id_type> RCSet;
2920
2921 // First insert the DOFS we already depend on into the set.
2922 RCSet dof_set (elem_dofs.begin(), elem_dofs.end());
2923
2924 bool done = true;
2925
2926 // Next insert any dofs those might be constrained in terms
2927 // of. Note that in this case we may not be done: Those may
2928 // in turn depend on others. So, we need to repeat this process
2929 // in that case until the system depends only on unconstrained
2930 // degrees of freedom.
2931 for (const auto & dof : elem_dofs)
2932 if (this->is_constrained_dof(dof))
2933 {
2934 // If the DOF is constrained
2935 DofConstraints::const_iterator
2936 pos = _dof_constraints.find(dof);
2937
2938 libmesh_assert (pos != _dof_constraints.end());
2939
2940 const DofConstraintRow & constraint_row = pos->second;
2941
2942 // adaptive p refinement currently gives us lots of empty constraint
2943 // rows - we should optimize those DoFs away in the future. [RHS]
2944 //libmesh_assert (!constraint_row.empty());
2945
2946 // Add the DOFs this dof is constrained in terms of.
2947 // note that these dofs might also be constrained, so
2948 // we will need to call this function recursively.
2949 for (const auto & pr : constraint_row)
2950 if (!dof_set.count (pr.first))
2951 {
2952 dof_set.insert (pr.first);
2953 done = false;
2954 }
2955 }
2956
2957
2958 // If not done then we need to do more work
2959 // (obviously :-) )!
2960 if (!done)
2961 {
2962 // Fill the vector with the contents of the set
2963 elem_dofs.clear();
2964 elem_dofs.insert (elem_dofs.end(),
2965 dof_set.begin(), dof_set.end());
2966
2967
2968 // May need to do this recursively. It is possible
2969 // that we just replaced a constrained DOF with another
2970 // constrained DOF.
2971 this->find_connected_dofs (elem_dofs);
2972
2973 } // end if (!done)
2974}
void find_connected_dofs(std::vector< dof_id_type > &elem_dofs) const
Finds all the DOFS associated with the element DOFs elem_dofs.
Definition dof_map.C:2917

References libMesh::libmesh_assert().

Referenced by libMesh::SparsityPattern::Build::sorted_connected_dofs().

◆ first_dof() [1/2]

dof_id_type libMesh::DofMapBase::first_dof ( ) const
inlineinherited

◆ first_dof() [2/2]

dof_id_type libMesh::DofMapBase::first_dof ( const processor_id_type  proc) const
inlineinherited

◆ first_old_dof() [1/2]

dof_id_type libMesh::DofMapBase::first_old_dof ( ) const
inlineinherited

Definition at line 130 of file dof_map_base.h.

130{ return this->first_old_dof(this->processor_id()); }
dof_id_type first_old_dof() const

References libMesh::DofMapBase::first_old_dof(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::DofMapBase::first_old_dof().

◆ first_old_dof() [2/2]

dof_id_type libMesh::DofMapBase::first_old_dof ( const processor_id_type  proc) const
inlineinherited
Returns
The first old dof index that is local to partition proc.

Definition at line 204 of file dof_map_base.h.

205{
206 libmesh_assert_less(proc, _first_old_df.size());
207 return _first_old_df[proc];
208}

References libMesh::DofMapBase::_first_old_df.

Referenced by libMesh::PetscDMWrapper::init_petscdm(), libMesh::BuildProjectionList::operator()(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), and SystemsTest::testProjectMatrix3D().

◆ full_sparsity_pattern_needed()

void libMesh::DofMap::full_sparsity_pattern_needed ( )
inline

Sets _need_full_sparsity_pattern to true regardless of the requirements by matrices.

Definition at line 2567 of file dof_map.h.

2568{
2570}

References _need_full_sparsity_pattern.

◆ gather_constraints()

void libMesh::DofMap::gather_constraints ( MeshBase &  mesh,
std::set< dof_id_type > &  unexpanded_dofs,
bool  look_for_constrainees 
)

Helper function for querying about constraint equations on other processors.

If any id in requested_dof_ids is constrained on another processor, its constraint will be added on this processor as well. If look_for_constrainees is true, then constraints will also be returned if the id appears as a constraining value not just if it appears as a constrained value.

This function operates recursively: if the constraint for a constrained dof is newly added locally, then any other dofs which constrain it are queried to see if they are in turn constrained, and so on.

Definition at line 5015 of file dof_map_constraints.C.

5018{
5019 typedef std::set<dof_id_type> DoF_RCSet;
5020
5021 // If we have heterogeneous adjoint constraints we need to
5022 // communicate those too.
5023 const unsigned int max_qoi_num =
5025 0 : _adjoint_constraint_values.rbegin()->first+1;
5026
5027 // We have to keep recursing while the unexpanded set is
5028 // nonempty on *any* processor
5029 bool unexpanded_set_nonempty = !unexpanded_dofs.empty();
5030 this->comm().max(unexpanded_set_nonempty);
5031
5032 while (unexpanded_set_nonempty)
5033 {
5034 // Let's make sure we don't lose sync in this loop.
5035 parallel_object_only();
5036
5037 // Request sets
5038 DoF_RCSet dof_request_set;
5039
5040 // Request sets to send to each processor
5041 std::map<processor_id_type, std::vector<dof_id_type>>
5042 requested_dof_ids;
5043
5044 // And the sizes of each
5045 std::map<processor_id_type, dof_id_type>
5046 dof_ids_on_proc;
5047
5048 // Fill (and thereby sort and uniq!) the main request sets
5049 for (const auto & unexpanded_dof : unexpanded_dofs)
5050 {
5051 // If we were asked for a DoF and we don't already have a
5052 // constraint for it, then we need to check for one.
5053 if (auto pos = _dof_constraints.find(unexpanded_dof);
5054 pos == _dof_constraints.end())
5055 {
5056 if (!this->local_index(unexpanded_dof) &&
5057 !_dof_constraints.count(unexpanded_dof) )
5058 dof_request_set.insert(unexpanded_dof);
5059 }
5060 // If we were asked for a DoF and we already have a
5061 // constraint for it, then we need to check if the
5062 // constraint is recursive.
5063 else
5064 {
5065 const DofConstraintRow & row = pos->second;
5066 for (const auto & j : row)
5067 {
5068 const dof_id_type constraining_dof = j.first;
5069
5070 // If it's non-local and we haven't already got a
5071 // constraint for it, we might need to ask for one
5072 if (!this->local_index(constraining_dof) &&
5073 !_dof_constraints.count(constraining_dof))
5074 dof_request_set.insert(constraining_dof);
5075 }
5076 }
5077 }
5078
5079 // Clear the unexpanded constraint set; we're about to expand it
5080 unexpanded_dofs.clear();
5081
5082 // Count requests by processor
5083 processor_id_type proc_id = 0;
5084 for (const auto & i : dof_request_set)
5085 {
5086 while (i >= _end_df[proc_id])
5087 proc_id++;
5088 dof_ids_on_proc[proc_id]++;
5089 }
5090
5091 for (auto & pair : dof_ids_on_proc)
5092 {
5093 requested_dof_ids[pair.first].reserve(pair.second);
5094 }
5095
5096 // Prepare each processor's request set
5097 proc_id = 0;
5098 for (const auto & i : dof_request_set)
5099 {
5100 while (i >= _end_df[proc_id])
5101 proc_id++;
5102 requested_dof_ids[proc_id].push_back(i);
5103 }
5104
5105 typedef std::vector<std::pair<dof_id_type, Real>> row_datum;
5106
5107 typedef std::vector<Number> rhss_datum;
5108
5109 auto row_gather_functor =
5110 [this]
5112 const std::vector<dof_id_type> & ids,
5113 std::vector<row_datum> & data)
5114 {
5115 // Fill those requests
5116 const std::size_t query_size = ids.size();
5117
5118 data.resize(query_size);
5119 for (std::size_t i=0; i != query_size; ++i)
5120 {
5121 dof_id_type constrained = ids[i];
5122 if (_dof_constraints.count(constrained))
5123 {
5124 DofConstraintRow & row = _dof_constraints[constrained];
5125 std::size_t row_size = row.size();
5126 data[i].reserve(row_size);
5127 for (const auto & j : row)
5128 {
5129 data[i].push_back(j);
5130
5131 // We should never have an invalid constraining
5132 // dof id
5134
5135 // We should never have a 0 constraint
5136 // coefficient; that's implicit via sparse
5137 // constraint storage
5138 //
5139 // But we can't easily control how users add
5140 // constraints, so we can't safely assert that
5141 // we're being efficient here.
5142 //
5143 // libmesh_assert(j.second);
5144 }
5145 }
5146 else
5147 {
5148 // We have to distinguish "constraint with no
5149 // constraining dofs" (e.g. due to Dirichlet
5150 // constraint equations) from "no constraint".
5151 // We'll use invalid_id for the latter.
5152 data[i].emplace_back(DofObject::invalid_id, Real(0));
5153 }
5154 }
5155 };
5156
5157 auto rhss_gather_functor =
5158 [this,
5159 max_qoi_num]
5161 const std::vector<dof_id_type> & ids,
5162 std::vector<rhss_datum> & data)
5163 {
5164 // Fill those requests
5165 const std::size_t query_size = ids.size();
5166
5167 data.resize(query_size);
5168 for (std::size_t i=0; i != query_size; ++i)
5169 {
5170 dof_id_type constrained = ids[i];
5171 data[i].clear();
5172 if (_dof_constraints.count(constrained))
5173 {
5174 DofConstraintValueMap::const_iterator rhsit =
5175 _primal_constraint_values.find(constrained);
5176 data[i].push_back
5177 ((rhsit == _primal_constraint_values.end()) ?
5178 0 : rhsit->second);
5179
5180 for (unsigned int q = 0; q != max_qoi_num; ++q)
5181 {
5182 AdjointDofConstraintValues::const_iterator adjoint_map_it =
5184
5185 if (adjoint_map_it == _adjoint_constraint_values.end())
5186 {
5187 data[i].push_back(0);
5188 continue;
5189 }
5190
5191 const DofConstraintValueMap & constraint_map =
5192 adjoint_map_it->second;
5193
5194 DofConstraintValueMap::const_iterator adj_rhsit =
5195 constraint_map.find(constrained);
5196 data[i].push_back
5197 ((adj_rhsit == constraint_map.end()) ?
5198 0 : adj_rhsit->second);
5199 }
5200 }
5201 }
5202 };
5203
5204 auto row_action_functor =
5205 [this,
5206 & unexpanded_dofs]
5208 const std::vector<dof_id_type> & ids,
5209 const std::vector<row_datum> & data)
5210 {
5211 // Add any new constraint rows we've found
5212 const std::size_t query_size = ids.size();
5213
5214 for (std::size_t i=0; i != query_size; ++i)
5215 {
5216 const dof_id_type constrained = ids[i];
5217
5218 // An empty row is an constraint with an empty row; for
5219 // no constraint we use a "no row" placeholder
5220 if (data[i].empty())
5221 {
5222 DofConstraintRow & row = _dof_constraints[constrained];
5223 row.clear();
5224 }
5225 else if (data[i][0].first != DofObject::invalid_id)
5226 {
5227 DofConstraintRow & row = _dof_constraints[constrained];
5228 row.clear();
5229 for (auto & pair : data[i])
5230 {
5231 libmesh_assert_less(pair.first, this->n_dofs());
5232 row[pair.first] = pair.second;
5233 }
5234
5235 // And prepare to check for more recursive constraints
5236 unexpanded_dofs.insert(constrained);
5237 }
5238 }
5239 };
5240
5241 auto rhss_action_functor =
5242 [this,
5243 max_qoi_num]
5245 const std::vector<dof_id_type> & ids,
5246 const std::vector<rhss_datum> & data)
5247 {
5248 // Add rhs data for any new constraint rows we've found
5249 const std::size_t query_size = ids.size();
5250
5251 for (std::size_t i=0; i != query_size; ++i)
5252 {
5253 if (!data[i].empty())
5254 {
5255 dof_id_type constrained = ids[i];
5256 if (data[i][0] != Number(0))
5257 _primal_constraint_values[constrained] = data[i][0];
5258 else
5259 _primal_constraint_values.erase(constrained);
5260
5261 for (unsigned int q = 0; q != max_qoi_num; ++q)
5262 {
5263 AdjointDofConstraintValues::iterator adjoint_map_it =
5265
5266 if ((adjoint_map_it == _adjoint_constraint_values.end()) &&
5267 data[i][q+1] == Number(0))
5268 continue;
5269
5270 if (adjoint_map_it == _adjoint_constraint_values.end())
5271 adjoint_map_it = _adjoint_constraint_values.emplace
5272 (q, DofConstraintValueMap()).first;
5273
5274 DofConstraintValueMap & constraint_map =
5275 adjoint_map_it->second;
5276
5277 if (data[i][q+1] != Number(0))
5278 constraint_map[constrained] =
5279 data[i][q+1];
5280 else
5281 constraint_map.erase(constrained);
5282 }
5283 }
5284 }
5285
5286 };
5287
5288 // Now request constraint rows from other processors
5289 row_datum * row_ex = nullptr;
5291 (this->comm(), requested_dof_ids, row_gather_functor,
5292 row_action_functor, row_ex);
5293
5294 // And request constraint right hand sides from other procesors
5295 rhss_datum * rhs_ex = nullptr;
5297 (this->comm(), requested_dof_ids, rhss_gather_functor,
5298 rhss_action_functor, rhs_ex);
5299
5300 // We have to keep recursing while the unexpanded set is
5301 // nonempty on *any* processor
5302 unexpanded_set_nonempty = !unexpanded_dofs.empty();
5303 this->comm().max(unexpanded_set_nonempty);
5304 }
5305}

References _adjoint_constraint_values, _dof_constraints, libMesh::DofMapBase::_end_df, _primal_constraint_values, libMesh::ParallelObject::comm(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), local_index(), libMesh::Parallel::Communicator::max(), TIMPI::pull_parallel_vector_data(), and libMesh::Real.

Referenced by allgather_recursive_constraints(), and scatter_constraints().

◆ get_adjoint_dirichlet_boundaries() [1/2]

DirichletBoundaries * libMesh::DofMap::get_adjoint_dirichlet_boundaries ( unsigned int  q)

Definition at line 5476 of file dof_map_constraints.C.

5477{
5478 unsigned int old_size = cast_int<unsigned int>
5480 for (unsigned int i = old_size; i <= q; ++i)
5481 _adjoint_dirichlet_boundaries.push_back(std::make_unique<DirichletBoundaries>());
5482
5483 return _adjoint_dirichlet_boundaries[q].get();
5484}

References _adjoint_dirichlet_boundaries.

◆ get_adjoint_dirichlet_boundaries() [2/2]

const DirichletBoundaries * libMesh::DofMap::get_adjoint_dirichlet_boundaries ( unsigned int  q) const

Definition at line 5468 of file dof_map_constraints.C.

5469{
5470 libmesh_assert_greater(_adjoint_dirichlet_boundaries.size(),q);
5471 return _adjoint_dirichlet_boundaries[q].get();
5472}

References _adjoint_dirichlet_boundaries.

◆ get_all_variable_numbers()

void libMesh::DofMap::get_all_variable_numbers ( std::vector< unsigned int > &  all_variable_numbers) const

Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.

Definition at line 3391 of file dof_map.C.

3392{
3393 all_variable_numbers.resize(n_vars());
3394
3395 unsigned int count = 0;
3396 for (auto vn : _variable_numbers)
3397 all_variable_numbers[count++] = vn.second;
3398}

References n_vars.

Referenced by libMesh::System::get_all_variable_numbers().

◆ get_dirichlet_boundaries() [1/2]

DirichletBoundaries * libMesh::DofMap::get_dirichlet_boundaries ( )
inline

Definition at line 1648 of file dof_map.h.

1649 {
1650 return _dirichlet_boundaries.get();
1651 }

References _dirichlet_boundaries.

◆ get_dirichlet_boundaries() [2/2]

const DirichletBoundaries * libMesh::DofMap::get_dirichlet_boundaries ( ) const
inline

Definition at line 1643 of file dof_map.h.

1644 {
1645 return _dirichlet_boundaries.get();
1646 }

References _dirichlet_boundaries.

Referenced by libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs().

◆ get_dof_constraints()

const DofConstraints & libMesh::DofMap::get_dof_constraints ( ) const
inline

Provide a const accessor to the DofConstraints map.

This allows the user to quickly search the data structure rather than just iterating over it.

Definition at line 1184 of file dof_map.h.

1184{ return _dof_constraints; }

References _dof_constraints.

Referenced by libMesh::StaticCondensationDofMap::add_uncondensed_dof_plus_constraint_dofs().

◆ get_info() [1/2]

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

48{
49#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50
51 std::ostringstream oss;
52
53 oss << '\n'
54 << " ---------------------------------------------------------------------------- \n"
55 << "| Reference count information |\n"
56 << " ---------------------------------------------------------------------------- \n";
57
58 for (const auto & [name, cd] : _counts)
59 oss << "| " << name << " reference count information:\n"
60 << "| Creations: " << cd.first << '\n'
61 << "| Destructions: " << cd.second << '\n';
62
63 oss << " ---------------------------------------------------------------------------- \n";
64
65 return oss.str();
66
67#else
68
69 return "";
70
71#endif
72}
static Counts _counts
Actually holds the data.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.

References libMesh::ReferenceCounter::_counts.

Referenced by libMesh::ReferenceCounter::print_info().

◆ get_info() [2/2]

std::string libMesh::DofMap::get_info ( ) const

Gets summary info about the sparsity bandwidth and constraints.

Definition at line 2987 of file dof_map.C.

2988{
2989 std::ostringstream os;
2990
2991 // If we didn't calculate the exact sparsity pattern, the threaded
2992 // sparsity pattern assembly may have just given us an upper bound
2993 // on sparsity.
2994 const char * may_equal = " <= ";
2995
2996 // If we calculated the exact sparsity pattern, then we can report
2997 // exact bandwidth figures:
2998 for (const auto & mat : _matrices)
2999 if (mat->need_full_sparsity_pattern())
3000 may_equal = " = ";
3001
3002 dof_id_type max_n_nz = 0, max_n_oz = 0;
3003 long double avg_n_nz = 0, avg_n_oz = 0;
3004
3005 if (_sp)
3006 {
3007 for (const auto & val : _sp->get_n_nz())
3008 {
3009 max_n_nz = std::max(max_n_nz, val);
3010 avg_n_nz += val;
3011 }
3012
3013 std::size_t n_nz_size = _sp->get_n_nz().size();
3014
3015 this->comm().max(max_n_nz);
3016 this->comm().sum(avg_n_nz);
3017 this->comm().sum(n_nz_size);
3018
3019 avg_n_nz /= std::max(n_nz_size,std::size_t(1));
3020
3021 for (const auto & val : _sp->get_n_oz())
3022 {
3023 max_n_oz = std::max(max_n_oz, val);
3024 avg_n_oz += val;
3025 }
3026
3027 std::size_t n_oz_size = _sp->get_n_oz().size();
3028
3029 this->comm().max(max_n_oz);
3030 this->comm().sum(avg_n_oz);
3031 this->comm().sum(n_oz_size);
3032
3033 avg_n_oz /= std::max(n_oz_size,std::size_t(1));
3034 }
3035
3036 os << " DofMap Sparsity\n Average On-Processor Bandwidth"
3037 << may_equal << avg_n_nz << '\n';
3038
3039 os << " Average Off-Processor Bandwidth"
3040 << may_equal << avg_n_oz << '\n';
3041
3042 os << " Maximum On-Processor Bandwidth"
3043 << may_equal << max_n_nz << '\n';
3044
3045 os << " Maximum Off-Processor Bandwidth"
3046 << may_equal << max_n_oz << std::endl;
3047
3048#ifdef LIBMESH_ENABLE_CONSTRAINTS
3049
3050 std::size_t n_constraints = 0, max_constraint_length = 0,
3051 n_rhss = 0;
3052 long double avg_constraint_length = 0.;
3053
3054 for (const auto & [constrained_dof, row] : _dof_constraints)
3055 {
3056 // Only count local constraints, then sum later
3057 if (!this->local_index(constrained_dof))
3058 continue;
3059
3060 std::size_t rowsize = row.size();
3061
3062 max_constraint_length = std::max(max_constraint_length,
3063 rowsize);
3064 avg_constraint_length += rowsize;
3065 n_constraints++;
3066
3067 if (_primal_constraint_values.count(constrained_dof))
3068 n_rhss++;
3069 }
3070
3071 this->comm().sum(n_constraints);
3072 this->comm().sum(n_rhss);
3073 this->comm().sum(avg_constraint_length);
3074 this->comm().max(max_constraint_length);
3075
3076 os << " DofMap Constraints\n Number of DoF Constraints = "
3077 << n_constraints;
3078 if (n_rhss)
3079 os << '\n'
3080 << " Number of Heterogenous Constraints= " << n_rhss;
3081 if (n_constraints)
3082 {
3083 avg_constraint_length /= n_constraints;
3084
3085 os << '\n'
3086 << " Average DoF Constraint Length= " << avg_constraint_length;
3087 }
3088
3089#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
3090 std::size_t n_node_constraints = 0, max_node_constraint_length = 0,
3091 n_node_rhss = 0;
3092 long double avg_node_constraint_length = 0.;
3093
3094 for (const auto & [node, pr] : _node_constraints)
3095 {
3096 // Only count local constraints, then sum later
3097 if (node->processor_id() != this->processor_id())
3098 continue;
3099
3100 const NodeConstraintRow & row = pr.first;
3101 std::size_t rowsize = row.size();
3102
3103 max_node_constraint_length = std::max(max_node_constraint_length,
3104 rowsize);
3105 avg_node_constraint_length += rowsize;
3106 n_node_constraints++;
3107
3108 if (pr.second != Point(0))
3109 n_node_rhss++;
3110 }
3111
3112 this->comm().sum(n_node_constraints);
3113 this->comm().sum(n_node_rhss);
3114 this->comm().sum(avg_node_constraint_length);
3115 this->comm().max(max_node_constraint_length);
3116
3117 os << "\n Number of Node Constraints = " << n_node_constraints;
3118 if (n_node_rhss)
3119 os << '\n'
3120 << " Number of Heterogenous Node Constraints= " << n_node_rhss;
3121 if (n_node_constraints)
3122 {
3123 avg_node_constraint_length /= n_node_constraints;
3124 os << "\n Maximum Node Constraint Length= " << max_node_constraint_length
3125 << '\n'
3126 << " Average Node Constraint Length= " << avg_node_constraint_length;
3127 }
3128#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
3129
3130 os << std::endl;
3131
3132#endif // LIBMESH_ENABLE_CONSTRAINTS
3133
3134 return os.str();
3135}
const std::vector< dof_id_type > & get_n_oz() const
Definition dof_map.h:562
const std::vector< dof_id_type > & get_n_nz() const
Definition dof_map.h:549

◆ get_local_constraints()

std::string libMesh::DofMap::get_local_constraints ( bool  print_nonlocal = false) const

Gets a string reporting all DoF and Node constraints local to this processor.

If print_nonlocal is true, then nonlocal constraints which are locally known are included.

Definition at line 2275 of file dof_map_constraints.C.

2276{
2277 std::ostringstream os;
2278#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2279 if (print_nonlocal)
2280 os << "All ";
2281 else
2282 os << "Local ";
2283
2284 os << "Node Constraints:"
2285 << std::endl;
2286
2287 for (const auto & [node, pr] : _node_constraints)
2288 {
2289 // Skip non-local nodes if requested
2290 if (!print_nonlocal &&
2291 node->processor_id() != this->processor_id())
2292 continue;
2293
2294 const NodeConstraintRow & row = pr.first;
2295 const Point & offset = pr.second;
2296
2297 os << "Constraints for Node id " << node->id()
2298 << ": \t";
2299
2300 for (const auto & [cnode, val] : row)
2301 os << " (" << cnode->id() << "," << val << ")\t";
2302
2303 os << "rhs: " << offset;
2304
2305 os << std::endl;
2306 }
2307#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
2308
2309 if (print_nonlocal)
2310 os << "All ";
2311 else
2312 os << "Local ";
2313
2314 os << "DoF Constraints:"
2315 << std::endl;
2316
2317 for (const auto & [i, row] : _dof_constraints)
2318 {
2319 // Skip non-local dofs if requested
2320 if (!print_nonlocal && !this->local_index(i))
2321 continue;
2322
2323 DofConstraintValueMap::const_iterator rhsit =
2325 const Number rhs = (rhsit == _primal_constraint_values.end()) ?
2326 0 : rhsit->second;
2327
2328 os << "Constraints for DoF " << i
2329 << ": \t";
2330
2331 for (const auto & item : row)
2332 os << " (" << item.first << "," << item.second << ")\t";
2333
2334 os << "rhs: " << rhs;
2335 os << std::endl;
2336 }
2337
2338 for (unsigned int qoi_index = 0,
2339 n_qois = cast_int<unsigned int>(_adjoint_dirichlet_boundaries.size());
2340 qoi_index != n_qois; ++qoi_index)
2341 {
2342 os << "Adjoint " << qoi_index << " DoF rhs values:"
2343 << std::endl;
2344
2345 if (auto adjoint_map_it = _adjoint_constraint_values.find(qoi_index);
2346 adjoint_map_it != _adjoint_constraint_values.end())
2347 for (const auto & [i, rhs] : adjoint_map_it->second)
2348 {
2349 // Skip non-local dofs if requested
2350 if (!print_nonlocal && !this->local_index(i))
2351 continue;
2352
2353 os << "RHS for DoF " << i
2354 << ": " << rhs;
2355
2356 os << std::endl;
2357 }
2358 }
2359
2360 return os.str();
2361}

References _adjoint_constraint_values, _adjoint_dirichlet_boundaries, _dof_constraints, _node_constraints, _primal_constraint_values, local_index(), and libMesh::ParallelObject::processor_id().

Referenced by print_dof_constraints().

◆ get_n_nz()

const std::vector< dof_id_type > & libMesh::DofMap::get_n_nz ( ) const
inline
Returns
A constant reference to the _n_nz list for this processor.

The vector contains the bandwidth of the on-processor coupling for each row of the global matrix that the current processor owns. This information can be used to preallocate space for a parallel sparse matrix.

Definition at line 549 of file dof_map.h.

550 {
552 return _sp->get_n_nz();
553 }

References _sp, and libMesh::libmesh_assert().

◆ get_n_oz()

const std::vector< dof_id_type > & libMesh::DofMap::get_n_oz ( ) const
inline
Returns
A constant reference to the _n_oz list for this processor.

The vector contains the bandwidth of the off-processor coupling for each row of the global matrix that the current processor owns. This information can be used to preallocate space for a parallel sparse matrix.

Definition at line 562 of file dof_map.h.

563 {
565 return _sp->get_n_oz();
566 }

References _sp, and libMesh::libmesh_assert().

◆ get_periodic_boundaries() [1/2]

PeriodicBoundaries * libMesh::DofMap::get_periodic_boundaries ( )
inline

Definition at line 1590 of file dof_map.h.

1591 {
1592 return _periodic_boundaries.get();
1593 }

References _periodic_boundaries.

Referenced by main().

◆ get_periodic_boundaries() [2/2]

const PeriodicBoundaries * libMesh::DofMap::get_periodic_boundaries ( ) const
inline

Definition at line 1595 of file dof_map.h.

1596 {
1597 return _periodic_boundaries.get();
1598 }

References _periodic_boundaries.

◆ get_primal_constraint_values()

DofConstraintValueMap & libMesh::DofMap::get_primal_constraint_values ( )
inline
Returns
A reference to the set of right-hand-side values in primal constraint equations

Definition at line 2484 of file dof_map.h.

2485{
2487}

References _primal_constraint_values.

◆ get_send_list()

const std::vector< dof_id_type > & libMesh::DofMap::get_send_list ( ) const
inline

◆ get_sparsity_pattern()

const SparsityPattern::Build * libMesh::DofMap::get_sparsity_pattern ( ) const
inline
Returns
A constant pointer to the sparsity pattern stored here, once that has been computed. Returns null if no sparsity pattern has yet been computed.

If need_full_sparsity_pattern is false, the "sparsity pattern" may only own n_nz and n_oz lists.

Definition at line 577 of file dof_map.h.

578 {
579 return _sp.get();
580 }

References _sp.

Referenced by libMesh::SparseMatrix< T >::attach_dof_map().

◆ get_static_condensation() [1/2]

StaticCondensationDofMap & libMesh::DofMap::get_static_condensation ( )
inline
Returns
the static condensation class. This should have been already added with a call to add_static_condensation()

Definition at line 2878 of file dof_map.h.

2879{
2881 return *_sc;
2882}

References _sc, and libMesh::libmesh_assert().

◆ get_static_condensation() [2/2]

const StaticCondensationDofMap & libMesh::DofMap::get_static_condensation ( ) const
inline
Returns
the static condensation class. This should have been already added with a call to add_static_condensation()

Definition at line 2885 of file dof_map.h.

2886{
2888 return *_sc;
2889}

References _sc, and libMesh::libmesh_assert().

◆ get_variable_array()

const std::pair< unsigned int, unsigned int > & libMesh::DofMap::get_variable_array ( unsigned int  vi) const
inlineprivate

Retrieve the array variable bounds for a given variable vi.

This variable may lie anywhere within an array variable range. An 'array variable' is simply a sequence of contiguous variable numbers defined by pair where the first member of the pair is the first number in the variable sequence and the second member of the pair is the number of the last variable in the sequence plus one. Array variables may be used in tandem with variable grouping by downstream code to build optimized physics kernels since each variable in the array will have the same shape functions.

We note that we store array variables as a container of the above described pairs. Within this API we will do a binary search such that the complexity is O(log(N)) where N is the number of array variables present in this

Definition at line 2892 of file dof_map.h.

2893{
2894 auto it = std::upper_bound(
2895 _array_variables.begin(),
2896 _array_variables.end(),
2897 vi,
2898 [](unsigned int value, const std::pair<unsigned int, unsigned int> & b) { return value < b.first; });
2899
2900 libmesh_assert_msg(it != _array_variables.begin(),
2901 "Passed in " << std::to_string(vi) << " is not in any of our array variables");
2902 --it;
2903 libmesh_assert_msg(vi < it->second,
2904 "Passed in " << std::to_string(vi) << " is not in any of our array variables");
2905 return *it;
2906}
static const Real b
static const bool value
Definition xdr_io.C:55

References _array_variables, b, and value.

Referenced by array_dof_indices().

◆ ghost_constraints_needed()

void libMesh::DofMap::ghost_constraints_needed ( )
inline

Sets _need_ghost_constraints to true regardless of the requirements by static condensation.

Definition at line 2573 of file dof_map.h.

2574{
2576}

References _need_ghost_constraints.

Referenced by DofMapTest::testGhostConstraintSendList().

◆ has_adjoint_dirichlet_boundaries()

bool libMesh::DofMap::has_adjoint_dirichlet_boundaries ( unsigned int  q) const

Definition at line 5458 of file dof_map_constraints.C.

5459{
5460 if (_adjoint_dirichlet_boundaries.size() > q)
5461 return true;
5462
5463 return false;
5464}

References _adjoint_dirichlet_boundaries.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

◆ has_blocked_representation()

bool libMesh::DofMap::has_blocked_representation ( ) const
inline
Returns
true if the variables are capable of being stored in a blocked form. Presently, this means that there can only be one variable group, and that the group has more than one variable.

Definition at line 756 of file dof_map.h.

757 {
758 return ((this->n_variable_groups() == 1) && (this->n_variables() > 1));
759 }

References n_variable_groups(), and n_variables().

Referenced by block_size().

◆ has_heterogeneous_adjoint_constraint()

Number libMesh::DofMap::has_heterogeneous_adjoint_constraint ( const unsigned int  qoi_num,
const dof_id_type  dof 
) const
inline
Returns
The heterogeneous constraint value if the degree of freedom dof has a heterogeneous constraint for adjoint solution qoi_num, zero otherwise.

Definition at line 2463 of file dof_map.h.

2465{
2466 AdjointDofConstraintValues::const_iterator it =
2467 _adjoint_constraint_values.find(qoi_num);
2468 if (it != _adjoint_constraint_values.end())
2469 {
2470 DofConstraintValueMap::const_iterator rhsit =
2471 it->second.find(dof);
2472 if (rhsit == it->second.end())
2473 return 0;
2474 else
2475 return rhsit->second;
2476 }
2477
2478 return 0;
2479}

References _adjoint_constraint_values.

Referenced by has_heterogenous_adjoint_constraint().

◆ has_heterogeneous_adjoint_constraints()

bool libMesh::DofMap::has_heterogeneous_adjoint_constraints ( const unsigned int  qoi_num) const
inline
Returns
true if the system has any heterogeneous constraints for adjoint solution qoi_num, false otherwise.

Definition at line 2449 of file dof_map.h.

2450{
2451 AdjointDofConstraintValues::const_iterator it =
2452 _adjoint_constraint_values.find(qoi_num);
2453 if (it == _adjoint_constraint_values.end())
2454 return false;
2455 if (it->second.empty())
2456 return false;
2457
2458 return true;
2459}

References _adjoint_constraint_values.

Referenced by has_heterogenous_adjoint_constraints().

◆ has_heterogenous_adjoint_constraint()

Number libMesh::DofMap::has_heterogenous_adjoint_constraint ( const unsigned int  qoi_num,
const dof_id_type  dof 
) const
inline

Backwards compatibility with misspelling.

Definition at line 1260 of file dof_map.h.

1262 {
1263 return this->has_heterogeneous_adjoint_constraint (qoi_num, dof);
1264 }
Number has_heterogeneous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Definition dof_map.h:2463

References has_heterogeneous_adjoint_constraint().

◆ has_heterogenous_adjoint_constraints()

bool libMesh::DofMap::has_heterogenous_adjoint_constraints ( const unsigned int  qoi_num) const
inline

Backwards compatibility with misspelling.

Definition at line 1244 of file dof_map.h.

1245 {
1246 return this->has_heterogeneous_adjoint_constraints (qoi_num);
1247 }
bool has_heterogeneous_adjoint_constraints(const unsigned int qoi_num) const
Definition dof_map.h:2449

References has_heterogeneous_adjoint_constraints().

◆ has_static_condensation()

bool libMesh::DofMap::has_static_condensation ( ) const
inline

Checks whether we have static condensation.

Definition at line 1804 of file dof_map.h.

1804{ return _sc.get(); }

References _sc.

Referenced by add_constraints_to_send_list(), and build_sparsity().

◆ has_variable()

bool libMesh::DofMap::has_variable ( std::string_view  var) const
inline
Returns
true if a variable named var exists in this System

Definition at line 3005 of file dof_map.h.

3006{
3007 return _variable_numbers.count(var);
3008}

References _variable_numbers.

Referenced by libMesh::System::has_variable().

◆ heterogeneously_constrain_element_jacobian_and_residual()

void libMesh::DofMap::heterogeneously_constrain_element_jacobian_and_residual ( DenseMatrix< Number > &  matrix,
DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
NumericVector< Number > &  solution_local 
) const

Constrains the element Jacobian and residual.

The element Jacobian is square, and the elem_dofs should correspond to the global DOF indices of both the rows and columns of the element matrix.

The residual-constraining version of this method creates linear systems in which heterogeneously constrained degrees of freedom create non-zero residual terms when not at their correct offset values, as would be appropriate for finding a solution to a nonlinear problem in a quasi-Newton solve.

Note the sign difference from the linear heterogeneous constraint method: Solving u:=u_in-J\r has the opposite sign convention from u:=K\f, and we apply heterogeneous constraints accordingly.

The solution vector passed in should be a serialized or ghosted primal solution

Definition at line 2615 of file dof_map_constraints.C.

2620{
2621 libmesh_assert_equal_to (elem_dofs.size(), matrix.m());
2622 libmesh_assert_equal_to (elem_dofs.size(), matrix.n());
2623 libmesh_assert_equal_to (elem_dofs.size(), rhs.size());
2624
2625 libmesh_assert (solution_local.type() == SERIAL ||
2626 solution_local.type() == GHOSTED);
2627
2628 // check for easy return
2629 if (this->_dof_constraints.empty())
2630 return;
2631
2632 // The constrained matrix is built up as C^T K C.
2633 // The constrained RHS is built up as C^T F
2634 // Asymmetric residual terms are added if we do not have x = Cx+h
2637
2638 this->build_constraint_matrix_and_vector (C, H, elem_dofs);
2639
2640 LOG_SCOPE("hetero_cnstrn_elem_jac_res()", "DofMap");
2641
2642 // It is possible that the matrix is not constrained at all.
2643 if ((C.m() != matrix.m()) ||
2644 (C.n() != elem_dofs.size()))
2645 return;
2646
2647 // Compute the matrix-vector product C^T F
2648 DenseVector<Number> old_rhs(rhs);
2649 C.vector_mult_transpose(rhs, old_rhs);
2650
2651 // Compute the matrix-matrix-matrix product C^T K C
2652 matrix.left_multiply_transpose (C);
2653 matrix.right_multiply (C);
2654
2655 libmesh_assert_equal_to (matrix.m(), matrix.n());
2656 libmesh_assert_equal_to (matrix.m(), elem_dofs.size());
2657 libmesh_assert_equal_to (matrix.n(), elem_dofs.size());
2658
2659 for (unsigned int i=0,
2660 n_elem_dofs = cast_int<unsigned int>(elem_dofs.size());
2661 i != n_elem_dofs; i++)
2662 {
2663 const dof_id_type dof_id = elem_dofs[i];
2664
2665 if (auto pos = _dof_constraints.find(dof_id);
2666 pos != _dof_constraints.end())
2667 {
2668 for (auto j : make_range(matrix.n()))
2669 matrix(i,j) = 0.;
2670
2671 // If the DOF is constrained
2672 matrix(i,i) = 1.;
2673
2674 // This will put a nonsymmetric entry in the constraint
2675 // row to ensure that the linear system produces the
2676 // correct value for the constrained DOF.
2677 const DofConstraintRow & constraint_row = pos->second;
2678
2679 for (const auto & item : constraint_row)
2680 for (unsigned int j=0; j != n_elem_dofs; j++)
2681 if (elem_dofs[j] == item.first)
2682 matrix(i,j) = -item.second;
2683
2684 const DofConstraintValueMap::const_iterator valpos =
2685 _primal_constraint_values.find(dof_id);
2686
2687 Number & rhs_val = rhs(i);
2688 rhs_val = (valpos == _primal_constraint_values.end()) ?
2689 0 : -valpos->second;
2690 for (const auto & [constraining_dof, coef] : constraint_row)
2691 rhs_val -= coef * solution_local(constraining_dof);
2692 rhs_val += solution_local(dof_id);
2693 }
2694 }
2695}
void left_multiply_transpose(const DenseMatrix< T > &A)
Left multiplies by the transpose of the matrix A.

References _dof_constraints, _primal_constraint_values, build_constraint_matrix_and_vector(), libMesh::GHOSTED, libMesh::DenseMatrix< T >::left_multiply_transpose(), libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::m(), libMesh::make_range(), libMesh::DenseMatrixBase< T >::n(), libMesh::DenseMatrix< T >::right_multiply(), libMesh::SERIAL, libMesh::DenseVector< T >::size(), libMesh::NumericVector< T >::type(), and libMesh::DenseMatrix< T >::vector_mult_transpose().

◆ heterogeneously_constrain_element_matrix_and_vector()

void libMesh::DofMap::heterogeneously_constrain_element_matrix_and_vector ( DenseMatrix< Number > &  matrix,
DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
bool  asymmetric_constraint_rows = true,
int  qoi_index = -1 
) const
inline

Constrains the element matrix and vector.

This method requires the element matrix to be square, in which case the elem_dofs correspond to the global DOF indices of both the rows and columns of the element matrix. For this case the rows and columns of the matrix necessarily correspond to variables of the same approximation order.

The heterogeneous version of this method creates linear systems in which heterogeneously constrained degrees of freedom will solve to their correct offset values, as would be appropriate for finding a solution to a linear problem in a single algebraic solve. The non-heterogeneous version of this method creates linear systems in which even heterogeneously constrained degrees of freedom are solved without offset values taken into account, as would be appropriate for finding linearized updates to a solution in which heterogeneous constraints are already satisfied.

By default, the constraints for the primal solution of this system are used. If a non-negative qoi_index is passed in, then the constraints for the corresponding adjoint solution are used instead.

Definition at line 2516 of file dof_map.h.

2518 {}

Referenced by heterogenously_constrain_element_matrix_and_vector(), and process_mesh_constraint_rows().

◆ heterogeneously_constrain_element_residual()

void libMesh::DofMap::heterogeneously_constrain_element_residual ( DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
NumericVector< Number > &  solution_local 
) const

Constrains the element residual.

The element Jacobian is square, and the elem_dofs should correspond to the global DOF indices of both the rows and columns of the element matrix.

The residual-constraining version of this method creates linear systems in which heterogeneously constrained degrees of freedom create non-zero residual terms when not at their correct offset values, as would be appropriate for finding a solution to a nonlinear problem in a quasi-Newton solve.

The solution vector passed in should be a serialized or ghosted primal solution

Definition at line 2698 of file dof_map_constraints.C.

2702{
2703 libmesh_assert_equal_to (elem_dofs.size(), rhs.size());
2704
2705 libmesh_assert (solution_local.type() == SERIAL ||
2706 solution_local.type() == GHOSTED);
2707
2708 // check for easy return
2709 if (this->_dof_constraints.empty())
2710 return;
2711
2712 // The constrained RHS is built up as C^T F
2713 // Asymmetric residual terms are added if we do not have x = Cx+h
2716
2717 this->build_constraint_matrix_and_vector (C, H, elem_dofs);
2718
2719 LOG_SCOPE("hetero_cnstrn_elem_res()", "DofMap");
2720
2721 // It is possible that the element is not constrained at all.
2722 if ((C.m() != rhs.size()) ||
2723 (C.n() != elem_dofs.size()))
2724 return;
2725
2726 // Compute the matrix-vector product C^T F
2727 DenseVector<Number> old_rhs(rhs);
2728 C.vector_mult_transpose(rhs, old_rhs);
2729
2730 for (unsigned int i=0,
2731 n_elem_dofs = cast_int<unsigned int>(elem_dofs.size());
2732 i != n_elem_dofs; i++)
2733 {
2734 const dof_id_type dof_id = elem_dofs[i];
2735
2736 if (auto pos = _dof_constraints.find(dof_id);
2737 pos != _dof_constraints.end())
2738 {
2739 // This will put a nonsymmetric entry in the constraint
2740 // row to ensure that the linear system produces the
2741 // correct value for the constrained DOF.
2742 const DofConstraintRow & constraint_row = pos->second;
2743
2744 const DofConstraintValueMap::const_iterator valpos =
2745 _primal_constraint_values.find(dof_id);
2746
2747 Number & rhs_val = rhs(i);
2748 rhs_val = (valpos == _primal_constraint_values.end()) ?
2749 0 : -valpos->second;
2750 for (const auto & [constraining_dof, coef] : constraint_row)
2751 rhs_val -= coef * solution_local(constraining_dof);
2752 rhs_val += solution_local(dof_id);
2753 }
2754 }
2755}

References _dof_constraints, _primal_constraint_values, build_constraint_matrix_and_vector(), libMesh::GHOSTED, libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::m(), libMesh::DenseMatrixBase< T >::n(), libMesh::SERIAL, libMesh::DenseVector< T >::size(), libMesh::NumericVector< T >::type(), and libMesh::DenseMatrix< T >::vector_mult_transpose().

◆ heterogeneously_constrain_element_vector()

void libMesh::DofMap::heterogeneously_constrain_element_vector ( const DenseMatrix< Number > &  matrix,
DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
bool  asymmetric_constraint_rows = true,
int  qoi_index = -1 
) const
inline

Constrains the element vector.

This method requires the element matrix to be square and not-yet-constrained, in which case the elem_dofs correspond to the global DOF indices of both the rows and columns of the element matrix.

The heterogeneous version of this method creates linear systems in which heterogeneously constrained degrees of freedom will solve to their correct offset values, as would be appropriate for finding a solution to a linear problem in a single algebraic solve. The non-heterogeneous version of this method creates linear systems in which even heterogeneously constrained degrees of freedom are solved without offset values taken into account, as would be appropriate for finding linearized updates to a solution in which heterogeneous constraints are already satisfied.

Note the sign difference from the nonlinear heterogeneous constraint method: Solving u:=K\f has the opposite sign convention from u:=u_in-J\r, and we apply heterogeneous constraints accordingly.

By default, the constraints for the primal solution of this system are used. If a non-negative qoi_index is passed in, then the constraints for the corresponding adjoint solution are used instead.

Definition at line 2520 of file dof_map.h.

2522 {}

Referenced by heterogenously_constrain_element_vector().

◆ heterogenously_constrain_element_matrix_and_vector()

void libMesh::DofMap::heterogenously_constrain_element_matrix_and_vector ( DenseMatrix< Number > &  matrix,
DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
bool  asymmetric_constraint_rows = true,
int  qoi_index = -1 
) const
inline

Definition at line 1395 of file dof_map.h.

1400 {
1402 (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1403 }
void heterogeneously_constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
Constrains the element matrix and vector.
Definition dof_map.h:2517

References heterogeneously_constrain_element_matrix_and_vector().

Referenced by assemble_stokes(), and libMesh::System::solve_for_unconstrained_dofs().

◆ heterogenously_constrain_element_vector()

void libMesh::DofMap::heterogenously_constrain_element_vector ( const DenseMatrix< Number > &  matrix,
DenseVector< Number > &  rhs,
std::vector< dof_id_type > &  elem_dofs,
bool  asymmetric_constraint_rows = true,
int  qoi_index = -1 
) const
inline

Definition at line 1439 of file dof_map.h.

1444 {
1446 (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1447 }
void heterogeneously_constrain_element_vector(const DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true, int qoi_index=-1) const
Constrains the element vector.
Definition dof_map.h:2521

References heterogeneously_constrain_element_vector().

◆ identify_variable_groups() [1/2]

bool libMesh::DofMap::identify_variable_groups ( ) const
inline
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2970 of file dof_map.h.

2971{
2973}
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition dof_map.h:2137

References _identify_variable_groups.

◆ identify_variable_groups() [2/2]

void libMesh::DofMap::identify_variable_groups ( const bool  ivg)
inline

Toggle automatic VariableGroup identification.

Definition at line 2976 of file dof_map.h.

2977{
2979}

References _identify_variable_groups.

◆ increment_constructor_count()

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 183 of file reference_counter.h.

184{
185 libmesh_try
186 {
187 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188 std::pair<unsigned int, unsigned int> & p = _counts[name];
189 p.first++;
190 }
191 libmesh_catch (...)
192 {
193 auto stream = libMesh::err.get();
194 stream->exceptions(stream->goodbit); // stream must not throw
195 libMesh::err << "Encountered unrecoverable error while calling "
196 << "ReferenceCounter::increment_constructor_count() "
197 << "for a(n) " << name << " object." << std::endl;
198 std::terminate();
199 }
200}
streamT * get()
Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go th...
OStreamProxy err

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< T >::ReferenceCountedObject(), libMesh::ReferenceCountedObject< T >::ReferenceCountedObject(), and libMesh::ReferenceCountedObject< T >::ReferenceCountedObject().

◆ increment_destructor_count()

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 207 of file reference_counter.h.

208{
209 libmesh_try
210 {
211 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212 std::pair<unsigned int, unsigned int> & p = _counts[name];
213 p.second++;
214 }
215 libmesh_catch (...)
216 {
217 auto stream = libMesh::err.get();
218 stream->exceptions(stream->goodbit); // stream must not throw
219 libMesh::err << "Encountered unrecoverable error while calling "
220 << "ReferenceCounter::increment_destructor_count() "
221 << "for a(n) " << name << " object." << std::endl;
222 std::terminate();
223 }
224}

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< T >::~ReferenceCountedObject().

◆ invalidate_dofs()

void libMesh::DofMap::invalidate_dofs ( MeshBase &  mesh) const
private

Invalidates all active DofObject dofs for this system.

Definition at line 857 of file dof_map.C.

858{
859 const unsigned int sys_num = this->sys_number();
860
861 // All the nodes
862 for (auto & node : mesh.node_ptr_range())
863 node->invalidate_dofs(sys_num);
864
865 // All the active elements.
866 for (auto & elem : mesh.active_element_ptr_range())
867 elem->invalidate_dofs(sys_num);
868}

References mesh.

◆ is_attached()

bool libMesh::DofMap::is_attached ( SparseMatrix< Number > &  matrix)

Matrices should not be attached more than once.

We can test for an already-attached matrix if necessary using is_attached

Definition at line 296 of file dof_map.C.

297{
298 return (std::find(_matrices.begin(), _matrices.end(),
299 &matrix) != _matrices.end());
300}

References _matrices.

Referenced by OverlappingCouplingGhostingTest::run_sparsity_pattern_test().

◆ is_constrained_dof()

bool libMesh::DofMap::is_constrained_dof ( const dof_id_type  dof) const
inline

◆ is_constrained_node()

bool libMesh::DofMap::is_constrained_node ( const Node *  node) const
inline
Returns
true if the Node is constrained, false otherwise.

Definition at line 2423 of file dof_map.h.

2428{
2429#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2430 if (_node_constraints.count(node))
2431 return true;
2432#endif
2433
2434 return false;
2435}

References _node_constraints.

Referenced by allgather_recursive_constraints(), and scatter_constraints().

◆ is_evaluable()

template<typename DofObjectSubclass >
template LIBMESH_EXPORT bool libMesh::DofMap::is_evaluable< Node > ( const DofObjectSubclass &  obj,
unsigned int  var_num = libMesh::invalid_uint 
) const
Returns
true iff our solutions can be locally evaluated on obj (which should be an Elem or a Node) for variable number var_num (for all variables, if var_num is invalid_uint)

Definition at line 2675 of file dof_map.C.

2677{
2678 // Everything is evaluable on a local object
2679 if (obj.processor_id() == this->processor_id())
2680 return true;
2681
2682 std::vector<dof_id_type> di;
2683
2684 if (var_num == libMesh::invalid_uint)
2685 this->dof_indices(&obj, di);
2686 else
2687 this->dof_indices(&obj, di, var_num);
2688
2689 return this->all_semilocal_indices(di);
2690}
bool all_semilocal_indices(const std::vector< dof_id_type > &dof_indices) const
Definition dof_map.C:2662

References libMesh::invalid_uint.

Referenced by libMesh::MeshFunction::check_found_elem(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), DefaultCouplingTest::testCoupling(), and PointNeighborCouplingTest::testCoupling().

◆ is_periodic_boundary()

bool libMesh::DofMap::is_periodic_boundary ( const boundary_id_type  boundaryid) const
Returns
true if the boundary given by boundaryid is periodic, false otherwise

Definition at line 218 of file dof_map.C.

219{
220 if (_periodic_boundaries->count(boundaryid) != 0)
221 return true;
222
223 return false;
224}

References _periodic_boundaries.

◆ local_index()

bool libMesh::DofMap::local_index ( dof_id_type  dof_index) const
inline

◆ local_variable_indices() [1/2]

template<typename T , std::enable_if_t< std::is_same_v< T, dof_id_type >||std::is_same_v< T, std::vector< dof_id_type > >, int > >
void libMesh::DofMap::local_variable_indices ( T &  idx,
const MeshBase &  mesh,
unsigned int  var_num 
) const

If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices which belong to the given variable number and live on the current processor.

Definition at line 1124 of file dof_map.C.

1127{
1128 // Only used if T == dof_id_type to keep track of the greatest dof we've seen
1129 dof_id_type greatest = 0;
1130
1131 if constexpr (std::is_same_v<T, dof_id_type>)
1132 idx = 0;
1133 else if constexpr (std::is_same_v<T, std::vector<dof_id_type>>)
1134 idx.clear();
1135
1136 // Count dofs in the *exact* order that distribute_dofs numbered
1137 // them, so that we can assume ascending indices and use push_back
1138 // instead of find+insert.
1139
1140 const unsigned int sys_num = this->sys_number();
1141
1142 // If this isn't a SCALAR variable, we need to find all its field
1143 // dofs on the mesh
1144 if (this->variable_type(var_num).family != SCALAR)
1145 {
1146 const Variable & var(this->variable(var_num));
1147
1148 for (auto & elem : mesh.active_local_element_ptr_range())
1149 {
1150 if (!var.active_on_subdomain(elem->subdomain_id()))
1151 continue;
1152
1153 // Only count dofs connected to active
1154 // elements on this processor.
1155 const unsigned int n_nodes = elem->n_nodes();
1156
1157 // First get any new nodal DOFS
1158 for (unsigned int n=0; n<n_nodes; n++)
1159 {
1160 const Node & node = elem->node_ref(n);
1161
1162 if (node.processor_id() != this->processor_id())
1163 continue;
1164
1165 const unsigned int n_comp = node.n_comp(sys_num, var_num);
1166 for(unsigned int i=0; i<n_comp; i++)
1167 {
1168 const dof_id_type index = node.dof_number(sys_num,var_num,i);
1169 libmesh_assert (this->local_index(index));
1170
1171 if constexpr (std::is_same_v<T, dof_id_type>)
1172 {
1173 if (idx == 0 || index > greatest)
1174 { idx++; greatest = index; }
1175 }
1176 else if constexpr (std::is_same_v<T, std::vector<dof_id_type>>)
1177 {
1178 if (idx.empty() || index > idx.back())
1179 idx.push_back(index);
1180 }
1181 }
1182 }
1183
1184 // Next get any new element DOFS
1185 const unsigned int n_comp = elem->n_comp(sys_num, var_num);
1186 for (unsigned int i=0; i<n_comp; i++)
1187 {
1188 const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1189
1190 if constexpr (std::is_same_v<T, dof_id_type>)
1191 {
1192 if (idx == 0 || index > greatest)
1193 { idx++; greatest = index; }
1194 }
1195 else if constexpr (std::is_same_v<T, std::vector<dof_id_type>>)
1196 {
1197 if (idx.empty() || index > idx.back())
1198 idx.push_back(index);
1199 }
1200 }
1201 } // done looping over elements
1202
1203
1204 // we may have missed assigning DOFs to nodes that we own
1205 // but to which we have no connected elements matching our
1206 // variable restriction criterion. this will happen, for example,
1207 // if variable V is restricted to subdomain S. We may not own
1208 // any elements which live in S, but we may own nodes which are
1209 // *connected* to elements which do. in this scenario these nodes
1210 // will presently have unnumbered DOFs. we need to take care of
1211 // them here since we own them and no other processor will touch them.
1212 for (const auto & node : mesh.local_node_ptr_range())
1213 {
1214 libmesh_assert(node);
1215
1216 const unsigned int n_comp = node->n_comp(sys_num, var_num);
1217 for (unsigned int i=0; i<n_comp; i++)
1218 {
1219 const dof_id_type index = node->dof_number(sys_num,var_num,i);
1220
1221 if constexpr (std::is_same_v<T, dof_id_type>)
1222 {
1223 if (idx == 0 || index > greatest)
1224 { idx++; greatest = index; }
1225 }
1226 else if constexpr (std::is_same_v<T, std::vector<dof_id_type>>)
1227 {
1228 if (idx.empty() || index > idx.back())
1229 idx.push_back(index);
1230 }
1231 }
1232 }
1233 }
1234 // Otherwise, count up the SCALAR dofs, if we're on the processor
1235 // that holds this SCALAR variable
1236 else if (this->processor_id() == (this->n_processors()-1))
1237 {
1238 std::vector<dof_id_type> di_scalar;
1239 this->SCALAR_dof_indices(di_scalar,var_num);
1240
1241 if constexpr (std::is_same_v<T, dof_id_type>)
1242 idx += std::distance(di_scalar.begin(), di_scalar.end());
1243 else if constexpr (std::is_same_v<T, std::vector<dof_id_type>>)
1244 idx.insert(idx.end(), di_scalar.begin(), di_scalar.end());
1245 }
1246}
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.

References libMesh::Variable::active_on_subdomain(), libMesh::DofObject::dof_number(), libMesh::libmesh_assert(), mesh, libMesh::DofObject::n_comp(), n_nodes, libMesh::DofObject::processor_id(), and libMesh::SCALAR.

Referenced by libMesh::PetscDMWrapper::init_petscdm(), local_variable_indices(), n_local_dofs(), libMesh::petsc_auto_fieldsplit(), libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), and SystemsTest::testBlockRestrictedVarNDofs().

◆ local_variable_indices() [2/2]

template<typename T , std::enable_if_t< std::is_same_v< T, dof_id_type >||std::is_same_v< T, std::vector< dof_id_type > >, int > = 0>
void libMesh::DofMap::local_variable_indices ( T &  idx,
unsigned int  var_num 
) const
inline

If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices which belong to the given variable number and live on the current processor.

Definition at line 1042 of file dof_map.h.

1043 { this->local_variable_indices(idx, this->_mesh, var_num); }
void local_variable_indices(T &idx, const MeshBase &mesh, unsigned int var_num) const
If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an array of, those dof indices w...
Definition dof_map.C:1124

References _mesh, and local_variable_indices().

◆ max_constraint_error()

std::pair< Real, Real > libMesh::DofMap::max_constraint_error ( const System &  system,
NumericVector< Number > *  v = nullptr 
) const

Tests the constrained degrees of freedom on the numeric vector v, which represents a solution defined on the mesh, returning a pair whose first entry is the maximum absolute error on a constrained DoF and whose second entry is the maximum relative error.

Useful for debugging purposes.

If v == nullptr, the system solution vector is tested.

Definition at line 3351 of file dof_map_constraints.C.

3353{
3354 if (!v)
3355 v = system.solution.get();
3356 NumericVector<Number> & vec = *v;
3357
3358 // We'll assume the vector is closed
3359 libmesh_assert (vec.closed());
3360
3361 Real max_absolute_error = 0., max_relative_error = 0.;
3362
3363 const MeshBase & mesh = system.get_mesh();
3364
3365 libmesh_assert_equal_to (this, &(system.get_dof_map()));
3366
3367 // indices on each element
3368 std::vector<dof_id_type> local_dof_indices;
3369
3370 for (const auto & elem : mesh.active_local_element_ptr_range())
3371 {
3372 this->dof_indices(elem, local_dof_indices);
3373 std::vector<dof_id_type> raw_dof_indices = local_dof_indices;
3374
3375 // Constraint matrix for each element
3377
3378 this->build_constraint_matrix (C, local_dof_indices);
3379
3380 // Continue if the element is unconstrained
3381 if (!C.m())
3382 continue;
3383
3384 libmesh_assert_equal_to (C.m(), raw_dof_indices.size());
3385 libmesh_assert_equal_to (C.n(), local_dof_indices.size());
3386
3387 for (auto i : make_range(C.m()))
3388 {
3389 // Recalculate any constrained dof owned by this processor
3390 dof_id_type global_dof = raw_dof_indices[i];
3391 if (this->is_constrained_dof(global_dof) &&
3392 global_dof >= vec.first_local_index() &&
3393 global_dof < vec.last_local_index())
3394 {
3395#ifndef NDEBUG
3396 DofConstraints::const_iterator
3397 pos = _dof_constraints.find(global_dof);
3398
3399 libmesh_assert (pos != _dof_constraints.end());
3400#endif
3401
3402 Number exact_value = 0;
3403 DofConstraintValueMap::const_iterator rhsit =
3404 _primal_constraint_values.find(global_dof);
3405 if (rhsit != _primal_constraint_values.end())
3406 exact_value = rhsit->second;
3407
3408 for (auto j : make_range(C.n()))
3409 {
3410 if (local_dof_indices[j] != global_dof)
3411 exact_value += C(i,j) *
3412 vec(local_dof_indices[j]);
3413 }
3414
3415 max_absolute_error = std::max(max_absolute_error,
3416 std::abs(vec(global_dof) - exact_value));
3417 max_relative_error = std::max(max_relative_error,
3418 std::abs(vec(global_dof) - exact_value)
3419 / std::abs(exact_value));
3420 }
3421 }
3422 }
3423
3424 return std::pair<Real, Real>(max_absolute_error, max_relative_error);
3425}
Number exact_value(const Point &p, const Parameters &parameters, const std::string &, const std::string &)
This is the MeshBase class.
Definition mesh_base.h:81
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual bool closed() const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1655
const DofMap & get_dof_map() const
Definition system.h:2417
const MeshBase & get_mesh() const
Definition system.h:2401

References _dof_constraints, _primal_constraint_values, build_constraint_matrix(), libMesh::NumericVector< T >::closed(), dof_indices(), exact_value(), libMesh::NumericVector< T >::first_local_index(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), is_constrained_dof(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), libMesh::DenseMatrixBase< T >::m(), libMesh::make_range(), mesh, libMesh::DenseMatrixBase< T >::n(), libMesh::Real, and libMesh::System::solution.

◆ merge_ghost_functor_outputs()

void libMesh::DofMap::merge_ghost_functor_outputs ( GhostingFunctor::map_type &  elements_to_ghost,
CouplingMatricesSet &  temporary_coupling_matrices,
const GhostingFunctorIterator &  gf_begin,
const GhostingFunctorIterator &  gf_end,
const MeshBase::const_element_iterator &  elems_begin,
const MeshBase::const_element_iterator &  elems_end,
processor_id_type  p 
)
staticprivate

Definition at line 1586 of file dof_map.C.

1594{
1595 for (const auto & gf : as_range(gf_begin, gf_end))
1596 {
1597 GhostingFunctor::map_type more_elements_to_ghost;
1598
1599 libmesh_assert(gf);
1600 (*gf)(elems_begin, elems_end, p, more_elements_to_ghost);
1601
1602 // A GhostingFunctor should only return active elements, but
1603 // I forgot to *document* that, so let's go as easy as we
1604 // can on functors that return inactive elements.
1605#if defined(LIBMESH_ENABLE_DEPRECATED) && defined(LIBMESH_ENABLE_AMR)
1606 std::vector<std::pair<const Elem*, const CouplingMatrix*>> children_to_couple;
1607 for (auto it = more_elements_to_ghost.begin();
1608 it != more_elements_to_ghost.end();)
1609 {
1610 const Elem * elem = it->first;
1611 if (!elem->active())
1612 {
1613 libmesh_deprecated();
1614 std::vector<const Elem*> children_to_ghost;
1615 elem->active_family_tree(children_to_ghost,
1616 /*reset=*/ false);
1617 for (const Elem * child : children_to_ghost)
1618 if (child->processor_id() != p)
1619 children_to_couple.emplace_back(child, it->second);
1620
1621 it = more_elements_to_ghost.erase(it);
1622 }
1623 else
1624 ++it;
1625 }
1626 more_elements_to_ghost.insert(children_to_couple.begin(),
1627 children_to_couple.end());
1628#endif
1629
1630 for (const auto & [elem, elem_cm] : more_elements_to_ghost)
1631 {
1632 // At this point we should only have active elements, even
1633 // if we had to fix up gf output to get here.
1634 libmesh_assert(elem->active());
1635
1636 if (const auto existing_it = elements_to_ghost.find(elem);
1637 existing_it == elements_to_ghost.end())
1638 elements_to_ghost.emplace(elem, elem_cm);
1639 else
1640 {
1641 if (existing_it->second)
1642 {
1643 if (elem_cm)
1644 {
1645 // If this isn't already a temporary
1646 // then we need to make one so we'll
1647 // have a non-const matrix to merge
1648 if (temporary_coupling_matrices.empty() ||
1649 !temporary_coupling_matrices.count(existing_it->second))
1650 {
1651 // Make copy. This just calls the
1652 // compiler-generated copy constructor
1653 // because the CouplingMatrix class does not
1654 // define a custom copy constructor.
1655 auto result_pr = temporary_coupling_matrices.insert(std::make_unique<CouplingMatrix>(*existing_it->second));
1656 existing_it->second = result_pr.first->get();
1657 }
1658
1659 // Merge elem_cm into existing CouplingMatrix
1660 const_cast<CouplingMatrix &>(*existing_it->second) &= *elem_cm;
1661 }
1662 else // elem_cm == nullptr
1663 {
1664 // Any existing_it matrix merged with a full
1665 // matrix (symbolized as nullptr) gives another
1666 // full matrix (symbolizable as nullptr).
1667
1668 // So if existing_it->second is a temporary then
1669 // we don't need it anymore; we might as well
1670 // remove it to keep the set of temporaries
1671 // small.
1672 if (const auto temp_it = temporary_coupling_matrices.find(existing_it->second);
1673 temp_it != temporary_coupling_matrices.end())
1674 temporary_coupling_matrices.erase(temp_it);
1675
1676 existing_it->second = nullptr;
1677 }
1678 }
1679 // else we have a nullptr already, then we have a full
1680 // coupling matrix, already, and merging with anything
1681 // else won't change that, so we're done.
1682 }
1683 }
1684 }
1685}

References libMesh::Elem::active(), libMesh::Elem::active_family_tree(), libMesh::as_range(), and libMesh::libmesh_assert().

Referenced by libMesh::SparsityPattern::Build::operator()(), and scatter_constraints().

◆ n_components()

unsigned int libMesh::DofMap::n_components ( const MeshBase &  mesh) const
inline
Returns
The total number of scalar components in the system's variables. This will equal n_vars() in the case of all scalar-valued variables. If vector variables are involved, we will need to leverage the mesh

Definition at line 2982 of file dof_map.h.

2983{
2984 if (_variables.empty())
2985 return 0;
2986
2987 const Variable & last = _variables.back();
2988 return last.first_scalar_number() + last.n_components(mesh);
2989}

References _variables, libMesh::Variable::first_scalar_number(), mesh, and libMesh::Variable::n_components().

◆ n_constrained_dofs()

dof_id_type libMesh::DofMap::n_constrained_dofs ( ) const
Returns
The total number of constrained degrees of freedom in the problem.

Definition at line 1714 of file dof_map_constraints.C.

1715{
1716 parallel_object_only();
1717
1718 dof_id_type nc_dofs = this->n_local_constrained_dofs();
1719 this->comm().sum(nc_dofs);
1720 return nc_dofs;
1721}
dof_id_type n_local_constrained_dofs() const

References libMesh::ParallelObject::comm(), n_local_constrained_dofs(), and libMesh::Parallel::Communicator::sum().

Referenced by libMesh::CondensedEigenSystem::initialize_condensed_dofs(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), and MeshInputTest::testDynaReadPatch().

◆ n_constrained_nodes()

dof_id_type libMesh::DofMap::n_constrained_nodes ( ) const
inline
Returns
The total number of constrained Nodes in the mesh.

Definition at line 1066 of file dof_map.h.

1067 { return cast_int<dof_id_type>(_node_constraints.size()); }

References _node_constraints.

◆ n_dofs() [1/2]

dof_id_type libMesh::DofMapBase::n_dofs ( ) const
inline
Returns
The total number of degrees of freedom in the problem.

Definition at line 105 of file dof_map_base.h.

105{ return _n_dfs; }
dof_id_type _n_dfs
Total number of degrees of freedom.

Referenced by _dof_indices(), add_constraint_row(), and process_mesh_constraint_rows().

◆ n_dofs() [2/2]

dof_id_type libMesh::DofMap::n_dofs ( const unsigned int  vn) const
inline

◆ n_dofs_on_processor()

dof_id_type libMesh::DofMapBase::n_dofs_on_processor ( const processor_id_type  proc) const
inlineinherited
Returns
The number of degrees of freedom on partition proc.

Definition at line 197 of file dof_map_base.h.

198{
199 libmesh_assert_less(proc, _first_df.size());
200 return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
201}

References libMesh::DofMapBase::_end_df, and libMesh::DofMapBase::_first_df.

Referenced by libMesh::DofMapBase::n_local_dofs(), and SystemsTest::testProjectMatrix3D().

◆ n_dofs_per_processor()

std::vector< dof_id_type > libMesh::DofMap::n_dofs_per_processor ( const unsigned int  vn) const
inline
Returns
The number of degrees of freedom on each partition for a particular variable vn.

Definition at line 812 of file dof_map.h.

813 {
814 std::vector<dof_id_type> n_local_dofs(this->n_processors(), 0);
815 this->comm().allgather(this->n_local_dofs(vn), n_local_dofs);
816 return n_local_dofs;
817 }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const

References libMesh::Parallel::Communicator::allgather(), libMesh::ParallelObject::comm(), n_local_dofs(), and libMesh::ParallelObject::n_processors().

Referenced by libMesh::PetscPreconditioner< T >::set_hypre_ads_data(), libMesh::PetscPreconditioner< T >::set_hypre_ams_data(), and SystemsTest::test100KVariables().

◆ n_local_constrained_dofs()

dof_id_type libMesh::DofMap::n_local_constrained_dofs ( ) const
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 1724 of file dof_map_constraints.C.

1725{
1726 const DofConstraints::const_iterator lower =
1727 _dof_constraints.lower_bound(this->first_dof()),
1728 upper =
1729 _dof_constraints.lower_bound(this->end_dof());
1730
1731 return cast_int<dof_id_type>(std::distance(lower, upper));
1732}

References _dof_constraints, libMesh::DofMapBase::end_dof(), and libMesh::DofMapBase::first_dof().

Referenced by n_constrained_dofs().

◆ n_local_dofs() [1/2]

dof_id_type libMesh::DofMapBase::n_local_dofs ( ) const
inline
Returns
The number of degrees of freedom on this processor.

Definition at line 115 of file dof_map_base.h.

115{ return this->n_dofs_on_processor(this->processor_id()); }
dof_id_type n_dofs_on_processor(const processor_id_type proc) const

Referenced by n_dofs(), n_dofs_per_processor(), and process_mesh_constraint_rows().

◆ n_local_dofs() [2/2]

dof_id_type libMesh::DofMap::n_local_dofs ( const unsigned int  vn) const
inline

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 85 of file reference_counter.h.

86 { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

References libMesh::ReferenceCounter::_n_objects.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

◆ n_old_dofs()

dof_id_type libMesh::DofMapBase::n_old_dofs ( ) const
inlineinherited
Returns
The total number of degrees of freedom on old_dof_objects

Definition at line 123 of file dof_map_base.h.

123{ return _n_old_dfs; }

References libMesh::DofMapBase::_n_old_dfs.

Referenced by libMesh::BuildProjectionList::operator()().

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 103 of file parallel_object.h.

104 {
105 processor_id_type returnval =
106 cast_int<processor_id_type>(_communicator.size());
107 libmesh_assert(returnval); // We never have an empty comm
108 return returnval;
109 }
processor_id_type size() const

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and libMesh::Parallel::Communicator::size().

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), ExodusC0PolyhedronTest::assert_distributed_if_parallel(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::Partitioner::build_graph(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::NumericVector< T >::is_effectively_ghosted(), libMesh::NumericVector< T >::is_effectively_serial(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::MeshBase::print_constraint_rows(), print_dof_constraints(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::NameBasedIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), scatter_constraints(), libMesh::DistributedMesh::set_next_ids(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DistributedMesh::set_next_unique_ids(), set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusC0PolyhedronTest::test_write_and_read_mixed_hex_tet_block_names_impl(), CheckpointIOTest::testDisjointNeighborPairsCheckpoint(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

◆ n_SCALAR_dofs()

dof_id_type libMesh::DofMap::n_SCALAR_dofs ( ) const
inline
Returns
The number of SCALAR dofs.

Definition at line 793 of file dof_map.h.

793{ return _n_SCALAR_dofs; }

References _n_SCALAR_dofs.

Referenced by libMesh::PetscDMWrapper::set_point_range_in_section().

◆ n_variable_groups()

unsigned int libMesh::DofMap::n_variable_groups ( ) const
inline
Returns
The number of variables in the global solution vector. Defaults to 1, should be 1 for a scalar equation, 3 for 2D incompressible Navier Stokes (u,v,p), etc...

Definition at line 740 of file dof_map.h.

741 { return cast_int<unsigned int>(_variable_groups.size()); }

References _variable_groups.

Referenced by has_blocked_representation(), libMesh::StaticCondensationDofMap::reinit(), reinit(), and set_nonlocal_dof_objects().

◆ n_variables()

unsigned int libMesh::DofMap::n_variables ( ) const
inlineoverridevirtual
Returns
The number of variables in the global solution vector. Defaults to 1, should be 1 for a scalar equation, 3 for 2D incompressible Navier Stokes (u,v,p), etc...

Implements libMesh::DofMapBase.

Definition at line 743 of file dof_map.h.

744 { return cast_int<unsigned int>(_variables.size()); }

References _variables.

Referenced by block_size(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), create_dof_constraints(), DMlibMeshSetSystem_libMesh(), has_blocked_representation(), libMesh::SparsityPattern::Build::operator()(), process_mesh_constraint_rows(), and var_group_from_var_number().

◆ n_vars()

unsigned int libMesh::DofMap::n_vars ( ) const
inline
Returns
The number of variables in the system

Definition at line 2956 of file dof_map.h.

2957{
2958 return cast_int<unsigned int>(_variables.size());
2959}

References _variables.

Referenced by allgather_recursive_constraints(), and create_dof_constraints().

◆ node_constraint_rows_begin()

NodeConstraints::const_iterator libMesh::DofMap::node_constraint_rows_begin ( ) const
inline
Returns
An iterator pointing to the first Node constraint row.

Definition at line 1219 of file dof_map.h.

1220 { return _node_constraints.begin(); }

References _node_constraints.

◆ node_constraint_rows_end()

NodeConstraints::const_iterator libMesh::DofMap::node_constraint_rows_end ( ) const
inline
Returns
An iterator pointing just past the last Node constraint row.

Definition at line 1225 of file dof_map.h.

1226 { return _node_constraints.end(); }

References _node_constraints.

◆ node_ptr()

DofObject * libMesh::DofMap::node_ptr ( MeshBase &  mesh,
dof_id_type  i 
) const
private
Returns
The Node pointer with index i from the mesh.

Definition at line 304 of file dof_map.C.

305{
306 return mesh.node_ptr(i);
307}

References mesh.

◆ old_dof_indices() [1/2]

void libMesh::DofMap::old_dof_indices ( const Elem &  elem,
unsigned int  n,
std::vector< dof_id_type > &  di,
const unsigned int  vn 
) const

Appends to the vector di the old global degree of freedom indices for elem.node_ref(n), for one variable vn.

On hanging nodes with both vertex and non-vertex DoFs, only those indices which are directly supported on elem are included.

Definition at line 2480 of file dof_map.C.

2484{
2485 const DofObject & old_obj = elem.node_ref(n).get_old_dof_object_ref();
2486 this->_node_dof_indices(elem, n, old_obj, di, vn);
2487}

References libMesh::DofObject::get_old_dof_object_ref(), and libMesh::Elem::node_ref().

Referenced by libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), libMesh::BuildProjectionList::operator()(), and libMesh::FEMContext::pre_fe_reinit().

◆ old_dof_indices() [2/2]

void libMesh::DofMap::old_dof_indices ( const Elem *const  elem,
std::vector< dof_id_type > &  di,
const unsigned int  vn = libMesh::invalid_uint 
) const

After a mesh is refined and repartitioned it is possible that the _send_list will need to be augmented.

This is the case when an element is refined and its children end up on different processors than the parent. These children will need values from the parent when projecting the solution onto the refined mesh, hence the parent's DOF indices need to be included in the _send_list. Fills the vector di with the global degree of freedom indices for the element using the DofMap::old_dof_object. If no variable number is specified then all variables are returned.

Definition at line 2696 of file dof_map.C.

2699{
2700 // dof_indices() is a relatively light-weight function; the cost of
2701 // the logging code itself is roughly on par with the time required
2702 // to call dof_indices().
2703 // LOG_SCOPE("old_dof_indices()", "DofMap");
2704
2705 libmesh_assert(elem);
2706
2707 const ElemType type = elem->type();
2708 const unsigned int sys_num = this->sys_number();
2709 const unsigned int n_var_groups = this->n_variable_groups();
2710#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2711 const bool is_inf = elem->infinite();
2712#endif
2713
2714 // If we have dof indices stored on the elem, and there's no chance
2715 // that we only have those indices because we were just p refined,
2716 // then we should have old dof indices too.
2717 libmesh_assert(!elem->has_dofs(sys_num) ||
2718 elem->p_refinement_flag() == Elem::JUST_REFINED ||
2719 elem->get_old_dof_object());
2720
2721 // Clear the DOF indices vector.
2722 di.clear();
2723
2724 // Determine the nodes contributing to element elem
2725 std::vector<const Node *> elem_nodes;
2726 const Node * const * nodes_ptr;
2727 unsigned int n_nodes;
2728 if (elem->type() == TRI3SUBDIVISION)
2729 {
2730 // Subdivision surface FE require the 1-ring around elem
2731 const Tri3Subdivision * sd_elem = static_cast<const Tri3Subdivision *>(elem);
2732 MeshTools::Subdivision::find_one_ring(sd_elem, elem_nodes);
2733 nodes_ptr = elem_nodes.data();
2734 n_nodes = cast_int<unsigned int>(elem_nodes.size());
2735 }
2736 else
2737 {
2738 // All other FE use only the nodes of elem itself
2739 nodes_ptr = elem->get_nodes();
2740 n_nodes = elem->n_nodes();
2741 }
2742
2743 // Get the dof numbers
2744 for (unsigned int vg=0; vg<n_var_groups; vg++)
2745 {
2746 const VariableGroup & var = this->variable_group(vg);
2747 const unsigned int vars_in_group = var.n_variables();
2748
2749 for (unsigned int vig=0; vig<vars_in_group; vig++)
2750 {
2751 const unsigned int v = var.number(vig);
2752 if ((vn == v) || (vn == libMesh::invalid_uint))
2753 {
2754 if (var.type().family == SCALAR &&
2755 (!elem ||
2756 var.active_on_subdomain(elem->subdomain_id())))
2757 {
2758 // We asked for this variable, so add it to the vector.
2759 std::vector<dof_id_type> di_new;
2760 this->SCALAR_dof_indices(di_new,v,true);
2761 di.insert( di.end(), di_new.begin(), di_new.end());
2762 }
2763 else
2764 if (var.active_on_subdomain(elem->subdomain_id()))
2765 { // Do this for all the variables if one was not specified
2766 // or just for the specified variable
2767
2768 FEType fe_type = var.type();
2769 const bool add_p_level = fe_type.p_refinement;
2770
2771 // Increase the polynomial order on p refined elements,
2772 // but make sure you get the right polynomial order for
2773 // the OLD degrees of freedom
2774 int p_adjustment = 0;
2775 if (elem->p_refinement_flag() == Elem::JUST_REFINED)
2776 {
2777 libmesh_assert_greater (elem->p_level(), 0);
2778 p_adjustment = -1;
2779 }
2780 else if (elem->p_refinement_flag() == Elem::JUST_COARSENED)
2781 {
2782 p_adjustment = 1;
2783 }
2784 p_adjustment *= add_p_level;
2785
2786 // Compute the net amount of "extra" order, including Elem::p_level()
2787 int extra_order = int(add_p_level*elem->p_level()) + p_adjustment;
2788
2789 const bool extra_hanging_dofs =
2791
2794
2795 // Get the node-based DOF numbers
2796 for (unsigned int n=0; n<n_nodes; n++)
2797 {
2798 const Node * node = nodes_ptr[n];
2799 const DofObject & old_dof_obj = node->get_old_dof_object_ref();
2800
2801 // There is a potential problem with h refinement. Imagine a
2802 // quad9 that has a linear FE on it. Then, on the hanging side,
2803 // it can falsely identify a DOF at the mid-edge node. This is why
2804 // we call FEInterface instead of node->n_comp() directly.
2805 const unsigned int nc =
2806#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2807 is_inf ?
2808 FEInterface::n_dofs_at_node(var.type(), extra_order, elem, n) :
2809#endif
2810 ndan (type, var.type().order + extra_order, n);
2811
2812 const int n_comp = old_dof_obj.n_comp_group(sys_num,vg);
2813
2814 // If this is a non-vertex on a hanging node with extra
2815 // degrees of freedom, we use the non-vertex dofs (which
2816 // come in reverse order starting from the end, to
2817 // simplify p refinement)
2818 if (extra_hanging_dofs && !elem->is_vertex(n))
2819 {
2820 const int dof_offset = n_comp - nc;
2821
2822 // We should never have fewer dofs than necessary on a
2823 // node unless we're getting indices on a parent element
2824 // or a just-coarsened element
2825 if (dof_offset < 0)
2826 {
2827 libmesh_assert(!elem->active() || elem->refinement_flag() ==
2829 di.resize(di.size() + nc, DofObject::invalid_id);
2830 }
2831 else
2832 for (int i=n_comp-1; i>=dof_offset; i--)
2833 {
2834 const dof_id_type d =
2835 old_dof_obj.dof_number(sys_num, vg, vig, i, n_comp);
2836
2837 // On a newly-expanded subdomain, we
2838 // may have some DoFs that didn't
2839 // exist in the old system, in which
2840 // case we can't assert this:
2841 // libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2842
2843 di.push_back(d);
2844 }
2845 }
2846 // If this is a vertex or an element without extra hanging
2847 // dofs, our dofs come in forward order coming from the
2848 // beginning. But we still might not have all
2849 // those dofs on the old_dof_obj, in cases
2850 // where a subdomain-restricted variable just
2851 // had its subdomain expanded.
2852 else
2853 {
2854 const unsigned int old_nc =
2855 std::min(static_cast<unsigned int>(n_comp), nc);
2856 for (unsigned int i=0; i != old_nc; ++i)
2857 {
2858 const dof_id_type d =
2859 old_dof_obj.dof_number(sys_num, vg, vig, i, n_comp);
2860
2861 libmesh_assert_not_equal_to (d, DofObject::invalid_id);
2862
2863 di.push_back(d);
2864 }
2865 for (unsigned int i=old_nc; i != nc; ++i)
2866 di.push_back(DofObject::invalid_id);
2867 }
2868 }
2869
2870 // If there are any element-based DOF numbers, get them
2871 const unsigned int nc =
2872 FEInterface::n_dofs_per_elem(fe_type, extra_order, elem);
2873
2874 if (nc != 0)
2875 {
2876 const DofObject & old_dof_obj = elem->get_old_dof_object_ref();
2877
2878 const unsigned int n_comp =
2879 old_dof_obj.n_comp_group(sys_num,vg);
2880
2881 if (old_dof_obj.n_systems() > sys_num &&
2882 nc <= n_comp)
2883 {
2884
2885 for (unsigned int i=0; i<nc; i++)
2886 {
2887 const dof_id_type d =
2888 old_dof_obj.dof_number(sys_num, vg, vig, i, n_comp);
2889
2890 di.push_back(d);
2891 }
2892 }
2893 else
2894 {
2895 // We should never have fewer dofs than
2896 // necessary on an element unless we're
2897 // getting indices on a parent element, a
2898 // just-coarsened element ... or a
2899 // subdomain-restricted variable with a
2900 // just-expanded subdomain
2901 // libmesh_assert(!elem->active() || fe_type.family == LAGRANGE ||
2902 // elem->refinement_flag() == Elem::JUST_COARSENED);
2903 di.resize(di.size() + nc, DofObject::invalid_id);
2904 }
2905 }
2906 }
2907 }
2908 } // end loop over variables within group
2909 } // end loop over variable groups
2910}
@ JUST_COARSENED
Definition elem.h:1571

References libMesh::Elem::active(), libMesh::Variable::active_on_subdomain(), libMesh::DofObject::dof_number(), libMesh::FEType::family, libMesh::Elem::get_nodes(), libMesh::DofObject::get_old_dof_object(), libMesh::DofObject::get_old_dof_object_ref(), libMesh::DofObject::has_dofs(), libMesh::Elem::infinite(), int, libMesh::invalid_uint, libMesh::Elem::is_vertex(), libMesh::libmesh_assert(), libMesh::DofObject::n_comp_group(), libMesh::Elem::n_nodes(), n_nodes, libMesh::DofObject::n_systems(), libMesh::VariableGroup::n_variables(), libMesh::VariableGroup::number(), libMesh::FEType::order, libMesh::Elem::p_level(), libMesh::FEType::p_refinement, libMesh::Elem::p_refinement_flag(), libMesh::Elem::refinement_flag(), libMesh::SCALAR, libMesh::Elem::subdomain_id(), libMesh::TRI3SUBDIVISION, libMesh::Variable::type(), and libMesh::Elem::type().

◆ prepare_send_list()

void libMesh::DofMap::prepare_send_list ( )

Takes the _send_list vector (which may have duplicate entries) and sorts it.

The duplicate entries are then removed, resulting in a sorted _send_list with unique entries. Also calls any user-provided methods for adding to the send list.

Definition at line 1837 of file dof_map.C.

1838{
1839 LOG_SCOPE("prepare_send_list()", "DofMap");
1840
1841 // Return immediately if there's no ghost data
1842 if (this->n_processors() == 1)
1843 return;
1844
1845 // Check to see if we have any extra stuff to add to the send_list
1847 {
1849 {
1850 libmesh_here();
1851 libMesh::out << "WARNING: You have specified both an extra send list function and object.\n"
1852 << " Are you sure this is what you meant to do??"
1853 << std::endl;
1854 }
1855
1857 }
1858
1861
1862 // First sort the send list. After this
1863 // duplicated elements will be adjacent in the
1864 // vector
1865 std::sort(_send_list.begin(), _send_list.end());
1866
1867 // Now use std::unique to remove duplicate entries
1868 std::vector<dof_id_type>::iterator new_end =
1869 std::unique (_send_list.begin(), _send_list.end());
1870
1871 // Remove the end of the send_list. Use the "swap trick"
1872 // from Effective STL
1873 std::vector<dof_id_type> (_send_list.begin(), new_end).swap (_send_list);
1874
1875 // Make sure the send list has nothing invalid in it.
1876 libmesh_assert(_send_list.empty() || _send_list.back() < this->n_dofs());
1877}
virtual void augment_send_list(std::vector< dof_id_type > &send_list)=0
User-defined function to augment the send list.

References libMesh::libmesh_assert(), and libMesh::out.

Referenced by libMesh::PetscDMWrapper::init_petscdm(), and libMesh::System::reinit_constraints().

◆ print_dof_constraints()

void libMesh::DofMap::print_dof_constraints ( std::ostream &  os = libMesh::out,
bool  print_nonlocal = false 
) const

Prints (from processor 0) all DoF and Node constraints.

If print_nonlocal is true, then each constraint is printed once for each processor that knows about it, which may be useful for DistributedMesh debugging.

Definition at line 2249 of file dof_map_constraints.C.

2251{
2252 parallel_object_only();
2253
2254 std::string local_constraints =
2255 this->get_local_constraints(print_nonlocal);
2256
2257 if (this->processor_id())
2258 {
2259 this->comm().send(0, local_constraints);
2260 }
2261 else
2262 {
2263 os << "Processor 0:\n";
2264 os << local_constraints;
2265
2266 for (auto p : IntRange<processor_id_type>(1, this->n_processors()))
2267 {
2268 this->comm().receive(p, local_constraints);
2269 os << "Processor " << p << ":\n";
2270 os << local_constraints;
2271 }
2272 }
2273}
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
std::string get_local_constraints(bool print_nonlocal=false) const
Gets a string reporting all DoF and Node constraints local to this processor.
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Definition int_range.h:54

References libMesh::ParallelObject::comm(), get_local_constraints(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), and libMesh::Parallel::Communicator::send().

Referenced by main(), and libMesh::System::reinit_constraints().

◆ print_info() [1/2]

void libMesh::DofMap::print_info ( std::ostream &  os = libMesh::out) const

Prints summary info about the sparsity bandwidth and constraints.

Definition at line 2980 of file dof_map.C.

2981{
2982 os << this->get_info();
2983}
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition dof_map.C:2987

◆ print_info() [2/2]

void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 81 of file reference_counter.C.

82{
84 out_stream << ReferenceCounter::get_info();
85}
static std::string get_info()
Gets a string containing the reference information.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::~LibMeshInit().

◆ process_constraints()

void libMesh::DofMap::process_constraints ( MeshBase &  mesh)

Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dofs, then adds unconstrained dofs to the send_list and prepares that for use.

This should be run after both system (create_dof_constraints) and user constraints have all been added.

Definition at line 4337 of file dof_map_constraints.C.

4338{
4339 // We've computed our local constraints, but they may depend on
4340 // non-local constraints that we'll need to take into account.
4342
4344 {
4345 // Optionally check for constraint loops and throw an error
4346 // if they're detected. We always do this check below in dbg/devel
4347 // mode but here we optionally do it in opt mode as well.
4349 }
4350
4351 // Adjoints will be constrained where the primal is
4352 // Therefore, we will expand the adjoint_constraint_values
4353 // map whenever the primal_constraint_values map is expanded
4354
4355 // First, figure out the total number of QoIs
4356 const unsigned int max_qoi_num =
4358 0 : _adjoint_constraint_values.rbegin()->first+1;
4359
4360 // Create a set containing the DOFs we already depend on
4361 typedef std::set<dof_id_type> RCSet;
4362 RCSet unexpanded_set;
4363
4364 for (const auto & i : _dof_constraints)
4365 unexpanded_set.insert(i.first);
4366
4367 while (!unexpanded_set.empty())
4368 for (RCSet::iterator i = unexpanded_set.begin();
4369 i != unexpanded_set.end(); /* nothing */)
4370 {
4371 // If the DOF is constrained
4372 DofConstraints::iterator
4373 pos = _dof_constraints.find(*i);
4374
4375 libmesh_assert (pos != _dof_constraints.end());
4376
4377 DofConstraintRow & constraint_row = pos->second;
4378
4379 DofConstraintValueMap::iterator rhsit =
4381 Number constraint_rhs = (rhsit == _primal_constraint_values.end()) ?
4382 0 : rhsit->second;
4383
4384 // A vector of DofConstraintValueMaps for each adjoint variable
4385 std::vector<DofConstraintValueMap::iterator> adjoint_rhs_iterators;
4386 adjoint_rhs_iterators.resize(max_qoi_num);
4387
4388 // Another to hold the adjoint constraint rhs
4389 std::vector<Number> adjoint_constraint_rhs(max_qoi_num, 0.0);
4390
4391 // Find and gather recursive constraints for each adjoint variable
4392 for (auto & adjoint_map : _adjoint_constraint_values)
4393 {
4394 const std::size_t q = adjoint_map.first;
4395 adjoint_rhs_iterators[q] = adjoint_map.second.find(*i);
4396
4397 adjoint_constraint_rhs[q] =
4398 (adjoint_rhs_iterators[q] == adjoint_map.second.end()) ?
4399 0 : adjoint_rhs_iterators[q]->second;
4400 }
4401
4402 std::vector<dof_id_type> constraints_to_expand;
4403
4404 for (const auto & item : constraint_row)
4405 if (item.first != *i && this->is_constrained_dof(item.first))
4406 {
4407 unexpanded_set.insert(item.first);
4408 constraints_to_expand.push_back(item.first);
4409 }
4410
4411 for (const auto & expandable : constraints_to_expand)
4412 {
4413 const Real this_coef = constraint_row[expandable];
4414
4415 DofConstraints::const_iterator
4416 subpos = _dof_constraints.find(expandable);
4417
4418 libmesh_assert (subpos != _dof_constraints.end());
4419
4420 const DofConstraintRow & subconstraint_row = subpos->second;
4421
4422 for (const auto & item : subconstraint_row)
4423 {
4424 // Assert that the constraint does not form a cycle.
4425 libmesh_assert(item.first != expandable);
4426 constraint_row[item.first] += item.second * this_coef;
4427 }
4428
4429 if (auto subrhsit = _primal_constraint_values.find(expandable);
4430 subrhsit != _primal_constraint_values.end())
4431 constraint_rhs += subrhsit->second * this_coef;
4432
4433 // Find and gather recursive constraints for each adjoint variable
4434 for (const auto & adjoint_map : _adjoint_constraint_values)
4435 {
4436 if (auto adjoint_subrhsit = adjoint_map.second.find(expandable);
4437 adjoint_subrhsit != adjoint_map.second.end())
4438 adjoint_constraint_rhs[adjoint_map.first] += adjoint_subrhsit->second * this_coef;
4439 }
4440
4441 constraint_row.erase(expandable);
4442 }
4443
4444 if (rhsit == _primal_constraint_values.end())
4445 {
4446 if (constraint_rhs != Number(0))
4447 _primal_constraint_values[*i] = constraint_rhs;
4448 else
4449 _primal_constraint_values.erase(*i);
4450 }
4451 else
4452 {
4453 if (constraint_rhs != Number(0))
4454 rhsit->second = constraint_rhs;
4455 else
4456 _primal_constraint_values.erase(rhsit);
4457 }
4458
4459 // Finally fill in the adjoint constraints for each adjoint variable if possible
4460 for (auto & adjoint_map : _adjoint_constraint_values)
4461 {
4462 const std::size_t q = adjoint_map.first;
4463
4464 if(adjoint_rhs_iterators[q] == adjoint_map.second.end())
4465 {
4466 if (adjoint_constraint_rhs[q] != Number(0))
4467 (adjoint_map.second)[*i] = adjoint_constraint_rhs[q];
4468 else
4469 adjoint_map.second.erase(*i);
4470 }
4471 else
4472 {
4473 if (adjoint_constraint_rhs[q] != Number(0))
4474 adjoint_rhs_iterators[q]->second = adjoint_constraint_rhs[q];
4475 else
4476 adjoint_map.second.erase(adjoint_rhs_iterators[q]);
4477 }
4478 }
4479
4480 if (constraints_to_expand.empty())
4481 i = unexpanded_set.erase(i);
4482 else
4483 ++i;
4484 }
4485
4486 // In parallel we can't guarantee that nodes/dofs which constrain
4487 // others are on processors which are aware of that constraint, yet
4488 // we need such awareness for sparsity pattern generation. So send
4489 // other processors any constraints they might need to know about.
4490 this->scatter_constraints(mesh);
4491
4492 // Now that we have our root constraint dependencies sorted out, add
4493 // them to the send_list
4494 this->add_constraints_to_send_list(mesh);
4495}
void allgather_recursive_constraints(MeshBase &)
Gathers constraint equation dependencies from other processors.
void scatter_constraints(MeshBase &)
Sends constraint equations to constraining processors.
void add_constraints_to_send_list(const MeshBase &mesh)
Adds entries to the _send_list vector corresponding to DoFs which are dependencies for constraint equ...

References _adjoint_constraint_values, _dof_constraints, _error_on_constraint_loop, _primal_constraint_values, add_constraints_to_send_list(), allgather_recursive_constraints(), check_for_constraint_loops(), libMesh::libmesh_assert(), libMesh::Real, and scatter_constraints().

Referenced by libMesh::System::reinit_constraints().

◆ process_mesh_constraint_rows()

void libMesh::DofMap::process_mesh_constraint_rows ( const MeshBase &  mesh)
private

Adds any spline constraints from the Mesh to our DoF constraints.

If any Dirichlet constraints exist on spline-constrained nodes, l2-projects those constraints onto the spline basis.

Definition at line 1891 of file dof_map_constraints.C.

1892{
1893 // If we already have simple Dirichlet constraints (with right hand
1894 // sides but with no coupling between DoFs) on spline-constrained FE
1895 // nodes, then we'll need a solve to compute the corresponding
1896 // constraints on the relevant spline nodes. (If we already have
1897 // constraints with coupling between DoFs on spline-constrained FE
1898 // nodes, then we'll need to go sit down and cry until we figure out
1899 // how to handle that.)
1900
1901 const auto & constraint_rows = mesh.get_constraint_rows();
1902
1903 // This routine is too expensive to use unless we really might
1904 // need it
1905#ifdef DEBUG
1906 bool constraint_rows_empty = constraint_rows.empty();
1907 this->comm().min(constraint_rows_empty);
1908 libmesh_assert_equal_to(constraint_rows_empty, !mesh.n_constraint_rows());
1909#endif
1910
1911 if (!mesh.n_constraint_rows())
1912 return;
1913
1914 // We can't handle periodic boundary conditions on spline meshes
1915 // yet.
1916#ifdef LIBMESH_ENABLE_PERIODIC
1917 libmesh_error_msg_if (!_periodic_boundaries->empty(),
1918 "Periodic boundary conditions are not yet implemented for spline meshes");
1919#endif
1920
1921 // We can handle existing Dirichlet constraints, but we'll need
1922 // to do solves to project them down onto the spline basis.
1923 std::unique_ptr<SparsityPattern::Build> sp;
1924 std::unique_ptr<SparseMatrix<Number>> mat;
1925
1926 const unsigned int n_adjoint_rhs =
1928
1929 // [0] for primal rhs, [q+1] for adjoint qoi q
1930 std::vector<std::unique_ptr<NumericVector<Number>>>
1931 solve_rhs(n_adjoint_rhs+1);
1932
1933 // Keep track of which spline DoFs will be Dirichlet.
1934 // We use a set here to make it easier to find what processors
1935 // to send the DoFs to later.
1936 std::set<dof_id_type> my_dirichlet_spline_dofs;
1937
1938 // And keep track of which non-spline Dofs were Dirichlet
1939 std::unordered_set<dof_id_type> was_previously_constrained;
1940
1941 const unsigned int sys_num = this->sys_number();
1942 for (auto & node_row : constraint_rows)
1943 {
1944 const Node * node = node_row.first;
1945 libmesh_assert(node == mesh.node_ptr(node->id()));
1946
1947 // Each processor only computes its own (and in distributed
1948 // cases, is only guaranteed to have the dependency data to
1949 // compute its own) constraints here.
1950 if (node->processor_id() != mesh.processor_id())
1951 continue;
1952
1953 for (auto var_num : IntRange<unsigned int>(0, this->n_variables()))
1954 {
1955 const FEFamily & fe_family = this->variable_type(var_num).family;
1956
1957 // constraint_rows only applies to nodal variables
1958 if (fe_family != LAGRANGE &&
1959 fe_family != RATIONAL_BERNSTEIN)
1960 continue;
1961
1962 DofConstraintRow dc_row;
1963
1964 const dof_id_type constrained_id =
1965 node->dof_number(sys_num, var_num, 0);
1966 for (const auto & [pr, val] : node_row.second)
1967 {
1968 const Elem * spline_elem = pr.first;
1969 libmesh_assert(spline_elem == mesh.elem_ptr(spline_elem->id()));
1970
1971 const Node & spline_node =
1972 spline_elem->node_ref(pr.second);
1973
1974 const dof_id_type spline_dof_id =
1975 spline_node.dof_number(sys_num, var_num, 0);
1976 dc_row[spline_dof_id] = val;
1977 }
1978
1979 // See if we already have a constraint here.
1980 if (this->is_constrained_dof(constrained_id))
1981 {
1982 was_previously_constrained.insert(constrained_id);
1983
1984 // Keep track of which spline DoFs will be
1985 // inheriting this non-spline DoF's constraints
1986 for (auto & row_entry : dc_row)
1987 my_dirichlet_spline_dofs.insert(row_entry.first);
1988
1989 // If it wasn't a simple Dirichlet-type constraint
1990 // then I don't know what to do with it. We'll make
1991 // this an assertion only because this should only
1992 // crop up with periodic boundary conditions, which
1993 // we've already made sure we don't have.
1994 libmesh_assert(_dof_constraints[constrained_id].empty());
1995 }
1996
1997 // Add the constraint, replacing any previous, so we can
1998 // use the new constraint in setting up the solve below
1999 this->add_constraint_row(constrained_id, dc_row, false);
2000 }
2001 }
2002
2003 // my_dirichlet_spline_dofs may now include DoFs whose owners
2004 // don't know they need to become spline DoFs! We need to push
2005 // this data to them.
2006 if (this->comm().size() > 1)
2007 {
2008 std::unordered_map
2009 <processor_id_type, std::vector<dof_id_type>>
2010 their_dirichlet_spline_dofs;
2011
2012 // If we ever change the underlying container here then we'd
2013 // better do some kind of sort before using it; we'll rely
2014 // on sorting to make the processor id lookup efficient.
2015 libmesh_assert(std::is_sorted(my_dirichlet_spline_dofs.begin(),
2016 my_dirichlet_spline_dofs.end()));
2017 processor_id_type destination_pid = 0;
2018 for (auto d : my_dirichlet_spline_dofs)
2019 {
2020 libmesh_assert_less(d, this->end_dof(this->comm().size()-1));
2021 while (d >= this->end_dof(destination_pid))
2022 destination_pid++;
2023
2024 if (destination_pid != this->processor_id())
2025 their_dirichlet_spline_dofs[destination_pid].push_back(d);
2026 }
2027
2028 auto receive_dof_functor =
2029 [& my_dirichlet_spline_dofs]
2031 const std::vector<dof_id_type> & dofs)
2032 {
2033 my_dirichlet_spline_dofs.insert(dofs.begin(), dofs.end());
2034 };
2035
2037 (this->comm(), their_dirichlet_spline_dofs, receive_dof_functor);
2038 }
2039
2040
2041 // If anyone had any prior constraints in effect, then we need
2042 // to convert them to constraints on the spline nodes.
2043 //
2044 // NOT simply testing prior_constraints here; maybe it turned
2045 // out that all our constraints were on non-spline-constrained
2046 // parts of a hybrid mesh?
2047 bool important_prior_constraints =
2048 !was_previously_constrained.empty();
2049 this->comm().max(important_prior_constraints);
2050
2051 if (important_prior_constraints)
2052 {
2053 // Now that we have the spline constraints added, we can
2054 // finally construct a sparsity pattern that correctly
2055 // accounts for those constraints!
2056 mat = SparseMatrix<Number>::build(this->comm());
2057 for (auto q : IntRange<unsigned int>(0, n_adjoint_rhs+1))
2058 {
2059 solve_rhs[q] = NumericVector<Number>::build(this->comm());
2060 solve_rhs[q]->init(this->n_dofs(), this->n_local_dofs(),
2061 false, PARALLEL);
2062 }
2063
2064 // We need to compute our own sparsity pattern, to take into
2065 // account the particularly non-sparse rows that can be
2066 // created by the spline constraints we just added.
2067 mat->attach_dof_map(*this);
2068 sp = this->build_sparsity(mesh);
2069 mat->attach_sparsity_pattern(*sp);
2070 mat->init();
2071
2072 for (auto & node_row : constraint_rows)
2073 {
2074 const Node * node = node_row.first;
2075 libmesh_assert(node == mesh.node_ptr(node->id()));
2076
2077 for (auto var_num : IntRange<unsigned int>(0, this->n_variables()))
2078 {
2079 const FEFamily & fe_family = this->variable_type(var_num).family;
2080
2081 // constraint_rows only applies to nodal variables
2082 if (fe_family != LAGRANGE &&
2083 fe_family != RATIONAL_BERNSTEIN)
2084 continue;
2085
2086 const dof_id_type constrained_id =
2087 node->dof_number(sys_num, var_num, 0);
2088
2089 if (was_previously_constrained.count(constrained_id))
2090 {
2091 for (auto q : IntRange<int>(0, n_adjoint_rhs+1))
2092 {
2093 DenseMatrix<Number> K(1,1);
2095 std::vector<dof_id_type> dof_indices(1, constrained_id);
2096
2097 K(0,0) = 1;
2098
2099 DofConstraintValueMap & vals = q ?
2102
2103 DofConstraintValueMap::const_iterator rhsit =
2104 vals.find(constrained_id);
2105 F(0) = (rhsit == vals.end()) ? 0 : rhsit->second;
2106
2107 // We no longer need any rhs values here directly.
2108 if (rhsit != vals.end())
2109 vals.erase(rhsit);
2110
2112 (K, F, dof_indices, false, q ? (q-1) : -1);
2113 if (!q)
2114 mat->add_matrix(K, dof_indices);
2115 solve_rhs[q]->add_vector(F, dof_indices);
2116 }
2117 }
2118 }
2119 }
2120
2121 // Any DoFs that aren't part of any constraint, directly or
2122 // indirectly, need a diagonal term to make the matrix
2123 // here invertible.
2124 for (dof_id_type d : IntRange<dof_id_type>(this->first_dof(),
2125 this->end_dof()))
2126 if (!was_previously_constrained.count(d) &&
2127 !my_dirichlet_spline_dofs.count(d))
2128 mat->add(d,d,1);
2129
2130 // At this point, we're finally ready to solve for Dirichlet
2131 // constraint values on spline nodes.
2132 std::unique_ptr<LinearSolver<Number>> linear_solver =
2134
2135 std::unique_ptr<NumericVector<Number>> projected_vals =
2137
2138 projected_vals->init(this->n_dofs(), this->n_local_dofs(),
2139 false, PARALLEL);
2140
2141 DofConstraintRow empty_row;
2142 for (auto sd : my_dirichlet_spline_dofs)
2143 if (this->local_index(sd))
2144 this->add_constraint_row(sd, empty_row);
2145
2146 for (auto q : IntRange<unsigned int>(0, n_adjoint_rhs+1))
2147 {
2148 // FIXME: we don't have an EquationSystems here, but I'd
2149 // rather not hardcode these...
2150 const double tol = double(TOLERANCE * TOLERANCE);
2151 const unsigned int max_its = 5000;
2152
2153 linear_solver->solve(*mat, *projected_vals,
2154 *(solve_rhs[q]), tol, max_its);
2155
2156 DofConstraintValueMap & vals = q ?
2159
2160 for (auto sd : my_dirichlet_spline_dofs)
2161 if (this->local_index(sd))
2162 {
2163 Number constraint_rhs = (*projected_vals)(sd);
2164
2165 std::pair<DofConstraintValueMap::iterator, bool> rhs_it =
2166 vals.emplace(sd, constraint_rhs);
2167 if (!rhs_it.second)
2168 rhs_it.first->second = constraint_rhs;
2169 }
2170 }
2171 }
2172}
void min(const T &r, T &o, Request &req) const
This is the base class from which all geometric element types are derived.
Definition elem.h:96
FEFamily family
The type of finite element.
Definition fe_type.h:228
static std::unique_ptr< LinearSolver< T > > build(const libMesh::Parallel::Communicator &comm_in, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a LinearSolver using the linear solver package specified by solver_package.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, SolverPackage solver_package=libMesh::default_solver_package(), ParallelType parallel_type=AUTOMATIC)
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
static constexpr Real TOLERANCE
@ RATIONAL_BERNSTEIN

References _adjoint_constraint_values, _dof_constraints, _periodic_boundaries, _primal_constraint_values, add_constraint_row(), libMesh::LinearSolver< T >::build(), libMesh::SparseMatrix< T >::build(), libMesh::NumericVector< T >::build(), build_sparsity(), libMesh::ParallelObject::comm(), dof_indices(), libMesh::DofObject::dof_number(), libMesh::MeshBase::elem_ptr(), libMesh::DofMapBase::end_dof(), libMesh::FEType::family, libMesh::DofMapBase::first_dof(), libMesh::MeshBase::get_constraint_rows(), heterogeneously_constrain_element_matrix_and_vector(), libMesh::DofObject::id(), is_constrained_dof(), libMesh::LAGRANGE, libMesh::libmesh_assert(), local_index(), libMesh::Parallel::Communicator::max(), mesh, libMesh::Parallel::Communicator::min(), libMesh::MeshBase::n_constraint_rows(), n_dofs(), n_local_dofs(), n_variables(), libMesh::MeshBase::node_ptr(), libMesh::Elem::node_ref(), libMesh::PARALLEL, libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), TIMPI::push_parallel_vector_data(), libMesh::RATIONAL_BERNSTEIN, sys_number(), libMesh::TOLERANCE, and variable_type().

Referenced by create_dof_constraints().

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 114 of file parallel_object.h.

115 { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshBase::count_constraint_rows(), libMesh::ExodusII_IO_Helper::create(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), get_local_constraints(), libMesh::MeshBase::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::Modification::interpolate_surface(), libMesh::SparsityPattern::Build::join(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), main(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshBase::print_constraint_rows(), print_dof_constraints(), process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::XdrIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::NameBasedIO::read(), libMesh::EquationSystems::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::ExodusII_IO::read_header(), libMesh::System::read_header(), libMesh::XdrIO::read_header(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_ids(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DistributedMesh::set_next_unique_ids(), set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), MeshFunctionTest::test_bad_gradient_var_with_out_of_mesh_value(), MeshFunctionTest::test_bad_hessian_var_with_out_of_mesh_value(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), ExodusC0PolyhedronTest::test_write_and_read_hexagonal_prism(), ExodusC0PolyhedronTest::test_write_and_read_mixed_hex_tet_block_names_impl(), ExodusC0PolygonTest::test_write_and_read_pentagon(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), BoundaryInfoTest::testBoundaryIDs(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyHighOrderElementSolution(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), DofMapTest::testGhostConstraintSendList(), MeshInputTest::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), BoundaryInfoTest::testInternalBoundary(), MeshInputTest::testLowOrderEdgeBlocks(), BoundaryMeshSubdomainTest::testPerBoundarySubdomain(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), BoundaryMeshSubdomainTest::testSingleSubdomain(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshSmootherTest::testVariationalSmoother(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::XdrIO::write(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO::write_element_data_from_discontinuous_nodal_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

◆ reinit()

void libMesh::DofMap::reinit ( MeshBase &  mesh,
const std::map< const Node *, std::set< subdomain_id_type > > &  constraining_subdomains 
)

Reinitialize the underlying data structures conformal to the current mesh.

Definition at line 469 of file dof_map.C.

473{
474 libmesh_assert (mesh.is_prepared());
475
476 LOG_SCOPE("reinit()", "DofMap");
477
478 // This is the common case and we want to optimize for it
479 const bool constraining_subdomains_empty =
480 constraining_subdomains.empty();
481
482 // We ought to reconfigure our default coupling functor.
483 //
484 // The user might have removed it from our coupling functors set,
485 // but if so, who cares, this reconfiguration is cheap.
486
487 // Avoid calling set_dof_coupling() with an empty/non-nullptr
488 // _dof_coupling matrix which may happen when there are actually no
489 // variables on the system.
490 if (this->_dof_coupling && this->_dof_coupling->empty() && !this->n_variables())
491 this->_dof_coupling = nullptr;
492 _default_coupling->set_dof_coupling(this->_dof_coupling);
493
494 // By default we may want 0 or 1 levels of coupling
495 unsigned int standard_n_levels =
497 _default_coupling->set_n_levels
498 (std::max(_default_coupling->n_levels(), standard_n_levels));
499
500 // But we *don't* want to restrict to a CouplingMatrix unless the
501 // user does so manually; the original libMesh behavior was to put
502 // ghost indices on the send_list regardless of variable.
503 //_default_evaluating->set_dof_coupling(this->_dof_coupling);
504
505 const unsigned int
506 sys_num = this->sys_number(),
507 n_var_groups = this->n_variable_groups();
508
509 // The DofObjects need to know how many variable groups we have, and
510 // how many variables there are in each group.
511 std::vector<unsigned int> n_vars_per_group; n_vars_per_group.reserve (n_var_groups);
512
513 for (unsigned int vg=0; vg<n_var_groups; vg++)
514 n_vars_per_group.push_back (this->variable_group(vg).n_variables());
515
516#ifdef LIBMESH_ENABLE_AMR
517
518 //------------------------------------------------------------
519 // Clear the old_dof_objects for all the nodes
520 // and elements so that we can overwrite them
521 for (auto & node : mesh.node_ptr_range())
522 {
523 node->clear_old_dof_object();
524 libmesh_assert (!node->get_old_dof_object());
525 }
526
528 (mesh.element_stored_range(),
529 [](const ElemRange & range)
530 {
531 for (Elem * elem : range)
532 {
533 elem->clear_old_dof_object();
534 libmesh_assert (!elem->get_old_dof_object());
535 }
536 });
537
538 //------------------------------------------------------------
539 // Set the old_dof_objects for the elements that
540 // weren't just created, if these old dof objects
541 // had variables
542 for (auto & elem : mesh.element_ptr_range())
543 {
544 // Skip the elements that were just refined
545 if (elem->refinement_flag() == Elem::JUST_REFINED)
546 continue;
547
548 for (Node & node : elem->node_ref_range())
549 if (node.get_old_dof_object() == nullptr)
550 if (node.has_dofs(sys_num))
551 node.set_old_dof_object();
552
553 libmesh_assert (!elem->get_old_dof_object());
554
555 if (elem->has_dofs(sys_num))
556 elem->set_old_dof_object();
557 }
558
559#endif // #ifdef LIBMESH_ENABLE_AMR
560
561
562 //------------------------------------------------------------
563 // Then set the number of variables for each \p DofObject
564 // equal to n_variables() for this system. This will
565 // handle new \p DofObjects that may have just been created
566
567 // All the nodes
568 for (auto & node : mesh.node_ptr_range())
569 node->set_n_vars_per_group(sys_num, n_vars_per_group);
570
571 // All the elements
573 (mesh.element_stored_range(),
574 [sys_num, n_vars_per_group](const ElemRange & range)
575 {
576 for (Elem * elem : range)
577 elem->set_n_vars_per_group(sys_num, n_vars_per_group);
578 });
579
580 // Zero _n_SCALAR_dofs, it will be updated below.
581 this->_n_SCALAR_dofs = 0;
582
583 //------------------------------------------------------------
584 // Next allocate space for the DOF indices
585 for (unsigned int vg=0; vg<n_var_groups; vg++)
586 {
587 const VariableGroup & vg_description = this->variable_group(vg);
588
589 const unsigned int n_var_in_group = vg_description.n_variables();
590 const FEType & base_fe_type = vg_description.type();
591
592 const bool add_p_level = base_fe_type.p_refinement;
593
594 // Don't need to loop over elements for a SCALAR variable
595 // Just increment _n_SCALAR_dofs
596 if (base_fe_type.family == SCALAR)
597 {
598 this->_n_SCALAR_dofs += base_fe_type.order.get_order()*n_var_in_group;
599 continue;
600 }
601
602 // This should be constant even on p-refined elements
603 const bool extra_hanging_dofs =
605
606 // For all the active elements, count vertex degrees of freedom.
607 for (auto & elem : mesh.active_element_ptr_range())
608 {
609 libmesh_assert(elem);
610
611 // Only number dofs connected to active elements on this
612 // processor and only for variables which are active on on
613 // this element's subdomain or which are active on the
614 // subdomain of a node constrained by this node.
615 const bool active_on_elem =
616 vg_description.active_on_subdomain(elem->subdomain_id());
617
618 // If there's no way we're active on this element then we're
619 // done
620 if (!active_on_elem && constraining_subdomains_empty)
621 continue;
622
623 FEType fe_type = base_fe_type;
624
625 const ElemType type = elem->type();
626
627 libmesh_error_msg_if(base_fe_type.order.get_order() >
628 int(FEInterface::max_order(base_fe_type,type)),
629 "ERROR: Finite element "
630 << Utility::enum_to_string(base_fe_type.family)
631 << " on geometric element "
633 << "\nonly supports FEInterface::max_order = "
634 << FEInterface::max_order(base_fe_type,type)
635 << ", not fe_type.order = "
636 << base_fe_type.order);
637
638#ifdef LIBMESH_ENABLE_AMR
639 // Make sure we haven't done more p refinement than we can
640 // handle
641 if (base_fe_type.order + add_p_level*elem->p_level() >
642 FEInterface::max_order(base_fe_type, type))
643 {
644# ifdef DEBUG
645 libMesh::err << "WARNING: Finite element "
646 << Utility::enum_to_string(base_fe_type.family)
647 << " on geometric element "
648 << Utility::enum_to_string(type) << std::endl
649 << "could not be p refined past FEInterface::max_order = "
650 << FEInterface::max_order(base_fe_type,type)
651 << std::endl;
652# endif
653 elem->set_p_level(int(FEInterface::max_order(base_fe_type,type))
654 - int(base_fe_type.order));
655 }
656#endif
657
658 // Allocate the vertex DOFs
659 for (auto n : elem->node_index_range())
660 {
661 Node & node = elem->node_ref(n);
662
663 // If we're active on the element then we're active on
664 // its nodes. If we're not then we might *still* be
665 // active on particular constraining nodes.
666 bool active_on_node = active_on_elem;
667 if (!active_on_node)
668 if (auto it = constraining_subdomains.find(&node);
669 it != constraining_subdomains.end())
670 for (auto s : it->second)
671 if (vg_description.active_on_subdomain(s))
672 {
673 active_on_node = true;
674 break;
675 }
676
677 if (!active_on_node)
678 continue;
679
680 if (elem->is_vertex(n))
681 {
682 const unsigned int old_node_dofs =
683 node.n_comp_group(sys_num, vg);
684
685 const unsigned int vertex_dofs =
686 std::max(FEInterface::n_dofs_at_node(fe_type, elem, n, add_p_level),
687 old_node_dofs);
688
689 // Some discontinuous FEs have no vertex dofs
690 if (vertex_dofs > old_node_dofs)
691 {
692 node.set_n_comp_group(sys_num, vg,
693 vertex_dofs);
694
695 // Abusing dof_number to set a "this is a
696 // vertex" flag
697 node.set_vg_dof_base(sys_num, vg,
698 vertex_dofs);
699
700 // libMesh::out << "sys_num,vg,old_node_dofs,vertex_dofs="
701 // << sys_num << ","
702 // << vg << ","
703 // << old_node_dofs << ","
704 // << vertex_dofs << '\n',
705 // node.debug_buffer();
706
707 // libmesh_assert_equal_to (vertex_dofs, node.n_comp(sys_num, vg));
708 // libmesh_assert_equal_to (vertex_dofs, node.vg_dof_base(sys_num, vg));
709 }
710 }
711 }
712 } // done counting vertex dofs
713
714 // count edge & face dofs next
715 for (auto & elem : mesh.active_element_ptr_range())
716 {
717 libmesh_assert(elem);
718
719 // Only number dofs connected to active elements on this
720 // processor and only for variables which are active on on
721 // this element's subdomain or which are active on the
722 // subdomain of a node constrained by this node.
723 const bool active_on_elem =
724 vg_description.active_on_subdomain(elem->subdomain_id());
725
726 // If there's no way we're active on this element then we're
727 // done
728 if (!active_on_elem && constraining_subdomains_empty)
729 continue;
730
731 // Allocate the edge and face DOFs
732 for (auto n : elem->node_index_range())
733 {
734 Node & node = elem->node_ref(n);
735
736 // If we're active on the element then we're active on
737 // its nodes. If we're not then we might *still* be
738 // active on particular constraining nodes.
739 bool active_on_node = active_on_elem;
740 if (!active_on_node)
741 if (auto it = constraining_subdomains.find(&node);
742 it != constraining_subdomains.end())
743 for (auto s : it->second)
744 if (vg_description.active_on_subdomain(s))
745 {
746 active_on_node = true;
747 break;
748 }
749
750 if (!active_on_node)
751 continue;
752
753 const unsigned int old_node_dofs =
754 node.n_comp_group(sys_num, vg);
755
756 const unsigned int vertex_dofs = old_node_dofs?
757 cast_int<unsigned int>(node.vg_dof_base (sys_num,vg)):0;
758
759 const unsigned int new_node_dofs =
760 FEInterface::n_dofs_at_node(base_fe_type, elem, n, add_p_level);
761
762 // We've already allocated vertex DOFs
763 if (elem->is_vertex(n))
764 {
765 libmesh_assert_greater_equal (old_node_dofs, vertex_dofs);
766 // //if (vertex_dofs < new_node_dofs)
767 // libMesh::out << "sys_num,vg,old_node_dofs,vertex_dofs,new_node_dofs="
768 // << sys_num << ","
769 // << vg << ","
770 // << old_node_dofs << ","
771 // << vertex_dofs << ","
772 // << new_node_dofs << '\n',
773 // node.debug_buffer();
774
775 libmesh_assert_greater_equal (vertex_dofs, new_node_dofs);
776 }
777 // We need to allocate the rest
778 else
779 {
780 // If this has no dofs yet, it needs no vertex
781 // dofs, so we just give it edge or face dofs
782 if (!old_node_dofs)
783 {
784 node.set_n_comp_group(sys_num, vg,
785 new_node_dofs);
786 // Abusing dof_number to set a "this has no
787 // vertex dofs" flag
788 if (new_node_dofs)
789 node.set_vg_dof_base(sys_num, vg, 0);
790 }
791
792 // If this has dofs, but has no vertex dofs,
793 // it may still need more edge or face dofs if
794 // we're p-refined.
795 else if (vertex_dofs == 0)
796 {
797 if (new_node_dofs > old_node_dofs)
798 {
799 node.set_n_comp_group(sys_num, vg,
800 new_node_dofs);
801
802 node.set_vg_dof_base(sys_num, vg,
803 vertex_dofs);
804 }
805 }
806 // If this is another element's vertex,
807 // add more (non-overlapping) edge/face dofs if
808 // necessary
809 else if (extra_hanging_dofs)
810 {
811 if (new_node_dofs > old_node_dofs - vertex_dofs)
812 {
813 node.set_n_comp_group(sys_num, vg,
814 vertex_dofs + new_node_dofs);
815
816 node.set_vg_dof_base(sys_num, vg,
817 vertex_dofs);
818 }
819 }
820 // If this is another element's vertex, add any
821 // (overlapping) edge/face dofs if necessary
822 else
823 {
824 libmesh_assert_greater_equal (old_node_dofs, vertex_dofs);
825 if (new_node_dofs > old_node_dofs)
826 {
827 node.set_n_comp_group(sys_num, vg,
828 new_node_dofs);
829
830 node.set_vg_dof_base (sys_num, vg,
831 vertex_dofs);
832 }
833 }
834 }
835 }
836 // Allocate the element DOFs
837 const unsigned int dofs_per_elem =
838 FEInterface::n_dofs_per_elem(base_fe_type, elem, add_p_level);
839
840 elem->set_n_comp_group(sys_num, vg, dofs_per_elem);
841
842 }
843 } // end loop over variable groups
844
845 // Calling DofMap::reinit() by itself makes little sense,
846 // so we won't bother with nonlocal DofObjects.
847 // Those will be fixed by distribute_dofs
848
849 //------------------------------------------------------------
850 // Finally, clear all the current DOF indices
851 // (distribute_dofs expects them cleared!)
852 this->invalidate_dofs(mesh);
853}
static unsigned int max_order(const FEType &fe_t, const ElemType &el_t)
std::string enum_to_string(const T e)
StoredRange< MeshBase::element_iterator, Elem * > ElemRange
Definition elem_range.h:33

References _default_coupling, _dof_coupling, libMesh::CouplingMatrix::empty(), libMesh::libmesh_assert(), mesh, n_variable_groups(), libMesh::Threads::parallel_for(), sys_number(), and use_coupled_neighbor_dofs().

Referenced by libMesh::HPCoarsenTest::add_projection().

◆ reinit_send_list()

void libMesh::DofMap::reinit_send_list ( MeshBase &  mesh)

Clears the _send_list vector and then rebuilds it.

This may be needed in special situations, for example when an algebraic coupling functor cannot be added to the DofMap until after it is completely setup. Then this method can be used to rebuild the send_list once the algebraic coupling functor is added. Note that while this will recommunicate constraints with the updated send_list, this does assume no new constraints have been added since the previous reinit_constraints call.

Definition at line 1879 of file dof_map.C.

1880{
1881 this->clear_send_list();
1883
1884#ifdef LIBMESH_ENABLE_CONSTRAINTS
1885 // This is assuming that we only need to recommunicate
1886 // the constraints and no new ones have been added since
1887 // a previous call to reinit_constraints.
1889#endif
1890 this->prepare_send_list();
1891}
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition dof_map.C:1837
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...

References mesh.

Referenced by OverlappingAlgebraicGhostingTest::run_ghosting_test(), and OverlappingCouplingGhostingTest::run_sparsity_pattern_test().

◆ reinit_static_condensation()

void libMesh::DofMap::reinit_static_condensation ( )

Calls reinit on the static condensation map if it exists.

Definition at line 3142 of file dof_map.C.

3143{
3144 if (_sc)
3145 _sc->reinit();
3146}

Referenced by libMesh::System::reinit().

◆ remove_adjoint_dirichlet_boundary()

void libMesh::DofMap::remove_adjoint_dirichlet_boundary ( const DirichletBoundary &  dirichlet_boundary,
unsigned int  q 
)

Removes from the system the specified Dirichlet boundary for the adjoint equation defined by Quantity of interest index q.

Definition at line 5501 of file dof_map_constraints.C.

5503{
5504 libmesh_assert_greater(_adjoint_dirichlet_boundaries.size(),
5505 qoi_index);
5506
5507 auto lam = [&boundary_to_remove](const auto & bdy)
5508 {return bdy->b == boundary_to_remove.b && bdy->variables == boundary_to_remove.variables;};
5509
5510 auto it = std::find_if(_adjoint_dirichlet_boundaries[qoi_index]->begin(),
5511 _adjoint_dirichlet_boundaries[qoi_index]->end(),
5512 lam);
5513
5514 // Assert it was actually found and remove it from the vector
5515 libmesh_assert (it != _adjoint_dirichlet_boundaries[qoi_index]->end());
5516 _adjoint_dirichlet_boundaries[qoi_index]->erase(it);
5517}

References _adjoint_dirichlet_boundaries, libMesh::DirichletBoundary::b, libMesh::libmesh_assert(), and libMesh::DirichletBoundary::variables.

◆ remove_algebraic_ghosting_functor()

void libMesh::DofMap::remove_algebraic_ghosting_functor ( GhostingFunctor &  evaluable_functor)

Removes a functor which was previously added to the set of algebraic ghosting functors, from both this DofMap and from the underlying mesh.

Definition at line 2091 of file dof_map.C.

2092{
2093 auto raw_it = std::find(_algebraic_ghosting_functors.begin(),
2095 &evaluable_functor);
2096
2097#ifndef LIBMESH_ENABLE_DEPRECATED
2098 // We shouldn't be trying to remove a functor that isn't there
2100#else
2101 // Our old API supported trying to remove a functor that isn't there
2102 if (raw_it != _algebraic_ghosting_functors.end())
2103#endif
2104 _algebraic_ghosting_functors.erase(raw_it);
2105
2106 // We shouldn't have had two copies of the same functor
2109 &evaluable_functor) ==
2111
2112 _mesh.remove_ghosting_functor(evaluable_functor);
2113
2114 if (const auto it = _shared_functors.find(&evaluable_functor);
2115 it != _shared_functors.end())
2116 _shared_functors.erase(it);
2117}

References libMesh::libmesh_assert().

Referenced by PointNeighborCouplingTest::testCoupling().

◆ remove_coupling_functor()

void libMesh::DofMap::remove_coupling_functor ( GhostingFunctor &  coupling_functor)

Removes a functor which was previously added to the set of coupling functors, from both this DofMap and from the underlying mesh.

Definition at line 2034 of file dof_map.C.

2035{
2036 auto raw_it = std::find(_coupling_functors.begin(),
2037 _coupling_functors.end(), &coupling_functor);
2038
2039#ifndef LIBMESH_ENABLE_DEPRECATED
2040 // We shouldn't be trying to remove a functor that isn't there
2041 libmesh_assert(raw_it != _coupling_functors.end());
2042#else
2043 // Our old API supported trying to remove a functor that isn't there
2044 if (raw_it != _coupling_functors.end())
2045#endif
2046 _coupling_functors.erase(raw_it);
2047
2048 // We shouldn't have had two copies of the same functor
2049 libmesh_assert(std::find(_coupling_functors.begin(),
2050 _coupling_functors.end(),
2051 &coupling_functor) ==
2052 _coupling_functors.end());
2053
2054 _mesh.remove_ghosting_functor(coupling_functor);
2055
2056 if (const auto it = _shared_functors.find(&coupling_functor);
2057 it != _shared_functors.end())
2058 _shared_functors.erase(it);
2059}

References libMesh::libmesh_assert().

Referenced by PointNeighborCouplingTest::testCoupling().

◆ remove_default_ghosting()

void libMesh::DofMap::remove_default_ghosting ( )

Remove any default ghosting functor(s).

User-added ghosting functors will be unaffected.

Unless user-added equivalent ghosting functors exist, removing the default coupling functor is only safe for explicit solves, and removing the default algebraic ghosting functor is only safe for codes where no evaluations on neighbor cells (e.g. no jump error estimators) are done.

Defaults can be restored manually via add_default_ghosting(), or automatically if clear() returns the DofMap to a default state.

Definition at line 1990 of file dof_map.C.

1991{
1994}
void remove_coupling_functor(GhostingFunctor &coupling_functor)
Removes a functor which was previously added to the set of coupling functors, from both this DofMap a...
Definition dof_map.C:2034
void remove_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor)
Removes a functor which was previously added to the set of algebraic ghosting functors,...
Definition dof_map.C:2091

Referenced by libMesh::EquationSystems::enable_default_ghosting().

◆ remove_dirichlet_boundary()

void libMesh::DofMap::remove_dirichlet_boundary ( const DirichletBoundary &  dirichlet_boundary)

Removes the specified Dirichlet boundary from the system.

Definition at line 5487 of file dof_map_constraints.C.

5488{
5489 // Find a boundary condition matching the one to be removed
5490 auto lam = [&boundary_to_remove](const auto & bdy)
5491 {return bdy->b == boundary_to_remove.b && bdy->variables == boundary_to_remove.variables;};
5492
5493 auto it = std::find_if(_dirichlet_boundaries->begin(), _dirichlet_boundaries->end(), lam);
5494
5495 // Assert it was actually found and remove it from the vector
5497 _dirichlet_boundaries->erase(it);
5498}

References _dirichlet_boundaries, libMesh::DirichletBoundary::b, libMesh::libmesh_assert(), and libMesh::DirichletBoundary::variables.

◆ SCALAR_dof_indices()

void libMesh::DofMap::SCALAR_dof_indices ( std::vector< dof_id_type > &  di,
const unsigned int  vn,
const bool  old_dofs = false 
) const

Fills the vector di with the global degree of freedom indices corresponding to the SCALAR variable vn.

If old_dofs=true, the old SCALAR dof indices are returned.

Note
We do not need to pass in an element since SCALARs are global variables.

Definition at line 2607 of file dof_map.C.

2615{
2616 // dof_indices() is a relatively light-weight function; the cost of
2617 // the logging code itself is roughly on par with the time required
2618 // to call dof_indices().
2619 // LOG_SCOPE("SCALAR_dof_indices()", "DofMap");
2620
2621 libmesh_assert(this->variable(vn).type().family == SCALAR);
2622
2623#ifdef LIBMESH_ENABLE_AMR
2624 // If we're asking for old dofs then we'd better have some
2625 if (old_dofs)
2626 libmesh_assert_greater_equal(n_old_dofs(), n_SCALAR_dofs());
2627
2628 dof_id_type my_idx = old_dofs ?
2629 this->_first_old_scalar_df[vn] : this->_first_scalar_df[vn];
2630#else
2631 dof_id_type my_idx = this->_first_scalar_df[vn];
2632#endif
2633
2634 libmesh_assert_not_equal_to(my_idx, DofObject::invalid_id);
2635
2636 // The number of SCALAR dofs comes from the variable order
2637 const int n_dofs_vn = this->variable(vn).type().order.get_order();
2638
2639 di.resize(n_dofs_vn);
2640 for (int i = 0; i != n_dofs_vn; ++i)
2641 di[i] = my_idx++;
2642}
dof_id_type n_old_dofs() const

References libMesh::libmesh_assert(), and libMesh::SCALAR.

Referenced by libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), dof_indices(), libMesh::System::project_vector(), libMesh::System::project_vector(), libMesh::System::projection_matrix(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::StaticCondensationDofMap::reinit(), SystemsTest::testProjectScalarCoarsening(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), and libMesh::System::write_SCALAR_dofs().

◆ scatter_constraints()

void libMesh::DofMap::scatter_constraints ( MeshBase &  mesh)

Sends constraint equations to constraining processors.

Definition at line 4603 of file dof_map_constraints.C.

4604{
4605 // At this point each processor with a constrained node knows
4606 // the corresponding constraint row, but we also need each processor
4607 // with a constrainer node to know the corresponding row(s).
4608
4609 // This function must be run on all processors at once
4610 parallel_object_only();
4611
4612 // Return immediately if there's nothing to gather
4613 if (this->n_processors() == 1)
4614 return;
4615
4616 // We might get to return immediately if none of the processors
4617 // found any constraints
4618 unsigned int has_constraints = !_dof_constraints.empty()
4619#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
4620 || !_node_constraints.empty()
4621#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
4622 ;
4623 this->comm().max(has_constraints);
4624 if (!has_constraints)
4625 return;
4626
4627 // We may be receiving packed_range sends out of order with
4628 // parallel_sync tags, so make sure they're received correctly.
4629 Parallel::MessageTag range_tag = this->comm().get_unique_tag();
4630
4631#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
4632 std::map<processor_id_type, std::set<dof_id_type>> pushed_node_ids;
4633#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
4634
4635 std::map<processor_id_type, std::set<dof_id_type>> pushed_ids;
4636
4637 // Collect the dof constraints I need to push to each processor
4638 dof_id_type constrained_proc_id = 0;
4639 for (const auto & [constrained, row] : _dof_constraints)
4640 {
4641 while (constrained >= _end_df[constrained_proc_id])
4642 constrained_proc_id++;
4643
4644 if (constrained_proc_id != this->processor_id())
4645 continue;
4646
4647 for (auto & j : row)
4648 {
4649 const dof_id_type constraining = j.first;
4650
4651 processor_id_type constraining_proc_id = 0;
4652 while (constraining >= _end_df[constraining_proc_id])
4653 constraining_proc_id++;
4654
4655 if (constraining_proc_id != this->processor_id() &&
4656 constraining_proc_id != constrained_proc_id)
4657 pushed_ids[constraining_proc_id].insert(constrained);
4658 }
4659 }
4660
4661 // Pack the dof constraint rows and rhs's to push
4662
4663 std::map<processor_id_type,
4664 std::vector<std::vector<std::pair<dof_id_type, Real>>>>
4665 pushed_keys_vals, pushed_keys_vals_to_me;
4666
4667 std::map<processor_id_type, std::vector<std::pair<dof_id_type, Number>>>
4668 pushed_ids_rhss, pushed_ids_rhss_to_me;
4669
4670 auto gather_ids =
4671 [this,
4672 & pushed_ids,
4673 & pushed_keys_vals,
4674 & pushed_ids_rhss]
4675 ()
4676 {
4677 for (const auto & [pid, pid_ids] : pushed_ids)
4678 {
4679 const std::size_t ids_size = pid_ids.size();
4680 std::vector<std::vector<std::pair<dof_id_type, Real>>> &
4681 keys_vals = pushed_keys_vals[pid];
4682 std::vector<std::pair<dof_id_type,Number>> &
4683 ids_rhss = pushed_ids_rhss[pid];
4684 keys_vals.resize(ids_size);
4685 ids_rhss.resize(ids_size);
4686
4687 std::size_t push_i;
4688 std::set<dof_id_type>::const_iterator it;
4689 for (push_i = 0, it = pid_ids.begin();
4690 it != pid_ids.end(); ++push_i, ++it)
4691 {
4692 const dof_id_type constrained = *it;
4693 DofConstraintRow & row = _dof_constraints[constrained];
4694 keys_vals[push_i].assign(row.begin(), row.end());
4695
4696 DofConstraintValueMap::const_iterator rhsit =
4697 _primal_constraint_values.find(constrained);
4698 ids_rhss[push_i].first = constrained;
4699 ids_rhss[push_i].second =
4700 (rhsit == _primal_constraint_values.end()) ?
4701 0 : rhsit->second;
4702 }
4703 }
4704 };
4705
4706 gather_ids();
4707
4708 auto ids_rhss_action_functor =
4709 [& pushed_ids_rhss_to_me]
4710 (processor_id_type pid,
4711 const std::vector<std::pair<dof_id_type, Number>> & data)
4712 {
4713 pushed_ids_rhss_to_me[pid] = data;
4714 };
4715
4716 auto keys_vals_action_functor =
4717 [& pushed_keys_vals_to_me]
4718 (processor_id_type pid,
4719 const std::vector<std::vector<std::pair<dof_id_type, Real>>> & data)
4720 {
4721 pushed_keys_vals_to_me[pid] = data;
4722 };
4723
4725 (this->comm(), pushed_ids_rhss, ids_rhss_action_functor);
4727 (this->comm(), pushed_keys_vals, keys_vals_action_functor);
4728
4729 // Now work on traded dof constraint rows
4730 auto receive_dof_constraints =
4731 [this,
4732 & pushed_ids_rhss_to_me,
4733 & pushed_keys_vals_to_me]
4734 ()
4735 {
4736 for (const auto & [pid, ids_rhss] : pushed_ids_rhss_to_me)
4737 {
4738 const auto & keys_vals = pushed_keys_vals_to_me[pid];
4739
4740 libmesh_assert_equal_to
4741 (ids_rhss.size(), keys_vals.size());
4742
4743 // Add the dof constraints that I've been sent
4744 for (auto i : index_range(ids_rhss))
4745 {
4746 dof_id_type constrained = ids_rhss[i].first;
4747
4748 // If we don't already have a constraint for this dof,
4749 // add the one we were sent
4750 if (!this->is_constrained_dof(constrained))
4751 {
4752 DofConstraintRow & row = _dof_constraints[constrained];
4753 for (auto & key_val : keys_vals[i])
4754 {
4755 libmesh_assert_less(key_val.first, this->n_dofs());
4756 row[key_val.first] = key_val.second;
4757 }
4758 if (ids_rhss[i].second != Number(0))
4759 _primal_constraint_values[constrained] =
4760 ids_rhss[i].second;
4761 else
4762 _primal_constraint_values.erase(constrained);
4763 }
4764 }
4765 }
4766 };
4767
4768 receive_dof_constraints();
4769
4770#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
4771 // Collect the node constraints to push to each processor
4772 for (auto & i : _node_constraints)
4773 {
4774 const Node * constrained = i.first;
4775
4776 if (constrained->processor_id() != this->processor_id())
4777 continue;
4778
4779 NodeConstraintRow & row = i.second.first;
4780 for (auto & j : row)
4781 {
4782 const Node * constraining = j.first;
4783
4784 if (constraining->processor_id() != this->processor_id() &&
4785 constraining->processor_id() != constrained->processor_id())
4786 pushed_node_ids[constraining->processor_id()].insert(constrained->id());
4787 }
4788 }
4789
4790 // Pack the node constraint rows and rhss to push
4791 std::map<processor_id_type,
4792 std::vector<std::vector<std::pair<dof_id_type,Real>>>>
4793 pushed_node_keys_vals, pushed_node_keys_vals_to_me;
4794 std::map<processor_id_type, std::vector<std::pair<dof_id_type, Point>>>
4795 pushed_node_ids_offsets, pushed_node_ids_offsets_to_me;
4796 std::map<processor_id_type, std::vector<const Node *>> pushed_node_vecs;
4797
4798 for (const auto & [pid, pid_ids]: pushed_node_ids)
4799 {
4800 const std::size_t ids_size = pid_ids.size();
4801 std::vector<std::vector<std::pair<dof_id_type,Real>>> &
4802 keys_vals = pushed_node_keys_vals[pid];
4803 std::vector<std::pair<dof_id_type, Point>> &
4804 ids_offsets = pushed_node_ids_offsets[pid];
4805 keys_vals.resize(ids_size);
4806 ids_offsets.resize(ids_size);
4807 std::set<Node *> nodes;
4808
4809 std::size_t push_i;
4810 std::set<dof_id_type>::const_iterator it;
4811 for (push_i = 0, it = pid_ids.begin();
4812 it != pid_ids.end(); ++push_i, ++it)
4813 {
4814 Node * constrained = mesh.node_ptr(*it);
4815
4816 if (constrained->processor_id() != pid)
4817 nodes.insert(constrained);
4818
4819 NodeConstraintRow & row = _node_constraints[constrained].first;
4820 std::size_t row_size = row.size();
4821 keys_vals[push_i].reserve(row_size);
4822 for (const auto & j : row)
4823 {
4824 Node * constraining = const_cast<Node *>(j.first);
4825
4826 keys_vals[push_i].emplace_back(constraining->id(), j.second);
4827
4828 if (constraining->processor_id() != pid)
4829 nodes.insert(constraining);
4830 }
4831
4832 ids_offsets[push_i].first = *it;
4833 ids_offsets[push_i].second = _node_constraints[constrained].second;
4834 }
4835
4836 if (!mesh.is_serial())
4837 {
4838 auto & pid_nodes = pushed_node_vecs[pid];
4839 pid_nodes.assign(nodes.begin(), nodes.end());
4840 }
4841 }
4842
4843 auto node_ids_offsets_action_functor =
4844 [& pushed_node_ids_offsets_to_me]
4845 (processor_id_type pid,
4846 const std::vector<std::pair<dof_id_type, Point>> & data)
4847 {
4848 pushed_node_ids_offsets_to_me[pid] = data;
4849 };
4850
4851 auto node_keys_vals_action_functor =
4852 [& pushed_node_keys_vals_to_me]
4853 (processor_id_type pid,
4854 const std::vector<std::vector<std::pair<dof_id_type, Real>>> & data)
4855 {
4856 pushed_node_keys_vals_to_me[pid] = data;
4857 };
4858
4859 // Trade pushed node constraint rows
4861 (this->comm(), pushed_node_ids_offsets, node_ids_offsets_action_functor);
4863 (this->comm(), pushed_node_keys_vals, node_keys_vals_action_functor);
4864
4865 // Constraining nodes might not even exist on our subset of a
4866 // distributed mesh, so let's make them exist.
4867
4868 // Node unpack() now automatically adds them to the context mesh
4869 auto null_node_functor = [](processor_id_type, const std::vector<const Node *> &){};
4870
4871 if (!mesh.is_serial())
4873 (this->comm(), pushed_node_vecs, &mesh, null_node_functor);
4874
4875 for (const auto & [pid, ids_offsets] : pushed_node_ids_offsets_to_me)
4876 {
4877 const auto & keys_vals = pushed_node_keys_vals_to_me[pid];
4878
4879 libmesh_assert_equal_to
4880 (ids_offsets.size(), keys_vals.size());
4881
4882 // Add the node constraints that I've been sent
4883 for (auto i : index_range(ids_offsets))
4884 {
4885 dof_id_type constrained_id = ids_offsets[i].first;
4886
4887 // If we don't already have a constraint for this node,
4888 // add the one we were sent
4889 const Node * constrained = mesh.node_ptr(constrained_id);
4890 if (!this->is_constrained_node(constrained))
4891 {
4892 NodeConstraintRow & row = _node_constraints[constrained].first;
4893 for (auto & key_val : keys_vals[i])
4894 {
4895 const Node * key_node = mesh.node_ptr(key_val.first);
4896 row[key_node] = key_val.second;
4897 }
4898 _node_constraints[constrained].second =
4899 ids_offsets[i].second;
4900 }
4901 }
4902 }
4903#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
4904
4905 // Next we need to push constraints to processors which don't own
4906 // the constrained dof, don't own the constraining dof, but own an
4907 // element supporting the constraining dof.
4908 //
4909 // We need to be able to quickly look up constrained dof ids by what
4910 // constrains them, so that we can handle the case where we see a
4911 // foreign element containing one of our constraining DoF ids and we
4912 // need to push that constraint.
4913 //
4914 // Getting distributed adaptive sparsity patterns right is hard.
4915
4916 typedef std::map<dof_id_type, std::set<dof_id_type>> DofConstrainsMap;
4917 DofConstrainsMap dof_id_constrains;
4918
4919 for (const auto & [constrained, row] : _dof_constraints)
4920 {
4921 for (const auto & j : row)
4922 {
4923 const dof_id_type constraining = j.first;
4924
4925 dof_id_type constraining_proc_id = 0;
4926 while (constraining >= _end_df[constraining_proc_id])
4927 constraining_proc_id++;
4928
4929 if (constraining_proc_id == this->processor_id())
4930 dof_id_constrains[constraining].insert(constrained);
4931 }
4932 }
4933
4934 // Loop over all foreign elements, find any supporting our
4935 // constrained dof indices.
4936 pushed_ids.clear();
4937
4938 for (const auto & elem : as_range(mesh.active_not_local_elements_begin(),
4939 mesh.active_not_local_elements_end()))
4940 {
4941 std::vector<dof_id_type> my_dof_indices;
4942 this->dof_indices (elem, my_dof_indices);
4943
4944 for (const auto & dof : my_dof_indices)
4945 {
4946 if (auto dcmi = dof_id_constrains.find(dof);
4947 dcmi != dof_id_constrains.end())
4948 {
4949 for (const auto & constrained : dcmi->second)
4950 {
4951 dof_id_type the_constrained_proc_id = 0;
4952 while (constrained >= _end_df[the_constrained_proc_id])
4953 the_constrained_proc_id++;
4954
4955 const processor_id_type elemproc = elem->processor_id();
4956 if (elemproc != the_constrained_proc_id)
4957 pushed_ids[elemproc].insert(constrained);
4958 }
4959 }
4960 }
4961 }
4962
4963 pushed_ids_rhss.clear();
4964 pushed_ids_rhss_to_me.clear();
4965 pushed_keys_vals.clear();
4966 pushed_keys_vals_to_me.clear();
4967
4968 gather_ids();
4969
4970 // Trade pushed dof constraint rows
4972 (this->comm(), pushed_ids_rhss, ids_rhss_action_functor);
4974 (this->comm(), pushed_keys_vals, keys_vals_action_functor);
4975
4976 receive_dof_constraints();
4977
4978 // Finally, we need to handle the case of remote dof coupling. If a
4979 // processor's element is coupled to a ghost element, then the
4980 // processor needs to know about all constraints which affect the
4981 // dofs on that ghost element, so we'll have to query the ghost
4982 // element's owner.
4983
4984 GhostingFunctor::map_type elements_to_couple;
4985 DofMap::CouplingMatricesSet temporary_coupling_matrices;
4986
4988 (elements_to_couple,
4989 temporary_coupling_matrices,
4991 this->coupling_functors_end(),
4992 mesh.active_local_elements_begin(),
4993 mesh.active_local_elements_end(),
4994 this->processor_id());
4995
4996 // Each ghost-coupled element's owner should get a request for its dofs
4997 std::set<dof_id_type> requested_dofs;
4998
4999 for (const auto & pr : elements_to_couple)
5000 {
5001 const Elem * elem = pr.first;
5002
5003 // FIXME - optimize for the non-fully-coupled case?
5004 std::vector<dof_id_type> element_dofs;
5005 this->dof_indices(elem, element_dofs);
5006
5007 for (auto dof : element_dofs)
5008 requested_dofs.insert(dof);
5009 }
5010
5011 this->gather_constraints(mesh, requested_dofs, false);
5012}
void push_parallel_packed_range(const Communicator &comm, MapToContainers &&data, Context *context, const ActionFunctor &act_on_data)

References _dof_constraints, libMesh::DofMapBase::_end_df, _node_constraints, _primal_constraint_values, libMesh::as_range(), libMesh::ParallelObject::comm(), coupling_functors_begin(), coupling_functors_end(), dof_indices(), gather_constraints(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::DofObject::id(), libMesh::index_range(), is_constrained_dof(), is_constrained_node(), libMesh::MeshBase::is_serial(), libMesh::Parallel::Communicator::max(), merge_ghost_functor_outputs(), mesh, libMesh::ParallelObject::n_processors(), libMesh::MeshBase::node_ptr(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), TIMPI::push_parallel_packed_range(), and TIMPI::push_parallel_vector_data().

Referenced by process_constraints().

◆ semilocal_index()

bool libMesh::DofMap::semilocal_index ( dof_id_type  dof_index) const
Returns
true if degree of freedom index dof_index is either a local index or in the send_list.
Note
This is an O(logN) operation for a send_list of size N; we don't cache enough information for O(1) right now.

Definition at line 2646 of file dof_map.C.

2647{
2648 // If it's not in the local indices
2649 if (!this->local_index(dof_index))
2650 {
2651 // and if it's not in the ghost indices, then we're not
2652 // semilocal
2653 if (!std::binary_search(_send_list.begin(), _send_list.end(), dof_index))
2654 return false;
2655 }
2656
2657 return true;
2658}

◆ set_constrained_sparsity_construction()

void libMesh::DofMap::set_constrained_sparsity_construction ( bool  use_constraints)
inline

Sets the current policy for constructing sparsity patterns: if use_constraints is true (for robustness), we explicitly account for sparsity entries created by constraint matrix pre- and post- application.

If use_constraints is false (for speed), we calculate only the sparsity pattern of an unconstrained matrix. This is false by default, because in nearly all applications our constraints do not increase the number of non-zeros required in a sparse matrix.

Definition at line 2554 of file dof_map.h.

2555{
2556 // This got only partly finished...
2557 if (use_constraints)
2558 libmesh_not_implemented();
2559
2560#ifdef LIBMESH_ENABLE_CONSTRAINTS
2561 _constrained_sparsity_construction = use_constraints;
2562#endif
2563 libmesh_ignore(use_constraints);
2564}
void libmesh_ignore(const Args &...)

References _constrained_sparsity_construction, and libMesh::libmesh_ignore().

◆ set_error_on_constraint_loop()

void libMesh::DofMap::set_error_on_constraint_loop ( bool  error_on_constraint_loop)

Definition at line 235 of file dof_map.C.

236{
237 _error_on_constraint_loop = error_on_constraint_loop;
238}

References _error_on_constraint_loop.

Referenced by set_error_on_cyclic_constraint(), and DofMapTest::testConstraintLoopDetection().

◆ set_error_on_cyclic_constraint()

void libMesh::DofMap::set_error_on_cyclic_constraint ( bool  error_on_cyclic_constraint)

Specify whether or not we perform an extra (opt-mode enabled) check for constraint loops.

If a constraint loop is present then the system constraints are not valid, so if error_on_constraint_loop is true we will throw an error in this case.

Note
We previously referred to these types of constraints as "cyclic" but that has now been deprecated, and these will now instead be referred to as "constraint loops" in libMesh.

Definition at line 228 of file dof_map.C.

229{
230 // This function will eventually be officially libmesh_deprecated();
231 // Call DofMap::set_error_on_constraint_loop() instead.
232 set_error_on_constraint_loop(error_on_cyclic_constraint);
233}
void set_error_on_constraint_loop(bool error_on_constraint_loop)
Definition dof_map.C:235

References set_error_on_constraint_loop().

◆ set_implicit_neighbor_dofs()

void libMesh::DofMap::set_implicit_neighbor_dofs ( bool  implicit_neighbor_dofs)

Allow the implicit_neighbor_dofs flag to be set programmatically.

This overrides the –implicit_neighbor_dofs commandline option. We can use this to set the implicit neighbor dofs option differently for different systems, whereas the commandline option is the same for all systems.

Definition at line 1893 of file dof_map.C.

1894{
1896 _implicit_neighbor_dofs = implicit_neighbor_dofs;
1897}

Referenced by DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ set_nonlocal_dof_objects()

template<typename iterator_type >
void libMesh::DofMap::set_nonlocal_dof_objects ( iterator_type  objects_begin,
iterator_type  objects_end,
MeshBase &  mesh,
dofobject_accessor  objects 
)
private

Helper function for distributing dofs in parallel.

Definition at line 319 of file dof_map.C.

323{
324 // This function must be run on all processors at once
325 parallel_object_only();
326
327 // First, iterate over local objects to find out how many
328 // are on each processor
329 std::unordered_map<processor_id_type, dof_id_type> ghost_objects_from_proc;
330
331 iterator_type it = objects_begin;
332
333 for (; it != objects_end; ++it)
334 {
335 DofObject * obj = *it;
336
337 if (obj)
338 {
339 processor_id_type obj_procid = obj->processor_id();
340 // We'd better be completely partitioned by now
341 libmesh_assert_not_equal_to (obj_procid, DofObject::invalid_processor_id);
342 ghost_objects_from_proc[obj_procid]++;
343 }
344 }
345
346 // Request sets to send to each processor
347 std::map<processor_id_type, std::vector<dof_id_type>>
348 requested_ids;
349
350 // We know how many of our objects live on each processor, so
351 // reserve() space for requests from each.
352 for (auto [p, size] : ghost_objects_from_proc)
353 {
354 if (p != this->processor_id())
355 requested_ids[p].reserve(size);
356 }
357
358 for (it = objects_begin; it != objects_end; ++it)
359 {
360 DofObject * obj = *it;
361 if (obj->processor_id() != DofObject::invalid_processor_id)
362 requested_ids[obj->processor_id()].push_back(obj->id());
363 }
364#ifdef DEBUG
365 for (auto p : make_range(this->n_processors()))
366 {
367 if (ghost_objects_from_proc.count(p))
368 libmesh_assert_equal_to (requested_ids[p].size(), ghost_objects_from_proc[p]);
369 else
370 libmesh_assert(!requested_ids.count(p));
371 }
372#endif
373
374 typedef std::vector<dof_id_type> datum;
375
376 auto gather_functor =
377 [this, &mesh, &objects]
379 const std::vector<dof_id_type> & ids,
380 std::vector<datum> & data)
381 {
382 // Fill those requests
383 const unsigned int
384 sys_num = this->sys_number(),
385 n_var_groups = this->n_variable_groups();
386
387 const std::size_t query_size = ids.size();
388
389 data.resize(query_size);
390 for (auto & d : data)
391 d.resize(2 * n_var_groups);
392
393 for (std::size_t i=0; i != query_size; ++i)
394 {
395 DofObject * requested = (this->*objects)(mesh, ids[i]);
396 libmesh_assert(requested);
397 libmesh_assert_equal_to (requested->processor_id(), this->processor_id());
398 libmesh_assert_equal_to (requested->n_var_groups(sys_num), n_var_groups);
399 for (unsigned int vg=0; vg != n_var_groups; ++vg)
400 {
401 unsigned int n_comp_g =
402 requested->n_comp_group(sys_num, vg);
403 data[i][vg] = n_comp_g;
404 dof_id_type my_first_dof = n_comp_g ?
405 requested->vg_dof_base(sys_num, vg) : 0;
406 libmesh_assert_not_equal_to (my_first_dof, DofObject::invalid_id);
407 data[i][n_var_groups+vg] = my_first_dof;
408 }
409 }
410 };
411
412 auto action_functor =
413 [this, &mesh, &objects]
414 (processor_id_type libmesh_dbg_var(pid),
415 const std::vector<dof_id_type> & ids,
416 const std::vector<datum> & data)
417 {
418 const unsigned int
419 sys_num = this->sys_number(),
420 n_var_groups = this->n_variable_groups();
421
422 // Copy the id changes we've now been informed of
423 for (auto i : index_range(ids))
424 {
425 DofObject * requested = (this->*objects)(mesh, ids[i]);
426 libmesh_assert(requested);
427 libmesh_assert_equal_to (requested->processor_id(), pid);
428 for (unsigned int vg=0; vg != n_var_groups; ++vg)
429 {
430 unsigned int n_comp_g =
431 cast_int<unsigned int>(data[i][vg]);
432 requested->set_n_comp_group(sys_num, vg, n_comp_g);
433 if (n_comp_g)
434 {
435 dof_id_type my_first_dof = data[i][n_var_groups+vg];
436 libmesh_assert_not_equal_to (my_first_dof, DofObject::invalid_id);
437 requested->set_vg_dof_base
438 (sys_num, vg, my_first_dof);
439 }
440 }
441 }
442 };
443
444 datum * ex = nullptr;
446 (this->comm(), requested_ids, gather_functor, action_functor, ex);
447
448#ifdef DEBUG
449 // Double check for invalid dofs
450 for (it = objects_begin; it != objects_end; ++it)
451 {
452 DofObject * obj = *it;
453 libmesh_assert (obj);
454 unsigned int num_variables = obj->n_vars(this->sys_number());
455 for (unsigned int v=0; v != num_variables; ++v)
456 {
457 unsigned int n_comp =
458 obj->n_comp(this->sys_number(), v);
459 dof_id_type my_first_dof = n_comp ?
460 obj->dof_number(this->sys_number(), v, 0) : 0;
461 libmesh_assert_not_equal_to (my_first_dof, DofObject::invalid_id);
462 }
463 }
464#endif
465}
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition dof_object.h:484

References libMesh::ParallelObject::comm(), libMesh::DofObject::dof_number(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::DofObject::invalid_id, libMesh::DofObject::invalid_processor_id, libMesh::libmesh_assert(), libMesh::make_range(), mesh, libMesh::DofObject::n_comp(), libMesh::DofObject::n_comp_group(), libMesh::ParallelObject::n_processors(), libMesh::DofObject::n_var_groups(), n_variable_groups(), libMesh::DofObject::n_vars(), libMesh::DofObject::processor_id(), libMesh::ParallelObject::processor_id(), TIMPI::pull_parallel_vector_data(), libMesh::DofObject::set_n_comp_group(), libMesh::DofObject::set_vg_dof_base(), sys_number(), and libMesh::DofObject::vg_dof_base().

◆ set_verify_dirichlet_bc_consistency()

void libMesh::DofMap::set_verify_dirichlet_bc_consistency ( bool  val)

Set the _verify_dirichlet_bc_consistency flag.

Definition at line 1899 of file dof_map.C.

1900{
1902}

◆ should_p_refine() [1/6]

bool libMesh::DofMap::should_p_refine ( FEFamily  ) const
delete

◆ should_p_refine() [2/6]

void libMesh::DofMap::should_p_refine ( FEFamily  ,
bool   
)
delete

◆ should_p_refine() [3/6]

bool libMesh::DofMap::should_p_refine ( Order  ) const
delete

◆ should_p_refine() [4/6]

void libMesh::DofMap::should_p_refine ( Order  ,
bool   
)
delete

◆ should_p_refine() [5/6]

bool libMesh::DofMap::should_p_refine ( unsigned int  g) const
inline

Whether the given variable group should be p-refined.

Definition at line 2607 of file dof_map.h.

2608{
2609#ifdef LIBMESH_ENABLE_AMR
2610 const VariableGroup & var = this->variable_group(g);
2611 return var.type().p_refinement;
2612#else
2613 libmesh_ignore(g);
2614 return false;
2615#endif
2616}

References libMesh::libmesh_ignore(), libMesh::FEType::p_refinement, libMesh::Variable::type(), and variable_group().

◆ should_p_refine() [6/6]

void libMesh::DofMap::should_p_refine ( unsigned int  g,
bool  p_refine 
)
inline

Set whether the given variable group should be p-refined on a p-refined Elem.

This changes the FEType of the variable group to enable or disable p-refinement.

Definition at line 2589 of file dof_map.h.

2590{
2591#ifdef LIBMESH_ENABLE_AMR
2592 VariableGroup & var = _variable_groups[g];
2593 var.type().p_refinement = p_refine;
2594
2595 for (auto v : make_range(var.first_scalar_number(0),
2596 var.first_scalar_number(0) +
2597 var.n_variables()))
2598 this->_variables[v].type().p_refinement = p_refine;
2599
2600
2601#else
2602 libmesh_ignore(g, p_refine);
2603#endif
2604}

References _variable_groups, _variables, libMesh::VariableGroup::first_scalar_number(), libMesh::libmesh_ignore(), libMesh::make_range(), libMesh::VariableGroup::n_variables(), libMesh::FEType::p_refinement, and libMesh::Variable::type().

Referenced by should_p_refine_var().

◆ should_p_refine_var()

bool libMesh::DofMap::should_p_refine_var ( unsigned int  var) const
inline

Whether the given variable should be p-refined.

Definition at line 2626 of file dof_map.h.

2627{
2628#ifdef LIBMESH_ENABLE_AMR
2629 const auto vg = this->var_group_from_var_number(var);
2630 return this->should_p_refine(vg);
2631#else
2632 libmesh_ignore(var);
2633 return false;
2634#endif
2635}
unsigned int var_group_from_var_number(unsigned int var_num) const
Definition dof_map.h:2619
void should_p_refine(unsigned int g, bool p_refine)
Set whether the given variable group should be p-refined on a p-refined Elem.
Definition dof_map.h:2589

References libMesh::libmesh_ignore(), should_p_refine(), and var_group_from_var_number().

◆ stash_dof_constraints()

void libMesh::DofMap::stash_dof_constraints ( )
inline

◆ swap_dof_constraints()

void libMesh::DofMap::swap_dof_constraints ( )
inline

Similar to the stash/unstash_dof_constraints() API, but swaps _dof_constraints and _stashed_dof_constraints without asserting that the source or destination is empty first.

Note
There is an implicit assumption that swapping between sets of Constraints does not change the sparsity pattern or expand the send_list, since the only thing changed is the DofConstraints themselves. This is intended to work for swapping between DofConstraints A and B, where A is used to define the send_list, and B is a subset of A.

Definition at line 1210 of file dof_map.h.

1211 {
1213 }

References _dof_constraints, and _stashed_dof_constraints.

◆ sys_number()

unsigned int libMesh::DofMap::sys_number ( ) const
inline
Returns
The number of the system we are responsible for.

Definition at line 2353 of file dof_map.h.

2354{
2355 return _sys_number;
2356}

References _sys_number.

Referenced by _dof_indices(), allgather_recursive_constraints(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), constrain_p_dofs(), process_mesh_constraint_rows(), reinit(), and set_nonlocal_dof_objects().

◆ unstash_dof_constraints()

void libMesh::DofMap::unstash_dof_constraints ( )
inline

◆ update_sparsity_pattern()

void libMesh::DofMap::update_sparsity_pattern ( SparseMatrix< Number > &  matrix) const

Additional matrices may be be temporarily initialized by this DofMap.

They are initialized to the same sparsity structure as the major matrix.

Definition at line 270 of file dof_map.C.

271{
272 matrix.attach_dof_map (*this);
273
274 // If we've already computed sparsity, then it's too late
275 // to wait for "compute_sparsity" to help with sparse matrix
276 // initialization, and we need to handle this matrix individually
277 if (this->computed_sparsity_already())
278 {
279 libmesh_assert(_sp.get());
280
281 if (matrix.need_full_sparsity_pattern())
282 {
283 // We'd better have already computed the full sparsity
284 // pattern if we need it here
286
287 matrix.update_sparsity_pattern (_sp->get_sparsity_pattern());
288 }
289
291 }
292}
virtual void update_sparsity_pattern(const SparsityPattern::Graph &)
Updates the matrix sparsity pattern.
void attach_dof_map(const DofMap &dof_map)
Set a pointer to the DofMap to use.
void attach_sparsity_pattern(const SparsityPattern::Build &sp)
Set a pointer to a sparsity pattern to use.

References _need_full_sparsity_pattern, _sp, libMesh::SparseMatrix< T >::attach_dof_map(), libMesh::SparseMatrix< T >::attach_sparsity_pattern(), computed_sparsity_already(), libMesh::libmesh_assert(), libMesh::SparseMatrix< T >::need_full_sparsity_pattern(), and libMesh::SparseMatrix< T >::update_sparsity_pattern().

Referenced by attach_matrix(), and libMesh::System::solve_for_unconstrained_dofs().

◆ use_coupled_neighbor_dofs()

bool libMesh::DofMap::use_coupled_neighbor_dofs ( const MeshBase &  mesh) const

Tells other library functions whether or not this problem includes coupling between dofs in neighboring cells, as can currently be specified on the command line or inferred from the use of all discontinuous variables.

Definition at line 1905 of file dof_map.C.

1906{
1907 // If we were asked on the command line, then we need to
1908 // include sensitivities between neighbor degrees of freedom
1909 bool implicit_neighbor_dofs =
1910 libMesh::on_command_line ("--implicit-neighbor-dofs");
1911
1912 // If the user specifies --implicit-neighbor-dofs 0, then
1913 // presumably he knows what he is doing and we won't try to
1914 // automatically turn it on even when all the variables are
1915 // discontinuous.
1916 if (implicit_neighbor_dofs)
1917 {
1918 // No flag provided defaults to 'true'
1919 int flag = 1;
1920 flag = libMesh::command_line_next ("--implicit-neighbor-dofs", flag);
1921
1922 if (!flag)
1923 {
1924 // The user said --implicit-neighbor-dofs 0, so he knows
1925 // what he is doing and really doesn't want it.
1926 return false;
1927 }
1928 }
1929
1930 // Possibly override the commandline option, if set_implicit_neighbor_dofs
1931 // has been called.
1933 {
1934 implicit_neighbor_dofs = _implicit_neighbor_dofs;
1935
1936 // Again, if the user explicitly says implicit_neighbor_dofs = false,
1937 // then we return here.
1938 if (!implicit_neighbor_dofs)
1939 return false;
1940 }
1941
1942 // Look at all the variables in this system. If every one is
1943 // discontinuous then the user must be doing DG/FVM, so be nice
1944 // and force implicit_neighbor_dofs=true.
1945 {
1946 bool all_discontinuous_dofs = true;
1947
1948 // We may call this method even without ever having initialized our data
1949 for (auto var : index_range(this->_variables))
1950 if (FEInterface::get_continuity(this->variable_type(var)) != DISCONTINUOUS)
1951 all_discontinuous_dofs = false;
1952
1953 if (all_discontinuous_dofs)
1954 implicit_neighbor_dofs = true;
1955 }
1956
1957 return implicit_neighbor_dofs;
1958}
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.
Definition libmesh.C:1025

References libMesh::command_line_next(), libMesh::DISCONTINUOUS, libMesh::index_range(), and libMesh::on_command_line().

Referenced by build_sparsity(), and reinit().

◆ var_group_from_var_number()

unsigned int libMesh::DofMap::var_group_from_var_number ( unsigned int  var_num) const
inline
Returns
The variable group number that the provided variable number belongs to

Definition at line 2619 of file dof_map.h.

2620{
2621 libmesh_assert(var_num < n_variables());
2622 return libmesh_map_find(_var_to_vg, var_num);
2623}

References _var_to_vg, libMesh::libmesh_assert(), and n_variables().

Referenced by should_p_refine_var(), and EquationSystemsTest::testSelectivePRefine().

◆ variable()

const Variable & libMesh::DofMap::variable ( const unsigned int  c) const
inlineoverridevirtual
Returns
The variable description object for variable c.

Implements libMesh::DofMapBase.

Definition at line 2371 of file dof_map.h.

2372{
2373 libmesh_assert_less (c, _variables.size());
2374
2375 return _variables[c];
2376}

References _variables.

Referenced by libMesh::FEGenericBase< OutputType >::compute_proj_constraints(), DMlibMeshSetSystem_libMesh(), libMesh::BoundaryProjectSolution::operator()(), and libMesh::StaticCondensationDofMap::reinit().

◆ variable_group()

const VariableGroup & libMesh::DofMap::variable_group ( const unsigned int  c) const
inline
Returns
The VariableGroup description object for group g.

Definition at line 2361 of file dof_map.h.

2362{
2363 libmesh_assert_less (g, _variable_groups.size());
2364
2365 return _variable_groups[g];
2366}

References _variable_groups.

Referenced by _dof_indices(), dof_indices(), libMesh::StaticCondensationDofMap::reinit(), and should_p_refine().

◆ variable_group_order()

Order libMesh::DofMap::variable_group_order ( const unsigned int  vg) const
inline
Returns
The approximation order for VariableGroup vg.

Definition at line 2391 of file dof_map.h.

2392{
2393 libmesh_assert_less (vg, _variable_groups.size());
2394
2395 return _variable_groups[vg].type().order;
2396}

References _variable_groups.

◆ variable_group_type()

const FEType & libMesh::DofMap::variable_group_type ( const unsigned int  vg) const
inline
Returns
The finite element type for VariableGroup vg.

Definition at line 2411 of file dof_map.h.

2412{
2413 libmesh_assert_less (vg, _variable_groups.size());
2414
2415 return _variable_groups[vg].type();
2416}

References _variable_groups.

◆ variable_name()

const std::string & libMesh::DofMap::variable_name ( const unsigned int  i) const
inline
Returns
The name of variable i.

Definition at line 2962 of file dof_map.h.

2963{
2964 libmesh_assert_less (i, _variables.size());
2965
2966 return _variables[i].name();
2967}

References _variables.

◆ variable_number()

unsigned int libMesh::DofMap::variable_number ( std::string_view  var) const
inline
Returns
The variable number associated with the user-specified variable named var.

Definition at line 3010 of file dof_map.h.

3011{
3012 auto var_num = libmesh_map_find(_variable_numbers, var);
3013 libmesh_assert_equal_to(_variables[var_num].name(), var);
3014 return var_num;
3015}

References _variable_numbers, and _variables.

Referenced by create_dof_constraints(), libMesh::System::variable_number(), and variable_type().

◆ variable_order()

Order libMesh::DofMap::variable_order ( const unsigned int  c) const
inline
Returns
The approximation order for variable c.

Definition at line 2381 of file dof_map.h.

2382{
2383 libmesh_assert_less (c, _variables.size());
2384
2385 return _variables[c].type().order;
2386}

References _variables.

◆ variable_scalar_number()

unsigned int libMesh::DofMap::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
inline
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as var_num

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2993 of file dof_map.h.

2995{
2996 return _variables[var_num].first_scalar_number() + component;
2997}

References _variables.

◆ variable_type() [1/2]

const FEType & libMesh::DofMap::variable_type ( const unsigned int  i) const
inline
Returns
The finite element type for variable number i.

Definition at line 2401 of file dof_map.h.

2402{
2403 libmesh_assert_less (c, _variables.size());
2404
2405 return _variables[c].type();
2406}

References _variables.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::MeshFunction::_gradient_on_elem(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_elasticity(), assemble_mass(), assemble_matrices(), assemble_poisson(), assemble_SchroedingerEquation(), Biharmonic::JR::bounds(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), libMesh::FEInterface::compute_constraints(), compute_enriched_soln(), compute_jacobian(), libMesh::FEGenericBase< OutputType >::compute_periodic_constraints(), libMesh::FEInterface::compute_periodic_constraints(), compute_residual(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), LinearElasticityWithContact::compute_stresses(), compute_stresses(), constrain_p_dofs(), libMesh::MeshFunction::discontinuous_value(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshFunction::hessian(), libMesh::InfFE< Dim, T_radial, T_map >::inf_compute_constraints(), LargeDeformationElasticity::jacobian(), LinearElasticityWithContact::move_mesh(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SmoothnessEstimator::EstimateSmoothness::operator()(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), process_mesh_constraint_rows(), LargeDeformationElasticity::residual(), LinearElasticityWithContact::residual_and_jacobian(), Biharmonic::JR::residual_and_jacobian(), and libMesh::HPCoarsenTest::select_refinement().

◆ variable_type() [2/2]

const FEType & libMesh::DofMap::variable_type ( std::string_view  var) const
inline
Returns
The finite element type for variable var.

Definition at line 3000 of file dof_map.h.

3001{
3002 return _variables[this->variable_number(var)].type();
3003}

References _variables, and variable_number().

Friends And Related Symbol Documentation

◆ SparsityPattern::Build

friend class SparsityPattern::Build
friend

Definition at line 2324 of file dof_map.h.

Member Data Documentation

◆ _adjoint_constraint_values

AdjointDofConstraintValues libMesh::DofMap::_adjoint_constraint_values
private

◆ _adjoint_dirichlet_boundaries

std::vector<std::unique_ptr<DirichletBoundaries> > libMesh::DofMap::_adjoint_dirichlet_boundaries
private

Data structure containing Dirichlet functions.

The ith entry is the constraint matrix row for boundaryid i.

Definition at line 2321 of file dof_map.h.

Referenced by add_adjoint_dirichlet_boundary(), create_dof_constraints(), get_adjoint_dirichlet_boundaries(), get_adjoint_dirichlet_boundaries(), get_local_constraints(), has_adjoint_dirichlet_boundaries(), and remove_adjoint_dirichlet_boundary().

◆ _algebraic_ghosting_functors

std::vector<GhostingFunctor *> libMesh::DofMap::_algebraic_ghosting_functors
private

The list of all GhostingFunctor objects to be used when distributing ghosted vectors.

The library should automatically refer these functors to the MeshBase, too, so any algebraically ghosted dofs will live on geometrically ghosted elements.

Keep these in a vector so any parallel computation is done in the same order on all processors.

Definition at line 2227 of file dof_map.h.

Referenced by algebraic_ghosting_functors_begin(), and algebraic_ghosting_functors_end().

◆ _array_variables

std::vector<std::pair<unsigned int, unsigned int> > libMesh::DofMap::_array_variables
private

Array variable information storage.

For a given array "variable", the first member of the pair denotes the first variable number present in the array variable and the second member of the pair denotes the last variable number present in the array variables plus one

Definition at line 2131 of file dof_map.h.

Referenced by get_variable_array().

◆ _augment_send_list

AugmentSendList* libMesh::DofMap::_augment_send_list
private

Function object to call to add extra entries to the send list.

Definition at line 2188 of file dof_map.h.

Referenced by attach_extra_send_list_object().

◆ _augment_sparsity_pattern

SparsityPattern::AugmentSparsityPattern* libMesh::DofMap::_augment_sparsity_pattern
private

Function object to call to add extra entries to the sparsity pattern.

Definition at line 2171 of file dof_map.h.

Referenced by attach_extra_sparsity_object(), and build_sparsity().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _constrained_sparsity_construction

bool libMesh::DofMap::_constrained_sparsity_construction
private

This flag indicates whether or not we explicitly take constraint equations into account when computing a sparsity pattern.

Definition at line 2098 of file dof_map.h.

Referenced by constrained_sparsity_construction(), and set_constrained_sparsity_construction().

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::get_info().

◆ _coupling_functors

std::vector<GhostingFunctor *> libMesh::DofMap::_coupling_functors
private

The list of all GhostingFunctor objects to be used when coupling degrees of freedom in matrix sparsity patterns.

These objects will also be used as algebraic ghosting functors, but not vice-versa.

The library should automatically refer these functors to the MeshBase, too, so any dofs coupled to local dofs will live on geometrically ghosted elements.

Definition at line 2240 of file dof_map.h.

Referenced by build_sparsity(), coupling_functors_begin(), and coupling_functors_end().

◆ _default_coupling

std::unique_ptr<DefaultCoupling> libMesh::DofMap::_default_coupling
private

The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern construction.

We use a std::unique_ptr here to reduce header dependencies.

Definition at line 2206 of file dof_map.h.

Referenced by default_coupling(), DofMap(), reinit(), and ~DofMap().

◆ _default_evaluating

std::unique_ptr<DefaultCoupling> libMesh::DofMap::_default_evaluating
private

The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction.

We use a std::unique_ptr here to reduce header dependencies.

Definition at line 2214 of file dof_map.h.

Referenced by default_algebraic_ghosting(), DofMap(), and ~DofMap().

◆ _dirichlet_boundaries

std::unique_ptr<DirichletBoundaries> libMesh::DofMap::_dirichlet_boundaries
private

Data structure containing Dirichlet functions.

The ith entry is the constraint matrix row for boundaryid i.

Definition at line 2315 of file dof_map.h.

Referenced by add_dirichlet_boundary(), create_dof_constraints(), get_dirichlet_boundaries(), get_dirichlet_boundaries(), and remove_dirichlet_boundary().

◆ _dof_constraints

DofConstraints libMesh::DofMap::_dof_constraints
private

◆ _dof_coupling

CouplingMatrix* libMesh::DofMap::_dof_coupling

Degree of freedom coupling.

If left empty each DOF couples to all others. Can be used to reduce memory requirements for sparse matrices. DOF 0 might only couple to itself, in which case dof_coupling(0,0) should be 1 and dof_coupling(0,j) = 0 for j not equal to 0.

This variable is named as though it were class private, but it is in the public interface. Also there are no public methods for accessing it... This typically means you should only use it if you know what you are doing.

Definition at line 1748 of file dof_map.h.

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector(), build_sparsity(), main(), and reinit().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _end_df

std::vector<dof_id_type> libMesh::DofMapBase::_end_df
protectedinherited

◆ _end_old_df

std::vector<dof_id_type> libMesh::DofMapBase::_end_old_df
protectedinherited

Last old DOF index (plus 1) on processor p.

Definition at line 181 of file dof_map_base.h.

Referenced by libMesh::DofMapBase::end_old_dof().

◆ _error_on_constraint_loop

bool libMesh::DofMap::_error_on_constraint_loop
private

This flag indicates whether or not we do an opt-mode check for the presence of constraint loops, i.e.

cases where the constraint graph is cyclic.

Definition at line 2092 of file dof_map.h.

Referenced by process_constraints(), and set_error_on_constraint_loop().

◆ _extra_send_list_context

void* libMesh::DofMap::_extra_send_list_context
private

A pointer associated with the extra send list that can optionally be passed in.

Definition at line 2198 of file dof_map.h.

Referenced by attach_extra_send_list_function().

◆ _extra_send_list_function

void(* libMesh::DofMap::_extra_send_list_function) (std::vector< dof_id_type > &, void *)
private

A function pointer to a function to call to add extra entries to the send list.

Definition at line 2193 of file dof_map.h.

Referenced by attach_extra_send_list_function().

◆ _extra_sparsity_context

void* libMesh::DofMap::_extra_sparsity_context
private

A pointer associated with the extra sparsity that can optionally be passed in.

Definition at line 2183 of file dof_map.h.

Referenced by attach_extra_sparsity_function(), and build_sparsity().

◆ _extra_sparsity_function

void(* libMesh::DofMap::_extra_sparsity_function) (SparsityPattern::Graph &, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *)
private

A function pointer to a function to call to add extra entries to the sparsity pattern.

Definition at line 2176 of file dof_map.h.

Referenced by attach_extra_sparsity_function(), and build_sparsity().

◆ _first_df

std::vector<dof_id_type> libMesh::DofMapBase::_first_df
protectedinherited

◆ _first_old_df

std::vector<dof_id_type> libMesh::DofMapBase::_first_old_df
protectedinherited

First old DOF index on processor p.

Definition at line 176 of file dof_map_base.h.

Referenced by libMesh::DofMapBase::first_old_dof().

◆ _first_old_scalar_df

std::vector<dof_id_type> libMesh::DofMap::_first_old_scalar_df
private

First old DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.

Definition at line 2279 of file dof_map.h.

◆ _first_scalar_df

std::vector<dof_id_type> libMesh::DofMap::_first_scalar_df
private

First DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.

Definition at line 2160 of file dof_map.h.

◆ _identify_variable_groups

bool libMesh::DofMap::_identify_variable_groups = true
private

true when VariableGroup structures should be automatically identified, false otherwise.

Defaults to true.

Definition at line 2137 of file dof_map.h.

Referenced by identify_variable_groups(), and identify_variable_groups().

◆ _implicit_neighbor_dofs

bool libMesh::DofMap::_implicit_neighbor_dofs
private

Definition at line 2331 of file dof_map.h.

◆ _implicit_neighbor_dofs_initialized

bool libMesh::DofMap::_implicit_neighbor_dofs_initialized
private

Bools to indicate if we override the –implicit_neighbor_dofs commandline options.

Definition at line 2330 of file dof_map.h.

◆ _matrices

std::vector<SparseMatrix<Number> * > libMesh::DofMap::_matrices
private

Additional matrices handled by this object.

These pointers do not handle the memory, instead, System, who told DofMap about them, owns them.

Definition at line 2154 of file dof_map.h.

Referenced by attach_matrix(), DofMap(), and is_attached().

◆ _mesh

MeshBase& libMesh::DofMap::_mesh
private

The mesh that system uses.

Definition at line 2147 of file dof_map.h.

Referenced by DofMap(), local_variable_indices(), n_local_dofs(), and ~DofMap().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_dfs

dof_id_type libMesh::DofMapBase::_n_dfs
protectedinherited

Total number of degrees of freedom.

Definition at line 164 of file dof_map_base.h.

Referenced by libMesh::DofMapBase::clear(), and libMesh::DofMapBase::n_dofs().

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

◆ _n_old_dfs

dof_id_type libMesh::DofMapBase::_n_old_dfs
protectedinherited

Total number of degrees of freedom on old dof objects.

Definition at line 171 of file dof_map_base.h.

Referenced by libMesh::DofMapBase::n_old_dofs().

◆ _n_SCALAR_dofs

dof_id_type libMesh::DofMap::_n_SCALAR_dofs
private

The total number of SCALAR dofs associated to all SCALAR variables.

Definition at line 2271 of file dof_map.h.

Referenced by n_SCALAR_dofs().

◆ _need_full_sparsity_pattern

bool libMesh::DofMap::_need_full_sparsity_pattern
private

Default false; set to true if any attached matrix requires a full sparsity pattern.

Definition at line 2252 of file dof_map.h.

Referenced by attach_matrix(), build_sparsity(), full_sparsity_pattern_needed(), and update_sparsity_pattern().

◆ _need_ghost_constraints

bool libMesh::DofMap::_need_ghost_constraints
private

Default false; set to true if the dependencies of constrained ghost DOFs supported by local elements should also be ghosted.

Definition at line 2258 of file dof_map.h.

Referenced by add_constraints_to_send_list(), and ghost_constraints_needed().

◆ _node_constraints

NodeConstraints libMesh::DofMap::_node_constraints
private

◆ _periodic_boundaries

std::unique_ptr<PeriodicBoundaries> libMesh::DofMap::_periodic_boundaries
private

Data structure containing periodic boundaries.

The ith entry is the constraint matrix row for boundaryid i.

Definition at line 2307 of file dof_map.h.

Referenced by add_periodic_boundary(), create_dof_constraints(), DofMap(), get_periodic_boundaries(), get_periodic_boundaries(), is_periodic_boundary(), and process_mesh_constraint_rows().

◆ _primal_constraint_values

DofConstraintValueMap libMesh::DofMap::_primal_constraint_values
private

◆ _sc

std::unique_ptr<StaticCondensationDofMap> libMesh::DofMap::_sc
private

Static condensation class.

Definition at line 2346 of file dof_map.h.

Referenced by build_sparsity(), get_static_condensation(), get_static_condensation(), and has_static_condensation().

◆ _send_list

std::vector<dof_id_type> libMesh::DofMap::_send_list
private

A list containing all the global DOF indices that affect the solution on my processor.

Definition at line 2166 of file dof_map.h.

Referenced by add_constraints_to_send_list(), clear_send_list(), and get_send_list().

◆ _shared_functors

std::map<GhostingFunctor *, std::shared_ptr<GhostingFunctor> > libMesh::DofMap::_shared_functors
private

Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.

Definition at line 2246 of file dof_map.h.

Referenced by add_algebraic_ghosting_functor(), and add_coupling_functor().

◆ _sp

std::unique_ptr<SparsityPattern::Build> libMesh::DofMap::_sp
private

The sparsity pattern of the global matrix.

If need_full_sparsity_pattern is true, we save the entire sparse graph here. Otherwise we save just the n_nz and n_oz vectors.

Definition at line 2265 of file dof_map.h.

Referenced by computed_sparsity_already(), get_n_nz(), get_n_oz(), get_sparsity_pattern(), and update_sparsity_pattern().

◆ _stashed_dof_constraints

DofConstraints libMesh::DofMap::_stashed_dof_constraints
private

◆ _sys_number

const unsigned int libMesh::DofMap::_sys_number
private

The number of the system we manage DOFs for.

Definition at line 2142 of file dof_map.h.

Referenced by sys_number().

◆ _var_to_vg

std::unordered_map<unsigned int, unsigned int> libMesh::DofMap::_var_to_vg
private

A map from variable number to variable group number.

Definition at line 2118 of file dof_map.h.

Referenced by array_dof_indices(), and var_group_from_var_number().

◆ _variable_group_numbers

std::vector<unsigned int> libMesh::DofMap::_variable_group_numbers
private

The variable group number for each variable.

Definition at line 2113 of file dof_map.h.

Referenced by dof_indices().

◆ _variable_groups

std::vector<VariableGroup> libMesh::DofMap::_variable_groups
private

The variable groups in this system/degree of freedom map.

Definition at line 2108 of file dof_map.h.

Referenced by array_dof_indices(), n_variable_groups(), should_p_refine(), variable_group(), variable_group_order(), and variable_group_type().

◆ _variable_numbers

std::map<std::string, unsigned int, std::less<> > libMesh::DofMap::_variable_numbers
private

The variable numbers corresponding to user-specified names, useful for name-based lookups.

Definition at line 2124 of file dof_map.h.

Referenced by has_variable(), and variable_number().

◆ _variables

std::vector<Variable> libMesh::DofMap::_variables
private

The variables in this system/degree of freedom map.

Definition at line 2103 of file dof_map.h.

Referenced by n_components(), n_variables(), n_vars(), should_p_refine(), variable(), variable_name(), variable_number(), variable_order(), variable_scalar_number(), variable_type(), and variable_type().

◆ _verify_dirichlet_bc_consistency

bool libMesh::DofMap::_verify_dirichlet_bc_consistency
private

Flag which determines whether we should do some additional checking of the consistency of the DirichletBoundary objects added by the user.

Defaults to true, but can be disabled in cases where you only want to add DirichletBoundary objects "locally" and can guarantee that no repartitioning will be done, since repartitioning could cause processors to own new boundary sides for which they no longer have the proper DirichletBoundary objects stored.

Definition at line 2343 of file dof_map.h.

Referenced by create_dof_constraints().


The documentation for this class was generated from the following files: