dof_map.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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/auto_ptr.h" // deprecated
26 #include "libmesh/enum_order.h"
28 #include "libmesh/libmesh.h" // libMesh::invalid_uint
29 #include "libmesh/variable.h"
30 #include "libmesh/threads.h"
32 #include "libmesh/elem_range.h"
36 #include "libmesh/point.h"
37 
38 // C++ Includes
39 #include <algorithm>
40 #include <cstddef>
41 #include <iterator>
42 #include <map>
43 #include <string>
44 #include <vector>
45 #include <memory>
46 
47 namespace libMesh
48 {
49 
50 // Forward Declarations
51 class CouplingMatrix;
52 class DefaultCoupling;
53 class DirichletBoundary;
54 class DirichletBoundaries;
55 class DofMap;
56 class DofObject;
57 class Elem;
58 class FEType;
59 class MeshBase;
60 class PeriodicBoundaryBase;
61 class PeriodicBoundaries;
62 class System;
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 
69 
70 
71 // ------------------------------------------------------------
72 // Do we need constraints for anything?
73 
74 #if defined(LIBMESH_ENABLE_AMR) || \
75  defined(LIBMESH_ENABLE_PERIODIC) || \
76  defined(LIBMESH_ENABLE_DIRICHLET)
77 # define LIBMESH_ENABLE_CONSTRAINTS 1
78 #endif
79 
80 // ------------------------------------------------------------
81 // AMR constraint matrix types
82 
83 #ifdef LIBMESH_ENABLE_CONSTRAINTS
84 
87 typedef std::map<dof_id_type, Real,
88  std::less<dof_id_type>,
90 
97 class DofConstraints : public std::map<dof_id_type,
98  DofConstraintRow,
99  std::less<dof_id_type>,
100  Threads::scalable_allocator<std::pair<const dof_id_type, DofConstraintRow>>>
101 {
102 };
103 
110  public std::map<dof_id_type, Number,
111  std::less<dof_id_type>,
112  Threads::scalable_allocator<std::pair<const dof_id_type, Number>>>
113 {
114 };
115 
121  public std::map<unsigned int, DofConstraintValueMap,
122  std::less<unsigned int>,
123  Threads::scalable_allocator
124  <std::pair<const unsigned int, DofConstraintValueMap>>>
125 {
126 };
127 
128 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
129 
135 typedef std::map<const Node *, Real,
136  std::less<const Node *>,
138 
145 class NodeConstraints : public std::map<const Node *,
146  std::pair<NodeConstraintRow,Point>,
147  std::less<const Node *>,
148  Threads::scalable_allocator<std::pair<const Node * const, std::pair<NodeConstraintRow,Point>>>>
149 {
150 };
151 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
152 
153 #endif // LIBMESH_ENABLE_CONSTRAINTS
154 
155 
156 
168 class DofMap : public ReferenceCountedObject<DofMap>,
169  public ParallelObject
170 {
171 public:
172 
178  explicit
179  DofMap(const unsigned int sys_number,
180  MeshBase & mesh);
181 
185  ~DofMap();
186 
192  {
193  public:
195 
199  virtual void augment_sparsity_pattern (SparsityPattern::Graph & sparsity,
200  std::vector<dof_id_type> & n_nz,
201  std::vector<dof_id_type> & n_oz) = 0;
202  };
203 
209  {
210  public:
211  virtual ~AugmentSendList () {}
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 
230  bool is_attached (SparseMatrix<Number> & matrix);
231 
237  void distribute_dofs (MeshBase &);
238 
244  void compute_sparsity (const MeshBase &);
245 
249  void clear_sparsity();
250 
265  void add_coupling_functor(GhostingFunctor & coupling_functor);
266 
271  void remove_coupling_functor(GhostingFunctor & coupling_functor);
272 
276  std::set<GhostingFunctor *>::const_iterator coupling_functors_begin() const
277  { return _coupling_functors.begin(); }
278 
282  std::set<GhostingFunctor *>::const_iterator coupling_functors_end() const
283  { return _coupling_functors.end(); }
284 
288  DefaultCoupling & default_coupling() { return *_default_coupling; }
289 
301  void add_algebraic_ghosting_functor(GhostingFunctor & ghosting_functor);
302 
307  void remove_algebraic_ghosting_functor(GhostingFunctor & ghosting_functor);
308 
312  std::set<GhostingFunctor *>::const_iterator algebraic_ghosting_functors_begin() const
313  { return _algebraic_ghosting_functors.begin(); }
314 
318  std::set<GhostingFunctor *>::const_iterator algebraic_ghosting_functors_end() const
319  { return _algebraic_ghosting_functors.end(); }
320 
324  DefaultCoupling & default_algebraic_ghosting() { return *_default_evaluating; }
325 
337  {
338  _augment_sparsity_pattern = &asp;
339  }
340 
352  std::vector<dof_id_type> & n_nz,
353  std::vector<dof_id_type> & n_oz,
354  void *),
355  void * context = libmesh_nullptr)
356  { _extra_sparsity_function = func; _extra_sparsity_context = context; }
357 
366  {
367  _augment_send_list = &asl;
368  }
369 
374  void attach_extra_send_list_function(void (*func)(std::vector<dof_id_type> &, void *),
375  void * context = libmesh_nullptr)
376  { _extra_send_list_function = func; _extra_send_list_context = context; }
377 
384  void prepare_send_list ();
385 
395  const std::vector<dof_id_type> & get_send_list() const { return _send_list; }
396 
404  const std::vector<dof_id_type> & get_n_nz() const
405  {
406  libmesh_assert(_n_nz);
407  return *_n_nz;
408  }
409 
417  const std::vector<dof_id_type> & get_n_oz() const
418  {
419  libmesh_assert(_n_oz);
420  return *_n_oz;
421  }
422 
423  // /**
424  // * Add an unknown of order \p order and finite element type
425  // * \p type to the system of equations.
426  // */
427  // void add_variable (const Variable & var);
428 
433  void add_variable_group (const VariableGroup & var_group);
434 
441  void set_error_on_cyclic_constraint(bool error_on_cyclic_constraint);
442 
446  const VariableGroup & variable_group (const unsigned int c) const;
447 
451  const Variable & variable (const unsigned int c) const;
452 
456  Order variable_order (const unsigned int c) const;
457 
461  Order variable_group_order (const unsigned int vg) const;
462 
466  const FEType & variable_type (const unsigned int c) const;
467 
471  const FEType & variable_group_type (const unsigned int vg) const;
472 
478  unsigned int n_variable_groups() const
479  { return cast_int<unsigned int>(_variable_groups.size()); }
480 
486  unsigned int n_variables() const
487  { return cast_int<unsigned int>(_variables.size()); }
488 
495  {
496 #ifdef LIBMESH_ENABLE_BLOCKED_STORAGE
497  return ((this->n_variable_groups() == 1) && (this->n_variables() > 1));
498 #else
499  return false;
500 #endif
501  }
502 
507  unsigned int block_size() const
508  {
509 #ifdef LIBMESH_ENABLE_BLOCKED_STORAGE
510  return (this->has_blocked_representation() ? this->n_variables() : 1);
511 #else
512  return 1;
513 #endif
514  }
515 
519  dof_id_type n_dofs() const { return _n_dfs; }
520 
524  dof_id_type n_SCALAR_dofs() const { return _n_SCALAR_dofs; }
525 
529  dof_id_type n_local_dofs () const
530  { return this->n_dofs_on_processor (this->processor_id()); }
531 
535  dof_id_type n_dofs_on_processor(const processor_id_type proc) const
536  {
537  libmesh_assert_less (proc, _first_df.size());
538  return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
539  }
540 
544  dof_id_type first_dof(const processor_id_type proc) const
545  { libmesh_assert_less (proc, _first_df.size()); return _first_df[proc]; }
546 
547  dof_id_type first_dof() const
548  { return this->first_dof(this->processor_id()); }
549 
550 #ifdef LIBMESH_ENABLE_AMR
551 
554  dof_id_type first_old_dof(const processor_id_type proc) const
555  { libmesh_assert_less (proc, _first_old_df.size()); return _first_old_df[proc]; }
556 
557  dof_id_type first_old_dof() const
558  { return this->first_old_dof(this->processor_id()); }
559 
560 #endif //LIBMESH_ENABLE_AMR
561 
568 #ifdef LIBMESH_ENABLE_DEPRECATED
569  dof_id_type last_dof(const processor_id_type proc) const
570  {
571  libmesh_deprecated();
572  libmesh_assert_less (proc, _end_df.size());
573  return cast_int<dof_id_type>(_end_df[proc] - 1);
574  }
575 
576  dof_id_type last_dof() const
577  { return this->last_dof(this->processor_id()); }
578 #endif
579 
586  dof_id_type end_dof(const processor_id_type proc) const
587  { libmesh_assert_less (proc, _end_df.size()); return _end_df[proc]; }
588 
589  dof_id_type end_dof() const
590  { return this->end_dof(this->processor_id()); }
591 
595  processor_id_type dof_owner(const dof_id_type dof) const
596  { std::vector<dof_id_type>::const_iterator ub =
597  std::upper_bound(_end_df.begin(), _end_df.end(), dof);
598  libmesh_assert (ub != _end_df.end());
599  return (ub - _end_df.begin());
600  }
601 
602 #ifdef LIBMESH_ENABLE_AMR
603 
609  dof_id_type end_old_dof(const processor_id_type proc) const
610  { libmesh_assert_less (proc, _end_old_df.size()); return _end_old_df[proc]; }
611 
612  dof_id_type end_old_dof() const
613  { return this->end_old_dof(this->processor_id()); }
614 
615 #endif //LIBMESH_ENABLE_AMR
616 
621  void dof_indices (const Elem * const elem,
622  std::vector<dof_id_type> & di) const;
623 
629  void dof_indices (const Elem * const elem,
630  std::vector<dof_id_type> & di,
631  const unsigned int vn,
632  int p_level = -12345) const;
633 
638  void dof_indices (const Node * const node,
639  std::vector<dof_id_type> & di) const;
640 
645  void dof_indices (const Node * const node,
646  std::vector<dof_id_type> & di,
647  const unsigned int vn) const;
648 
657  void SCALAR_dof_indices (std::vector<dof_id_type> & di,
658  const unsigned int vn,
659  const bool old_dofs=false) const;
660 
668  bool semilocal_index (dof_id_type dof_index) const;
669 
677  bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
678 
684  template <typename DofObjectSubclass>
685  bool is_evaluable(const DofObjectSubclass & obj,
686  unsigned int var_num = libMesh::invalid_uint) const;
687 
695  void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
696 
703  bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
704 
715  void extract_local_vector (const NumericVector<Number> & Ug,
716  const std::vector<dof_id_type> & dof_indices,
717  DenseVectorBase<Number> & Ue) const;
718 
723  void local_variable_indices(std::vector<dof_id_type> & idx,
724  const MeshBase & mesh,
725  unsigned int var_num) const;
726 
727 #ifdef LIBMESH_ENABLE_CONSTRAINTS
728 
729  //--------------------------------------------------------------------
730  // Constraint-specific methods
735  dof_id_type n_constrained_dofs() const;
736 
741  dof_id_type n_local_constrained_dofs() const;
742 
743 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
744 
748  dof_id_type n_constrained_nodes() const
749  { return cast_int<dof_id_type>(_node_constraints.size()); }
750 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
751 
757  void create_dof_constraints (const MeshBase &, Real time=0);
758 
762  void allgather_recursive_constraints (MeshBase &);
763 
767  void scatter_constraints (MeshBase &);
768 
782  void gather_constraints (MeshBase & mesh,
783  std::set<dof_id_type> & unexpanded_dofs,
784  bool look_for_constrainees);
785 
793  void process_constraints (MeshBase &);
794 
800  void check_for_cyclic_constraints();
801 
806  void add_constraint_row (const dof_id_type dof_number,
807  const DofConstraintRow & constraint_row,
808  const Number constraint_rhs,
809  const bool forbid_constraint_overwrite);
810 
821  void add_adjoint_constraint_row (const unsigned int qoi_index,
822  const dof_id_type dof_number,
823  const DofConstraintRow & constraint_row,
824  const Number constraint_rhs,
825  const bool forbid_constraint_overwrite);
826 
832  void add_constraint_row (const dof_id_type dof_number,
833  const DofConstraintRow & constraint_row,
834  const bool forbid_constraint_overwrite = true)
835  { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
836 
840  DofConstraints::const_iterator constraint_rows_begin() const
841  { return _dof_constraints.begin(); }
842 
846  DofConstraints::const_iterator constraint_rows_end() const
847  { return _dof_constraints.end(); }
848 
850  {
851  libmesh_assert(_stashed_dof_constraints.empty());
852  _dof_constraints.swap(_stashed_dof_constraints);
853  }
854 
856  {
857  libmesh_assert(_dof_constraints.empty());
858  _dof_constraints.swap(_stashed_dof_constraints);
859  }
860 
861 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
862 
865  NodeConstraints::const_iterator node_constraint_rows_begin() const
866  { return _node_constraints.begin(); }
867 
871  NodeConstraints::const_iterator node_constraint_rows_end() const
872  { return _node_constraints.end(); }
873 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
874 
879  bool is_constrained_dof (const dof_id_type dof) const;
880 
885  bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const;
886 
892  Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
893  const dof_id_type dof) const;
894 
899  DofConstraintValueMap & get_primal_constraint_values();
900 
905  bool is_constrained_node (const Node * node) const;
906 
913  void print_dof_constraints(std::ostream & os=libMesh::out,
914  bool print_nonlocal=false) const;
915 
921  std::string get_local_constraints(bool print_nonlocal=false) const;
922 
923 
932  std::pair<Real, Real> max_constraint_error(const System & system,
934 
935 #endif // LIBMESH_ENABLE_CONSTRAINTS
936 
937  //--------------------------------------------------------------------
938  // Constraint-specific methods
939  // Some of these methods are enabled (but inlined away to nothing)
940  // when constraints are disabled at configure-time. This is to
941  // increase API compatibility of user code with different library
942  // builds.
943 
957  void constrain_element_matrix (DenseMatrix<Number> & matrix,
958  std::vector<dof_id_type> & elem_dofs,
959  bool asymmetric_constraint_rows = true) const;
960 
967  void constrain_element_matrix (DenseMatrix<Number> & matrix,
968  std::vector<dof_id_type> & row_dofs,
969  std::vector<dof_id_type> & col_dofs,
970  bool asymmetric_constraint_rows = true) const;
971 
975  void constrain_element_vector (DenseVector<Number> & rhs,
976  std::vector<dof_id_type> & dofs,
977  bool asymmetric_constraint_rows = true) const;
978 
987  void constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
988  DenseVector<Number> & rhs,
989  std::vector<dof_id_type> & elem_dofs,
990  bool asymmetric_constraint_rows = true) const;
991 
1015  void heterogenously_constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
1016  DenseVector<Number> & rhs,
1017  std::vector<dof_id_type> & elem_dofs,
1018  bool asymmetric_constraint_rows = true,
1019  int qoi_index = -1) const;
1020 
1042  void heterogenously_constrain_element_vector (const DenseMatrix<Number> & matrix,
1043  DenseVector<Number> & rhs,
1044  std::vector<dof_id_type> & elem_dofs,
1045  bool asymmetric_constraint_rows = true,
1046  int qoi_index = -1) const;
1047 
1048 
1049 
1058  void constrain_element_dyad_matrix (DenseVector<Number> & v,
1059  DenseVector<Number> & w,
1060  std::vector<dof_id_type> & row_dofs,
1061  bool asymmetric_constraint_rows = true) const;
1062 
1069  void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1070 
1084  void enforce_constraints_exactly (const System & system,
1086  bool homogeneous = false) const;
1087 
1094  void enforce_adjoint_constraints_exactly (NumericVector<Number> & v,
1095  unsigned int q) const;
1096 
1097 
1098 
1099 #ifdef LIBMESH_ENABLE_PERIODIC
1100 
1101  //--------------------------------------------------------------------
1102  // PeriodicBoundary-specific methods
1103 
1107  void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1108 
1115  void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1116 
1121  bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1122 
1124  {
1125  return _periodic_boundaries.get();
1126  }
1127 
1128 #endif // LIBMESH_ENABLE_PERIODIC
1129 
1130 
1131 #ifdef LIBMESH_ENABLE_DIRICHLET
1132 
1133  //--------------------------------------------------------------------
1134  // DirichletBoundary-specific methods
1135 
1139  void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1140 
1146  void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1147  unsigned int q);
1148 
1152  void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1153 
1158  void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1159  unsigned int q);
1160 
1162  {
1163  return _dirichlet_boundaries.get();
1164  }
1165 
1167  {
1168  return _dirichlet_boundaries.get();
1169  }
1170 
1171  bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1172 
1173  const DirichletBoundaries *
1174  get_adjoint_dirichlet_boundaries(unsigned int q) const;
1175 
1177  get_adjoint_dirichlet_boundaries(unsigned int q);
1178 
1179 #endif // LIBMESH_ENABLE_DIRICHLET
1180 
1181 
1182 #ifdef LIBMESH_ENABLE_AMR
1183 
1184  //--------------------------------------------------------------------
1185  // AMR-specific methods
1186 
1195  // void augment_send_list_for_projection(const MeshBase &);
1196 
1203  void old_dof_indices (const Elem * const elem,
1204  std::vector<dof_id_type> & di,
1205  const unsigned int vn = libMesh::invalid_uint) const;
1209  dof_id_type n_old_dofs() const { return _n_old_dfs; }
1210 
1216  void constrain_p_dofs (unsigned int var,
1217  const Elem * elem,
1218  unsigned int s,
1219  unsigned int p);
1220 
1221 #endif // LIBMESH_ENABLE_AMR
1222 
1226  void reinit (MeshBase & mesh);
1227 
1231  void clear ();
1232 
1236  void print_info(std::ostream & os=libMesh::out) const;
1237 
1241  std::string get_info() const;
1242 
1257 
1261  unsigned int sys_number() const;
1262 
1263 private:
1264 
1272  void _dof_indices (const Elem & elem,
1273  int p_level,
1274  std::vector<dof_id_type> & di,
1275  const unsigned int v,
1276  const Node * const * nodes,
1277  unsigned int n_nodes
1278 #ifdef DEBUG
1279  ,
1280  std::size_t & tot_size
1281 #endif
1282  ) const;
1283 
1287  std::unique_ptr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh) const;
1288 
1292  void invalidate_dofs(MeshBase & mesh) const;
1293 
1297  DofObject * node_ptr(MeshBase & mesh, dof_id_type i) const;
1298 
1302  DofObject * elem_ptr(MeshBase & mesh, dof_id_type i) const;
1303 
1307  typedef DofObject * (DofMap::*dofobject_accessor)
1308  (MeshBase & mesh, dof_id_type i) const;
1309 
1313  template<typename iterator_type>
1314  void set_nonlocal_dof_objects(iterator_type objects_begin,
1315  iterator_type objects_end,
1316  MeshBase & mesh,
1317  dofobject_accessor objects);
1318 
1327  void distribute_local_dofs_var_major (dof_id_type & next_free_dof,
1328  MeshBase & mesh);
1329 
1341  void distribute_local_dofs_node_major (dof_id_type & next_free_dof,
1342  MeshBase & mesh);
1343 
1344  /*
1345  * A utility method for obtaining a set of elements to ghost along
1346  * with merged coupling matrices.
1347  */
1348  static void
1349  merge_ghost_functor_outputs (GhostingFunctor::map_type & elements_to_ghost,
1350  std::set<CouplingMatrix *> & temporary_coupling_matrices,
1351  const std::set<GhostingFunctor *>::iterator & gf_begin,
1352  const std::set<GhostingFunctor *>::iterator & gf_end,
1353  const MeshBase::const_element_iterator & elems_begin,
1354  const MeshBase::const_element_iterator & elems_end,
1355  processor_id_type p);
1356 
1361  void add_neighbors_to_send_list(MeshBase & mesh);
1362 
1363 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1364 
1375  void build_constraint_matrix (DenseMatrix<Number> & C,
1376  std::vector<dof_id_type> & elem_dofs,
1377  const bool called_recursively=false) const;
1378 
1394  void build_constraint_matrix_and_vector (DenseMatrix<Number> & C,
1395  DenseVector<Number> & H,
1396  std::vector<dof_id_type> & elem_dofs,
1397  int qoi_index = -1,
1398  const bool called_recursively=false) const;
1399 
1404  void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
1405 
1410  void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
1411 
1417  void add_constraints_to_send_list();
1418 
1419 #endif // LIBMESH_ENABLE_CONSTRAINTS
1420 
1426 
1430  std::vector<Variable> _variables;
1431 
1435  std::vector<VariableGroup> _variable_groups;
1436 
1440  const unsigned int _sys_number;
1441 
1446 
1452  std::vector<SparseMatrix<Number> * > _matrices;
1453 
1457  std::vector<dof_id_type> _first_df;
1458 
1462  std::vector<dof_id_type> _end_df;
1463 
1468  std::vector<dof_id_type> _first_scalar_df;
1469 
1474  std::vector<dof_id_type> _send_list;
1475 
1480 
1484  void (*_extra_sparsity_function)(SparsityPattern::Graph &,
1485  std::vector<dof_id_type> & n_nz,
1486  std::vector<dof_id_type> & n_oz,
1487  void *);
1492 
1497 
1501  void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
1502 
1507 
1514  std::unique_ptr<DefaultCoupling> _default_coupling;
1515 
1522  std::unique_ptr<DefaultCoupling> _default_evaluating;
1523 
1532  std::set<GhostingFunctor *> _algebraic_ghosting_functors;
1533 
1545  std::set<GhostingFunctor *> _coupling_functors;
1546 
1552 
1557  std::unique_ptr<SparsityPattern::Build> _sp;
1558 
1565  std::vector<dof_id_type> * _n_nz;
1566 
1571  std::vector<dof_id_type> * _n_oz;
1572 
1576  dof_id_type _n_dfs;
1577 
1582  dof_id_type _n_SCALAR_dofs;
1583 
1584 #ifdef LIBMESH_ENABLE_AMR
1585 
1589  dof_id_type _n_old_dfs;
1590 
1594  std::vector<dof_id_type> _first_old_df;
1595 
1599  std::vector<dof_id_type> _end_old_df;
1600 
1605  std::vector<dof_id_type> _first_old_scalar_df;
1606 
1607 #endif
1608 
1609 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1610 
1615 
1617 
1619 #endif
1620 
1621 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1622 
1626 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1627 
1628 
1629 #ifdef LIBMESH_ENABLE_PERIODIC
1630 
1634  std::unique_ptr<PeriodicBoundaries> _periodic_boundaries;
1635 #endif
1636 
1637 #ifdef LIBMESH_ENABLE_DIRICHLET
1638 
1642  void check_dirichlet_bcid_consistency (const MeshBase & mesh,
1643  const DirichletBoundary & boundary) const;
1648  std::unique_ptr<DirichletBoundaries> _dirichlet_boundaries;
1649 
1654  std::vector<DirichletBoundaries *> _adjoint_dirichlet_boundaries;
1655 #endif
1656 
1658 
1665 };
1666 
1667 
1668 // ------------------------------------------------------------
1669 // Dof Map inline member functions
1670 inline
1671 unsigned int DofMap::sys_number() const
1672 {
1673  return _sys_number;
1674 }
1675 
1676 
1677 
1678 inline
1679 const VariableGroup & DofMap::variable_group (const unsigned int g) const
1680 {
1681  libmesh_assert_less (g, _variable_groups.size());
1682 
1683  return _variable_groups[g];
1684 }
1685 
1686 
1687 
1688 inline
1689 const Variable & DofMap::variable (const unsigned int c) const
1690 {
1691  libmesh_assert_less (c, _variables.size());
1692 
1693  return _variables[c];
1694 }
1695 
1696 
1697 
1698 inline
1699 Order DofMap::variable_order (const unsigned int c) const
1700 {
1701  libmesh_assert_less (c, _variables.size());
1702 
1703  return _variables[c].type().order;
1704 }
1705 
1706 
1707 
1708 inline
1709 Order DofMap::variable_group_order (const unsigned int vg) const
1710 {
1711  libmesh_assert_less (vg, _variable_groups.size());
1712 
1713  return _variable_groups[vg].type().order;
1714 }
1715 
1716 
1717 
1718 inline
1719 const FEType & DofMap::variable_type (const unsigned int c) const
1720 {
1721  libmesh_assert_less (c, _variables.size());
1722 
1723  return _variables[c].type();
1724 }
1725 
1726 
1727 
1728 inline
1729 const FEType & DofMap::variable_group_type (const unsigned int vg) const
1730 {
1731  libmesh_assert_less (vg, _variable_groups.size());
1732 
1733  return _variable_groups[vg].type();
1734 }
1735 
1736 
1737 
1738 inline
1740 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1741  node
1742 #endif
1743  ) const
1744 {
1745 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1746  if (_node_constraints.count(node))
1747  return true;
1748 #endif
1749 
1750  return false;
1751 }
1752 
1753 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1754 
1755 inline
1756 bool DofMap::is_constrained_dof (const dof_id_type dof) const
1757 {
1758  if (_dof_constraints.count(dof))
1759  return true;
1760 
1761  return false;
1762 }
1763 
1764 
1765 inline
1766 bool DofMap::has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1767 {
1768  AdjointDofConstraintValues::const_iterator it =
1769  _adjoint_constraint_values.find(qoi_num);
1770  if (it == _adjoint_constraint_values.end())
1771  return false;
1772  if (it->second.empty())
1773  return false;
1774 
1775  return true;
1776 }
1777 
1778 
1779 inline
1781  const dof_id_type dof) const
1782 {
1783  AdjointDofConstraintValues::const_iterator it =
1784  _adjoint_constraint_values.find(qoi_num);
1785  if (it != _adjoint_constraint_values.end())
1786  {
1787  DofConstraintValueMap::const_iterator rhsit =
1788  it->second.find(dof);
1789  if (rhsit == it->second.end())
1790  return 0;
1791  else
1792  return rhsit->second;
1793  }
1794 
1795  return 0;
1796 }
1797 
1798 
1799 
1800 inline
1802 {
1803  return _primal_constraint_values;
1804 }
1805 
1806 
1807 
1808 #else
1809 
1810 //--------------------------------------------------------------------
1811 // Constraint-specific methods get inlined into nothing if
1812 // constraints are disabled, so there's no reason for users not to
1813 // use them.
1814 
1816  std::vector<dof_id_type> &,
1817  bool) const {}
1818 
1820  std::vector<dof_id_type> &,
1821  std::vector<dof_id_type> &,
1822  bool) const {}
1823 
1825  std::vector<dof_id_type> &,
1826  bool) const {}
1827 
1830  std::vector<dof_id_type> &,
1831  bool) const {}
1832 
1835  std::vector<dof_id_type> &,
1836  bool) const {}
1837 
1838 inline void DofMap::enforce_constraints_exactly (const System &,
1840  bool = false) const {}
1841 
1843  unsigned int) const {}
1844 
1845 #endif // LIBMESH_ENABLE_CONSTRAINTS
1846 
1847 } // namespace libMesh
1848 
1849 #endif // LIBMESH_DOF_MAP_H
std::vector< VariableGroup > _variable_groups
Definition: dof_map.h:1435
std::unique_ptr< SparsityPattern::Build > _sp
Definition: dof_map.h:1557
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:179
bool _error_on_cyclic_constraint
Definition: dof_map.h:1425
bool _implicit_neighbor_dofs_initialized
Definition: dof_map.h:1663
dof_id_type end_old_dof(const processor_id_type proc) const
Definition: dof_map.h:609
const unsigned int _sys_number
Definition: dof_map.h:1440
bool _implicit_neighbor_dofs
Definition: dof_map.h:1664
DofConstraintValueMap & get_primal_constraint_values()
Definition: dof_map.h:1801
DefaultCoupling & default_coupling()
Definition: dof_map.h:288
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_begin() const
Definition: dof_map.h:312
const unsigned int invalid_uint
Definition: libmesh.h:184
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=libmesh_nullptr)
Definition: dof_map.h:351
void * _extra_sparsity_context
Definition: dof_map.h:1491
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1719
Maps between boundary ids and PeriodicBoundaryBase objects.
dof_id_type end_old_dof() const
Definition: dof_map.h:612
std::set< GhostingFunctor * >::const_iterator coupling_functors_begin() const
Definition: dof_map.h:276
std::vector< dof_id_type > _send_list
Definition: dof_map.h:1474
void constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
The base class for all geometric element types.
Definition: elem.h:90
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
DefaultCoupling & default_algebraic_ghosting()
Definition: dof_map.h:324
AugmentSparsityPattern * _augment_sparsity_pattern
Definition: dof_map.h:1479
const class libmesh_nullptr_t libmesh_nullptr
DofConstraints::const_iterator constraint_rows_begin() const
Definition: dof_map.h:840
std::unique_ptr< DirichletBoundaries > _dirichlet_boundaries
Definition: dof_map.h:1648
Class for specifying Dirichlet boundary conditions as constraints.
std::set< GhostingFunctor * > _algebraic_ghosting_functors
Definition: dof_map.h:1532
std::vector< dof_id_type > _end_old_df
Definition: dof_map.h:1599
processor_id_type dof_owner(const dof_id_type dof) const
Definition: dof_map.h:595
unsigned int block_size() const
Definition: dof_map.h:507
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:1689
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const bool forbid_constraint_overwrite=true)
Definition: dof_map.h:832
dof_id_type n_dofs() const
Definition: dof_map.h:519
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1679
const FEType & variable_group_type(const unsigned int vg) const
Definition: dof_map.h:1729
std::vector< dof_id_type > _first_old_df
Definition: dof_map.h:1594
void attach_extra_sparsity_object(DofMap::AugmentSparsityPattern &asp)
Definition: dof_map.h:336
Base class for Mesh.
Definition: mesh_base.h:69
std::vector< dof_id_type > _first_scalar_df
Definition: dof_map.h:1468
dof_id_type first_old_dof() const
Definition: dof_map.h:557
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map.h:535
AdjointDofConstraintValues _adjoint_constraint_values
Definition: dof_map.h:1618
std::vector< dof_id_type > * _n_nz
Definition: dof_map.h:1565
AugmentSendList * _augment_send_list
Definition: dof_map.h:1496
std::vector< dof_id_type > * _n_oz
Definition: dof_map.h:1571
bool need_full_sparsity_pattern
Definition: dof_map.h:1551
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:168
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:544
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:586
const dof_id_type n_nodes
Definition: tecplot_io.C:67
bool is_constrained_dof(const dof_id_type dof) const
Definition: dof_map.h:1756
bool is_constrained_node(const Node *node) const
Definition: dof_map.h:1739
A variable which is solved for in a System of equations.
Definition: variable.h:49
std::vector< dof_id_type > _first_old_scalar_df
Definition: dof_map.h:1605
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type _n_SCALAR_dofs
Definition: dof_map.h:1582
PeriodicBoundaries * get_periodic_boundaries()
Definition: dof_map.h:1123
NodeConstraints::const_iterator node_constraint_rows_end() const
Definition: dof_map.h:871
DirichletBoundaries * get_dirichlet_boundaries()
Definition: dof_map.h:1166
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
std::unordered_map< const Elem *, const CouplingMatrix * > map_type
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition: dof_map.h:1161
CouplingMatrix * _dof_coupling
Definition: dof_map.h:1256
unsigned int n_variable_groups() const
Definition: dof_map.h:478
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Definition: dof_map.h:1780
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition: dof_map.h:865
void attach_extra_send_list_function(void(*func)(std::vector< dof_id_type > &, void *), void *context=libmesh_nullptr)
Definition: dof_map.h:374
std::vector< DirichletBoundaries * > _adjoint_dirichlet_boundaries
Definition: dof_map.h:1654
unsigned int sys_number() const
Definition: dof_map.h:1671
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=libmesh_nullptr, bool homogeneous=false) const
void * _extra_send_list_context
Definition: dof_map.h:1506
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_end() const
Definition: dof_map.h:318
std::vector< SparseMatrix< Number > * > _matrices
Definition: dof_map.h:1452
dof_id_type end_dof() const
Definition: dof_map.h:589
dof_id_type last_dof() const
Definition: dof_map.h:576
DofConstraints::const_iterator constraint_rows_end() const
Definition: dof_map.h:846
const std::vector< dof_id_type > & get_n_oz() const
Definition: dof_map.h:417
unsigned int n_variables() const
Definition: dof_map.h:486
std::unique_ptr< PeriodicBoundaries > _periodic_boundaries
Definition: dof_map.h:1634
void unstash_dof_constraints()
Definition: dof_map.h:855
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void constrain_element_matrix(DenseMatrix< Number > &matrix, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
void stash_dof_constraints()
Definition: dof_map.h:849
dof_id_type n_old_dofs() const
Definition: dof_map.h:1209
std::unique_ptr< DefaultCoupling > _default_coupling
Definition: dof_map.h:1514
DofConstraintValueMap _primal_constraint_values
Definition: dof_map.h:1616
std::vector< Variable > _variables
Definition: dof_map.h:1430
Order variable_order(const unsigned int c) const
Definition: dof_map.h:1699
DofConstraints _stashed_dof_constraints
Definition: dof_map.h:1614
dof_id_type n_local_dofs() const
Definition: dof_map.h:529
std::map< dof_id_type, Real, std::less< dof_id_type >, Threads::scalable_allocator< std::pair< const dof_id_type, Real > > > DofConstraintRow
Definition: dof_map.h:89
dof_id_type _n_old_dfs
Definition: dof_map.h:1589
std::set< GhostingFunctor * > _coupling_functors
Definition: dof_map.h:1545
std::vector< dof_id_type > _end_df
Definition: dof_map.h:1462
dof_id_type n_SCALAR_dofs() const
Definition: dof_map.h:524
std::vector< dof_id_type > _first_df
Definition: dof_map.h:1457
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Definition: dof_map.h:1766
Base class for all PeriodicBoundary implementations.
std::map< const Node *, Real, std::less< const Node * >, Threads::scalable_allocator< std::pair< const Node *const, Real > > > NodeConstraintRow
Definition: dof_map.h:137
MeshBase & _mesh
Definition: dof_map.h:1445
std::unique_ptr< DefaultCoupling > _default_evaluating
Definition: dof_map.h:1522
std::set< GhostingFunctor * >::const_iterator coupling_functors_end() const
Definition: dof_map.h:282
void attach_extra_send_list_object(DofMap::AugmentSendList &asl)
Definition: dof_map.h:365
bool has_blocked_representation() const
Definition: dof_map.h:494
Order variable_group_order(const unsigned int vg) const
Definition: dof_map.h:1709
void constrain_element_dyad_matrix(DenseVector< Number > &v, DenseVector< Number > &w, std::vector< dof_id_type > &row_dofs, bool asymmetric_constraint_rows=true) const
const std::vector< dof_id_type > & get_n_nz() const
Definition: dof_map.h:404
OStreamProxy out(std::cout)
dof_id_type first_old_dof(const processor_id_type proc) const
Definition: dof_map.h:554
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:395
processor_id_type processor_id()
Definition: libmesh_base.h:96
dof_id_type n_constrained_nodes() const
Definition: dof_map.h:748
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
dof_id_type last_dof(const processor_id_type proc) const
Definition: dof_map.h:569
dof_id_type first_dof() const
Definition: dof_map.h:547
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
uint8_t dof_id_type
Definition: id_types.h:64
dof_id_type _n_dfs
Definition: dof_map.h:1576
NodeConstraints _node_constraints
Definition: dof_map.h:1625
Defines the coupling between variables of a System.