20#ifndef LIBMESH_DOF_MAP_H
21#define LIBMESH_DOF_MAP_H
24#include "libmesh/libmesh_common.h"
25#include "libmesh/reference_counted_object.h"
26#include "libmesh/libmesh.h"
27#include "libmesh/variable.h"
28#include "libmesh/threads.h"
29#include "libmesh/threads_allocators.h"
30#include "libmesh/elem_range.h"
31#include "libmesh/ghosting_functor.h"
32#include "libmesh/sparsity_pattern.h"
33#include "libmesh/parallel_object.h"
34#include "libmesh/point.h"
35#include "libmesh/utility.h"
36#include "libmesh/elem.h"
37#include "libmesh/fe_interface.h"
38#include "libmesh/libmesh_logging.h"
39#include "libmesh/enum_elem_type.h"
40#include "libmesh/mesh_subdivision_support.h"
41#include "libmesh/dof_map_base.h"
62class DirichletBoundary;
63class DirichletBoundaries;
68class PeriodicBoundaryBase;
69class PeriodicBoundaries;
71class NonlinearImplicitSystem;
72class StaticCondensationDofMap;
73template <
typename T>
class DenseVectorBase;
74template <
typename T>
class DenseVector;
75template <
typename T>
class DenseMatrix;
76template <
typename T>
class SparseMatrix;
77template <
typename T>
class NumericVector;
85#if defined(LIBMESH_ENABLE_AMR) || \
86 defined(LIBMESH_ENABLE_PERIODIC) || \
87 defined(LIBMESH_ENABLE_DIRICHLET)
88# define LIBMESH_ENABLE_CONSTRAINTS 1
94#ifdef LIBMESH_ENABLE_CONSTRAINTS
99 std::less<dof_id_type>,
110 std::less<dof_id_type>,
111 Threads::scalable_allocator<std::pair<const dof_id_type, DofConstraintRow>>>
121 public std::map<dof_id_type, Number,
122 std::less<dof_id_type>,
123 Threads::scalable_allocator<std::pair<const dof_id_type, Number>>>
132 public std::map<unsigned int, DofConstraintValueMap,
133 std::less<unsigned int>,
134 Threads::scalable_allocator
135 <std::pair<const unsigned int, DofConstraintValueMap>>>
139#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
147 std::less<const Node *>,
157 std::pair<NodeConstraintRow,Point>,
158 std::less<const Node *>,
159 Threads::scalable_allocator<std::pair<const Node * const, std::pair<NodeConstraintRow,Point>>>>
342 bool to_mesh =
true);
404 bool to_mesh =
true);
468 std::vector<dof_id_type> & n_nz,
469 std::vector<dof_id_type> & n_oz,
471 void * context =
nullptr)
491 void * context =
nullptr)
545 return _sp->get_n_nz();
558 return _sp->get_n_oz();
578 unsigned int n_vars()
const;
583 const std::string &
variable_name(
const unsigned int i)
const;
615 unsigned int component)
const;
653 std::string_view var,
655 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
666 const std::vector<std::string> & vars,
668 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
689 const std::vector<std::string> & vars,
691 const std::set<subdomain_id_type> *
const active_subdomains =
nullptr);
737 {
return cast_int<unsigned int>(
_variables.size()); }
776 dof_id_type
n_dofs(
const unsigned int vn)
const
816 { std::vector<dof_id_type>::const_iterator ub =
819 return cast_int<processor_id_type>(ub -
_end_df.begin());
823 std::vector<dof_id_type> & di)
const;
831 std::vector<dof_id_type> & di,
832 const unsigned int vn,
833 int p_level = -12345)
const override;
842 std::vector<dof_id_type> & di,
843 const unsigned int vn,
844 int p_level = -12345)
const;
847 std::vector<dof_id_type> & di,
848 const unsigned int vn)
const;
850 template <
typename DofIndicesFunctor>
852 std::vector<dof_id_type> & di,
853 const unsigned int vn)
const;
884 template <
typename ScalarDofsFunctor,
typename FieldDofsFunctor>
886 std::vector<dof_id_type> & di,
887 const unsigned int vn,
888 ScalarDofsFunctor scalar_dofs_functor,
889 FieldDofsFunctor field_dofs_functor,
890 int p_level = -12345)
const;
897 std::vector<dof_id_type> & di)
const;
904 std::vector<dof_id_type> & di,
905 const unsigned int vn)
const override;
915 std::vector<dof_id_type> & di,
916 const unsigned int vn)
const;
918#ifdef LIBMESH_ENABLE_AMR
928 std::vector<dof_id_type> & di,
929 const unsigned int vn)
const;
942 const unsigned int vn,
943 const bool old_dofs=
false)
const;
968 {
return (dof_index >= this->
first_dof()) && (dof_index < this->
end_dof()); }
975 template <
typename DofObjectSub
class>
1020 template <
typename T, std::enable_if_t<std::is_same_v<T, dof_
id_type> ||
1021 std::is_same_v<T, std::vector<dof_
id_type>>,
int> = 0>
1024 unsigned int var_num)
const;
1031 template <
typename T,
1032 std::enable_if_t<std::is_same_v<T, dof_id_type> ||
1033 std::is_same_v<T, std::vector<dof_id_type>>,
1038#ifdef LIBMESH_ENABLE_CONSTRAINTS
1054#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1097 std::set<dof_id_type> & unexpanded_dofs,
1098 bool look_for_constrainees);
1132 const Number constraint_rhs,
1133 const bool forbid_constraint_overwrite);
1148 const Number constraint_rhs,
1149 const bool forbid_constraint_overwrite);
1158 const bool forbid_constraint_overwrite =
true)
1208#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1278 bool print_nonlocal=
false)
const;
1322 std::vector<dof_id_type> & elem_dofs,
1323 bool asymmetric_constraint_rows =
true)
const;
1332 std::vector<dof_id_type> & row_dofs,
1333 std::vector<dof_id_type> & col_dofs,
1334 bool asymmetric_constraint_rows =
true)
const;
1340 std::vector<dof_id_type> & dofs,
1341 bool asymmetric_constraint_rows =
true)
const;
1353 std::vector<dof_id_type> & elem_dofs,
1354 bool asymmetric_constraint_rows =
true)
const;
1381 std::vector<dof_id_type> & elem_dofs,
1382 bool asymmetric_constraint_rows =
true,
1383 int qoi_index = -1)
const;
1390 std::vector<dof_id_type> & elem_dofs,
1391 bool asymmetric_constraint_rows =
true,
1392 int qoi_index = -1)
const
1395 (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1425 std::vector<dof_id_type> & elem_dofs,
1426 bool asymmetric_constraint_rows =
true,
1427 int qoi_index = -1)
const;
1434 std::vector<dof_id_type> & elem_dofs,
1435 bool asymmetric_constraint_rows =
true,
1436 int qoi_index = -1)
const
1439 (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1463 std::vector<dof_id_type> & elem_dofs,
1481 std::vector<dof_id_type> & elem_dofs,
1501 std::vector<dof_id_type> & elem_dofs,
1514 std::vector<dof_id_type> & row_dofs,
1515 bool asymmetric_constraint_rows =
true)
const;
1540 bool homogeneous =
false)
const;
1549 unsigned int q)
const;
1554 bool homogeneous =
true)
const;
1559#ifdef LIBMESH_ENABLE_PERIODIC
1596#ifdef LIBMESH_ENABLE_DIRICHLET
1663#ifdef LIBMESH_ENABLE_AMR
1678#ifdef LIBMESH_ENABLE_AMR
1687 std::vector<dof_id_type> & di,
1709 const std::map<
const Node *, std::set<subdomain_id_type>> &
1710 constraining_subdomains);
1716 virtual void clear ()
override;
1763 bool calculate_constrained =
false,
1764 bool use_condensed_system =
false)
const;
1831 const std::pair<unsigned int, unsigned int> &
1846 std::vector<dof_id_type> & di,
1847 const unsigned int vg,
1848 const unsigned int vig,
1849 const Node *
const * nodes,
1851 const unsigned int v
1854 std::size_t & tot_size
1873 template <
typename FieldDofsFunctor>
1876 std::vector<dof_id_type> & di,
1877 const unsigned int vg,
1878 const unsigned int vig,
1879 const Node *
const * nodes,
1881 const unsigned int v,
1883 std::size_t & tot_size,
1885 FieldDofsFunctor field_dofs_functor)
const;
1894 std::vector<dof_id_type> & di,
1895 const unsigned int vn)
const;
1921 template<
typename iterator_type>
1923 iterator_type objects_end,
1941 std::map<const Node *, std::set<subdomain_id_type>>
1959 const std::map<
const Node *, std::set<subdomain_id_type>> &
1960 constraining_subdomains);
1980 const std::map<
const Node *, std::set<subdomain_id_type>> &
1981 constraining_subdomains);
2015#ifdef LIBMESH_ENABLE_CONSTRAINTS
2028 std::vector<dof_id_type> & elem_dofs,
2029 const bool called_recursively=
false)
const;
2048 std::vector<dof_id_type> & elem_dofs,
2050 const bool called_recursively=
false)
const;
2170 std::vector<dof_id_type> & n_nz,
2171 std::vector<dof_id_type> & n_oz,
2252 std::unique_ptr<SparsityPattern::Build>
_sp;
2260#ifdef LIBMESH_ENABLE_AMR
2269#ifdef LIBMESH_ENABLE_CONSTRAINTS
2281#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2289#ifdef LIBMESH_ENABLE_PERIODIC
2297#ifdef LIBMESH_ENABLE_DIRICHLET
2333 std::unique_ptr<StaticCondensationDofMap>
_sc;
2406#ifdef LIBMESH_ENABLE_CONSTRAINTS
2411#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2416#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2438 AdjointDofConstraintValues::const_iterator it =
2442 if (it->second.empty())
2453 AdjointDofConstraintValues::const_iterator it =
2457 DofConstraintValueMap::const_iterator rhsit =
2458 it->second.find(dof);
2459 if (rhsit == it->second.end())
2462 return rhsit->second;
2486 std::vector<dof_id_type> &,
2490 std::vector<dof_id_type> &,
2491 std::vector<dof_id_type> &,
2495 std::vector<dof_id_type> &,
2500 std::vector<dof_id_type> &,
2505 std::vector<dof_id_type> &,
bool,
int)
const {}
2509 std::vector<dof_id_type> &,
bool,
int)
const {}
2513 std::vector<dof_id_type> &,
2523 unsigned int)
const {}
2544 if (use_constraints)
2545 libmesh_not_implemented();
2547#ifdef LIBMESH_ENABLE_CONSTRAINTS
2562#ifdef LIBMESH_ENABLE_CONSTRAINTS
2572#ifdef LIBMESH_ENABLE_AMR
2579 this->
_variables[v].type().p_refinement = p_refine;
2590#ifdef LIBMESH_ENABLE_AMR
2603 return libmesh_map_find(
_var_to_vg, var_num);
2609#ifdef LIBMESH_ENABLE_AMR
2618template <
typename FieldDofsFunctor>
2621 std::vector<dof_id_type> & di,
2622 const unsigned int vg,
2623 const unsigned int vig,
2624 const Node *
const * nodes,
2626 const unsigned int v,
2628 std::size_t & tot_size,
2630 FieldDofsFunctor field_dofs_functor)
const
2637 const unsigned int sys_num = this->
sys_number();
2638#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2639 const bool is_inf = elem.
infinite();
2642 const bool extra_hanging_dofs =
2666 for (
unsigned int n=0; n !=
n_nodes; n++)
2668 const Node & node = *nodes[n];
2673 const std::pair<unsigned int, unsigned int>
2675 libmesh_assert_equal_to (vg, vg_and_offset.first);
2676 libmesh_assert_equal_to (vig, vg_and_offset.second);
2678 const unsigned int n_comp = node.
n_comp_group(sys_num,vg);
2684 const unsigned int nc =
2685#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2689 ndan (type, fe_type.
order + add_p_level*p_level, n);
2695 if (extra_hanging_dofs && !elem.
is_vertex(n))
2697 const int dof_offset = n_comp - nc;
2708 for (
int i=
int(n_comp)-1; i>=dof_offset; i--)
2711 node.
dof_number(sys_num, vg, vig, i, n_comp);
2713 field_dofs_functor(elem, n, v, di, d);
2724 const unsigned int good_nc = std::min(n_comp, nc);
2725 for (
unsigned int i=0; i!=good_nc; ++i)
2728 node.
dof_number(sys_num, vg, vig, i, n_comp);
2730 libmesh_assert_less (d, this->
n_dofs());
2731 field_dofs_functor(elem, n, v, di, d);
2738 for (
unsigned int i=n_comp; i!=nc; ++i)
2753 const unsigned int n_comp = elem.
n_comp_group(sys_num,vg);
2754 if (elem.
n_systems() > sys_num && nc <= n_comp)
2756 for (
unsigned int i=0; i<nc; i++)
2759 elem.
dof_number(sys_num, vg, vig, i, n_comp);
2776template <
typename ScalarDofsFunctor,
typename FieldDofsFunctor>
2778 std::vector<dof_id_type> & di,
2779 const unsigned int vn,
2780 ScalarDofsFunctor scalar_dofs_functor,
2781 FieldDofsFunctor field_dofs_functor,
2798 if (p_level == -12345)
2799 p_level = elem ? elem->
p_level() : 0;
2803 const unsigned int vig = vn - var.
number();
2807 std::size_t tot_size = 0;
2819 std::vector<const Node *> elem_nodes;
2822 _dof_indices(*elem, p_level, di, vg, vig, elem_nodes.data(),
2823 cast_int<unsigned int>(elem_nodes.size()), vn,
2827 field_dofs_functor);
2841 std::vector<dof_id_type> di_new;
2843 scalar_dofs_functor(*elem, di, di_new);
2851 field_dofs_functor);
2854 libmesh_assert_equal_to (tot_size, di.size());
2872inline const std::pair<unsigned int, unsigned int> &
2875 auto it = std::upper_bound(
2879 [](
unsigned int value,
const std::pair<unsigned int, unsigned int> &
b) { return value < b.first; });
2882 "Passed in " << std::to_string(vi) <<
" is not in any of our array variables");
2884 libmesh_assert_msg(vi < it->second,
2885 "Passed in " << std::to_string(vi) <<
" is not in any of our array variables");
2889template <
typename DofIndicesFunctor>
2891 std::vector<dof_id_type> & di,
2892 const unsigned int vn)
const
2897 const unsigned int count = end - begin;
2902 di.resize(count * component_size);
2904 const auto pack_container = [&di,
2905 component_size](
const unsigned int j,
2906 const std::vector<dof_id_type> & j_dof_indices,
2907 const unsigned int stride) {
2908 if (&j_dof_indices != &di)
2910 for (
const auto i :
make_range(component_size))
2911 di[j * component_size + i] = j_dof_indices[i] + stride * j;
2913 pack_container(0, di, 0);
2916 if (
const bool lagrange = fe_type.family ==
LAGRANGE;
2919 const auto stride = lagrange ? 1 : component_size;
2920 for (
const auto j :
make_range((
unsigned int)1, count))
2921 pack_container(j, di, stride);
2925 static thread_local std::vector<dof_id_type> work_dof_indices;
2927 for (
const auto i :
make_range(begin + 1, end))
2929 functor(work_dof_indices, i);
2930 pack_container(j++, work_dof_indices, 0);
2939 return cast_int<unsigned int>(
_variables.size());
2975 unsigned int component)
const
2977 return _variables[var_num].first_scalar_number() + component;
2994 libmesh_assert_equal_to(
_variables[var_num].name(), var);
void ErrorVector unsigned int
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
Storage for DofConstraint right hand sides for all adjoint problems.
This class defines a coupling matrix.
This class implements the default algebraic coupling in libMesh: elements couple to themselves,...
Defines a dense matrix for use in Finite Element-type computations.
Defines an abstract dense vector base class for use in Finite Element-type computations.
Defines a dense vector for use in Finite Element-type computations.
We're using a class instead of a typedef to allow forward declarations and future flexibility.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
Storage for DofConstraint right hand sides for a particular problem.
The constraint matrix storage format.
This base class provides a minimal set of interfaces for satisfying user requests for.
dof_id_type n_dofs() const
std::vector< dof_id_type > _end_df
Last DOF index (plus 1) on processor p.
dof_id_type end_dof() const
dof_id_type first_dof() const
dof_id_type n_local_dofs() const
Abstract base class to be used to add user-defined parallel degree of freedom couplings.
virtual void augment_send_list(std::vector< dof_id_type > &send_list)=0
User-defined function to augment the send list.
virtual ~AugmentSendList()=default
Backwards compatibility for prior AugmentSparsityPattern users.
This class handles the numbering of degrees of freedom on a mesh.
void remove_default_ghosting()
Remove any default ghosting functor(s).
bool should_p_refine(Order) const =delete
std::vector< unsigned int > _variable_group_numbers
The variable group number for each variable.
std::size_t distribute_dofs(MeshBase &)
Distribute dofs on the current mesh.
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 add_constraints_to_send_list()
Adds entries to the _send_list vector corresponding to DoFs which are dependencies for constraint equ...
bool _implicit_neighbor_dofs
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,...
void distribute_scalar_dofs(dof_id_type &next_free_dof)
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.
dof_id_type n_dofs() const
DofConstraints::const_iterator constraint_rows_begin() const
void reinit_send_list(MeshBase &mesh)
Clears the _send_list vector and then rebuilds it.
processor_id_type dof_owner(const dof_id_type dof) const
bool _verify_dirichlet_bc_consistency
Flag which determines whether we should do some additional checking of the consistency of the Dirichl...
DofObject *(DofMap::* dofobject_accessor)(MeshBase &mesh, dof_id_type i) const
A member function type like node_ptr() or elem_ptr().
void reinit_static_condensation()
Calls reinit on the static condensation map if it exists.
unsigned int var_group_from_var_number(unsigned int var_num) const
const DirichletBoundaries * get_dirichlet_boundaries() const
unsigned int n_variable_groups() const
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...
std::unordered_map< unsigned int, unsigned int > _var_to_vg
A map from variable number to variable group number.
bool use_coupled_neighbor_dofs(const MeshBase &mesh) const
Tells other library functions whether or not this problem includes coupling between dofs in neighbori...
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 t...
virtual void clear() override
Free all new memory associated with the object, but restore its original state, with the mesh pointer...
unsigned int n_variables() const override
const std::vector< dof_id_type > & get_send_list() const
std::vector< dof_id_type > n_dofs_per_processor(const unsigned int vn) const
const DofConstraints & get_dof_constraints() const
Provide a const accessor to the DofConstraints map.
void allgather_recursive_constraints(MeshBase &)
Gathers constraint equation dependencies from other processors.
GhostingFunctorIterator coupling_functors_begin() const
Beginning of range of coupling functors.
bool all_semilocal_indices(const std::vector< dof_id_type > &dof_indices) const
std::vector< GhostingFunctor * > _algebraic_ghosting_functors
The list of all GhostingFunctor objects to be used when distributing ghosted vectors.
dof_id_type n_local_dofs(const unsigned int vn) const
DofConstraintValueMap _primal_constraint_values
void * _extra_sparsity_context
A pointer associated with the extra sparsity that can optionally be passed in.
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.
NodeConstraints::const_iterator node_constraint_rows_end() const
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.
std::vector< dof_id_type > _send_list
A list containing all the global DOF indices that affect the solution on my processor.
std::unique_ptr< DirichletBoundaries > _dirichlet_boundaries
Data structure containing Dirichlet functions.
void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs)
Allow the implicit_neighbor_dofs flag to be set programmatically.
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...
void check_for_cyclic_constraints()
Throw an error if we detect any constraint loops, i.e.
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.
const unsigned int _sys_number
The number of the system we manage DOFs for.
void should_p_refine(Order, bool)=delete
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.
std::vector< std::unique_ptr< DirichletBoundaries > > _adjoint_dirichlet_boundaries
Data structure containing Dirichlet functions.
dof_id_type n_constrained_dofs() const
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups.
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
std::vector< GhostingFunctor * >::const_iterator GhostingFunctorIterator
Iterator type for coupling and algebraic ghosting functor ranges.
const DirichletBoundaries * get_adjoint_dirichlet_boundaries(unsigned int q) const
void set_constrained_sparsity_construction(bool use_constraints)
Sets the current policy for constructing sparsity patterns: if use_constraints is true (for robustnes...
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 scatter_constraints(MeshBase &)
Sends constraint equations to constraining processors.
void find_connected_dofs(std::vector< dof_id_type > &elem_dofs) const
Finds all the DOFS associated with the element DOFs elem_dofs.
AugmentSendList * _augment_send_list
Function object to call to add extra entries to the send list.
bool is_attached(SparseMatrix< Number > &matrix)
Matrices should not be attached more than once.
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.
bool identify_variable_groups() const
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 set_verify_dirichlet_bc_consistency(bool val)
Set the _verify_dirichlet_bc_consistency flag.
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
void compute_sparsity(const MeshBase &)
Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear...
DofConstraintValueMap & get_primal_constraint_values()
void process_mesh_constraint_rows(const MeshBase &mesh)
Adds any spline constraints from the Mesh to our DoF constraints.
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 th...
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 ...
std::unique_ptr< DefaultCoupling > _default_evaluating
The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction.
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 should_p_refine(FEFamily, bool)=delete
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.
std::vector< Variable > _variables
The variables in this system/degree of freedom map.
Order variable_order(const unsigned int c) const
void update_sparsity_pattern(SparseMatrix< Number > &matrix) const
Additional matrices may be be temporarily initialized by this DofMap.
bool computed_sparsity_already() const
Returns true iff a sparsity pattern has already been computed.
GhostingFunctorIterator coupling_functors_end() const
End of range of coupling functors.
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Backwards compatibility with misspelling.
void attach_extra_sparsity_object(SparsityPattern::AugmentSparsityPattern &asp)
Attach an object to use to populate the sparsity pattern with extra entries.
unsigned int variable_scalar_number(unsigned int var_num, unsigned int component) const
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.
bool should_p_refine(FEFamily) const =delete
void remove_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor)
Removes a functor which was previously added to the set of algebraic ghosting functors,...
void enforce_constraints_on_residual(const NonlinearImplicitSystem &system, NumericVector< Number > *rhs, NumericVector< Number > const *solution, bool homogeneous=true) const
DefaultCoupling & default_coupling()
Default coupling functor.
void constrain_element_matrix(DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix.
unsigned int n_vars() const
void print_dof_constraints(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all DoF and Node constraints.
void clear_sparsity()
Clears the sparsity pattern.
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.
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
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 assert_no_nodes_missed(MeshBase &mesh)
void constrain_element_residual(DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
Constrains the element residual.
void * _extra_send_list_context
A pointer associated with the extra send list that can optionally be passed in.
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.
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.
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.
void add_default_ghosting()
Add the default functor(s) for coupling and algebraic ghosting.
void swap_dof_constraints()
Similar to the stash/unstash_dof_constraints() API, but swaps _dof_constraints and _stashed_dof_const...
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 stash_dof_constraints()
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 d...
const FEType & variable_type(const unsigned int i) const
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...
bool _constrained_sparsity_construction
This flag indicates whether or not we explicitly take constraint equations into account when computin...
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary obj...
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.
unsigned int sys_number() const
const VariableGroup & variable_group(const unsigned int c) const
void clear_send_list()
Clears the _send_list vector.
unsigned int variable_number(std::string_view var) const
PeriodicBoundaries * get_periodic_boundaries()
bool semilocal_index(dof_id_type dof_index) const
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...
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 funct...
std::vector< GhostingFunctor * > _coupling_functors
The list of all GhostingFunctor objects to be used when coupling degrees of freedom in matrix sparsit...
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Backwards compatibility with misspelling.
const FEType & variable_group_type(const unsigned int vg) const
StaticCondensationDofMap & get_static_condensation()
NodeConstraints _node_constraints
Data structure containing DofObject constraints.
std::vector< std::pair< unsigned int, unsigned int > > _array_variables
Array variable information storage.
AdjointDofConstraintValues _adjoint_constraint_values
bool is_constrained_dof(const dof_id_type dof) const
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.
SparsityPattern::AugmentSparsityPattern * _augment_sparsity_pattern
Function object to call to add extra entries to the sparsity pattern.
dof_id_type _n_SCALAR_dofs
The total number of SCALAR dofs associated to all SCALAR variables.
dof_id_type n_constrained_nodes() const
const std::vector< dof_id_type > & get_n_oz() const
unsigned int block_size() const
std::vector< dof_id_type > _first_old_scalar_df
First old DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
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...
void constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
Constrains the element vector.
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.
Number has_heterogeneous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
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)
bool local_index(dof_id_type dof_index) const
const Variable & variable(const unsigned int c) const override
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
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.
const std::string & variable_name(const unsigned int i) const
bool has_heterogeneous_adjoint_constraints(const unsigned int qoi_num) const
void enforce_constraints_on_jacobian(const NonlinearImplicitSystem &system, SparseMatrix< Number > *jac) const
bool _implicit_neighbor_dofs_initialized
Bools to indicate if we override the –implicit_neighbor_dofs commandline options.
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 need_full_sparsity_pattern
Default false; set to true if any attached matrix requires a full sparsity pattern.
NodeConstraints::const_iterator node_constraint_rows_begin() const
std::vector< SparseMatrix< Number > * > _matrices
Additional matrices handled by this object.
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
std::unique_ptr< SparsityPattern::Build > _sp
The sparsity pattern of the global matrix.
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
bool has_adjoint_dirichlet_boundaries(unsigned int q) const
bool is_periodic_boundary(const boundary_id_type boundaryid) const
dof_id_type n_local_constrained_dofs() const
void check_for_constraint_loops()
std::unique_ptr< PeriodicBoundaries > _periodic_boundaries
Data structure containing periodic boundaries.
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'.
std::unique_ptr< DefaultCoupling > _default_coupling
The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern constructio...
void find_connected_dof_objects(std::vector< const DofObject * > &objs) const
Finds all the DofObjects associated with the set in objs.
std::set< std::unique_ptr< CouplingMatrix >, Utility::CompareUnderlying > CouplingMatricesSet
void full_sparsity_pattern_needed()
Sets need_full_sparsity_pattern to true regardless of the requirements by matrices.
bool has_blocked_representation() const
bool has_static_condensation() const
Checks whether we have static condensation.
dof_id_type n_dofs(const unsigned int vn) const
const std::vector< dof_id_type > & get_n_nz() const
MeshBase & _mesh
The mesh that system uses.
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 w...
const SparsityPattern::Build * get_sparsity_pattern() const
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.
void print_info(std::ostream &os=libMesh::out) const
Prints summary info about the sparsity bandwidth and constraints.
dof_id_type n_local_dofs() const
bool constrained_sparsity_construction()
Returns true iff the current policy when constructing sparsity patterns is to explicitly account for ...
GhostingFunctorIterator algebraic_ghosting_functors_end() const
End of range of algebraic ghosting functors.
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 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 ...
const PeriodicBoundaries * get_periodic_boundaries() const
DirichletBoundaries * get_dirichlet_boundaries()
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.
bool is_constrained_node(const Node *node) const
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 ...
std::vector< VariableGroup > _variable_groups
The variable groups in this system/degree of freedom map.
Order variable_group_order(const unsigned int vg) const
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
DofConstraints::const_iterator constraint_rows_end() const
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 ...
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.
unsigned int n_components(const MeshBase &mesh) const
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.
DofObject * node_ptr(MeshBase &mesh, dof_id_type i) const
void add_periodic_boundary(const PeriodicBoundaryBase &periodic_boundary)
Adds a copy of the specified periodic boundary to the system.
DofObject * elem_ptr(MeshBase &mesh, dof_id_type i) const
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
void create_static_condensation(MeshBase &mesh, System &system)
Add a static condensation class.
void add_coupling_functor(GhostingFunctor &coupling_functor, bool to_mesh=true)
Adds a functor which can specify coupling requirements for creation of sparse matrices.
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
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),...
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 ...
void attach_extra_send_list_object(DofMap::AugmentSendList &asl)
Attach an object to populate the send_list with extra entries.
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 remove_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Removes the specified Dirichlet boundary from the system.
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 add_neighbors_to_send_list(MeshBase &mesh)
Adds entries to the _send_list vector corresponding to DoFs on elements neighboring the current proce...
bool _error_on_constraint_loop
This flag indicates whether or not we do an opt-mode check for the presence of constraint loops,...
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...
std::string get_local_constraints(bool print_nonlocal=false) const
Gets a string reporting all DoF and Node constraints local to this processor.
void unstash_dof_constraints()
GhostingFunctorIterator algebraic_ghosting_functors_begin() const
Beginning of range of algebraic ghosting functors.
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.
std::vector< dof_id_type > _first_scalar_df
First DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
DofConstraints _stashed_dof_constraints
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.
dof_id_type n_SCALAR_dofs() const
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
bool should_p_refine_var(unsigned int var) const
Whether the given variable should be p-refined.
void set_error_on_constraint_loop(bool error_on_constraint_loop)
DofConstraints _dof_constraints
Data structure containing DOF constraints.
std::unique_ptr< StaticCondensationDofMap > _sc
Static condensation class.
bool has_variable(std::string_view var) const
void invalidate_dofs(MeshBase &mesh) const
Invalidates all active DofObject dofs for this system.
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
unsigned int n_systems() const
unsigned int n_comp_group(const unsigned int s, const unsigned int vg) const
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
std::pair< unsigned int, unsigned int > var_to_vg_and_offset(const unsigned int s, const unsigned int var) const
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
This is the base class from which all geometric element types are derived.
virtual unsigned int n_nodes() const =0
subdomain_id_type subdomain_id() const
const Node *const * get_nodes() const
virtual bool is_vertex(const unsigned int i) const =0
virtual ElemType type() const =0
unsigned int p_level() const
virtual bool infinite() const =0
static n_dofs_at_node_ptr n_dofs_at_node_function(const unsigned int dim, const FEType &fe_t)
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType's FEContinuity based on the underlying FEFamily and potentially the Order,...
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)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
bool p_refinement
Whether or not the finite elements for this type increase their p refinement level on geometric eleme...
FEFamily family
The type of finite element.
This abstract base class defines the interface by which library code and user code can report associa...
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?
This is the MeshBase class.
The Node constraint storage format.
A Node is like a Point, but with more information.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
We're using a class instead of a typedef to allow forward declarations and future flexibility.
The base class for defining periodic boundaries.
This class implements reference counting.
Abstract base class to be used to add user-defined implicit degree of freedom couplings.
This helper class can be called on multiple threads to compute the sparsity pattern (or graph) of the...
A class holding degree of freedom information pertinent to static condensation.
Manages consistently variables, degrees of freedom, and coefficient vectors.
Scalable allocator to be used in multithreaded code chunks which allocate a lot of dynamic memory.
The Tri3Subdivision element is a three-noded subdivision surface shell element used in mechanics calc...
This class defines a logically grouped set of variables in the system.
unsigned int n_variables() const
unsigned int number(unsigned int v) const
unsigned int first_scalar_number(unsigned int v) const
This class defines the notion of a variable in the system.
unsigned int first_scalar_number() const
bool active_on_subdomain(subdomain_id_type sid) const
unsigned int n_components() const
const FEType & type() const
The libMesh namespace provides an interface to certain functionality in the library.
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.
ElemType
Defines an enum for geometric element types.
void libmesh_ignore(const Args &...)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
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...
The definition of the const_element_iterator struct.
Struct which defines a custom comparison object that can be used with std::sets of std::unique_ptrs.
const dof_id_type n_nodes