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 
392  const std::vector<dof_id_type> & get_send_list() const { return _send_list; }
393 
400  const std::vector<dof_id_type> & get_n_nz() const
401  {
402  libmesh_assert(_n_nz);
403  return *_n_nz;
404  }
405 
412  const std::vector<dof_id_type> & get_n_oz() const
413  {
414  libmesh_assert(_n_oz);
415  return *_n_oz;
416  }
417 
418  // /**
419  // * Add an unknown of order \p order and finite element type
420  // * \p type to the system of equations.
421  // */
422  // void add_variable (const Variable & var);
423 
428  void add_variable_group (const VariableGroup & var_group);
429 
433  const VariableGroup & variable_group (const unsigned int c) const;
434 
438  const Variable & variable (const unsigned int c) const;
439 
443  Order variable_order (const unsigned int c) const;
444 
448  Order variable_group_order (const unsigned int vg) const;
449 
453  const FEType & variable_type (const unsigned int c) const;
454 
458  const FEType & variable_group_type (const unsigned int vg) const;
459 
465  unsigned int n_variable_groups() const
466  { return cast_int<unsigned int>(_variable_groups.size()); }
467 
473  unsigned int n_variables() const
474  { return cast_int<unsigned int>(_variables.size()); }
475 
482  {
483 #ifdef LIBMESH_ENABLE_BLOCKED_STORAGE
484  return ((this->n_variable_groups() == 1) && (this->n_variables() > 1));
485 #else
486  return false;
487 #endif
488  }
489 
494  unsigned int block_size() const
495  {
496 #ifdef LIBMESH_ENABLE_BLOCKED_STORAGE
497  return (this->has_blocked_representation() ? this->n_variables() : 1);
498 #else
499  return 1;
500 #endif
501  }
502 
506  dof_id_type n_dofs() const { return _n_dfs; }
507 
511  dof_id_type n_SCALAR_dofs() const { return _n_SCALAR_dofs; }
512 
516  dof_id_type n_local_dofs () const
517  { return this->n_dofs_on_processor (this->processor_id()); }
518 
522  dof_id_type n_dofs_on_processor(const processor_id_type proc) const
523  {
524  libmesh_assert_less (proc, _first_df.size());
525  return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
526  }
527 
531  dof_id_type first_dof(const processor_id_type proc) const
532  { libmesh_assert_less (proc, _first_df.size()); return _first_df[proc]; }
533 
534  dof_id_type first_dof() const
535  { return this->first_dof(this->processor_id()); }
536 
537 #ifdef LIBMESH_ENABLE_AMR
538 
541  dof_id_type first_old_dof(const processor_id_type proc) const
542  { libmesh_assert_less (proc, _first_old_df.size()); return _first_old_df[proc]; }
543 
544  dof_id_type first_old_dof() const
545  { return this->first_old_dof(this->processor_id()); }
546 
547 #endif //LIBMESH_ENABLE_AMR
548 
554  dof_id_type last_dof(const processor_id_type proc) const
555  {
556  libmesh_deprecated();
557  libmesh_assert_less (proc, _end_df.size());
558  return cast_int<dof_id_type>(_end_df[proc] - 1);
559  }
560 
561  dof_id_type last_dof() const
562  { return this->last_dof(this->processor_id()); }
563 
569  dof_id_type end_dof(const processor_id_type proc) const
570  { libmesh_assert_less (proc, _end_df.size()); return _end_df[proc]; }
571 
572  dof_id_type end_dof() const
573  { return this->end_dof(this->processor_id()); }
574 
575 #ifdef LIBMESH_ENABLE_AMR
576 
581  dof_id_type end_old_dof(const processor_id_type proc) const
582  { libmesh_assert_less (proc, _end_old_df.size()); return _end_old_df[proc]; }
583 
584  dof_id_type end_old_dof() const
585  { return this->end_old_dof(this->processor_id()); }
586 
587 #endif //LIBMESH_ENABLE_AMR
588 
593  void dof_indices (const Elem * const elem,
594  std::vector<dof_id_type> & di) const;
595 
601  void dof_indices (const Elem * const elem,
602  std::vector<dof_id_type> & di,
603  const unsigned int vn,
604  int p_level = -12345) const;
605 
610  void dof_indices (const Node * const node,
611  std::vector<dof_id_type> & di) const;
612 
617  void dof_indices (const Node * const node,
618  std::vector<dof_id_type> & di,
619  const unsigned int vn) const;
620 
627  void SCALAR_dof_indices (std::vector<dof_id_type> & di,
628  const unsigned int vn,
629  const bool old_dofs=false) const;
630 
637  bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
638 
644  template <typename DofObjectSubclass>
645  bool is_evaluable(const DofObjectSubclass & obj,
646  unsigned int var_num = libMesh::invalid_uint) const;
647 
655  void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
656 
663  bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
664 
675  void extract_local_vector (const NumericVector<Number> & Ug,
676  const std::vector<dof_id_type> & dof_indices,
677  DenseVectorBase<Number> & Ue) const;
678 
683  void local_variable_indices(std::vector<dof_id_type> & idx,
684  const MeshBase & mesh,
685  unsigned int var_num) const;
686 
687 #ifdef LIBMESH_ENABLE_CONSTRAINTS
688 
689  //--------------------------------------------------------------------
690  // Constraint-specific methods
695  dof_id_type n_constrained_dofs() const;
696 
701  dof_id_type n_local_constrained_dofs() const;
702 
703 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
704 
708  dof_id_type n_constrained_nodes() const
709  { return cast_int<dof_id_type>(_node_constraints.size()); }
710 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
711 
717  void create_dof_constraints (const MeshBase &, Real time=0);
718 
722  void allgather_recursive_constraints (MeshBase &);
723 
727  void scatter_constraints (MeshBase &);
728 
742  void gather_constraints (MeshBase & mesh,
743  std::set<dof_id_type> & unexpanded_dofs,
744  bool look_for_constrainees);
745 
753  void process_constraints (MeshBase &);
754 
759  void add_constraint_row (const dof_id_type dof_number,
760  const DofConstraintRow & constraint_row,
761  const Number constraint_rhs,
762  const bool forbid_constraint_overwrite);
763 
774  void add_adjoint_constraint_row (const unsigned int qoi_index,
775  const dof_id_type dof_number,
776  const DofConstraintRow & constraint_row,
777  const Number constraint_rhs,
778  const bool forbid_constraint_overwrite);
779 
785  void add_constraint_row (const dof_id_type dof_number,
786  const DofConstraintRow & constraint_row,
787  const bool forbid_constraint_overwrite = true)
788  { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
789 
793  DofConstraints::const_iterator constraint_rows_begin() const
794  { return _dof_constraints.begin(); }
795 
799  DofConstraints::const_iterator constraint_rows_end() const
800  { return _dof_constraints.end(); }
801 
803  {
804  libmesh_assert(_stashed_dof_constraints.empty());
805  _dof_constraints.swap(_stashed_dof_constraints);
806  }
807 
809  {
810  libmesh_assert(_dof_constraints.empty());
811  _dof_constraints.swap(_stashed_dof_constraints);
812  }
813 
814 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
815 
818  NodeConstraints::const_iterator node_constraint_rows_begin() const
819  { return _node_constraints.begin(); }
820 
824  NodeConstraints::const_iterator node_constraint_rows_end() const
825  { return _node_constraints.end(); }
826 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
827 
832  bool is_constrained_dof (const dof_id_type dof) const;
833 
838  bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const;
839 
845  Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
846  const dof_id_type dof) const;
847 
852  DofConstraintValueMap & get_primal_constraint_values();
853 
858  bool is_constrained_node (const Node * node) const;
859 
866  void print_dof_constraints(std::ostream & os=libMesh::out,
867  bool print_nonlocal=false) const;
868 
874  std::string get_local_constraints(bool print_nonlocal=false) const;
875 
876 
885  std::pair<Real, Real> max_constraint_error(const System & system,
887 
888 #endif // LIBMESH_ENABLE_CONSTRAINTS
889 
890  //--------------------------------------------------------------------
891  // Constraint-specific methods
892  // Some of these methods are enabled (but inlined away to nothing)
893  // when constraints are disabled at configure-time. This is to
894  // increase API compatibility of user code with different library
895  // builds.
896 
910  void constrain_element_matrix (DenseMatrix<Number> & matrix,
911  std::vector<dof_id_type> & elem_dofs,
912  bool asymmetric_constraint_rows = true) const;
913 
920  void constrain_element_matrix (DenseMatrix<Number> & matrix,
921  std::vector<dof_id_type> & row_dofs,
922  std::vector<dof_id_type> & col_dofs,
923  bool asymmetric_constraint_rows = true) const;
924 
928  void constrain_element_vector (DenseVector<Number> & rhs,
929  std::vector<dof_id_type> & dofs,
930  bool asymmetric_constraint_rows = true) const;
931 
940  void constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
941  DenseVector<Number> & rhs,
942  std::vector<dof_id_type> & elem_dofs,
943  bool asymmetric_constraint_rows = true) const;
944 
968  void heterogenously_constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
969  DenseVector<Number> & rhs,
970  std::vector<dof_id_type> & elem_dofs,
971  bool asymmetric_constraint_rows = true,
972  int qoi_index = -1) const;
973 
995  void heterogenously_constrain_element_vector (const DenseMatrix<Number> & matrix,
996  DenseVector<Number> & rhs,
997  std::vector<dof_id_type> & elem_dofs,
998  bool asymmetric_constraint_rows = true,
999  int qoi_index = -1) const;
1000 
1001 
1002 
1011  void constrain_element_dyad_matrix (DenseVector<Number> & v,
1012  DenseVector<Number> & w,
1013  std::vector<dof_id_type> & row_dofs,
1014  bool asymmetric_constraint_rows = true) const;
1015 
1022  void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1023 
1037  void enforce_constraints_exactly (const System & system,
1039  bool homogeneous = false) const;
1040 
1047  void enforce_adjoint_constraints_exactly (NumericVector<Number> & v,
1048  unsigned int q) const;
1049 
1050 
1051 
1052 #ifdef LIBMESH_ENABLE_PERIODIC
1053 
1054  //--------------------------------------------------------------------
1055  // PeriodicBoundary-specific methods
1056 
1060  void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1061 
1068  void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1069 
1074  bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1075 
1077  {
1078  return _periodic_boundaries.get();
1079  }
1080 
1081 #endif // LIBMESH_ENABLE_PERIODIC
1082 
1083 
1084 #ifdef LIBMESH_ENABLE_DIRICHLET
1085 
1086  //--------------------------------------------------------------------
1087  // DirichletBoundary-specific methods
1088 
1092  void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1093 
1099  void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1100  unsigned int q);
1101 
1105  void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1106 
1111  void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1112  unsigned int q);
1113 
1115  {
1116  return _dirichlet_boundaries.get();
1117  }
1118 
1120  {
1121  return _dirichlet_boundaries.get();
1122  }
1123 
1124  bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1125 
1126  const DirichletBoundaries *
1127  get_adjoint_dirichlet_boundaries(unsigned int q) const;
1128 
1130  get_adjoint_dirichlet_boundaries(unsigned int q);
1131 
1132 #endif // LIBMESH_ENABLE_DIRICHLET
1133 
1134 
1135 #ifdef LIBMESH_ENABLE_AMR
1136 
1137  //--------------------------------------------------------------------
1138  // AMR-specific methods
1139 
1148  // void augment_send_list_for_projection(const MeshBase &);
1149 
1156  void old_dof_indices (const Elem * const elem,
1157  std::vector<dof_id_type> & di,
1158  const unsigned int vn = libMesh::invalid_uint) const;
1163  dof_id_type n_old_dofs() const { return _n_old_dfs; }
1164 
1170  void constrain_p_dofs (unsigned int var,
1171  const Elem * elem,
1172  unsigned int s,
1173  unsigned int p);
1174 
1175 #endif // LIBMESH_ENABLE_AMR
1176 
1180  void reinit (MeshBase & mesh);
1181 
1185  void clear ();
1186 
1190  void print_info(std::ostream & os=libMesh::out) const;
1191 
1195  std::string get_info() const;
1196 
1211 
1215  unsigned int sys_number() const;
1216 
1217 private:
1218 
1226  void _dof_indices (const Elem * const elem,
1227  int p_level,
1228  std::vector<dof_id_type> & di,
1229  const unsigned int v,
1230  const Node * const * nodes,
1231  unsigned int n_nodes
1232 #ifdef DEBUG
1233  ,
1234  std::size_t & tot_size
1235 #endif
1236  ) const;
1237 
1241  UniquePtr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh) const;
1242 
1246  void invalidate_dofs(MeshBase & mesh) const;
1247 
1251  DofObject * node_ptr(MeshBase & mesh, dof_id_type i) const;
1252 
1256  DofObject * elem_ptr(MeshBase & mesh, dof_id_type i) const;
1257 
1261  typedef DofObject * (DofMap::*dofobject_accessor)
1262  (MeshBase & mesh, dof_id_type i) const;
1263 
1267  template<typename iterator_type>
1268  void set_nonlocal_dof_objects(iterator_type objects_begin,
1269  iterator_type objects_end,
1270  MeshBase & mesh,
1271  dofobject_accessor objects);
1272 
1281  void distribute_local_dofs_var_major (dof_id_type & next_free_dof,
1282  MeshBase & mesh);
1283 
1296  void distribute_local_dofs_node_major (dof_id_type & next_free_dof,
1297  MeshBase & mesh);
1298 
1299  /*
1300  * A utility method for obtaining a set of elements to ghost along
1301  * with merged coupling matrices.
1302  */
1303  static void merge_ghost_functor_outputs
1304  (GhostingFunctor::map_type & elements_to_ghost,
1305  std::set<CouplingMatrix*> & temporary_coupling_matrices,
1306  const std::set<GhostingFunctor *>::iterator & gf_begin,
1307  const std::set<GhostingFunctor *>::iterator & gf_end,
1308  const MeshBase::const_element_iterator & elems_begin,
1309  const MeshBase::const_element_iterator & elems_end,
1310  processor_id_type p);
1311 
1316  void add_neighbors_to_send_list(MeshBase & mesh);
1317 
1318 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1319 
1330  void build_constraint_matrix (DenseMatrix<Number> & C,
1331  std::vector<dof_id_type> & elem_dofs,
1332  const bool called_recursively=false) const;
1333 
1349  void build_constraint_matrix_and_vector (DenseMatrix<Number> & C,
1350  DenseVector<Number> & H,
1351  std::vector<dof_id_type> & elem_dofs,
1352  int qoi_index = -1,
1353  const bool called_recursively=false) const;
1354 
1359  void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
1360 
1365  void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
1366 
1372  void add_constraints_to_send_list();
1373 
1374 #endif // LIBMESH_ENABLE_CONSTRAINTS
1375 
1379  std::vector<Variable> _variables;
1380 
1384  std::vector<VariableGroup> _variable_groups;
1385 
1389  const unsigned int _sys_number;
1390 
1395 
1401  std::vector<SparseMatrix<Number> * > _matrices;
1402 
1406  std::vector<dof_id_type> _first_df;
1407 
1411  std::vector<dof_id_type> _end_df;
1412 
1417  std::vector<dof_id_type> _first_scalar_df;
1418 
1423  std::vector<dof_id_type> _send_list;
1424 
1429 
1433  void (*_extra_sparsity_function)(SparsityPattern::Graph &,
1434  std::vector<dof_id_type> & n_nz,
1435  std::vector<dof_id_type> & n_oz,
1436  void *);
1441 
1446 
1450  void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
1451 
1456 
1464 
1472 
1481  std::set<GhostingFunctor *> _algebraic_ghosting_functors;
1482 
1494  std::set<GhostingFunctor *> _coupling_functors;
1495 
1501 
1507 
1514  std::vector<dof_id_type> * _n_nz;
1515 
1520  std::vector<dof_id_type> * _n_oz;
1521 
1525  dof_id_type _n_dfs;
1526 
1531  dof_id_type _n_SCALAR_dofs;
1532 
1533 #ifdef LIBMESH_ENABLE_AMR
1534 
1538  dof_id_type _n_old_dfs;
1539 
1543  std::vector<dof_id_type> _first_old_df;
1544 
1548  std::vector<dof_id_type> _end_old_df;
1549 
1554  std::vector<dof_id_type> _first_old_scalar_df;
1555 
1556 #endif
1557 
1558 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1559 
1564 
1566 
1568 #endif
1569 
1570 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1571 
1575 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1576 
1577 
1578 #ifdef LIBMESH_ENABLE_PERIODIC
1579 
1584 #endif
1585 
1586 #ifdef LIBMESH_ENABLE_DIRICHLET
1587 
1591  void check_dirichlet_bcid_consistency (const MeshBase & mesh,
1592  const DirichletBoundary & boundary) const;
1598 
1603  std::vector<DirichletBoundaries *> _adjoint_dirichlet_boundaries;
1604 #endif
1605 
1607 
1614 };
1615 
1616 
1617 // ------------------------------------------------------------
1618 // Dof Map inline member functions
1619 inline
1620 unsigned int DofMap::sys_number() const
1621 {
1622  return _sys_number;
1623 }
1624 
1625 
1626 
1627 inline
1628 const VariableGroup & DofMap::variable_group (const unsigned int g) const
1629 {
1630  libmesh_assert_less (g, _variable_groups.size());
1631 
1632  return _variable_groups[g];
1633 }
1634 
1635 
1636 
1637 inline
1638 const Variable & DofMap::variable (const unsigned int c) const
1639 {
1640  libmesh_assert_less (c, _variables.size());
1641 
1642  return _variables[c];
1643 }
1644 
1645 
1646 
1647 inline
1648 Order DofMap::variable_order (const unsigned int c) const
1649 {
1650  libmesh_assert_less (c, _variables.size());
1651 
1652  return _variables[c].type().order;
1653 }
1654 
1655 
1656 
1657 inline
1658 Order DofMap::variable_group_order (const unsigned int vg) const
1659 {
1660  libmesh_assert_less (vg, _variable_groups.size());
1661 
1662  return _variable_groups[vg].type().order;
1663 }
1664 
1665 
1666 
1667 inline
1668 const FEType & DofMap::variable_type (const unsigned int c) const
1669 {
1670  libmesh_assert_less (c, _variables.size());
1671 
1672  return _variables[c].type();
1673 }
1674 
1675 
1676 
1677 inline
1678 const FEType & DofMap::variable_group_type (const unsigned int vg) const
1679 {
1680  libmesh_assert_less (vg, _variable_groups.size());
1681 
1682  return _variable_groups[vg].type();
1683 }
1684 
1685 
1686 
1687 inline
1689 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1690  node
1691 #endif
1692  ) const
1693 {
1694 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1695  if (_node_constraints.count(node))
1696  return true;
1697 #endif
1698 
1699  return false;
1700 }
1701 
1702 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1703 
1704 inline
1705 bool DofMap::is_constrained_dof (const dof_id_type dof) const
1706 {
1707  if (_dof_constraints.count(dof))
1708  return true;
1709 
1710  return false;
1711 }
1712 
1713 
1714 inline
1715 bool DofMap::has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1716 {
1717  AdjointDofConstraintValues::const_iterator it =
1718  _adjoint_constraint_values.find(qoi_num);
1719  if (it == _adjoint_constraint_values.end())
1720  return false;
1721  if (it->second.empty())
1722  return false;
1723 
1724  return true;
1725 }
1726 
1727 
1728 inline
1730  const dof_id_type dof) const
1731 {
1732  AdjointDofConstraintValues::const_iterator it =
1733  _adjoint_constraint_values.find(qoi_num);
1734  if (it != _adjoint_constraint_values.end())
1735  {
1736  DofConstraintValueMap::const_iterator rhsit =
1737  it->second.find(dof);
1738  if (rhsit == it->second.end())
1739  return 0;
1740  else
1741  return rhsit->second;
1742  }
1743 
1744  return 0;
1745 }
1746 
1747 
1748 
1749 inline
1751 {
1752  return _primal_constraint_values;
1753 }
1754 
1755 
1756 
1757 #else
1758 
1759 //--------------------------------------------------------------------
1760 // Constraint-specific methods get inlined into nothing if
1761 // constraints are disabled, so there's no reason for users not to
1762 // use them.
1763 
1765  std::vector<dof_id_type> &,
1766  bool) const {}
1767 
1769  std::vector<dof_id_type> &,
1770  std::vector<dof_id_type> &,
1771  bool) const {}
1772 
1774  std::vector<dof_id_type> &,
1775  bool) const {}
1776 
1779  std::vector<dof_id_type> &,
1780  bool) const {}
1781 
1784  std::vector<dof_id_type> &,
1785  bool) const {}
1786 
1787 inline void DofMap::enforce_constraints_exactly (const System &,
1789  bool = false) const {}
1790 
1792  unsigned int) const {}
1793 
1794 #endif // LIBMESH_ENABLE_CONSTRAINTS
1795 
1796 } // namespace libMesh
1797 
1798 #endif // LIBMESH_DOF_MAP_H
std::vector< VariableGroup > _variable_groups
Definition: dof_map.h:1384
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:178
bool _implicit_neighbor_dofs_initialized
Definition: dof_map.h:1612
dof_id_type end_old_dof(const processor_id_type proc) const
Definition: dof_map.h:581
const unsigned int _sys_number
Definition: dof_map.h:1389
bool _implicit_neighbor_dofs
Definition: dof_map.h:1613
DofConstraintValueMap & get_primal_constraint_values()
Definition: dof_map.h:1750
UniquePtr< DefaultCoupling > _default_coupling
Definition: dof_map.h:1463
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:1440
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1668
Maps between boundary ids and PeriodicBoundaryBase objects.
dof_id_type end_old_dof() const
Definition: dof_map.h:584
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:1423
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:1428
const class libmesh_nullptr_t libmesh_nullptr
DofConstraints::const_iterator constraint_rows_begin() const
Definition: dof_map.h:793
Class for specifying Dirichlet boundary conditions as constraints.
std::set< GhostingFunctor * > _algebraic_ghosting_functors
Definition: dof_map.h:1481
std::vector< dof_id_type > _end_old_df
Definition: dof_map.h:1548
unsigned int block_size() const
Definition: dof_map.h:494
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:1638
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const bool forbid_constraint_overwrite=true)
Definition: dof_map.h:785
UniquePtr< DefaultCoupling > _default_evaluating
Definition: dof_map.h:1471
dof_id_type n_dofs() const
Definition: dof_map.h:506
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1628
const FEType & variable_group_type(const unsigned int vg) const
Definition: dof_map.h:1678
std::vector< dof_id_type > _first_old_df
Definition: dof_map.h:1543
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:1417
dof_id_type first_old_dof() const
Definition: dof_map.h:544
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map.h:522
AdjointDofConstraintValues _adjoint_constraint_values
Definition: dof_map.h:1567
libmesh_assert(j)
std::vector< dof_id_type > * _n_nz
Definition: dof_map.h:1514
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
AugmentSendList * _augment_send_list
Definition: dof_map.h:1445
std::vector< dof_id_type > * _n_oz
Definition: dof_map.h:1520
bool need_full_sparsity_pattern
Definition: dof_map.h:1500
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:167
UniquePtr< SparsityPattern::Build > _sp
Definition: dof_map.h:1506
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:531
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:569
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:1705
bool is_constrained_node(const Node *node) const
Definition: dof_map.h:1688
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:1554
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type _n_SCALAR_dofs
Definition: dof_map.h:1531
PeriodicBoundaries * get_periodic_boundaries()
Definition: dof_map.h:1076
NodeConstraints::const_iterator node_constraint_rows_end() const
Definition: dof_map.h:824
DirichletBoundaries * get_dirichlet_boundaries()
Definition: dof_map.h:1119
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:1114
CouplingMatrix * _dof_coupling
Definition: dof_map.h:1210
unsigned int n_variable_groups() const
Definition: dof_map.h:465
Number has_heterogenous_adjoint_constraint(const unsigned int qoi_num, const dof_id_type dof) const
Definition: dof_map.h:1729
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition: dof_map.h:818
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:1603
unsigned int sys_number() const
Definition: dof_map.h:1620
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:1455
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_end() const
Definition: dof_map.h:317
std::vector< SparseMatrix< Number > * > _matrices
Definition: dof_map.h:1401
dof_id_type end_dof() const
Definition: dof_map.h:572
dof_id_type last_dof() const
Definition: dof_map.h:561
DofConstraints::const_iterator constraint_rows_end() const
Definition: dof_map.h:799
const std::vector< dof_id_type > & get_n_oz() const
Definition: dof_map.h:412
unsigned int n_variables() const
Definition: dof_map.h:473
void unstash_dof_constraints()
Definition: dof_map.h:808
UniquePtr< DirichletBoundaries > _dirichlet_boundaries
Definition: dof_map.h:1597
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:802
dof_id_type n_old_dofs() const
Definition: dof_map.h:1163
DofConstraintValueMap _primal_constraint_values
Definition: dof_map.h:1565
std::vector< Variable > _variables
Definition: dof_map.h:1379
Order variable_order(const unsigned int c) const
Definition: dof_map.h:1648
DofConstraints _stashed_dof_constraints
Definition: dof_map.h:1563
dof_id_type n_local_dofs() const
Definition: dof_map.h:516
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:1538
std::set< GhostingFunctor * > _coupling_functors
Definition: dof_map.h:1494
UniquePtr< PeriodicBoundaries > _periodic_boundaries
Definition: dof_map.h:1583
std::vector< dof_id_type > _end_df
Definition: dof_map.h:1411
dof_id_type n_SCALAR_dofs() const
Definition: dof_map.h:511
std::vector< dof_id_type > _first_df
Definition: dof_map.h:1406
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Definition: dof_map.h:1715
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:1394
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:481
Order variable_group_order(const unsigned int vg) const
Definition: dof_map.h:1658
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:400
OStreamProxy out(std::cout)
dof_id_type first_old_dof(const processor_id_type proc) const
Definition: dof_map.h:541
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:392
processor_id_type processor_id()
Definition: libmesh_base.h:96
dof_id_type n_constrained_nodes() const
Definition: dof_map.h:708
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:554
dof_id_type first_dof() const
Definition: dof_map.h:534
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:1525
NodeConstraints _node_constraints
Definition: dof_map.h:1574
Defines the coupling between variables of a System.