libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
dof_map.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 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 
37 // C++ Includes
38 #include <algorithm>
39 #include <cstddef>
40 #include <iterator>
41 #include <map>
42 #include <string>
43 #include <vector>
44 #include <memory>
45 
46 namespace libMesh
47 {
48 
49 // Forward Declarations
50 class CouplingMatrix;
51 class DefaultCoupling;
52 class DirichletBoundary;
53 class DirichletBoundaries;
54 class DofMap;
55 class DofObject;
56 class Elem;
57 class FEType;
58 class MeshBase;
59 class PeriodicBoundaryBase;
60 class PeriodicBoundaries;
61 class System;
62 class NonlinearImplicitSystem;
63 template <typename T> class DenseVectorBase;
64 template <typename T> class DenseVector;
65 template <typename T> class DenseMatrix;
66 template <typename T> class SparseMatrix;
67 template <typename T> class NumericVector;
68 enum Order : int;
69 
70 
71 
72 // ------------------------------------------------------------
73 // Do we need constraints for anything?
74 
75 #if defined(LIBMESH_ENABLE_AMR) || \
76  defined(LIBMESH_ENABLE_PERIODIC) || \
77  defined(LIBMESH_ENABLE_DIRICHLET)
78 # define LIBMESH_ENABLE_CONSTRAINTS 1
79 #endif
80 
81 // ------------------------------------------------------------
82 // AMR constraint matrix types
83 
84 #ifdef LIBMESH_ENABLE_CONSTRAINTS
85 
88 typedef std::map<dof_id_type, Real,
89  std::less<dof_id_type>,
90  Threads::scalable_allocator<std::pair<const dof_id_type, Real>>> DofConstraintRow;
91 
98 class DofConstraints : public std::map<dof_id_type,
99  DofConstraintRow,
100  std::less<dof_id_type>,
101  Threads::scalable_allocator<std::pair<const dof_id_type, DofConstraintRow>>>
102 {
103 };
104 
111  public std::map<dof_id_type, Number,
112  std::less<dof_id_type>,
113  Threads::scalable_allocator<std::pair<const dof_id_type, Number>>>
114 {
115 };
116 
122  public std::map<unsigned int, DofConstraintValueMap,
123  std::less<unsigned int>,
124  Threads::scalable_allocator
125  <std::pair<const unsigned int, DofConstraintValueMap>>>
126 {
127 };
128 
129 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
130 
136 typedef std::map<const Node *, Real,
137  std::less<const Node *>,
138  Threads::scalable_allocator<std::pair<const Node * const, Real>>> NodeConstraintRow;
139 
146 class NodeConstraints : public std::map<const Node *,
147  std::pair<NodeConstraintRow,Point>,
148  std::less<const Node *>,
149  Threads::scalable_allocator<std::pair<const Node * const, std::pair<NodeConstraintRow,Point>>>>
150 {
151 };
152 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
153 
154 #endif // LIBMESH_ENABLE_CONSTRAINTS
155 
156 
157 
169 class DofMap : public ReferenceCountedObject<DofMap>,
170  public ParallelObject
171 {
172 public:
173 
179  explicit
180  DofMap(const unsigned int sys_number,
181  MeshBase & mesh);
182 
186  ~DofMap();
187 
192  {};
193 
199  {
200  public:
201  virtual ~AugmentSendList () = default;
202 
206  virtual void augment_send_list (std::vector<dof_id_type> & send_list) = 0;
207  };
208 
214  void attach_matrix (SparseMatrix<Number> & matrix);
215 
222  void update_sparsity_pattern(SparseMatrix<Number> & matrix) const;
223 
228  bool is_attached (SparseMatrix<Number> & matrix);
229 
236  std::size_t distribute_dofs (MeshBase &);
237 
243  void compute_sparsity (const MeshBase &);
244 
248  bool computed_sparsity_already () const;
249 
260  void set_constrained_sparsity_construction(bool use_constraints);
261 
268 
272  void clear_sparsity();
273 
288 
293  void add_default_ghosting();
294 
319  void add_coupling_functor(GhostingFunctor & coupling_functor,
320  bool to_mesh = true);
321 
329  void add_coupling_functor(std::shared_ptr<GhostingFunctor> coupling_functor,
330  bool to_mesh = true)
331  { _shared_functors[coupling_functor.get()] = coupling_functor;
332  this->add_coupling_functor(*coupling_functor, to_mesh); }
333 
339  void remove_coupling_functor(GhostingFunctor & coupling_functor);
340 
344  std::set<GhostingFunctor *>::const_iterator coupling_functors_begin() const
345  { return _coupling_functors.begin(); }
346 
350  std::set<GhostingFunctor *>::const_iterator coupling_functors_end() const
351  { return _coupling_functors.end(); }
352 
356  DefaultCoupling & default_coupling() { return *_default_coupling; }
357 
381  void add_algebraic_ghosting_functor(GhostingFunctor & evaluable_functor,
382  bool to_mesh = true);
383 
391  void add_algebraic_ghosting_functor(std::shared_ptr<GhostingFunctor> evaluable_functor,
392  bool to_mesh = true)
393  { _shared_functors[evaluable_functor.get()] = evaluable_functor;
394  this->add_algebraic_ghosting_functor(*evaluable_functor, to_mesh); }
395 
401  void remove_algebraic_ghosting_functor(GhostingFunctor & evaluable_functor);
402 
406  std::set<GhostingFunctor *>::const_iterator algebraic_ghosting_functors_begin() const
407  { return _algebraic_ghosting_functors.begin(); }
408 
412  std::set<GhostingFunctor *>::const_iterator algebraic_ghosting_functors_end() const
413  { return _algebraic_ghosting_functors.end(); }
414 
418  DefaultCoupling & default_algebraic_ghosting() { return *_default_evaluating; }
419 
431  {
433  }
434 
446  std::vector<dof_id_type> & n_nz,
447  std::vector<dof_id_type> & n_oz,
448  void *),
449  void * context = nullptr)
451 
460  {
461  _augment_send_list = &asl;
462  }
463 
468  void attach_extra_send_list_function(void (*func)(std::vector<dof_id_type> &, void *),
469  void * context = nullptr)
471 
478  void prepare_send_list ();
479 
486  {
487  _send_list.clear();
488  }
489 
499  void reinit_send_list (MeshBase & mesh);
500 
501 
511  const std::vector<dof_id_type> & get_send_list() const { return _send_list; }
512 
520  const std::vector<dof_id_type> & get_n_nz() const
521  {
522  libmesh_assert(_sp);
523  return _sp->get_n_nz();
524  }
525 
533  const std::vector<dof_id_type> & get_n_oz() const
534  {
535  libmesh_assert(_sp);
536  return _sp->get_n_oz();
537  }
538 
539 
549  {
550  return _sp.get();
551  }
552 
553  // /**
554  // * Add an unknown of order \p order and finite element type
555  // * \p type to the system of equations.
556  // */
557  // void add_variable (const Variable & var);
558 
563  void add_variable_group (VariableGroup var_group);
564 
575  void set_error_on_cyclic_constraint(bool error_on_cyclic_constraint);
576  void set_error_on_constraint_loop(bool error_on_constraint_loop);
577 
581  const VariableGroup & variable_group (const unsigned int c) const;
582 
586  const Variable & variable (const unsigned int c) const;
587 
591  Order variable_order (const unsigned int c) const;
592 
596  Order variable_group_order (const unsigned int vg) const;
597 
601  const FEType & variable_type (const unsigned int c) const;
602 
606  const FEType & variable_group_type (const unsigned int vg) const;
607 
613  unsigned int n_variable_groups() const
614  { return cast_int<unsigned int>(_variable_groups.size()); }
615 
621  unsigned int n_variables() const
622  { return cast_int<unsigned int>(_variables.size()); }
623 
627  unsigned int var_group_from_var_number(unsigned int var_num) const;
628 
635  {
636  return ((this->n_variable_groups() == 1) && (this->n_variables() > 1));
637  }
638 
651  unsigned int block_size() const
652  {
653  return (this->has_blocked_representation() ? this->n_variables() : 1);
654  }
655 
659  dof_id_type n_dofs() const { return _n_dfs; }
660 
665 
670  { return this->n_dofs_on_processor (this->processor_id()); }
671 
676  {
677  libmesh_assert_less (proc, _first_df.size());
678  return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
679  }
680 
685  { libmesh_assert_less (proc, _first_df.size()); return _first_df[proc]; }
686 
688  { return this->first_dof(this->processor_id()); }
689 
690 #ifdef LIBMESH_ENABLE_AMR
691 
695  { libmesh_assert_less (proc, _first_old_df.size()); return _first_old_df[proc]; }
696 
698  { return this->first_old_dof(this->processor_id()); }
699 
700 #endif //LIBMESH_ENABLE_AMR
701 
709  { libmesh_assert_less (proc, _end_df.size()); return _end_df[proc]; }
710 
712  { return this->end_dof(this->processor_id()); }
713 
718  { std::vector<dof_id_type>::const_iterator ub =
719  std::upper_bound(_end_df.begin(), _end_df.end(), dof);
720  libmesh_assert (ub != _end_df.end());
721  return cast_int<processor_id_type>(ub - _end_df.begin());
722  }
723 
724 #ifdef LIBMESH_ENABLE_AMR
725 
732  { libmesh_assert_less (proc, _end_old_df.size()); return _end_old_df[proc]; }
733 
735  { return this->end_old_dof(this->processor_id()); }
736 
737 #endif //LIBMESH_ENABLE_AMR
738 
743  void dof_indices (const Elem * const elem,
744  std::vector<dof_id_type> & di) const;
745 
751  void dof_indices (const Elem * const elem,
752  std::vector<dof_id_type> & di,
753  const unsigned int vn,
754  int p_level = -12345) const;
755 
760  void dof_indices (const Node * const node,
761  std::vector<dof_id_type> & di) const;
762 
767  void dof_indices (const Node * const node,
768  std::vector<dof_id_type> & di,
769  const unsigned int vn) const;
770 
777  void dof_indices (const Elem & elem,
778  unsigned int n,
779  std::vector<dof_id_type> & di,
780  const unsigned int vn) const;
781 
782 #ifdef LIBMESH_ENABLE_AMR
783 
790  void old_dof_indices (const Elem & elem,
791  unsigned int n,
792  std::vector<dof_id_type> & di,
793  const unsigned int vn) const;
794 
795 #endif // LIBMESH_ENABLE_AMR
796 
805  void SCALAR_dof_indices (std::vector<dof_id_type> & di,
806  const unsigned int vn,
807  const bool old_dofs=false) const;
808 
816  bool semilocal_index (dof_id_type dof_index) const;
817 
825  bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
826 
831  bool local_index (dof_id_type dof_index) const
832  { return (dof_index >= this->first_dof()) && (dof_index < this->end_dof()); }
833 
839  template <typename DofObjectSubclass>
840  bool is_evaluable(const DofObjectSubclass & obj,
841  unsigned int var_num = libMesh::invalid_uint) const;
842 
850  void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
851 
856 
863  bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
864 
876  const std::vector<dof_id_type> & dof_indices,
877  DenseVectorBase<Number> & Ue) const;
878 
883  void local_variable_indices(std::vector<dof_id_type> & idx,
884  const MeshBase & mesh,
885  unsigned int var_num) const;
886 
887 #ifdef LIBMESH_ENABLE_CONSTRAINTS
888 
889  //--------------------------------------------------------------------
890  // Constraint-specific methods
896 
902 
903 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
904 
909  { return cast_int<dof_id_type>(_node_constraints.size()); }
910 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
911 
917  void create_dof_constraints (const MeshBase &, Real time=0);
918 
922  void allgather_recursive_constraints (MeshBase &);
923 
927  void scatter_constraints (MeshBase &);
928 
942  void gather_constraints (MeshBase & mesh,
943  std::set<dof_id_type> & unexpanded_dofs,
944  bool look_for_constrainees);
945 
953  void process_constraints (MeshBase &);
954 
971 
976  void add_constraint_row (const dof_id_type dof_number,
977  const DofConstraintRow & constraint_row,
978  const Number constraint_rhs,
979  const bool forbid_constraint_overwrite);
980 
991  void add_adjoint_constraint_row (const unsigned int qoi_index,
992  const dof_id_type dof_number,
993  const DofConstraintRow & constraint_row,
994  const Number constraint_rhs,
995  const bool forbid_constraint_overwrite);
996 
1002  void add_constraint_row (const dof_id_type dof_number,
1003  const DofConstraintRow & constraint_row,
1004  const bool forbid_constraint_overwrite = true)
1005  { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
1006 
1010  DofConstraints::const_iterator constraint_rows_begin() const
1011  { return _dof_constraints.begin(); }
1012 
1016  DofConstraints::const_iterator constraint_rows_end() const
1017  { return _dof_constraints.end(); }
1018 
1024 
1026  {
1027  libmesh_assert(_stashed_dof_constraints.empty());
1029  }
1030 
1032  {
1033  libmesh_assert(_dof_constraints.empty());
1035  }
1036 
1050  {
1052  }
1053 
1054 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1055 
1058  NodeConstraints::const_iterator node_constraint_rows_begin() const
1059  { return _node_constraints.begin(); }
1060 
1064  NodeConstraints::const_iterator node_constraint_rows_end() const
1065  { return _node_constraints.end(); }
1066 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1067 
1072  bool is_constrained_dof (const dof_id_type dof) const;
1073 
1078  bool has_heterogeneous_adjoint_constraints (const unsigned int qoi_num) const;
1079 
1083  bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1084  {
1085  return this->has_heterogeneous_adjoint_constraints (qoi_num);
1086  }
1087 
1093  Number has_heterogeneous_adjoint_constraint (const unsigned int qoi_num,
1094  const dof_id_type dof) const;
1095 
1099  Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
1100  const dof_id_type dof) const
1101  {
1102  return this->has_heterogeneous_adjoint_constraint (qoi_num, dof);
1103  }
1104 
1110 
1115  bool is_constrained_node (const Node * node) const;
1116 
1123  void print_dof_constraints(std::ostream & os=libMesh::out,
1124  bool print_nonlocal=false) const;
1125 
1131  std::string get_local_constraints(bool print_nonlocal=false) const;
1132 
1133 
1142  std::pair<Real, Real> max_constraint_error(const System & system,
1143  NumericVector<Number> * v = nullptr) const;
1144 
1145 #endif // LIBMESH_ENABLE_CONSTRAINTS
1146 
1147  //--------------------------------------------------------------------
1148  // Constraint-specific methods
1149  // Some of these methods are enabled (but inlined away to nothing)
1150  // when constraints are disabled at configure-time. This is to
1151  // increase API compatibility of user code with different library
1152  // builds.
1153 
1168  std::vector<dof_id_type> & elem_dofs,
1169  bool asymmetric_constraint_rows = true) const;
1170 
1178  std::vector<dof_id_type> & row_dofs,
1179  std::vector<dof_id_type> & col_dofs,
1180  bool asymmetric_constraint_rows = true) const;
1181 
1186  std::vector<dof_id_type> & dofs,
1187  bool asymmetric_constraint_rows = true) const;
1188 
1198  DenseVector<Number> & rhs,
1199  std::vector<dof_id_type> & elem_dofs,
1200  bool asymmetric_constraint_rows = true) const;
1201 
1226  DenseVector<Number> & rhs,
1227  std::vector<dof_id_type> & elem_dofs,
1228  bool asymmetric_constraint_rows = true,
1229  int qoi_index = -1) const;
1230 
1231  /*
1232  * Backwards compatibility with misspelling.
1233  */
1235  DenseVector<Number> & rhs,
1236  std::vector<dof_id_type> & elem_dofs,
1237  bool asymmetric_constraint_rows = true,
1238  int qoi_index = -1) const
1239  {
1241  (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1242  }
1243 
1270  DenseVector<Number> & rhs,
1271  std::vector<dof_id_type> & elem_dofs,
1272  bool asymmetric_constraint_rows = true,
1273  int qoi_index = -1) const;
1274 
1275  /*
1276  * Backwards compatibility with misspelling.
1277  */
1279  DenseVector<Number> & rhs,
1280  std::vector<dof_id_type> & elem_dofs,
1281  bool asymmetric_constraint_rows = true,
1282  int qoi_index = -1) const
1283  {
1285  (matrix, rhs, elem_dofs, asymmetric_constraint_rows, qoi_index);
1286  }
1287 
1308  DenseVector<Number> & rhs,
1309  std::vector<dof_id_type> & elem_dofs,
1310  NumericVector<Number> & solution_local) const;
1311 
1327  std::vector<dof_id_type> & elem_dofs,
1328  NumericVector<Number> & solution_local) const;
1329 
1330 
1347  std::vector<dof_id_type> & elem_dofs,
1348  NumericVector<Number> & solution_local) const;
1349 
1359  DenseVector<Number> & w,
1360  std::vector<dof_id_type> & row_dofs,
1361  bool asymmetric_constraint_rows = true) const;
1362 
1369  void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1370 
1384  void enforce_constraints_exactly (const System & system,
1385  NumericVector<Number> * v = nullptr,
1386  bool homogeneous = false) const;
1387 
1395  unsigned int q) const;
1396 
1397  void enforce_constraints_on_residual (const NonlinearImplicitSystem & system,
1398  NumericVector<Number> * rhs,
1399  NumericVector<Number> const * solution,
1400  bool homogeneous = true) const;
1401 
1402  void enforce_constraints_on_jacobian (const NonlinearImplicitSystem & system,
1403  SparseMatrix<Number> * jac) const;
1404 
1405 #ifdef LIBMESH_ENABLE_PERIODIC
1406 
1407  //--------------------------------------------------------------------
1408  // PeriodicBoundary-specific methods
1409 
1413  void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1414 
1421  void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1422 
1427  bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1428 
1430  {
1431  return _periodic_boundaries.get();
1432  }
1433 
1435  {
1436  return _periodic_boundaries.get();
1437  }
1438 
1439 #endif // LIBMESH_ENABLE_PERIODIC
1440 
1441 
1442 #ifdef LIBMESH_ENABLE_DIRICHLET
1443 
1444  //--------------------------------------------------------------------
1445  // DirichletBoundary-specific methods
1446 
1460  void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1461 
1467  void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1468  unsigned int q);
1469 
1473  void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1474 
1479  void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1480  unsigned int q);
1481 
1483  {
1484  return _dirichlet_boundaries.get();
1485  }
1486 
1488  {
1489  return _dirichlet_boundaries.get();
1490  }
1491 
1492  bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1493 
1494  const DirichletBoundaries *
1495  get_adjoint_dirichlet_boundaries(unsigned int q) const;
1496 
1498  get_adjoint_dirichlet_boundaries(unsigned int q);
1499 
1504  void check_dirichlet_bcid_consistency (const MeshBase & mesh,
1505  const DirichletBoundary & boundary) const;
1506 #endif // LIBMESH_ENABLE_DIRICHLET
1507 
1508 
1509 #ifdef LIBMESH_ENABLE_AMR
1510 
1511  //--------------------------------------------------------------------
1512  // AMR-specific methods
1513 
1522  // void augment_send_list_for_projection(const MeshBase &);
1523 
1524 #ifdef LIBMESH_ENABLE_AMR
1525 
1532  void old_dof_indices (const Elem * const elem,
1533  std::vector<dof_id_type> & di,
1534  const unsigned int vn = libMesh::invalid_uint) const;
1535 
1539  dof_id_type n_old_dofs() const { return _n_old_dfs; }
1540 
1541 #endif // LIBMESH_ENABLE_AMR
1542 
1548  void constrain_p_dofs (unsigned int var,
1549  const Elem * elem,
1550  unsigned int s,
1551  unsigned int p);
1552 
1553 #endif // LIBMESH_ENABLE_AMR
1554 
1558  void reinit (MeshBase & mesh);
1559 
1564  void clear ();
1565 
1569  void print_info(std::ostream & os=libMesh::out) const;
1570 
1574  std::string get_info() const;
1575 
1589  CouplingMatrix * _dof_coupling;
1590 
1594  unsigned int sys_number() const;
1595 
1610  std::unique_ptr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh,
1611  bool calculate_constrained = false) const;
1612 
1617  void should_p_refine(unsigned int g, bool p_refine);
1618 
1622  bool should_p_refine(unsigned int g) const;
1623 
1627  bool should_p_refine_var(unsigned int var) const;
1628 
1629  // Prevent bad user implicit conversions
1630  void should_p_refine(FEFamily, bool) = delete;
1631  void should_p_refine(Order, bool) = delete;
1632  bool should_p_refine(FEFamily) const = delete;
1633  bool should_p_refine(Order) const = delete;
1634 
1635 private:
1636 
1647  void _dof_indices (const Elem & elem,
1648  int p_level,
1649  std::vector<dof_id_type> & di,
1650  const unsigned int vg,
1651  const unsigned int vig,
1652  const Node * const * nodes,
1653  unsigned int n_nodes
1654 #ifdef DEBUG
1655  ,
1656  const unsigned int v,
1657  std::size_t & tot_size
1658 #endif
1659  ) const;
1660 
1665  void _node_dof_indices (const Elem & elem,
1666  unsigned int n,
1667  const DofObject & obj,
1668  std::vector<dof_id_type> & di,
1669  const unsigned int vn) const;
1670 
1674  void invalidate_dofs(MeshBase & mesh) const;
1675 
1679  DofObject * node_ptr(MeshBase & mesh, dof_id_type i) const;
1680 
1684  DofObject * elem_ptr(MeshBase & mesh, dof_id_type i) const;
1685 
1689  typedef DofObject * (DofMap::*dofobject_accessor)
1690  (MeshBase & mesh, dof_id_type i) const;
1691 
1695  template<typename iterator_type>
1696  void set_nonlocal_dof_objects(iterator_type objects_begin,
1697  iterator_type objects_end,
1698  MeshBase & mesh,
1699  dofobject_accessor objects);
1700 
1709  void distribute_local_dofs_var_major (dof_id_type & next_free_dof,
1710  MeshBase & mesh);
1711 
1723  void distribute_local_dofs_node_major (dof_id_type & next_free_dof,
1724  MeshBase & mesh);
1725 
1726  /*
1727  * Helper method for the above two to count + distriubte SCALAR dofs
1728  */
1729  void distribute_scalar_dofs (dof_id_type & next_free_dof);
1730 
1731 #ifdef DEBUG
1732  /*
1733  * Internal assertions for distribute_local_dofs_*
1734  */
1735  void assert_no_nodes_missed(MeshBase & mesh);
1736 #endif
1737 
1738  /*
1739  * A utility method for obtaining a set of elements to ghost along
1740  * with merged coupling matrices.
1741  */
1742  typedef std::set<std::unique_ptr<CouplingMatrix>, Utility::CompareUnderlying> CouplingMatricesSet;
1743  static void
1744  merge_ghost_functor_outputs (GhostingFunctor::map_type & elements_to_ghost,
1745  CouplingMatricesSet & temporary_coupling_matrices,
1746  const std::set<GhostingFunctor *>::iterator & gf_begin,
1747  const std::set<GhostingFunctor *>::iterator & gf_end,
1748  const MeshBase::const_element_iterator & elems_begin,
1749  const MeshBase::const_element_iterator & elems_end,
1750  processor_id_type p);
1751 
1756  void add_neighbors_to_send_list(MeshBase & mesh);
1757 
1758 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1759 
1771  std::vector<dof_id_type> & elem_dofs,
1772  const bool called_recursively=false) const;
1773 
1790  DenseVector<Number> & H,
1791  std::vector<dof_id_type> & elem_dofs,
1792  int qoi_index = -1,
1793  const bool called_recursively=false) const;
1794 
1799  void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
1800 
1805  void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
1806 
1813 
1819  void process_mesh_constraint_rows(const MeshBase & mesh);
1820 
1821 #endif // LIBMESH_ENABLE_CONSTRAINTS
1822 
1829 
1835 
1839  std::vector<Variable> _variables;
1840 
1844  std::vector<VariableGroup> _variable_groups;
1845 
1849  std::vector<unsigned int> _variable_group_numbers;
1850 
1854  std::unordered_map<unsigned int, unsigned int> _var_to_vg;
1855 
1859  const unsigned int _sys_number;
1860 
1864  MeshBase & _mesh;
1865 
1871  std::vector<SparseMatrix<Number> * > _matrices;
1872 
1876  std::vector<dof_id_type> _first_df;
1877 
1881  std::vector<dof_id_type> _end_df;
1882 
1887  std::vector<dof_id_type> _first_scalar_df;
1888 
1893  std::vector<dof_id_type> _send_list;
1894 
1899 
1904  std::vector<dof_id_type> & n_nz,
1905  std::vector<dof_id_type> & n_oz,
1906  void *);
1911 
1916 
1920  void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
1921 
1926 
1933  std::unique_ptr<DefaultCoupling> _default_coupling;
1934 
1941  std::unique_ptr<DefaultCoupling> _default_evaluating;
1942 
1951  std::set<GhostingFunctor *> _algebraic_ghosting_functors;
1952 
1964  std::set<GhostingFunctor *> _coupling_functors;
1965 
1970  std::map<GhostingFunctor *, std::shared_ptr<GhostingFunctor> > _shared_functors;
1971 
1977 
1983  std::unique_ptr<SparsityPattern::Build> _sp;
1984 
1989 
1995 
1996 #ifdef LIBMESH_ENABLE_AMR
1997 
2002 
2006  std::vector<dof_id_type> _first_old_df;
2007 
2011  std::vector<dof_id_type> _end_old_df;
2012 
2017  std::vector<dof_id_type> _first_old_scalar_df;
2018 
2022  std::unordered_set<unsigned int> _dont_p_refine;
2023 #endif
2024 
2025 #ifdef LIBMESH_ENABLE_CONSTRAINTS
2026 
2031 
2033 
2035 #endif
2036 
2037 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2038 
2042 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
2043 
2044 
2045 #ifdef LIBMESH_ENABLE_PERIODIC
2046 
2050  std::unique_ptr<PeriodicBoundaries> _periodic_boundaries;
2051 #endif
2052 
2053 #ifdef LIBMESH_ENABLE_DIRICHLET
2054 
2058  std::unique_ptr<DirichletBoundaries> _dirichlet_boundaries;
2059 
2064  std::vector<std::unique_ptr<DirichletBoundaries>> _adjoint_dirichlet_boundaries;
2065 #endif
2066 
2068 
2075 
2087 };
2088 
2089 
2090 // ------------------------------------------------------------
2091 // Dof Map inline member functions
2092 inline
2093 unsigned int DofMap::sys_number() const
2094 {
2095  return _sys_number;
2096 }
2097 
2098 
2099 
2100 inline
2101 const VariableGroup & DofMap::variable_group (const unsigned int g) const
2102 {
2103  libmesh_assert_less (g, _variable_groups.size());
2104 
2105  return _variable_groups[g];
2106 }
2107 
2108 
2109 
2110 inline
2111 const Variable & DofMap::variable (const unsigned int c) const
2112 {
2113  libmesh_assert_less (c, _variables.size());
2114 
2115  return _variables[c];
2116 }
2117 
2118 
2119 
2120 inline
2121 Order DofMap::variable_order (const unsigned int c) const
2122 {
2123  libmesh_assert_less (c, _variables.size());
2124 
2125  return _variables[c].type().order;
2126 }
2127 
2128 
2129 
2130 inline
2131 Order DofMap::variable_group_order (const unsigned int vg) const
2132 {
2133  libmesh_assert_less (vg, _variable_groups.size());
2134 
2135  return _variable_groups[vg].type().order;
2136 }
2137 
2138 
2139 
2140 inline
2141 const FEType & DofMap::variable_type (const unsigned int c) const
2142 {
2143  libmesh_assert_less (c, _variables.size());
2144 
2145  return _variables[c].type();
2146 }
2147 
2148 
2149 
2150 inline
2151 const FEType & DofMap::variable_group_type (const unsigned int vg) const
2152 {
2153  libmesh_assert_less (vg, _variable_groups.size());
2154 
2155  return _variable_groups[vg].type();
2156 }
2157 
2158 
2159 #ifdef LIBMESH_ENABLE_CONSTRAINTS
2160 
2161 
2162 inline
2164 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2165  node
2166 #endif
2167  ) const
2168 {
2169 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
2170  if (_node_constraints.count(node))
2171  return true;
2172 #endif
2173 
2174  return false;
2175 }
2176 
2177 
2178 inline
2180 {
2181  if (_dof_constraints.count(dof))
2182  return true;
2183 
2184  return false;
2185 }
2186 
2187 
2188 inline
2189 bool DofMap::has_heterogeneous_adjoint_constraints (const unsigned int qoi_num) const
2190 {
2191  AdjointDofConstraintValues::const_iterator it =
2192  _adjoint_constraint_values.find(qoi_num);
2193  if (it == _adjoint_constraint_values.end())
2194  return false;
2195  if (it->second.empty())
2196  return false;
2197 
2198  return true;
2199 }
2200 
2201 
2202 inline
2204  const dof_id_type dof) const
2205 {
2206  AdjointDofConstraintValues::const_iterator it =
2207  _adjoint_constraint_values.find(qoi_num);
2208  if (it != _adjoint_constraint_values.end())
2209  {
2210  DofConstraintValueMap::const_iterator rhsit =
2211  it->second.find(dof);
2212  if (rhsit == it->second.end())
2213  return 0;
2214  else
2215  return rhsit->second;
2216  }
2217 
2218  return 0;
2219 }
2220 
2221 
2222 
2223 inline
2225 {
2227 }
2228 
2229 
2230 
2231 #else
2232 
2233 //--------------------------------------------------------------------
2234 // Constraint-specific methods get inlined into nothing if
2235 // constraints are disabled, so there's no reason for users not to
2236 // use them.
2237 
2239  std::vector<dof_id_type> &,
2240  bool) const {}
2241 
2242 inline void DofMap::constrain_element_matrix (DenseMatrix<Number> &,
2243  std::vector<dof_id_type> &,
2244  std::vector<dof_id_type> &,
2245  bool) const {}
2246 
2247 inline void DofMap::constrain_element_vector (DenseVector<Number> &,
2248  std::vector<dof_id_type> &,
2249  bool) const {}
2250 
2251 inline void DofMap::constrain_element_matrix_and_vector (DenseMatrix<Number> &,
2252  DenseVector<Number> &,
2253  std::vector<dof_id_type> &,
2254  bool) const {}
2255 
2257  (DenseMatrix<Number> &, DenseVector<Number> &,
2258  std::vector<dof_id_type> &, bool, int) const {}
2259 
2261  (const DenseMatrix<Number> &, DenseVector<Number> &,
2262  std::vector<dof_id_type> &, bool, int) const {}
2263 
2264 inline void DofMap::constrain_element_dyad_matrix (DenseVector<Number> &,
2265  DenseVector<Number> &,
2266  std::vector<dof_id_type> &,
2267  bool) const {}
2268 
2269 inline void DofMap::constrain_nothing (std::vector<dof_id_type> &) const {}
2270 
2271 inline void DofMap::enforce_constraints_exactly (const System &,
2273  bool) const {}
2274 
2276  unsigned int) const {}
2277 
2278 
2280  (const NonlinearImplicitSystem &,
2282  NumericVector<Number> const *,
2283  bool) const {}
2284 
2286  (const NonlinearImplicitSystem &,
2287  SparseMatrix<Number> *) const {}
2288 
2289 #endif // LIBMESH_ENABLE_CONSTRAINTS
2290 
2291 
2292 
2293 inline
2295 {
2296  // This got only partly finished...
2297  if (use_constraints)
2298  libmesh_not_implemented();
2299 
2300 #ifdef LIBMESH_ENABLE_CONSTRAINTS
2301  _constrained_sparsity_construction = use_constraints;
2302 #endif
2303  libmesh_ignore(use_constraints);
2304 }
2305 
2306 
2307 
2308 inline
2310 {
2311 #ifdef LIBMESH_ENABLE_CONSTRAINTS
2313 #else
2314  return true;
2315 #endif
2316 }
2317 
2318 inline
2319 void DofMap::should_p_refine(const unsigned int g, const bool p_refine)
2320 {
2321 #ifdef LIBMESH_ENABLE_AMR
2322  if (p_refine)
2323  {
2324  auto it = _dont_p_refine.find(g);
2325  if (it != _dont_p_refine.end())
2326  _dont_p_refine.erase(it);
2327  }
2328  else
2329  _dont_p_refine.insert(g);
2330 #else
2331  libmesh_ignore(g, p_refine);
2332 #endif
2333 }
2334 
2335 inline
2336 bool DofMap::should_p_refine(const unsigned int g) const
2337 {
2338 #ifdef LIBMESH_ENABLE_AMR
2339  return !_dont_p_refine.count(g);
2340 #else
2341  libmesh_ignore(g);
2342  return false;
2343 #endif
2344 }
2345 
2346 inline
2347 unsigned int DofMap::var_group_from_var_number(const unsigned int var_num) const
2348 {
2349  libmesh_assert(var_num < n_variables());
2350  return libmesh_map_find(_var_to_vg, var_num);
2351 }
2352 
2353 inline
2354 bool DofMap::should_p_refine_var(const unsigned int var) const
2355 {
2356 #ifdef LIBMESH_ENABLE_AMR
2357  const auto vg = this->var_group_from_var_number(var);
2358  return !_dont_p_refine.count(vg);
2359 #else
2360  libmesh_ignore(var);
2361  return false;
2362 #endif
2363 }
2364 } // namespace libMesh
2365 
2366 #endif // LIBMESH_DOF_MAP_H
std::vector< VariableGroup > _variable_groups
The finite element type for each variable group.
Definition: dof_map.h:1844
unsigned int var_group_from_var_number(unsigned int var_num) const
Definition: dof_map.h:2347
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::unique_ptr< SparsityPattern::Build > _sp
The sparsity pattern of the global matrix.
Definition: dof_map.h:1983
DofObject * elem_ptr(MeshBase &mesh, dof_id_type i) const
Definition: dof_map.C:348
bool _implicit_neighbor_dofs_initialized
Bools to indicate if we override the –implicit_neighbor_dofs commandline options. ...
Definition: dof_map.h:2073
dof_id_type end_old_dof(const processor_id_type proc) const
Definition: dof_map.h:731
void distribute_local_dofs_node_major(dof_id_type &next_free_dof, MeshBase &mesh)
Distributes the global degrees of freedom for dofs on this processor.
Definition: dof_map.C:1196
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 unsigned int _sys_number
The number of the system we manage DOFs for.
Definition: dof_map.h:1859
bool _implicit_neighbor_dofs
Definition: dof_map.h:2074
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2922
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:2296
DofConstraintValueMap & get_primal_constraint_values()
Definition: dof_map.h:2224
void print_info(std::ostream &os=libMesh::out) const
Prints summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2915
DefaultCoupling & default_coupling()
Default coupling functor.
Definition: dof_map.h:356
void old_dof_indices(const Elem &elem, unsigned int n, std::vector< dof_id_type > &di, const unsigned int vn) const
Appends to the vector di the old global degree of freedom indices for elem.node_ref(n), for one variable vn.
Definition: dof_map.C:2283
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_begin() const
Beginning of range of algebraic ghosting functors.
Definition: dof_map.h:406
~DofMap()
Destructor.
Definition: dof_map.C:206
This helper class can be called on multiple threads to compute the sparsity pattern (or graph) of the...
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:254
void scatter_constraints(MeshBase &)
Sends constraint equations to constraining processors.
void add_periodic_boundary(const PeriodicBoundaryBase &periodic_boundary)
Adds a copy of the specified periodic boundary to the system.
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:1828
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 ...
void process_mesh_constraint_rows(const MeshBase &mesh)
Adds any spline constraints from the Mesh to our DoF constraints.
void * _extra_sparsity_context
A pointer associated with the extra sparsity that can optionally be passed in.
Definition: dof_map.h:1910
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2141
dof_id_type n_constrained_dofs() const
std::size_t distribute_dofs(MeshBase &)
Distribute dofs on the current mesh.
Definition: dof_map.C:927
void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs)
Allow the implicit_neighbor_dofs flag to be set programmatically.
Definition: dof_map.C:1748
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 ...
void add_default_ghosting()
Add the default functor(s) for coupling and algebraic ghosting.
Definition: dof_map.C:1852
We&#39;re using a class instead of a typedef to allow forward declarations and future flexibility...
dof_id_type end_old_dof() const
Definition: dof_map.h:734
void check_dirichlet_bcid_consistency(const MeshBase &mesh, const DirichletBoundary &boundary) const
Check that all the ids in dirichlet_bcids are actually present in the mesh.
void remove_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Removes the specified Dirichlet boundary from the system.
std::set< GhostingFunctor * >::const_iterator coupling_functors_begin() const
Beginning of range of coupling functors.
Definition: dof_map.h:344
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#ifdef DEBUG, const unsigned int v, 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:2381
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:1893
void constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
Constrains the element vector.
void set_verify_dirichlet_bc_consistency(bool val)
Set the _verify_dirichlet_bc_consistency flag.
Definition: dof_map.C:1754
bool is_attached(SparseMatrix< Number > &matrix)
Matrices should not be attached more than once.
Definition: dof_map.C:333
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
Definition: dof_map.C:278
void enforce_constraints_on_jacobian(const NonlinearImplicitSystem &system, SparseMatrix< Number > *jac) const
DofObject * node_ptr(MeshBase &mesh, dof_id_type i) const
Definition: dof_map.C:341
void clear_send_list()
Clears the _send_list vector.
Definition: dof_map.h:485
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.
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition: dof_map.h:418
DofConstraints::const_iterator constraint_rows_begin() const
Definition: dof_map.h:1010
std::unique_ptr< DirichletBoundaries > _dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition: dof_map.h:2058
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
bool computed_sparsity_already() const
Returns true iff a sparsity pattern has already been computed.
Definition: dof_map.C:296
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
The Node constraint storage format.
Definition: dof_map.h:146
std::set< GhostingFunctor * > _algebraic_ghosting_functors
The list of all GhostingFunctor objects to be used when distributing ghosted vectors.
Definition: dof_map.h:1951
std::vector< dof_id_type > _end_old_df
Last old DOF index (plus 1) on processor p.
Definition: dof_map.h:2011
processor_id_type dof_owner(const dof_id_type dof) const
Definition: dof_map.h:717
unsigned int block_size() const
Definition: dof_map.h:651
void should_p_refine(unsigned int g, bool p_refine)
Describe whether the given variable group should be p-refined.
Definition: dof_map.h:2319
void local_variable_indices(std::vector< dof_id_type > &idx, const MeshBase &mesh, unsigned int var_num) const
Fills an array of those dof indices which belong to the given variable number and live on the current...
Definition: dof_map.C:1109
void invalidate_dofs(MeshBase &mesh) const
Invalidates all active DofObject dofs for this system.
Definition: dof_map.C:835
virtual void augment_send_list(std::vector< dof_id_type > &send_list)=0
User-defined function to augment the send list.
bool local_index(dof_id_type dof_index) const
Definition: dof_map.h:831
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:2111
void find_connected_dof_objects(std::vector< const DofObject * > &objs) const
Finds all the DofObjects associated with the set in objs.
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:1002
dof_id_type n_dofs() const
Definition: dof_map.h:659
void set_error_on_constraint_loop(bool error_on_constraint_loop)
Definition: dof_map.C:245
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:2101
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:1861
const FEType & variable_group_type(const unsigned int vg) const
Definition: dof_map.h:2151
std::vector< dof_id_type > _first_old_df
First old DOF index on processor p.
Definition: dof_map.h:2006
Number has_heterogeneous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Definition: dof_map.h:2203
uint8_t processor_id_type
Definition: id_types.h:104
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:1887
dof_id_type first_old_dof() const
Definition: dof_map.h:697
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map.h:675
bool has_heterogeneous_adjoint_constraints(const unsigned int qoi_num) const
Definition: dof_map.h:2189
AdjointDofConstraintValues _adjoint_constraint_values
Definition: dof_map.h:2034
bool _constrained_sparsity_construction
This flag indicates whether or not we explicitly take constraint equations into account when computin...
Definition: dof_map.h:1834
AugmentSendList * _augment_send_list
Function object to call to add extra entries to the send list.
Definition: dof_map.h:1915
bool has_adjoint_dirichlet_boundaries(unsigned int q) const
bool need_full_sparsity_pattern
Default false; set to true if any attached matrix requires a full sparsity pattern.
Definition: dof_map.h:1976
bool constrained_sparsity_construction()
Returns true iff the current policy when constructing sparsity patterns is to explicitly account for ...
Definition: dof_map.h:2309
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
Definition: dof_map.h:66
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:684
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:391
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:708
const DirichletBoundaries * get_adjoint_dirichlet_boundaries(unsigned int q) const
void reinit_send_list(MeshBase &mesh)
Clears the _send_list vector and then rebuilds it.
Definition: dof_map.C:1734
void libmesh_ignore(const Args &...)
const PeriodicBoundaries * get_periodic_boundaries() const
Definition: dof_map.h:1434
bool is_constrained_dof(const dof_id_type dof) const
Definition: dof_map.h:2179
void print_dof_constraints(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all DoF and Node constraints.
std::unordered_map< unsigned int, unsigned int > _var_to_vg
A map from variable number to variable group number.
Definition: dof_map.h:1854
bool is_constrained_node(const Node *node) const
Definition: dof_map.h:2163
This class defines the notion of a variable in the system.
Definition: variable.h:49
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:1544
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:2017
int8_t boundary_id_type
Definition: id_types.h:51
std::string get_local_constraints(bool print_nonlocal=false) const
Gets a string reporting all DoF and Node constraints local to this processor.
dof_id_type _n_SCALAR_dofs
The total number of SCALAR dofs associated to all SCALAR variables.
Definition: dof_map.h:1994
void assert_no_nodes_missed(MeshBase &mesh)
Definition: dof_map.C:1418
PeriodicBoundaries * get_periodic_boundaries()
Definition: dof_map.h:1429
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:356
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 ...
std::set< std::unique_ptr< CouplingMatrix >, Utility::CompareUnderlying > CouplingMatricesSet
Definition: dof_map.h:1742
NodeConstraints::const_iterator node_constraint_rows_end() const
Definition: dof_map.h:1064
bool is_periodic_boundary(const boundary_id_type boundaryid) const
Definition: dof_map.C:219
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh. ...
void add_variable_group(VariableGroup var_group)
Add an unknown of order order and finite element type type to the system of equations.
Definition: dof_map.C:252
void swap_dof_constraints()
Similar to the stash/unstash_dof_constraints() API, but swaps _dof_constraints and _stashed_dof_const...
Definition: dof_map.h:1049
dof_id_type n_local_constrained_dofs() const
We&#39;re using a class instead of a typedef to allow forward declarations and future flexibility...
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:430
DirichletBoundaries * get_dirichlet_boundaries()
Definition: dof_map.h:1487
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.
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition: dof_map.h:1482
void clear()
Free all new memory associated with the object, but restore its original state, with the mesh pointer...
Definition: dof_map.C:850
const SparsityPattern::Build * get_sparsity_pattern() const
Definition: dof_map.h:548
void allgather_recursive_constraints(MeshBase &)
Gathers constraint equation dependencies from other processors.
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...
DofConstraints _dof_constraints
Data structure containing DOF constraints.
Definition: dof_map.h:2030
std::unique_ptr< SparsityPattern::Build > build_sparsity(const MeshBase &mesh, bool calculate_constrained=false) const
Builds a sparsity pattern for matrices using the current degree-of-freedom numbering and coupling...
Definition: dof_map.C:64
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:329
OStreamProxy out
void reinit(MeshBase &mesh)
Reinitialize the underlying data structures conformal to the current mesh.
Definition: dof_map.C:506
DofMap(const unsigned int sys_number, MeshBase &mesh)
Constructor.
Definition: dof_map.C:135
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
Definition: dof_map.h:1589
unsigned int n_variable_groups() const
Definition: dof_map.h:613
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Backwards compatibility with misspelling.
Definition: dof_map.h:1099
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition: dof_map.h:1058
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...
unsigned int sys_number() const
Definition: dof_map.h:2093
void * _extra_send_list_context
A pointer associated with the extra send list that can optionally be passed in.
Definition: dof_map.h:1925
This class implements reference counting.
This class defines a logically grouped set of variables in the system.
Definition: variable.h:193
bool semilocal_index(dof_id_type dof_index) const
Definition: dof_map.C:2580
void constrain_element_residual(DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
Constrains the element residual.
void update_sparsity_pattern(SparseMatrix< Number > &matrix) const
Additional matrices may be be temporarily initialized by this DofMap.
Definition: dof_map.C:307
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_end() const
End of range of algebraic ghosting functors.
Definition: dof_map.h:412
Storage for DofConstraint right hand sides for a particular problem.
Definition: dof_map.h:110
std::vector< SparseMatrix< Number > * > _matrices
Additional matrices handled by this object.
Definition: dof_map.h:1871
Storage for DofConstraint right hand sides for all adjoint problems.
Definition: dof_map.h:121
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:1234
dof_id_type end_dof() const
Definition: dof_map.h:711
DofConstraints::const_iterator constraint_rows_end() const
Definition: dof_map.h:1016
std::vector< std::unique_ptr< DirichletBoundaries > > _adjoint_dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition: dof_map.h:2064
const std::vector< dof_id_type > & get_n_oz() const
Definition: dof_map.h:533
void distribute_scalar_dofs(dof_id_type &next_free_dof)
Definition: dof_map.C:1394
unsigned int n_variables() const
Definition: dof_map.h:621
std::unique_ptr< PeriodicBoundaries > _periodic_boundaries
Data structure containing periodic boundaries.
Definition: dof_map.h:2050
void heterogeneously_constrain_element_jacobian_and_residual(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
Constrains the element Jacobian and residual.
void heterogeneously_constrain_element_residual(DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, NumericVector< Number > &solution_local) const
Constrains the element residual.
void unstash_dof_constraints()
Definition: dof_map.h:1031
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:2544
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:1873
template class LIBMESH_EXPORT SparseMatrix< Number >
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
static void merge_ghost_functor_outputs(GhostingFunctor::map_type &elements_to_ghost, CouplingMatricesSet &temporary_coupling_matrices, const std::set< GhostingFunctor * >::iterator &gf_begin, const std::set< GhostingFunctor * >::iterator &gf_end, const MeshBase::const_element_iterator &elems_begin, const MeshBase::const_element_iterator &elems_end, processor_id_type p)
Definition: dof_map.C:1440
void constrain_element_matrix(DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix.
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...
void stash_dof_constraints()
Definition: dof_map.h:1025
dof_id_type n_old_dofs() const
Definition: dof_map.h:1539
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:468
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:2086
std::unique_ptr< DefaultCoupling > _default_coupling
The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern constructio...
Definition: dof_map.h:1933
void add_constraints_to_send_list()
Adds entries to the _send_list vector corresponding to DoFs which are dependencies for constraint equ...
DofConstraintValueMap _primal_constraint_values
Definition: dof_map.h:2032
std::vector< Variable > _variables
The finite element type for each variable.
Definition: dof_map.h:1839
DofConstraints _stashed_dof_constraints
Definition: dof_map.h:2030
Order variable_order(const unsigned int c) const
Definition: dof_map.h:2121
void remove_default_ghosting()
Remove any default ghosting functor(s).
Definition: dof_map.C:1844
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:445
dof_id_type n_local_dofs() const
Definition: dof_map.h:669
SparsityPattern::AugmentSparsityPattern * _augment_sparsity_pattern
Function object to call to add extra entries to the sparsity pattern.
Definition: dof_map.h:1898
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:90
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:54
dof_id_type _n_old_dfs
Total number of degrees of freedom on old dof objects.
Definition: dof_map.h:2001
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:1278
void clear_sparsity()
Clears the sparsity pattern.
Definition: dof_map.C:1837
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:2294
bool all_semilocal_indices(const std::vector< dof_id_type > &dof_indices) const
Definition: dof_map.C:2596
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.
std::set< GhostingFunctor * > _coupling_functors
The list of all GhostingFunctor objects to be used when coupling degrees of freedom in matrix sparsit...
Definition: dof_map.h:1964
std::unordered_set< unsigned int > _dont_p_refine
A container of variable groups that we should not p-refine.
Definition: dof_map.h:2022
std::vector< dof_id_type > _end_df
Last DOF index (plus 1) on processor p.
Definition: dof_map.h:1881
dof_id_type n_SCALAR_dofs() const
Definition: dof_map.h:664
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
std::vector< dof_id_type > _first_df
First DOF index on processor p.
Definition: dof_map.h:1876
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Backwards compatibility with misspelling.
Definition: dof_map.h:1083
const DofConstraints & get_dof_constraints() const
Provide a const accessor to the DofConstraints map.
Definition: dof_map.h:1023
The base class for defining periodic boundaries.
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints.
定义用于有限元计算的抽象稠密向量基类。 可以从这个类派生出特定的稠密向量,例如 DenseSubVectors。
Definition: dof_map.h:63
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:138
MeshBase & _mesh
The mesh that system uses.
Definition: dof_map.h:1864
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:2852
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1692
定义用于有限元计算的稠密向量类。该类基本上是为了补充 DenseMatrix 类而设计的。 它相对于 std::vector 具有额外的功能,使其在有限元中特别有用,特别是对于方程组。 所有重写的虚拟函...
Definition: dof_map.h:64
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:1903
std::unique_ptr< DefaultCoupling > _default_evaluating
The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction...
Definition: dof_map.h:1941
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:1920
std::vector< unsigned int > _variable_group_numbers
The variable group number for each variable.
Definition: dof_map.h:1849
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:1970
std::set< GhostingFunctor * >::const_iterator coupling_functors_end() const
End of range of coupling functors.
Definition: dof_map.h:350
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:1690
void remove_algebraic_ghosting_functor(GhostingFunctor &evaluable_functor)
Removes a functor which was previously added to the set of algebraic ghosting functors, from both this DofMap and from the underlying mesh.
Definition: dof_map.C:1898
virtual ~AugmentSendList()=default
Backwards compatibility for prior AugmentSparsityPattern users.
Definition: dof_map.h:191
void attach_extra_send_list_object(DofMap::AugmentSendList &asl)
Attach an object to populate the send_list with extra entries.
Definition: dof_map.h:459
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:1816
bool has_blocked_representation() const
Definition: dof_map.h:634
Order variable_group_order(const unsigned int vg) const
Definition: dof_map.h:2131
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:1886
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&#39;.
bool should_p_refine_var(unsigned int var) const
Whether the given variable should be p-refined.
Definition: dof_map.h:2354
const std::vector< dof_id_type > & get_n_nz() const
Definition: dof_map.h:520
定义用于有限元类型计算的密集矩阵。 用于在求和成全局矩阵之前存储单元刚度矩阵。所有被覆盖的虚函数都记录在dense_matrix_base.h中。
Definition: dof_map.h:65
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:1760
dof_id_type first_old_dof(const processor_id_type proc) const
Definition: dof_map.h:694
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:238
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:511
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:1910
Abstract base class to be used to add user-defined implicit degree of freedom couplings.
bool is_evaluable(const DofObjectSubclass &obj, unsigned int var_num=libMesh::invalid_uint) const
Definition: dof_map.C:2609
template class LIBMESH_EXPORT NumericVector< Number >
The constraint matrix storage format.
Definition: dof_map.h:98
dof_id_type n_constrained_nodes() const
Definition: dof_map.h:908
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.
Abstract base class to be used to add user-defined parallel degree of freedom couplings.
Definition: dof_map.h:198
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 distribute_local_dofs_var_major(dof_id_type &next_free_dof, MeshBase &mesh)
Distributes the global degrees of freedom, for dofs on this processor.
Definition: dof_map.C:1299
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...
void check_for_cyclic_constraints()
Throw an error if we detect any constraint loops, i.e.
dof_id_type first_dof() const
Definition: dof_map.h:687
uint8_t dof_id_type
Definition: id_types.h:67
dof_id_type _n_dfs
Total number of degrees of freedom.
Definition: dof_map.h:1988
void enforce_constraints_on_residual(const NonlinearImplicitSystem &system, NumericVector< Number > *rhs, NumericVector< Number > const *solution, bool homogeneous=true) const
NodeConstraints _node_constraints
Data structure containing DofObject constraints.
Definition: dof_map.h:2041
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992