dof_map.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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"
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 
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 template <typename T> class DenseVectorBase;
63 template <typename T> class DenseVector;
64 template <typename T> class DenseMatrix;
65 template <typename T> class SparseMatrix;
66 template <typename T> class NumericVector;
67 
68 
69 
70 // ------------------------------------------------------------
71 // Do we need constraints for anything?
72 
73 #if defined(LIBMESH_ENABLE_AMR) || \
74  defined(LIBMESH_ENABLE_PERIODIC) || \
75  defined(LIBMESH_ENABLE_DIRICHLET)
76 # define LIBMESH_ENABLE_CONSTRAINTS 1
77 #endif
78 
79 // ------------------------------------------------------------
80 // AMR constraint matrix types
81 
82 #ifdef LIBMESH_ENABLE_CONSTRAINTS
83 
86 typedef std::map<dof_id_type, Real,
87  std::less<dof_id_type>,
89 
96 class DofConstraints : public std::map<dof_id_type,
97  DofConstraintRow,
98  std::less<dof_id_type>,
99  Threads::scalable_allocator<std::pair<const dof_id_type, DofConstraintRow> > >
100 {
101 };
102 
109  public std::map<dof_id_type, Number,
110  std::less<dof_id_type>,
111  Threads::scalable_allocator<std::pair<const dof_id_type, Number> > >
112 {
113 };
114 
120  public std::map<unsigned int, DofConstraintValueMap,
121  std::less<unsigned int>,
122  Threads::scalable_allocator
123  <std::pair<const unsigned int, DofConstraintValueMap> > >
124 {
125 };
126 
127 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
128 
134 typedef std::map<const Node *, Real,
135  std::less<const Node *>,
137 
144 class NodeConstraints : public std::map<const Node *,
145  std::pair<NodeConstraintRow,Point>,
146  std::less<const Node *>,
147  Threads::scalable_allocator<std::pair<const Node * const, std::pair<NodeConstraintRow,Point> > > >
148 {
149 };
150 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
151 
152 #endif // LIBMESH_ENABLE_CONSTRAINTS
153 
154 
155 
167 class DofMap : public ReferenceCountedObject<DofMap>,
168  public ParallelObject
169 {
170 public:
171 
177  explicit
178  DofMap(const unsigned int sys_number,
179  MeshBase & mesh);
180 
184  ~DofMap();
185 
191  {
192  public:
194 
198  virtual void augment_sparsity_pattern (SparsityPattern::Graph & sparsity,
199  std::vector<dof_id_type> & n_nz,
200  std::vector<dof_id_type> & n_oz) = 0;
201  };
202 
208  {
209  public:
210  virtual ~AugmentSendList () {}
211 
215  virtual void augment_send_list (std::vector<dof_id_type> & send_list) = 0;
216  };
217 
223  void attach_matrix (SparseMatrix<Number> & matrix);
224 
229  bool is_attached (SparseMatrix<Number> & matrix);
230 
236  void distribute_dofs (MeshBase &);
237 
243  void compute_sparsity (const MeshBase &);
244 
248  void clear_sparsity();
249 
264  void add_coupling_functor(GhostingFunctor & coupling_functor);
265 
270  void remove_coupling_functor(GhostingFunctor & coupling_functor);
271 
275  std::set<GhostingFunctor *>::const_iterator coupling_functors_begin() const
276  { return _coupling_functors.begin(); }
277 
281  std::set<GhostingFunctor *>::const_iterator coupling_functors_end() const
282  { return _coupling_functors.end(); }
283 
287  DefaultCoupling & default_coupling() { return *_default_coupling; }
288 
300  void add_algebraic_ghosting_functor(GhostingFunctor & ghosting_functor);
301 
306  void remove_algebraic_ghosting_functor(GhostingFunctor & ghosting_functor);
307 
311  std::set<GhostingFunctor *>::const_iterator algebraic_ghosting_functors_begin() const
312  { return _algebraic_ghosting_functors.begin(); }
313 
317  std::set<GhostingFunctor *>::const_iterator algebraic_ghosting_functors_end() const
318  { return _algebraic_ghosting_functors.end(); }
319 
323  DefaultCoupling & default_algebraic_ghosting() { return *_default_evaluating; }
324 
336  {
337  _augment_sparsity_pattern = &asp;
338  }
339 
351  std::vector<dof_id_type> & n_nz,
352  std::vector<dof_id_type> & n_oz,
353  void *),
354  void * context = libmesh_nullptr)
355  { _extra_sparsity_function = func; _extra_sparsity_context = context; }
356 
365  {
366  _augment_send_list = &asl;
367  }
368 
373  void attach_extra_send_list_function(void (*func)(std::vector<dof_id_type> &, void *),
374  void * context = libmesh_nullptr)
375  { _extra_send_list_function = func; _extra_send_list_context = context; }
376 
383  void prepare_send_list ();
384 
394  const std::vector<dof_id_type> & get_send_list() const { return _send_list; }
395 
403  const std::vector<dof_id_type> & get_n_nz() const
404  {
405  libmesh_assert(_n_nz);
406  return *_n_nz;
407  }
408 
416  const std::vector<dof_id_type> & get_n_oz() const
417  {
418  libmesh_assert(_n_oz);
419  return *_n_oz;
420  }
421 
422  // /**
423  // * Add an unknown of order \p order and finite element type
424  // * \p type to the system of equations.
425  // */
426  // void add_variable (const Variable & var);
427 
432  void add_variable_group (const VariableGroup & var_group);
433 
437  const VariableGroup & variable_group (const unsigned int c) const;
438 
442  const Variable & variable (const unsigned int c) const;
443 
447  Order variable_order (const unsigned int c) const;
448 
452  Order variable_group_order (const unsigned int vg) const;
453 
457  const FEType & variable_type (const unsigned int c) const;
458 
462  const FEType & variable_group_type (const unsigned int vg) const;
463 
469  unsigned int n_variable_groups() const
470  { return cast_int<unsigned int>(_variable_groups.size()); }
471 
477  unsigned int n_variables() const
478  { return cast_int<unsigned int>(_variables.size()); }
479 
486  {
487 #ifdef LIBMESH_ENABLE_BLOCKED_STORAGE
488  return ((this->n_variable_groups() == 1) && (this->n_variables() > 1));
489 #else
490  return false;
491 #endif
492  }
493 
498  unsigned int block_size() const
499  {
500 #ifdef LIBMESH_ENABLE_BLOCKED_STORAGE
501  return (this->has_blocked_representation() ? this->n_variables() : 1);
502 #else
503  return 1;
504 #endif
505  }
506 
510  dof_id_type n_dofs() const { return _n_dfs; }
511 
515  dof_id_type n_SCALAR_dofs() const { return _n_SCALAR_dofs; }
516 
520  dof_id_type n_local_dofs () const
521  { return this->n_dofs_on_processor (this->processor_id()); }
522 
526  dof_id_type n_dofs_on_processor(const processor_id_type proc) const
527  {
528  libmesh_assert_less (proc, _first_df.size());
529  return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
530  }
531 
535  dof_id_type first_dof(const processor_id_type proc) const
536  { libmesh_assert_less (proc, _first_df.size()); return _first_df[proc]; }
537 
538  dof_id_type first_dof() const
539  { return this->first_dof(this->processor_id()); }
540 
541 #ifdef LIBMESH_ENABLE_AMR
542 
545  dof_id_type first_old_dof(const processor_id_type proc) const
546  { libmesh_assert_less (proc, _first_old_df.size()); return _first_old_df[proc]; }
547 
548  dof_id_type first_old_dof() const
549  { return this->first_old_dof(this->processor_id()); }
550 
551 #endif //LIBMESH_ENABLE_AMR
552 
559  dof_id_type last_dof(const processor_id_type proc) const
560  {
561  libmesh_deprecated();
562  libmesh_assert_less (proc, _end_df.size());
563  return cast_int<dof_id_type>(_end_df[proc] - 1);
564  }
565 
566  dof_id_type last_dof() const
567  { return this->last_dof(this->processor_id()); }
568 
575  dof_id_type end_dof(const processor_id_type proc) const
576  { libmesh_assert_less (proc, _end_df.size()); return _end_df[proc]; }
577 
578  dof_id_type end_dof() const
579  { return this->end_dof(this->processor_id()); }
580 
581 #ifdef LIBMESH_ENABLE_AMR
582 
588  dof_id_type end_old_dof(const processor_id_type proc) const
589  { libmesh_assert_less (proc, _end_old_df.size()); return _end_old_df[proc]; }
590 
591  dof_id_type end_old_dof() const
592  { return this->end_old_dof(this->processor_id()); }
593 
594 #endif //LIBMESH_ENABLE_AMR
595 
600  void dof_indices (const Elem * const elem,
601  std::vector<dof_id_type> & di) const;
602 
608  void dof_indices (const Elem * const elem,
609  std::vector<dof_id_type> & di,
610  const unsigned int vn,
611  int p_level = -12345) const;
612 
617  void dof_indices (const Node * const node,
618  std::vector<dof_id_type> & di) const;
619 
624  void dof_indices (const Node * const node,
625  std::vector<dof_id_type> & di,
626  const unsigned int vn) const;
627 
636  void SCALAR_dof_indices (std::vector<dof_id_type> & di,
637  const unsigned int vn,
638  const bool old_dofs=false) const;
639 
647  bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
648 
654  template <typename DofObjectSubclass>
655  bool is_evaluable(const DofObjectSubclass & obj,
656  unsigned int var_num = libMesh::invalid_uint) const;
657 
665  void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
666 
673  bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
674 
685  void extract_local_vector (const NumericVector<Number> & Ug,
686  const std::vector<dof_id_type> & dof_indices,
687  DenseVectorBase<Number> & Ue) const;
688 
693  void local_variable_indices(std::vector<dof_id_type> & idx,
694  const MeshBase & mesh,
695  unsigned int var_num) const;
696 
697 #ifdef LIBMESH_ENABLE_CONSTRAINTS
698 
699  //--------------------------------------------------------------------
700  // Constraint-specific methods
705  dof_id_type n_constrained_dofs() const;
706 
711  dof_id_type n_local_constrained_dofs() const;
712 
713 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
714 
718  dof_id_type n_constrained_nodes() const
719  { return cast_int<dof_id_type>(_node_constraints.size()); }
720 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
721 
727  void create_dof_constraints (const MeshBase &, Real time=0);
728 
732  void allgather_recursive_constraints (MeshBase &);
733 
737  void scatter_constraints (MeshBase &);
738 
752  void gather_constraints (MeshBase & mesh,
753  std::set<dof_id_type> & unexpanded_dofs,
754  bool look_for_constrainees);
755 
763  void process_constraints (MeshBase &);
764 
769  void add_constraint_row (const dof_id_type dof_number,
770  const DofConstraintRow & constraint_row,
771  const Number constraint_rhs,
772  const bool forbid_constraint_overwrite);
773 
784  void add_adjoint_constraint_row (const unsigned int qoi_index,
785  const dof_id_type dof_number,
786  const DofConstraintRow & constraint_row,
787  const Number constraint_rhs,
788  const bool forbid_constraint_overwrite);
789 
795  void add_constraint_row (const dof_id_type dof_number,
796  const DofConstraintRow & constraint_row,
797  const bool forbid_constraint_overwrite = true)
798  { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
799 
803  DofConstraints::const_iterator constraint_rows_begin() const
804  { return _dof_constraints.begin(); }
805 
809  DofConstraints::const_iterator constraint_rows_end() const
810  { return _dof_constraints.end(); }
811 
813  {
814  libmesh_assert(_stashed_dof_constraints.empty());
815  _dof_constraints.swap(_stashed_dof_constraints);
816  }
817 
819  {
820  libmesh_assert(_dof_constraints.empty());
821  _dof_constraints.swap(_stashed_dof_constraints);
822  }
823 
824 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
825 
828  NodeConstraints::const_iterator node_constraint_rows_begin() const
829  { return _node_constraints.begin(); }
830 
834  NodeConstraints::const_iterator node_constraint_rows_end() const
835  { return _node_constraints.end(); }
836 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
837 
842  bool is_constrained_dof (const dof_id_type dof) const;
843 
848  bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const;
849 
855  Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
856  const dof_id_type dof) const;
857 
862  DofConstraintValueMap & get_primal_constraint_values();
863 
868  bool is_constrained_node (const Node * node) const;
869 
876  void print_dof_constraints(std::ostream & os=libMesh::out,
877  bool print_nonlocal=false) const;
878 
884  std::string get_local_constraints(bool print_nonlocal=false) const;
885 
886 
895  std::pair<Real, Real> max_constraint_error(const System & system,
897 
898 #endif // LIBMESH_ENABLE_CONSTRAINTS
899 
900  //--------------------------------------------------------------------
901  // Constraint-specific methods
902  // Some of these methods are enabled (but inlined away to nothing)
903  // when constraints are disabled at configure-time. This is to
904  // increase API compatibility of user code with different library
905  // builds.
906 
920  void constrain_element_matrix (DenseMatrix<Number> & matrix,
921  std::vector<dof_id_type> & elem_dofs,
922  bool asymmetric_constraint_rows = true) const;
923 
930  void constrain_element_matrix (DenseMatrix<Number> & matrix,
931  std::vector<dof_id_type> & row_dofs,
932  std::vector<dof_id_type> & col_dofs,
933  bool asymmetric_constraint_rows = true) const;
934 
938  void constrain_element_vector (DenseVector<Number> & rhs,
939  std::vector<dof_id_type> & dofs,
940  bool asymmetric_constraint_rows = true) const;
941 
950  void constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
951  DenseVector<Number> & rhs,
952  std::vector<dof_id_type> & elem_dofs,
953  bool asymmetric_constraint_rows = true) const;
954 
978  void heterogenously_constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
979  DenseVector<Number> & rhs,
980  std::vector<dof_id_type> & elem_dofs,
981  bool asymmetric_constraint_rows = true,
982  int qoi_index = -1) const;
983 
1005  void heterogenously_constrain_element_vector (const DenseMatrix<Number> & matrix,
1006  DenseVector<Number> & rhs,
1007  std::vector<dof_id_type> & elem_dofs,
1008  bool asymmetric_constraint_rows = true,
1009  int qoi_index = -1) const;
1010 
1011 
1012 
1021  void constrain_element_dyad_matrix (DenseVector<Number> & v,
1022  DenseVector<Number> & w,
1023  std::vector<dof_id_type> & row_dofs,
1024  bool asymmetric_constraint_rows = true) const;
1025 
1032  void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1033 
1047  void enforce_constraints_exactly (const System & system,
1049  bool homogeneous = false) const;
1050 
1057  void enforce_adjoint_constraints_exactly (NumericVector<Number> & v,
1058  unsigned int q) const;
1059 
1060 
1061 
1062 #ifdef LIBMESH_ENABLE_PERIODIC
1063 
1064  //--------------------------------------------------------------------
1065  // PeriodicBoundary-specific methods
1066 
1070  void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1071 
1078  void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1079 
1084  bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1085 
1087  {
1088  return _periodic_boundaries.get();
1089  }
1090 
1091 #endif // LIBMESH_ENABLE_PERIODIC
1092 
1093 
1094 #ifdef LIBMESH_ENABLE_DIRICHLET
1095 
1096  //--------------------------------------------------------------------
1097  // DirichletBoundary-specific methods
1098 
1102  void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1103 
1109  void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1110  unsigned int q);
1111 
1115  void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1116 
1121  void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1122  unsigned int q);
1123 
1125  {
1126  return _dirichlet_boundaries.get();
1127  }
1128 
1130  {
1131  return _dirichlet_boundaries.get();
1132  }
1133 
1134  bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1135 
1136  const DirichletBoundaries *
1137  get_adjoint_dirichlet_boundaries(unsigned int q) const;
1138 
1140  get_adjoint_dirichlet_boundaries(unsigned int q);
1141 
1142 #endif // LIBMESH_ENABLE_DIRICHLET
1143 
1144 
1145 #ifdef LIBMESH_ENABLE_AMR
1146 
1147  //--------------------------------------------------------------------
1148  // AMR-specific methods
1149 
1158  // void augment_send_list_for_projection(const MeshBase &);
1159 
1166  void old_dof_indices (const Elem * const elem,
1167  std::vector<dof_id_type> & di,
1168  const unsigned int vn = libMesh::invalid_uint) const;
1172  dof_id_type n_old_dofs() const { return _n_old_dfs; }
1173 
1179  void constrain_p_dofs (unsigned int var,
1180  const Elem * elem,
1181  unsigned int s,
1182  unsigned int p);
1183 
1184 #endif // LIBMESH_ENABLE_AMR
1185 
1189  void reinit (MeshBase & mesh);
1190 
1194  void clear ();
1195 
1199  void print_info(std::ostream & os=libMesh::out) const;
1200 
1204  std::string get_info() const;
1205 
1220 
1224  unsigned int sys_number() const;
1225 
1226 private:
1227 
1235  void _dof_indices (const Elem * const elem,
1236  int p_level,
1237  std::vector<dof_id_type> & di,
1238  const unsigned int v,
1239  const Node * const * nodes,
1240  unsigned int n_nodes
1241 #ifdef DEBUG
1242  ,
1243  std::size_t & tot_size
1244 #endif
1245  ) const;
1246 
1250  UniquePtr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh) const;
1251 
1255  void invalidate_dofs(MeshBase & mesh) const;
1256 
1260  DofObject * node_ptr(MeshBase & mesh, dof_id_type i) const;
1261 
1265  DofObject * elem_ptr(MeshBase & mesh, dof_id_type i) const;
1266 
1270  typedef DofObject * (DofMap::*dofobject_accessor)
1271  (MeshBase & mesh, dof_id_type i) const;
1272 
1276  template<typename iterator_type>
1277  void set_nonlocal_dof_objects(iterator_type objects_begin,
1278  iterator_type objects_end,
1279  MeshBase & mesh,
1280  dofobject_accessor objects);
1281 
1290  void distribute_local_dofs_var_major (dof_id_type & next_free_dof,
1291  MeshBase & mesh);
1292 
1304  void distribute_local_dofs_node_major (dof_id_type & next_free_dof,
1305  MeshBase & mesh);
1306 
1307  /*
1308  * A utility method for obtaining a set of elements to ghost along
1309  * with merged coupling matrices.
1310  */
1311  static void
1312  merge_ghost_functor_outputs (GhostingFunctor::map_type & elements_to_ghost,
1313  std::set<CouplingMatrix *> & temporary_coupling_matrices,
1314  const std::set<GhostingFunctor *>::iterator & gf_begin,
1315  const std::set<GhostingFunctor *>::iterator & gf_end,
1316  const MeshBase::const_element_iterator & elems_begin,
1317  const MeshBase::const_element_iterator & elems_end,
1318  processor_id_type p);
1319 
1324  void add_neighbors_to_send_list(MeshBase & mesh);
1325 
1326 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1327 
1338  void build_constraint_matrix (DenseMatrix<Number> & C,
1339  std::vector<dof_id_type> & elem_dofs,
1340  const bool called_recursively=false) const;
1341 
1357  void build_constraint_matrix_and_vector (DenseMatrix<Number> & C,
1358  DenseVector<Number> & H,
1359  std::vector<dof_id_type> & elem_dofs,
1360  int qoi_index = -1,
1361  const bool called_recursively=false) const;
1362 
1367  void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
1368 
1373  void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
1374 
1380  void add_constraints_to_send_list();
1381 
1382 #endif // LIBMESH_ENABLE_CONSTRAINTS
1383 
1387  std::vector<Variable> _variables;
1388 
1392  std::vector<VariableGroup> _variable_groups;
1393 
1397  const unsigned int _sys_number;
1398 
1403 
1409  std::vector<SparseMatrix<Number> * > _matrices;
1410 
1414  std::vector<dof_id_type> _first_df;
1415 
1419  std::vector<dof_id_type> _end_df;
1420 
1425  std::vector<dof_id_type> _first_scalar_df;
1426 
1431  std::vector<dof_id_type> _send_list;
1432 
1437 
1441  void (*_extra_sparsity_function)(SparsityPattern::Graph &,
1442  std::vector<dof_id_type> & n_nz,
1443  std::vector<dof_id_type> & n_oz,
1444  void *);
1449 
1454 
1458  void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
1459 
1464 
1472 
1480 
1489  std::set<GhostingFunctor *> _algebraic_ghosting_functors;
1490 
1502  std::set<GhostingFunctor *> _coupling_functors;
1503 
1509 
1515 
1522  std::vector<dof_id_type> * _n_nz;
1523 
1528  std::vector<dof_id_type> * _n_oz;
1529 
1533  dof_id_type _n_dfs;
1534 
1539  dof_id_type _n_SCALAR_dofs;
1540 
1541 #ifdef LIBMESH_ENABLE_AMR
1542 
1546  dof_id_type _n_old_dfs;
1547 
1551  std::vector<dof_id_type> _first_old_df;
1552 
1556  std::vector<dof_id_type> _end_old_df;
1557 
1562  std::vector<dof_id_type> _first_old_scalar_df;
1563 
1564 #endif
1565 
1566 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1567 
1572 
1574 
1576 #endif
1577 
1578 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1579 
1583 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1584 
1585 
1586 #ifdef LIBMESH_ENABLE_PERIODIC
1587 
1592 #endif
1593 
1594 #ifdef LIBMESH_ENABLE_DIRICHLET
1595 
1599  void check_dirichlet_bcid_consistency (const MeshBase & mesh,
1600  const DirichletBoundary & boundary) const;
1606 
1611  std::vector<DirichletBoundaries *> _adjoint_dirichlet_boundaries;
1612 #endif
1613 
1615 
1622 };
1623 
1624 
1625 // ------------------------------------------------------------
1626 // Dof Map inline member functions
1627 inline
1628 unsigned int DofMap::sys_number() const
1629 {
1630  return _sys_number;
1631 }
1632 
1633 
1634 
1635 inline
1636 const VariableGroup & DofMap::variable_group (const unsigned int g) const
1637 {
1638  libmesh_assert_less (g, _variable_groups.size());
1639 
1640  return _variable_groups[g];
1641 }
1642 
1643 
1644 
1645 inline
1646 const Variable & DofMap::variable (const unsigned int c) const
1647 {
1648  libmesh_assert_less (c, _variables.size());
1649 
1650  return _variables[c];
1651 }
1652 
1653 
1654 
1655 inline
1656 Order DofMap::variable_order (const unsigned int c) const
1657 {
1658  libmesh_assert_less (c, _variables.size());
1659 
1660  return _variables[c].type().order;
1661 }
1662 
1663 
1664 
1665 inline
1666 Order DofMap::variable_group_order (const unsigned int vg) const
1667 {
1668  libmesh_assert_less (vg, _variable_groups.size());
1669 
1670  return _variable_groups[vg].type().order;
1671 }
1672 
1673 
1674 
1675 inline
1676 const FEType & DofMap::variable_type (const unsigned int c) const
1677 {
1678  libmesh_assert_less (c, _variables.size());
1679 
1680  return _variables[c].type();
1681 }
1682 
1683 
1684 
1685 inline
1686 const FEType & DofMap::variable_group_type (const unsigned int vg) const
1687 {
1688  libmesh_assert_less (vg, _variable_groups.size());
1689 
1690  return _variable_groups[vg].type();
1691 }
1692 
1693 
1694 
1695 inline
1697 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1698  node
1699 #endif
1700  ) const
1701 {
1702 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1703  if (_node_constraints.count(node))
1704  return true;
1705 #endif
1706 
1707  return false;
1708 }
1709 
1710 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1711 
1712 inline
1713 bool DofMap::is_constrained_dof (const dof_id_type dof) const
1714 {
1715  if (_dof_constraints.count(dof))
1716  return true;
1717 
1718  return false;
1719 }
1720 
1721 
1722 inline
1723 bool DofMap::has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1724 {
1725  AdjointDofConstraintValues::const_iterator it =
1726  _adjoint_constraint_values.find(qoi_num);
1727  if (it == _adjoint_constraint_values.end())
1728  return false;
1729  if (it->second.empty())
1730  return false;
1731 
1732  return true;
1733 }
1734 
1735 
1736 inline
1738  const dof_id_type dof) const
1739 {
1740  AdjointDofConstraintValues::const_iterator it =
1741  _adjoint_constraint_values.find(qoi_num);
1742  if (it != _adjoint_constraint_values.end())
1743  {
1744  DofConstraintValueMap::const_iterator rhsit =
1745  it->second.find(dof);
1746  if (rhsit == it->second.end())
1747  return 0;
1748  else
1749  return rhsit->second;
1750  }
1751 
1752  return 0;
1753 }
1754 
1755 
1756 
1757 inline
1759 {
1760  return _primal_constraint_values;
1761 }
1762 
1763 
1764 
1765 #else
1766 
1767 //--------------------------------------------------------------------
1768 // Constraint-specific methods get inlined into nothing if
1769 // constraints are disabled, so there's no reason for users not to
1770 // use them.
1771 
1773  std::vector<dof_id_type> &,
1774  bool) const {}
1775 
1777  std::vector<dof_id_type> &,
1778  std::vector<dof_id_type> &,
1779  bool) const {}
1780 
1782  std::vector<dof_id_type> &,
1783  bool) const {}
1784 
1787  std::vector<dof_id_type> &,
1788  bool) const {}
1789 
1792  std::vector<dof_id_type> &,
1793  bool) const {}
1794 
1795 inline void DofMap::enforce_constraints_exactly (const System &,
1797  bool = false) const {}
1798 
1800  unsigned int) const {}
1801 
1802 #endif // LIBMESH_ENABLE_CONSTRAINTS
1803 
1804 } // namespace libMesh
1805 
1806 #endif // LIBMESH_DOF_MAP_H
std::vector< VariableGroup > _variable_groups
Definition: dof_map.h:1392
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:178
bool _implicit_neighbor_dofs_initialized
Definition: dof_map.h:1620
dof_id_type end_old_dof(const processor_id_type proc) const
Definition: dof_map.h:588
const unsigned int _sys_number
Definition: dof_map.h:1397
bool _implicit_neighbor_dofs
Definition: dof_map.h:1621
DofConstraintValueMap & get_primal_constraint_values()
Definition: dof_map.h:1758
UniquePtr< DefaultCoupling > _default_coupling
Definition: dof_map.h:1471
DefaultCoupling & default_coupling()
Definition: dof_map.h:287
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:311
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:350
LIBMESH_BEST_UNORDERED_MAP< const Elem *, const CouplingMatrix * > map_type
void * _extra_sparsity_context
Definition: dof_map.h:1448
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1676
Maps between boundary ids and PeriodicBoundaryBase objects.
dof_id_type end_old_dof() const
Definition: dof_map.h:591
std::set< GhostingFunctor * >::const_iterator coupling_functors_begin() const
Definition: dof_map.h:275
std::vector< dof_id_type > _send_list
Definition: dof_map.h:1431
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:86
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
DefaultCoupling & default_algebraic_ghosting()
Definition: dof_map.h:323
AugmentSparsityPattern * _augment_sparsity_pattern
Definition: dof_map.h:1436
const class libmesh_nullptr_t libmesh_nullptr
DofConstraints::const_iterator constraint_rows_begin() const
Definition: dof_map.h:803
Class for specifying Dirichlet boundary conditions as constraints.
std::set< GhostingFunctor * > _algebraic_ghosting_functors
Definition: dof_map.h:1489
std::vector< dof_id_type > _end_old_df
Definition: dof_map.h:1556
unsigned int block_size() const
Definition: dof_map.h:498
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:1646
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const bool forbid_constraint_overwrite=true)
Definition: dof_map.h:795
UniquePtr< DefaultCoupling > _default_evaluating
Definition: dof_map.h:1479
dof_id_type n_dofs() const
Definition: dof_map.h:510
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1636
const FEType & variable_group_type(const unsigned int vg) const
Definition: dof_map.h:1686
std::vector< dof_id_type > _first_old_df
Definition: dof_map.h:1551
void attach_extra_sparsity_object(DofMap::AugmentSparsityPattern &asp)
Definition: dof_map.h:335
Base class for Mesh.
Definition: mesh_base.h:67
std::vector< dof_id_type > _first_scalar_df
Definition: dof_map.h:1425
dof_id_type first_old_dof() const
Definition: dof_map.h:548
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map.h:526
AdjointDofConstraintValues _adjoint_constraint_values
Definition: dof_map.h:1575
libmesh_assert(j)
std::vector< dof_id_type > * _n_nz
Definition: dof_map.h:1522
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
AugmentSendList * _augment_send_list
Definition: dof_map.h:1453
std::vector< dof_id_type > * _n_oz
Definition: dof_map.h:1528
bool need_full_sparsity_pattern
Definition: dof_map.h:1508
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:167
UniquePtr< SparsityPattern::Build > _sp
Definition: dof_map.h:1514
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:535
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:575
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:1713
bool is_constrained_node(const Node *node) const
Definition: dof_map.h:1696
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:1562
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type _n_SCALAR_dofs
Definition: dof_map.h:1539
PeriodicBoundaries * get_periodic_boundaries()
Definition: dof_map.h:1086
NodeConstraints::const_iterator node_constraint_rows_end() const
Definition: dof_map.h:834
DirichletBoundaries * get_dirichlet_boundaries()
Definition: dof_map.h:1129
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
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition: dof_map.h:1124
CouplingMatrix * _dof_coupling
Definition: dof_map.h:1219
unsigned int n_variable_groups() const
Definition: dof_map.h:469
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Definition: dof_map.h:1737
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition: dof_map.h:828
void attach_extra_send_list_function(void(*func)(std::vector< dof_id_type > &, void *), void *context=libmesh_nullptr)
Definition: dof_map.h:373
std::vector< DirichletBoundaries * > _adjoint_dirichlet_boundaries
Definition: dof_map.h:1611
unsigned int sys_number() const
Definition: dof_map.h:1628
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:1463
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_end() const
Definition: dof_map.h:317
std::vector< SparseMatrix< Number > * > _matrices
Definition: dof_map.h:1409
dof_id_type end_dof() const
Definition: dof_map.h:578
dof_id_type last_dof() const
Definition: dof_map.h:566
DofConstraints::const_iterator constraint_rows_end() const
Definition: dof_map.h:809
const std::vector< dof_id_type > & get_n_oz() const
Definition: dof_map.h:416
unsigned int n_variables() const
Definition: dof_map.h:477
void unstash_dof_constraints()
Definition: dof_map.h:818
UniquePtr< DirichletBoundaries > _dirichlet_boundaries
Definition: dof_map.h:1605
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:812
dof_id_type n_old_dofs() const
Definition: dof_map.h:1172
DofConstraintValueMap _primal_constraint_values
Definition: dof_map.h:1573
std::vector< Variable > _variables
Definition: dof_map.h:1387
Order variable_order(const unsigned int c) const
Definition: dof_map.h:1656
DofConstraints _stashed_dof_constraints
Definition: dof_map.h:1571
dof_id_type n_local_dofs() const
Definition: dof_map.h:520
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:88
dof_id_type _n_old_dfs
Definition: dof_map.h:1546
std::set< GhostingFunctor * > _coupling_functors
Definition: dof_map.h:1502
UniquePtr< PeriodicBoundaries > _periodic_boundaries
Definition: dof_map.h:1591
std::vector< dof_id_type > _end_df
Definition: dof_map.h:1419
dof_id_type n_SCALAR_dofs() const
Definition: dof_map.h:515
std::vector< dof_id_type > _first_df
Definition: dof_map.h:1414
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Definition: dof_map.h:1723
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:136
MeshBase & _mesh
Definition: dof_map.h:1402
std::set< GhostingFunctor * >::const_iterator coupling_functors_end() const
Definition: dof_map.h:281
void attach_extra_send_list_object(DofMap::AugmentSendList &asl)
Definition: dof_map.h:364
bool has_blocked_representation() const
Definition: dof_map.h:485
Order variable_group_order(const unsigned int vg) const
Definition: dof_map.h:1666
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:403
OStreamProxy out(std::cout)
dof_id_type first_old_dof(const processor_id_type proc) const
Definition: dof_map.h:545
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:394
processor_id_type processor_id()
Definition: libmesh_base.h:96
dof_id_type n_constrained_nodes() const
Definition: dof_map.h:718
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:559
dof_id_type first_dof() const
Definition: dof_map.h:538
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:1533
NodeConstraints _node_constraints
Definition: dof_map.h:1582
Defines the coupling between variables of a System.