libMesh
Loading...
Searching...
No Matches
dof_map.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20#ifndef LIBMESH_DOF_MAP_H
21#define LIBMESH_DOF_MAP_H
22
23// Local Includes
24#include "libmesh/libmesh_common.h"
25#include "libmesh/reference_counted_object.h"
26#include "libmesh/libmesh.h" // libMesh::invalid_uint
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"
42
43// TIMPI includes
45#include "timpi/parallel_sync.h"
46
47// C++ Includes
48#include <algorithm>
49#include <cstddef>
50#include <iterator>
51#include <map>
52#include <string>
53#include <vector>
54#include <memory>
55
56namespace libMesh
57{
58
59// Forward Declarations
60class CouplingMatrix;
61class DefaultCoupling;
62class DirichletBoundary;
63class DirichletBoundaries;
64class DofMap;
65class DofObject;
66class FEType;
67class MeshBase;
68class PeriodicBoundaryBase;
69class PeriodicBoundaries;
70class System;
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;
78enum Order : int;
79
80
81
82// ------------------------------------------------------------
83// Do we need constraints for anything?
84
85#if defined(LIBMESH_ENABLE_AMR) || \
86 defined(LIBMESH_ENABLE_PERIODIC) || \
87 defined(LIBMESH_ENABLE_DIRICHLET)
88# define LIBMESH_ENABLE_CONSTRAINTS 1
89#endif
90
91// ------------------------------------------------------------
92// AMR constraint matrix types
93
94#ifdef LIBMESH_ENABLE_CONSTRAINTS
98typedef std::map<dof_id_type, Real,
99 std::less<dof_id_type>,
101
108class DofConstraints : public std::map<dof_id_type,
109 DofConstraintRow,
110 std::less<dof_id_type>,
111 Threads::scalable_allocator<std::pair<const dof_id_type, DofConstraintRow>>>
112{
113};
114
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>>>
124{
125};
126
132 public std::map<unsigned int, DofConstraintValueMap,
133 std::less<unsigned int>,
134 Threads::scalable_allocator
135 <std::pair<const unsigned int, DofConstraintValueMap>>>
136{
137};
138
139#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
146typedef std::map<const Node *, Real,
147 std::less<const Node *>,
149
156class NodeConstraints : public std::map<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>>>>
160{
161};
162#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
163
164#endif // LIBMESH_ENABLE_CONSTRAINTS
165
166
167
179class DofMap : public DofMapBase,
180 public ReferenceCountedObject<DofMap>
181{
182public:
183
189 explicit
190 DofMap(const unsigned int sys_number,
191 MeshBase & mesh);
192
196 ~DofMap();
197
203
209 {
210 public:
211 virtual ~AugmentSendList () = default;
212
216 virtual void augment_send_list (std::vector<dof_id_type> & send_list) = 0;
217 };
218
224 void attach_matrix (SparseMatrix<Number> & matrix);
225
233
238 bool is_attached (SparseMatrix<Number> & matrix);
239
246 std::size_t distribute_dofs (MeshBase &);
247
253 void compute_sparsity (const MeshBase &);
254
258 bool computed_sparsity_already () const;
259
270 void set_constrained_sparsity_construction(bool use_constraints);
271
277
283
290
294 void clear_sparsity();
295
310
316
322 typedef std::vector<GhostingFunctor *>::const_iterator GhostingFunctorIterator;
323
348 void add_coupling_functor(GhostingFunctor & coupling_functor,
349 bool to_mesh = true);
350
358 void add_coupling_functor(std::shared_ptr<GhostingFunctor> coupling_functor,
359 bool to_mesh = true)
360 { _shared_functors[coupling_functor.get()] = coupling_functor;
361 this->add_coupling_functor(*coupling_functor, to_mesh); }
362
368 void remove_coupling_functor(GhostingFunctor & coupling_functor);
369
375
381
386
410 void add_algebraic_ghosting_functor(GhostingFunctor & evaluable_functor,
411 bool to_mesh = true);
412
420 void add_algebraic_ghosting_functor(std::shared_ptr<GhostingFunctor> evaluable_functor,
421 bool to_mesh = true)
422 { _shared_functors[evaluable_functor.get()] = evaluable_functor;
423 this->add_algebraic_ghosting_functor(*evaluable_functor, to_mesh); }
424
430 void remove_algebraic_ghosting_functor(GhostingFunctor & evaluable_functor);
431
437
443
448
463
475 std::vector<dof_id_type> & n_nz,
476 std::vector<dof_id_type> & n_oz,
477 void *),
478 void * context = nullptr)
480
492
497 void attach_extra_send_list_function(void (*func)(std::vector<dof_id_type> &, void *),
498 void * context = nullptr)
500
507 void prepare_send_list ();
508
515 {
516 _send_list.clear();
517 }
518
529
530
540 const std::vector<dof_id_type> & get_send_list() const { return _send_list; }
541
549 const std::vector<dof_id_type> & get_n_nz() const
550 {
552 return _sp->get_n_nz();
553 }
554
562 const std::vector<dof_id_type> & get_n_oz() const
563 {
565 return _sp->get_n_oz();
566 }
567
568
578 {
579 return _sp.get();
580 }
581
585 unsigned int n_vars() const;
586
590 const std::string & variable_name(const unsigned int i) const;
591
598 unsigned int n_components(const MeshBase & mesh) const;
599
604 bool identify_variable_groups () const;
605
609 void identify_variable_groups (const bool);
610
621 unsigned int variable_scalar_number (unsigned int var_num,
622 unsigned int component) const;
623
627 const FEType & variable_type (const unsigned int i) const;
628
632 const FEType & variable_type (std::string_view var) const;
633
638 unsigned int variable_number (std::string_view var) const;
639
643 bool has_variable(std::string_view var) const;
644
649 void get_all_variable_numbers(std::vector<unsigned int> & all_variable_numbers) const;
650
659 unsigned int add_variable (System & sys,
660 std::string_view var,
661 const FEType & type,
662 const std::set<subdomain_id_type> * const active_subdomains = nullptr);
663
672 unsigned int add_variables (System & sys,
673 const std::vector<std::string> & vars,
674 const FEType & type,
675 const std::set<subdomain_id_type> * const active_subdomains = nullptr);
676
695 unsigned int add_variable_array (System & sys,
696 const std::vector<std::string> & vars,
697 const FEType & type,
698 const std::set<subdomain_id_type> * const active_subdomains = nullptr);
699
710 void set_error_on_cyclic_constraint(bool error_on_cyclic_constraint);
711 void set_error_on_constraint_loop(bool error_on_constraint_loop);
712
716 const VariableGroup & variable_group (const unsigned int c) const;
717
718 const Variable & variable (const unsigned int c) const override;
719
723 Order variable_order (const unsigned int c) const;
724
728 Order variable_group_order (const unsigned int vg) const;
729
733 const FEType & variable_group_type (const unsigned int vg) const;
734
740 unsigned int n_variable_groups() const
741 { return cast_int<unsigned int>(_variable_groups.size()); }
742
743 unsigned int n_variables() const override
744 { return cast_int<unsigned int>(_variables.size()); }
745
749 unsigned int var_group_from_var_number(unsigned int var_num) const;
750
757 {
758 return ((this->n_variable_groups() == 1) && (this->n_variables() > 1));
759 }
760
773 unsigned int block_size() const
774 {
775 return (this->has_blocked_representation() ? this->n_variables() : 1);
776 }
777
778 using DofMapBase::n_dofs;
783 dof_id_type n_dofs(const unsigned int vn) const
784 {
785 dof_id_type n = this->n_local_dofs(vn);
786 this->comm().sum(n);
787 return n;
788 }
789
794
801 dof_id_type n_local_dofs(const unsigned int vn) const
802 {
803 dof_id_type n;
804 this->local_variable_indices(n, _mesh, vn);
805 return n;
806 }
807
812 std::vector<dof_id_type> n_dofs_per_processor(const unsigned int vn) const
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 }
818
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 }
828
829 void dof_indices (const Elem * const elem,
830 std::vector<dof_id_type> & di) const;
831
837 void dof_indices (const Elem * const elem,
838 std::vector<dof_id_type> & di,
839 const unsigned int vn,
840 int p_level = -12345) const override;
841
848 void array_dof_indices(const Elem * const elem,
849 std::vector<dof_id_type> & di,
850 const unsigned int vn,
851 int p_level = -12345) const;
852
853 void array_dof_indices(const Node * const node,
854 std::vector<dof_id_type> & di,
855 const unsigned int vn) const;
856
857 template <typename DofIndicesFunctor>
858 void array_dof_indices(const DofIndicesFunctor & functor,
859 std::vector<dof_id_type> & di,
860 const unsigned int vn) const;
861
891 template <typename ScalarDofsFunctor, typename FieldDofsFunctor>
892 void dof_indices(const Elem * const elem,
893 std::vector<dof_id_type> & di,
894 const unsigned int vn,
895 ScalarDofsFunctor scalar_dofs_functor,
896 FieldDofsFunctor field_dofs_functor,
897 int p_level = -12345) const;
898
903 void dof_indices (const Node * const node,
904 std::vector<dof_id_type> & di) const;
905
910 void dof_indices (const Node * const node,
911 std::vector<dof_id_type> & di,
912 const unsigned int vn) const override;
913
920 void dof_indices (const Elem & elem,
921 unsigned int n,
922 std::vector<dof_id_type> & di,
923 const unsigned int vn) const;
924
925#ifdef LIBMESH_ENABLE_AMR
926
933 void old_dof_indices (const Elem & elem,
934 unsigned int n,
935 std::vector<dof_id_type> & di,
936 const unsigned int vn) const;
937
938#endif // LIBMESH_ENABLE_AMR
939
948 void SCALAR_dof_indices (std::vector<dof_id_type> & di,
949 const unsigned int vn,
950 const bool old_dofs=false) const;
951
959 bool semilocal_index (dof_id_type dof_index) const;
960
968 bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
969
974 bool local_index (dof_id_type dof_index) const
975 { return (dof_index >= this->first_dof()) && (dof_index < this->end_dof()); }
976
982 template <typename DofObjectSubclass>
983 bool is_evaluable(const DofObjectSubclass & obj,
984 unsigned int var_num = libMesh::invalid_uint) const;
985
993 void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
994
999
1006 bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
1007
1019 const std::vector<dof_id_type> & dof_indices,
1020 DenseVectorBase<Number> & Ue) const;
1021
1027 template <typename T, std::enable_if_t<std::is_same_v<T, dof_id_type> ||
1028 std::is_same_v<T, std::vector<dof_id_type>>, int> = 0>
1029 void local_variable_indices(T & idx,
1030 const MeshBase & mesh,
1031 unsigned int var_num) const;
1032
1038 template <typename T,
1039 std::enable_if_t<std::is_same_v<T, dof_id_type> ||
1040 std::is_same_v<T, std::vector<dof_id_type>>,
1041 int> = 0>
1042 void local_variable_indices(T & idx, unsigned int var_num) const
1043 { this->local_variable_indices(idx, this->_mesh, var_num); }
1044
1045#ifdef LIBMESH_ENABLE_CONSTRAINTS
1046
1047 //--------------------------------------------------------------------
1048 // Constraint-specific methods
1054
1060
1061#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1067 { return cast_int<dof_id_type>(_node_constraints.size()); }
1068#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1069
1078 void create_dof_constraints (const MeshBase &, Real time=0);
1079
1084
1089
1104 std::set<dof_id_type> & unexpanded_dofs,
1105 bool look_for_constrainees);
1106
1115
1132
1137 void add_constraint_row (const dof_id_type dof_number,
1138 const DofConstraintRow & constraint_row,
1139 const Number constraint_rhs,
1140 const bool forbid_constraint_overwrite);
1141
1152 void add_adjoint_constraint_row (const unsigned int qoi_index,
1153 const dof_id_type dof_number,
1154 const DofConstraintRow & constraint_row,
1155 const Number constraint_rhs,
1156 const bool forbid_constraint_overwrite);
1157
1163 void add_constraint_row (const dof_id_type dof_number,
1164 const DofConstraintRow & constraint_row,
1165 const bool forbid_constraint_overwrite = true)
1166 { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
1167
1171 DofConstraints::const_iterator constraint_rows_begin() const
1172 { return _dof_constraints.begin(); }
1173
1177 DofConstraints::const_iterator constraint_rows_end() const
1178 { return _dof_constraints.end(); }
1179
1185
1191
1197
1214
1215#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1219 NodeConstraints::const_iterator node_constraint_rows_begin() const
1220 { return _node_constraints.begin(); }
1221
1225 NodeConstraints::const_iterator node_constraint_rows_end() const
1226 { return _node_constraints.end(); }
1227#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1228
1233 bool is_constrained_dof (const dof_id_type dof) const;
1234
1239 bool has_heterogeneous_adjoint_constraints (const unsigned int qoi_num) const;
1240
1244 bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1245 {
1246 return this->has_heterogeneous_adjoint_constraints (qoi_num);
1247 }
1248
1254 Number has_heterogeneous_adjoint_constraint (const unsigned int qoi_num,
1255 const dof_id_type dof) const;
1256
1260 Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
1261 const dof_id_type dof) const
1262 {
1263 return this->has_heterogeneous_adjoint_constraint (qoi_num, dof);
1264 }
1265
1271
1276 bool is_constrained_node (const Node * node) const;
1277
1284 void print_dof_constraints(std::ostream & os=libMesh::out,
1285 bool print_nonlocal=false) const;
1286
1292 std::string get_local_constraints(bool print_nonlocal=false) const;
1293
1294
1303 std::pair<Real, Real> max_constraint_error(const System & system,
1304 NumericVector<Number> * v = nullptr) const;
1305
1306#endif // LIBMESH_ENABLE_CONSTRAINTS
1307
1308 //--------------------------------------------------------------------
1309 // Constraint-specific methods
1310 // Some of these methods are enabled (but inlined away to nothing)
1311 // when constraints are disabled at configure-time. This is to
1312 // increase API compatibility of user code with different library
1313 // builds.
1314
1329 std::vector<dof_id_type> & elem_dofs,
1330 bool asymmetric_constraint_rows = true) const;
1331
1339 std::vector<dof_id_type> & row_dofs,
1340 std::vector<dof_id_type> & col_dofs,
1341 bool asymmetric_constraint_rows = true) const;
1342
1347 std::vector<dof_id_type> & dofs,
1348 bool asymmetric_constraint_rows = true) const;
1349
1359 DenseVector<Number> & rhs,
1360 std::vector<dof_id_type> & elem_dofs,
1361 bool asymmetric_constraint_rows = true) const;
1362
1387 DenseVector<Number> & rhs,
1388 std::vector<dof_id_type> & elem_dofs,
1389 bool asymmetric_constraint_rows = true,
1390 int qoi_index = -1) const;
1391
1392 /*
1393 * Backwards compatibility with misspelling.
1394 */
1396 DenseVector<Number> & rhs,
1397 std::vector<dof_id_type> & elem_dofs,
1398 bool asymmetric_constraint_rows = true,
1399 int qoi_index = -1) const
1400 {
1402 (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1403 }
1404
1431 DenseVector<Number> & rhs,
1432 std::vector<dof_id_type> & elem_dofs,
1433 bool asymmetric_constraint_rows = true,
1434 int qoi_index = -1) const;
1435
1436 /*
1437 * Backwards compatibility with misspelling.
1438 */
1440 DenseVector<Number> & rhs,
1441 std::vector<dof_id_type> & elem_dofs,
1442 bool asymmetric_constraint_rows = true,
1443 int qoi_index = -1) const
1444 {
1446 (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1447 }
1448
1469 DenseVector<Number> & rhs,
1470 std::vector<dof_id_type> & elem_dofs,
1471 NumericVector<Number> & solution_local) const;
1472
1488 std::vector<dof_id_type> & elem_dofs,
1489 NumericVector<Number> & solution_local) const;
1490
1491
1508 std::vector<dof_id_type> & elem_dofs,
1509 NumericVector<Number> & solution_local) const;
1510
1521 std::vector<dof_id_type> & row_dofs,
1522 bool asymmetric_constraint_rows = true) const;
1523
1530 void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1531
1545 void enforce_constraints_exactly (const System & system,
1546 NumericVector<Number> * v = nullptr,
1547 bool homogeneous = false) const;
1548
1556 unsigned int q) const;
1557
1560 NumericVector<Number> const * solution,
1561 bool homogeneous = true) const;
1562
1564 SparseMatrix<Number> * jac) const;
1565
1566#ifdef LIBMESH_ENABLE_PERIODIC
1567
1568 //--------------------------------------------------------------------
1569 // PeriodicBoundary-specific methods
1570
1574 void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1575
1582 void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1583
1588 bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1589
1594
1596 {
1597 return _periodic_boundaries.get();
1598 }
1599
1600#endif // LIBMESH_ENABLE_PERIODIC
1601
1602
1603#ifdef LIBMESH_ENABLE_DIRICHLET
1604
1605 //--------------------------------------------------------------------
1606 // DirichletBoundary-specific methods
1607
1621 void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1622
1628 void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1629 unsigned int q);
1630
1634 void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1635
1640 void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1641 unsigned int q);
1642
1644 {
1645 return _dirichlet_boundaries.get();
1646 }
1647
1652
1653 bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1654
1655 const DirichletBoundaries *
1656 get_adjoint_dirichlet_boundaries(unsigned int q) const;
1657
1659 get_adjoint_dirichlet_boundaries(unsigned int q);
1660
1666 const DirichletBoundary & boundary) const;
1667#endif // LIBMESH_ENABLE_DIRICHLET
1668
1669
1670#ifdef LIBMESH_ENABLE_AMR
1671
1672 //--------------------------------------------------------------------
1673 // AMR-specific methods
1674
1683 // void augment_send_list_for_projection(const MeshBase &);
1684
1685#ifdef LIBMESH_ENABLE_AMR
1686
1693 void old_dof_indices (const Elem * const elem,
1694 std::vector<dof_id_type> & di,
1695 const unsigned int vn = libMesh::invalid_uint) const;
1696
1697#endif // LIBMESH_ENABLE_AMR
1698
1704 void constrain_p_dofs (unsigned int var,
1705 const Elem * elem,
1706 unsigned int s,
1707 unsigned int p);
1708
1709#endif // LIBMESH_ENABLE_AMR
1710
1714 void reinit
1715 (MeshBase & mesh,
1716 const std::map<const Node *, std::set<subdomain_id_type>> &
1717 constraining_subdomains);
1718
1723 virtual void clear () override;
1724
1728 void print_info(std::ostream & os=libMesh::out) const;
1729
1733 std::string get_info() const;
1734
1749
1753 unsigned int sys_number() const;
1754
1769 std::unique_ptr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh,
1770 bool calculate_constrained = false,
1771 bool use_condensed_system = false) const;
1772
1778 void should_p_refine(unsigned int g, bool p_refine);
1779
1783 bool should_p_refine(unsigned int g) const;
1784
1788 bool should_p_refine_var(unsigned int var) const;
1789
1790 // Prevent bad user implicit conversions
1791 void should_p_refine(FEFamily, bool) = delete;
1792 void should_p_refine(Order, bool) = delete;
1793 bool should_p_refine(FEFamily) const = delete;
1794 bool should_p_refine(Order) const = delete;
1795
1800
1804 bool has_static_condensation() const { return _sc.get(); }
1805
1811
1817
1822
1823private:
1824
1838 const std::pair<unsigned int, unsigned int> &
1839 get_variable_array(unsigned int vi) const;
1840
1851 void _dof_indices (const Elem & elem,
1852 int p_level,
1853 std::vector<dof_id_type> & di,
1854 const unsigned int vg,
1855 const unsigned int vig,
1856 const Node * const * nodes,
1857 unsigned int n_nodes,
1858 const unsigned int v
1859#ifdef DEBUG
1860 ,
1861 std::size_t & tot_size
1862#endif
1863 ) const;
1864
1880 template <typename FieldDofsFunctor>
1881 void _dof_indices (const Elem & elem,
1882 int p_level,
1883 std::vector<dof_id_type> & di,
1884 const unsigned int vg,
1885 const unsigned int vig,
1886 const Node * const * nodes,
1887 unsigned int n_nodes,
1888 const unsigned int v,
1889#ifdef DEBUG
1890 std::size_t & tot_size,
1891#endif
1892 FieldDofsFunctor field_dofs_functor) const;
1893
1898 void _node_dof_indices (const Elem & elem,
1899 unsigned int n,
1900 const DofObject & obj,
1901 std::vector<dof_id_type> & di,
1902 const unsigned int vn) const;
1903
1907 void invalidate_dofs(MeshBase & mesh) const;
1908
1913
1918
1923 (MeshBase & mesh, dof_id_type i) const;
1924
1928 template<typename iterator_type>
1929 void set_nonlocal_dof_objects(iterator_type objects_begin,
1930 iterator_type objects_end,
1931 MeshBase & mesh,
1932 dofobject_accessor objects);
1933
1948 std::map<const Node *, std::set<subdomain_id_type>>
1950
1964 (dof_id_type & next_free_dof,
1965 MeshBase & mesh,
1966 const std::map<const Node *, std::set<subdomain_id_type>> &
1967 constraining_subdomains);
1968
1985 (dof_id_type & next_free_dof,
1986 MeshBase & mesh,
1987 const std::map<const Node *, std::set<subdomain_id_type>> &
1988 constraining_subdomains);
1989
1990 /*
1991 * Helper method for the above two to count + distriubte SCALAR dofs
1992 */
1993 void distribute_scalar_dofs (dof_id_type & next_free_dof);
1994
1995#ifdef DEBUG
1996 /*
1997 * Internal assertions for distribute_local_dofs_*
1998 */
2000#endif
2001
2002 /*
2003 * A utility method for obtaining a set of elements to ghost along
2004 * with merged coupling matrices.
2005 */
2006 typedef std::set<std::unique_ptr<CouplingMatrix>, Utility::CompareUnderlying> CouplingMatricesSet;
2007 static void
2009 CouplingMatricesSet & temporary_coupling_matrices,
2010 const GhostingFunctorIterator & gf_begin,
2011 const GhostingFunctorIterator & gf_end,
2012 const MeshBase::const_element_iterator & elems_begin,
2013 const MeshBase::const_element_iterator & elems_end,
2015
2021
2022#ifdef LIBMESH_ENABLE_CONSTRAINTS
2023
2035 std::vector<dof_id_type> & elem_dofs,
2036 const bool called_recursively=false) const;
2037
2055 std::vector<dof_id_type> & elem_dofs,
2056 int qoi_index = -1,
2057 const bool called_recursively=false) const;
2058
2063 void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
2064
2069 void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
2070
2077
2084
2085#endif // LIBMESH_ENABLE_CONSTRAINTS
2086
2093
2099
2103 std::vector<Variable> _variables;
2104
2108 std::vector<VariableGroup> _variable_groups;
2109
2113 std::vector<unsigned int> _variable_group_numbers;
2114
2118 std::unordered_map<unsigned int, unsigned int> _var_to_vg;
2119
2124 std::map<std::string, unsigned int, std::less<>> _variable_numbers;
2125
2131 std::vector<std::pair<unsigned int, unsigned int>> _array_variables;
2132
2138
2142 const unsigned int _sys_number;
2143
2148
2154 std::vector<SparseMatrix<Number> * > _matrices;
2155
2160 std::vector<dof_id_type> _first_scalar_df;
2161
2166 std::vector<dof_id_type> _send_list;
2167
2172
2177 std::vector<dof_id_type> & n_nz,
2178 std::vector<dof_id_type> & n_oz,
2179 void *);
2184
2189
2193 void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
2194
2199
2206 std::unique_ptr<DefaultCoupling> _default_coupling;
2207
2214 std::unique_ptr<DefaultCoupling> _default_evaluating;
2215
2227 std::vector<GhostingFunctor *> _algebraic_ghosting_functors;
2228
2240 std::vector<GhostingFunctor *> _coupling_functors;
2241
2246 std::map<GhostingFunctor *, std::shared_ptr<GhostingFunctor> > _shared_functors;
2247
2253
2259
2265 std::unique_ptr<SparsityPattern::Build> _sp;
2266
2272
2273#ifdef LIBMESH_ENABLE_AMR
2274
2279 std::vector<dof_id_type> _first_old_scalar_df;
2280#endif
2281
2282#ifdef LIBMESH_ENABLE_CONSTRAINTS
2288
2290
2292#endif
2293
2294#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2299#endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
2300
2301
2302#ifdef LIBMESH_ENABLE_PERIODIC
2307 std::unique_ptr<PeriodicBoundaries> _periodic_boundaries;
2308#endif
2309
2310#ifdef LIBMESH_ENABLE_DIRICHLET
2315 std::unique_ptr<DirichletBoundaries> _dirichlet_boundaries;
2316
2321 std::vector<std::unique_ptr<DirichletBoundaries>> _adjoint_dirichlet_boundaries;
2322#endif
2323
2325
2332
2344
2346 std::unique_ptr<StaticCondensationDofMap> _sc;
2347};
2348
2349
2350// ------------------------------------------------------------
2351// Dof Map inline member functions
2352inline
2353unsigned int DofMap::sys_number() const
2354{
2355 return _sys_number;
2356}
2357
2358
2359
2360inline
2361const VariableGroup & DofMap::variable_group (const unsigned int g) const
2362{
2363 libmesh_assert_less (g, _variable_groups.size());
2364
2365 return _variable_groups[g];
2366}
2367
2368
2369
2370inline
2371const Variable & DofMap::variable (const unsigned int c) const
2372{
2373 libmesh_assert_less (c, _variables.size());
2374
2375 return _variables[c];
2376}
2377
2378
2379
2380inline
2381Order DofMap::variable_order (const unsigned int c) const
2382{
2383 libmesh_assert_less (c, _variables.size());
2384
2385 return _variables[c].type().order;
2386}
2387
2388
2389
2390inline
2391Order DofMap::variable_group_order (const unsigned int vg) const
2392{
2393 libmesh_assert_less (vg, _variable_groups.size());
2394
2395 return _variable_groups[vg].type().order;
2396}
2397
2398
2399
2400inline
2401const FEType & DofMap::variable_type (const unsigned int c) const
2402{
2403 libmesh_assert_less (c, _variables.size());
2404
2405 return _variables[c].type();
2406}
2407
2408
2409
2410inline
2411const FEType & DofMap::variable_group_type (const unsigned int vg) const
2412{
2413 libmesh_assert_less (vg, _variable_groups.size());
2414
2415 return _variable_groups[vg].type();
2416}
2417
2418
2419#ifdef LIBMESH_ENABLE_CONSTRAINTS
2420
2421
2422inline
2424#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2425 node
2426#endif
2427 ) const
2428{
2429#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2430 if (_node_constraints.count(node))
2431 return true;
2432#endif
2433
2434 return false;
2435}
2436
2437
2438inline
2440{
2441 if (_dof_constraints.count(dof))
2442 return true;
2443
2444 return false;
2445}
2446
2447
2448inline
2449bool DofMap::has_heterogeneous_adjoint_constraints (const unsigned int qoi_num) const
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}
2460
2461
2462inline
2464 const dof_id_type dof) const
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}
2480
2481
2482
2483inline
2488
2489
2490
2491#else
2492
2493//--------------------------------------------------------------------
2494// Constraint-specific methods get inlined into nothing if
2495// constraints are disabled, so there's no reason for users not to
2496// use them.
2497
2499 std::vector<dof_id_type> &,
2500 bool) const {}
2501
2503 std::vector<dof_id_type> &,
2504 std::vector<dof_id_type> &,
2505 bool) const {}
2506
2508 std::vector<dof_id_type> &,
2509 bool) const {}
2510
2513 std::vector<dof_id_type> &,
2514 bool) const {}
2515
2518 std::vector<dof_id_type> &, bool, int) const {}
2519
2522 std::vector<dof_id_type> &, bool, int) const {}
2523
2526 std::vector<dof_id_type> &,
2527 bool) const {}
2528
2529inline void DofMap::constrain_nothing (std::vector<dof_id_type> &) const {}
2530
2533 bool) const {}
2534
2536 unsigned int) const {}
2537
2538
2540 (const NonlinearImplicitSystem &,
2542 NumericVector<Number> const *,
2543 bool) const {}
2544
2548
2549#endif // LIBMESH_ENABLE_CONSTRAINTS
2550
2551
2552
2553inline
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}
2565
2566inline
2571
2572inline
2577
2578inline
2580{
2581#ifdef LIBMESH_ENABLE_CONSTRAINTS
2583#else
2584 return true;
2585#endif
2586}
2587
2588inline
2589void DofMap::should_p_refine(const unsigned int g, const bool p_refine)
2590{
2591#ifdef LIBMESH_ENABLE_AMR
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}
2605
2606inline
2607bool DofMap::should_p_refine(const unsigned int g) const
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}
2617
2618inline
2619unsigned int DofMap::var_group_from_var_number(const unsigned int var_num) const
2620{
2621 libmesh_assert(var_num < n_variables());
2622 return libmesh_map_find(_var_to_vg, var_num);
2623}
2624
2625inline
2626bool DofMap::should_p_refine_var(const unsigned int var) const
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}
2636
2637template <typename FieldDofsFunctor>
2638void DofMap::_dof_indices (const Elem & elem,
2639 int p_level,
2640 std::vector<dof_id_type> & di,
2641 const unsigned int vg,
2642 const unsigned int vig,
2643 const Node * const * nodes,
2644 unsigned int n_nodes,
2645 const unsigned int v,
2646#ifdef DEBUG
2647 std::size_t & tot_size,
2648#endif
2649 FieldDofsFunctor field_dofs_functor) const
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}
2792
2793
2794
2795template <typename ScalarDofsFunctor, typename FieldDofsFunctor>
2796void DofMap::dof_indices (const Elem * const elem,
2797 std::vector<dof_id_type> & di,
2798 const unsigned int vn,
2799 ScalarDofsFunctor scalar_dofs_functor,
2800 FieldDofsFunctor field_dofs_functor,
2801 int p_level) const
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}
2876
2877inline
2883
2884inline
2886{
2888 return *_sc;
2889}
2890
2891inline const std::pair<unsigned int, unsigned int> &
2892DofMap::get_variable_array(const unsigned int vi) const
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}
2907
2908template <typename DofIndicesFunctor>
2909void DofMap::array_dof_indices(const DofIndicesFunctor & functor,
2910 std::vector<dof_id_type> & di,
2911 const unsigned int vn) const
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}
2954
2955inline
2956unsigned int DofMap::n_vars() const
2957{
2958 return cast_int<unsigned int>(_variables.size());
2959}
2960
2961inline
2962const std::string & DofMap::variable_name (const unsigned int i) const
2963{
2964 libmesh_assert_less (i, _variables.size());
2965
2966 return _variables[i].name();
2967}
2968
2969inline
2974
2975inline
2977{
2979}
2980
2981inline
2982unsigned int DofMap::n_components(const MeshBase & mesh) const
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}
2990
2991inline
2992unsigned int
2994 unsigned int component) const
2995{
2996 return _variables[var_num].first_scalar_number() + component;
2997}
2998
2999inline
3000const FEType & DofMap::variable_type (std::string_view var) const
3001{
3002 return _variables[this->variable_number(var)].type();
3003}
3004
3005inline bool DofMap::has_variable(std::string_view var) const
3006{
3007 return _variable_numbers.count(var);
3008}
3009
3010inline unsigned int DofMap::variable_number(std::string_view var) const
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}
3016
3017} // namespace libMesh
3018
3019#endif // LIBMESH_DOF_MAP_H
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.
Definition dof_map.h:136
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.
Definition dof_map.h:124
The constraint matrix storage format.
Definition dof_map.h:112
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.
Definition dof_map.h:209
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.
Definition dof_map.h:202
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
void remove_default_ghosting()
Remove any default ghosting functor(s).
Definition dof_map.C:1990
bool should_p_refine(Order) const =delete
std::vector< unsigned int > _variable_group_numbers
The variable group number for each variable.
Definition dof_map.h:2113
std::size_t distribute_dofs(MeshBase &)
Distribute dofs on the current mesh.
Definition dof_map.C:951
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
bool _implicit_neighbor_dofs
Definition dof_map.h:2331
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
void distribute_scalar_dofs(dof_id_type &next_free_dof)
Definition dof_map.C:1541
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
dof_id_type n_dofs() const
DofConstraints::const_iterator constraint_rows_begin() const
Definition dof_map.h:1171
void reinit_send_list(MeshBase &mesh)
Clears the _send_list vector and then rebuilds it.
Definition dof_map.C:1879
processor_id_type dof_owner(const dof_id_type dof) const
Definition dof_map.h:822
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
DofObject *(DofMap::* dofobject_accessor)(MeshBase &mesh, dof_id_type i) const
A member function type like node_ptr() or elem_ptr().
Definition dof_map.h:1923
void reinit_static_condensation()
Calls reinit on the static condensation map if it exists.
Definition dof_map.C:3142
unsigned int var_group_from_var_number(unsigned int var_num) const
Definition dof_map.h:2619
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition dof_map.h:1643
unsigned int n_variable_groups() const
Definition dof_map.h:740
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.
Definition dof_map.h:2118
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 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...
Definition dof_map.C:872
unsigned int n_variables() const override
Definition dof_map.h:743
const std::vector< dof_id_type > & get_send_list() const
Definition dof_map.h:540
std::vector< dof_id_type > n_dofs_per_processor(const unsigned int vn) const
Definition dof_map.h:812
const DofConstraints & get_dof_constraints() const
Provide a const accessor to the DofConstraints map.
Definition dof_map.h:1184
void allgather_recursive_constraints(MeshBase &)
Gathers constraint equation dependencies from other processors.
GhostingFunctorIterator coupling_functors_begin() const
Beginning of range of coupling functors.
Definition dof_map.h:373
bool all_semilocal_indices(const std::vector< dof_id_type > &dof_indices) const
Definition dof_map.C:2662
std::vector< GhostingFunctor * > _algebraic_ghosting_functors
The list of all GhostingFunctor objects to be used when distributing ghosted vectors.
Definition dof_map.h:2227
dof_id_type n_local_dofs(const unsigned int vn) const
Definition dof_map.h:801
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
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
Definition dof_map.h:1225
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.
Definition dof_map.h:2166
std::unique_ptr< DirichletBoundaries > _dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition dof_map.h:2315
void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs)
Allow the implicit_neighbor_dofs flag to be set programmatically.
Definition dof_map.C:1893
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 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.
Definition dof_map.h:2521
const unsigned int _sys_number
The number of the system we manage DOFs for.
Definition dof_map.h:2142
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.
Definition dof_map.h:497
std::vector< std::unique_ptr< DirichletBoundaries > > _adjoint_dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition dof_map.h:2321
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.
Definition dof_map.h:2124
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2203
std::vector< GhostingFunctor * >::const_iterator GhostingFunctorIterator
Iterator type for coupling and algebraic ghosting functor ranges.
Definition dof_map.h:322
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...
Definition dof_map.h:2554
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.
Definition dof_map.C:2917
AugmentSendList * _augment_send_list
Function object to call to add extra entries to the send list.
Definition dof_map.h:2188
bool is_attached(SparseMatrix< Number > &matrix)
Matrices should not be attached more than once.
Definition dof_map.C:296
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
Definition dof_map.h:2970
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
void set_verify_dirichlet_bc_consistency(bool val)
Set the _verify_dirichlet_bc_consistency flag.
Definition dof_map.C:1899
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition dof_map.C:1837
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...
Definition dof_map.C:1962
DofConstraintValueMap & get_primal_constraint_values()
Definition dof_map.h:2484
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...
Definition dof_map.C:3391
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 ...
Definition dof_map.C:2121
std::unique_ptr< DefaultCoupling > _default_evaluating
The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction.
Definition dof_map.h:2214
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...
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.
Definition dof_map.h:474
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.
Definition dof_map.C:3255
std::vector< Variable > _variables
The variables in this system/degree of freedom map.
Definition dof_map.h:2103
Order variable_order(const unsigned int c) const
Definition dof_map.h:2381
void update_sparsity_pattern(SparseMatrix< Number > &matrix) const
Additional matrices may be be temporarily initialized by this DofMap.
Definition dof_map.C:270
bool computed_sparsity_already() const
Returns true iff a sparsity pattern has already been computed.
Definition dof_map.C:259
GhostingFunctorIterator coupling_functors_end() const
End of range of coupling functors.
Definition dof_map.h:379
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
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Backwards compatibility with misspelling.
Definition dof_map.h:1260
void attach_extra_sparsity_object(SparsityPattern::AugmentSparsityPattern &asp)
Attach an object to use to populate the sparsity pattern with extra entries.
Definition dof_map.h:459
unsigned int variable_scalar_number(unsigned int var_num, unsigned int component) const
Definition dof_map.h:2993
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,...
Definition dof_map.C:2091
void enforce_constraints_on_residual(const NonlinearImplicitSystem &system, NumericVector< Number > *rhs, NumericVector< Number > const *solution, bool homogeneous=true) const
Definition dof_map.h:2540
DefaultCoupling & default_coupling()
Default coupling functor.
Definition dof_map.h:385
void constrain_element_matrix(DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix.
Definition dof_map.h:2498
unsigned int n_vars() const
Definition dof_map.h:2956
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.
Definition dof_map.C:1983
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.
Definition dof_map.C:3379
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition dof_map.h:447
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.
Definition dof_map.C:228
void assert_no_nodes_missed(MeshBase &mesh)
Definition dof_map.C:1565
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.
Definition dof_map.h:2198
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.
Definition dof_map.h:420
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.
Definition dof_map.C:3148
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
void add_default_ghosting()
Add the default functor(s) for coupling and algebraic ghosting.
Definition dof_map.C:1998
void swap_dof_constraints()
Similar to the stash/unstash_dof_constraints() API, but swaps _dof_constraints and _stashed_dof_const...
Definition dof_map.h:1210
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
void stash_dof_constraints()
Definition dof_map.h:1186
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
Definition dof_map.h:2401
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...
Definition dof_map.h:2098
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.
Definition dof_map.C:319
unsigned int sys_number() const
Definition dof_map.h:2353
const VariableGroup & variable_group(const unsigned int c) const
Definition dof_map.h:2361
void clear_send_list()
Clears the _send_list vector.
Definition dof_map.h:514
unsigned int variable_number(std::string_view var) const
Definition dof_map.h:3010
PeriodicBoundaries * get_periodic_boundaries()
Definition dof_map.h:1590
bool semilocal_index(dof_id_type dof_index) const
Definition dof_map.C:2646
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...
Definition dof_map.h:1163
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...
Definition dof_map.h:2529
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
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Backwards compatibility with misspelling.
Definition dof_map.h:1244
const FEType & variable_group_type(const unsigned int vg) const
Definition dof_map.h:2411
StaticCondensationDofMap & get_static_condensation()
Definition dof_map.h:2878
NodeConstraints _node_constraints
Data structure containing DofObject constraints.
Definition dof_map.h:2298
std::vector< std::pair< unsigned int, unsigned int > > _array_variables
Array variable information storage.
Definition dof_map.h:2131
AdjointDofConstraintValues _adjoint_constraint_values
Definition dof_map.h:2291
bool is_constrained_dof(const dof_id_type dof) const
Definition dof_map.h:2439
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
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
dof_id_type n_constrained_nodes() const
Definition dof_map.h:1066
const std::vector< dof_id_type > & get_n_oz() const
Definition dof_map.h:562
unsigned int block_size() const
Definition dof_map.h:773
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
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 constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
Constrains the element vector.
Definition dof_map.h:2507
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
Number has_heterogeneous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Definition dof_map.h:2463
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
bool local_index(dof_id_type dof_index) const
Definition dof_map.h:974
const Variable & variable(const unsigned int c) const override
Definition dof_map.h:2371
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
Definition dof_map.C:241
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.
Definition dof_map.h:2531
const std::string & variable_name(const unsigned int i) const
Definition dof_map.h:2962
bool has_heterogeneous_adjoint_constraints(const unsigned int qoi_num) const
Definition dof_map.h:2449
void enforce_constraints_on_jacobian(const NonlinearImplicitSystem &system, SparseMatrix< Number > *jac) const
Definition dof_map.h:2546
bool _implicit_neighbor_dofs_initialized
Bools to indicate if we override the –implicit_neighbor_dofs commandline options.
Definition dof_map.h:2330
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
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition dof_map.h:1219
std::vector< SparseMatrix< Number > * > _matrices
Additional matrices handled by this object.
Definition dof_map.h:2154
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
Definition dof_map.h:1439
std::unique_ptr< SparsityPattern::Build > _sp
The sparsity pattern of the global matrix.
Definition dof_map.h:2265
void ghost_constraints_needed()
Sets _need_ghost_constraints to true regardless of the requirements by static condensation.
Definition dof_map.h:2573
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
Definition dof_map.h:1748
bool has_adjoint_dirichlet_boundaries(unsigned int q) const
bool is_periodic_boundary(const boundary_id_type boundaryid) const
Definition dof_map.C:218
dof_id_type n_local_constrained_dofs() const
std::unique_ptr< PeriodicBoundaries > _periodic_boundaries
Data structure containing periodic boundaries.
Definition dof_map.h:2307
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'.
Definition dof_map.h:2524
std::unique_ptr< DefaultCoupling > _default_coupling
The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern constructio...
Definition dof_map.h:2206
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
Definition dof_map.h:2006
void full_sparsity_pattern_needed()
Sets _need_full_sparsity_pattern to true regardless of the requirements by matrices.
Definition dof_map.h:2567
bool has_blocked_representation() const
Definition dof_map.h:756
bool has_static_condensation() const
Checks whether we have static condensation.
Definition dof_map.h:1804
dof_id_type n_dofs(const unsigned int vn) const
Definition dof_map.h:783
const std::vector< dof_id_type > & get_n_nz() const
Definition dof_map.h:549
MeshBase & _mesh
The mesh that system uses.
Definition dof_map.h:2147
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...
Definition dof_map.h:1042
const SparsityPattern::Build * get_sparsity_pattern() const
Definition dof_map.h:577
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
void print_info(std::ostream &os=libMesh::out) const
Prints summary info about the sparsity bandwidth and constraints.
Definition dof_map.C:2980
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 ...
Definition dof_map.h:2579
GhostingFunctorIterator algebraic_ghosting_functors_end() const
End of range of algebraic ghosting functors.
Definition dof_map.h:441
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.
Definition dof_map.h:358
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
Definition dof_map.h:1595
DirichletBoundaries * get_dirichlet_boundaries()
Definition dof_map.h:1648
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
bool is_constrained_node(const Node *node) const
Definition dof_map.h:2423
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.
Definition dof_map.h:2108
Order variable_group_order(const unsigned int vg) const
Definition dof_map.h:2391
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition dof_map.h:2137
DofConstraints::const_iterator constraint_rows_end() const
Definition dof_map.h:1177
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.
Definition dof_map.C:1292
unsigned int n_components(const MeshBase &mesh) const
Definition dof_map.h:2982
~DofMap()
Destructor.
Definition dof_map.C:205
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
DofObject * node_ptr(MeshBase &mesh, dof_id_type i) const
Definition dof_map.C:304
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
Definition dof_map.C:311
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.
Definition dof_map.C:3137
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
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition dof_map.C:2987
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),...
Definition dof_map.C:2480
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 ...
Definition dof_map.h:2535
void attach_extra_send_list_object(DofMap::AugmentSendList &asl)
Attach an object to populate the send_list with extra entries.
Definition dof_map.h:488
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
Definition dof_map.h:1395
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.
Definition dof_map.C:63
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
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
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
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()
Definition dof_map.h:1192
GhostingFunctorIterator algebraic_ghosting_functors_begin() const
Beginning of range of algebraic ghosting functors.
Definition dof_map.h:435
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
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
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.
Definition dof_map.h:2511
dof_id_type n_SCALAR_dofs() const
Definition dof_map.h:793
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition dof_map.C:2675
bool should_p_refine_var(unsigned int var) const
Whether the given variable should be p-refined.
Definition dof_map.h:2626
void set_error_on_constraint_loop(bool error_on_constraint_loop)
Definition dof_map.C:235
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 has_variable(std::string_view var) const
Definition dof_map.h:3005
bool _need_full_sparsity_pattern
Default false; set to true if any attached matrix requires a full sparsity pattern.
Definition dof_map.h:2252
void invalidate_dofs(MeshBase &mesh) const
Invalidates all active DofObject dofs for this system.
Definition dof_map.C:857
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition dof_object.h:55
unsigned int n_systems() const
Definition dof_object.h:927
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.
Definition dof_object.h:473
This is the base class from which all geometric element types are derived.
Definition elem.h:96
bool active() const
Definition elem.h:3079
virtual unsigned int n_nodes() const =0
subdomain_id_type subdomain_id() const
Definition elem.h:2712
const Node *const * get_nodes() const
Definition elem.h:2629
virtual bool is_vertex(const unsigned int i) const =0
virtual ElemType type() const =0
unsigned int p_level() const
Definition elem.h:3246
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...
Definition fe_type.h:197
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
Definition fe_type.h:203
bool p_refinement
Whether or not the finite elements for this type increase their p refinement level on geometric eleme...
Definition fe_type.h:292
FEFamily family
The type of finite element.
Definition fe_type.h:228
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.
Definition mesh_base.h:81
The Node constraint storage format.
Definition dof_map.h:160
A Node is like a Point, but with more information.
Definition node.h:55
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.
Generic sparse matrix.
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.
Definition system.h:100
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.
Definition variable.h:216
unsigned int n_variables() const
Definition variable.h:278
unsigned int number(unsigned int v) const
Definition variable.h:316
unsigned int first_scalar_number(unsigned int v) const
Definition variable.h:329
This class defines the notion of a variable in the system.
Definition variable.h:51
unsigned int first_scalar_number() const
Definition variable.h:138
bool active_on_subdomain(subdomain_id_type sid) const
Definition variable.h:167
unsigned int n_components() const
Definition variable.C:23
const FEType & type() const
Definition variable.h:144
static const Real b
MeshBase & mesh
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.
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.
Definition dof_map.h:148
ElemType
Defines an enum for geometric element types.
int8_t boundary_id_type
Definition id_types.h:51
void libmesh_ignore(const Args &...)
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
OStreamProxy out
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
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104
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
The definition of the const_element_iterator struct.
Definition mesh_base.h:2575
Struct which defines a custom comparison object that can be used with std::sets of std::unique_ptrs.
Definition utility.h:486
const dof_id_type n_nodes
Definition tecplot_io.C:67
static const bool value
Definition xdr_io.C:55