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 
584  processor_id_type dof_owner(const dof_id_type dof) const
585  { std::vector<dof_id_type>::const_iterator ub =
586  std::upper_bound(_end_df.begin(), _end_df.end(), dof);
587  libmesh_assert (ub != _end_df.end());
588  return (ub - _end_df.begin());
589  }
590 
591 #ifdef LIBMESH_ENABLE_AMR
592 
598  dof_id_type end_old_dof(const processor_id_type proc) const
599  { libmesh_assert_less (proc, _end_old_df.size()); return _end_old_df[proc]; }
600 
601  dof_id_type end_old_dof() const
602  { return this->end_old_dof(this->processor_id()); }
603 
604 #endif //LIBMESH_ENABLE_AMR
605 
610  void dof_indices (const Elem * const elem,
611  std::vector<dof_id_type> & di) const;
612 
618  void dof_indices (const Elem * const elem,
619  std::vector<dof_id_type> & di,
620  const unsigned int vn,
621  int p_level = -12345) const;
622 
627  void dof_indices (const Node * const node,
628  std::vector<dof_id_type> & di) const;
629 
634  void dof_indices (const Node * const node,
635  std::vector<dof_id_type> & di,
636  const unsigned int vn) const;
637 
646  void SCALAR_dof_indices (std::vector<dof_id_type> & di,
647  const unsigned int vn,
648  const bool old_dofs=false) const;
649 
657  bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
658 
664  template <typename DofObjectSubclass>
665  bool is_evaluable(const DofObjectSubclass & obj,
666  unsigned int var_num = libMesh::invalid_uint) const;
667 
675  void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
676 
683  bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
684 
695  void extract_local_vector (const NumericVector<Number> & Ug,
696  const std::vector<dof_id_type> & dof_indices,
697  DenseVectorBase<Number> & Ue) const;
698 
703  void local_variable_indices(std::vector<dof_id_type> & idx,
704  const MeshBase & mesh,
705  unsigned int var_num) const;
706 
707 #ifdef LIBMESH_ENABLE_CONSTRAINTS
708 
709  //--------------------------------------------------------------------
710  // Constraint-specific methods
715  dof_id_type n_constrained_dofs() const;
716 
721  dof_id_type n_local_constrained_dofs() const;
722 
723 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
724 
728  dof_id_type n_constrained_nodes() const
729  { return cast_int<dof_id_type>(_node_constraints.size()); }
730 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
731 
737  void create_dof_constraints (const MeshBase &, Real time=0);
738 
742  void allgather_recursive_constraints (MeshBase &);
743 
747  void scatter_constraints (MeshBase &);
748 
762  void gather_constraints (MeshBase & mesh,
763  std::set<dof_id_type> & unexpanded_dofs,
764  bool look_for_constrainees);
765 
773  void process_constraints (MeshBase &);
774 
779  void add_constraint_row (const dof_id_type dof_number,
780  const DofConstraintRow & constraint_row,
781  const Number constraint_rhs,
782  const bool forbid_constraint_overwrite);
783 
794  void add_adjoint_constraint_row (const unsigned int qoi_index,
795  const dof_id_type dof_number,
796  const DofConstraintRow & constraint_row,
797  const Number constraint_rhs,
798  const bool forbid_constraint_overwrite);
799 
805  void add_constraint_row (const dof_id_type dof_number,
806  const DofConstraintRow & constraint_row,
807  const bool forbid_constraint_overwrite = true)
808  { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
809 
813  DofConstraints::const_iterator constraint_rows_begin() const
814  { return _dof_constraints.begin(); }
815 
819  DofConstraints::const_iterator constraint_rows_end() const
820  { return _dof_constraints.end(); }
821 
823  {
824  libmesh_assert(_stashed_dof_constraints.empty());
825  _dof_constraints.swap(_stashed_dof_constraints);
826  }
827 
829  {
830  libmesh_assert(_dof_constraints.empty());
831  _dof_constraints.swap(_stashed_dof_constraints);
832  }
833 
834 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
835 
838  NodeConstraints::const_iterator node_constraint_rows_begin() const
839  { return _node_constraints.begin(); }
840 
844  NodeConstraints::const_iterator node_constraint_rows_end() const
845  { return _node_constraints.end(); }
846 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
847 
852  bool is_constrained_dof (const dof_id_type dof) const;
853 
858  bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const;
859 
865  Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
866  const dof_id_type dof) const;
867 
872  DofConstraintValueMap & get_primal_constraint_values();
873 
878  bool is_constrained_node (const Node * node) const;
879 
886  void print_dof_constraints(std::ostream & os=libMesh::out,
887  bool print_nonlocal=false) const;
888 
894  std::string get_local_constraints(bool print_nonlocal=false) const;
895 
896 
905  std::pair<Real, Real> max_constraint_error(const System & system,
907 
908 #endif // LIBMESH_ENABLE_CONSTRAINTS
909 
910  //--------------------------------------------------------------------
911  // Constraint-specific methods
912  // Some of these methods are enabled (but inlined away to nothing)
913  // when constraints are disabled at configure-time. This is to
914  // increase API compatibility of user code with different library
915  // builds.
916 
930  void constrain_element_matrix (DenseMatrix<Number> & matrix,
931  std::vector<dof_id_type> & elem_dofs,
932  bool asymmetric_constraint_rows = true) const;
933 
940  void constrain_element_matrix (DenseMatrix<Number> & matrix,
941  std::vector<dof_id_type> & row_dofs,
942  std::vector<dof_id_type> & col_dofs,
943  bool asymmetric_constraint_rows = true) const;
944 
948  void constrain_element_vector (DenseVector<Number> & rhs,
949  std::vector<dof_id_type> & dofs,
950  bool asymmetric_constraint_rows = true) const;
951 
960  void constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
961  DenseVector<Number> & rhs,
962  std::vector<dof_id_type> & elem_dofs,
963  bool asymmetric_constraint_rows = true) const;
964 
988  void heterogenously_constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
989  DenseVector<Number> & rhs,
990  std::vector<dof_id_type> & elem_dofs,
991  bool asymmetric_constraint_rows = true,
992  int qoi_index = -1) const;
993 
1015  void heterogenously_constrain_element_vector (const 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 
1021 
1022 
1031  void constrain_element_dyad_matrix (DenseVector<Number> & v,
1032  DenseVector<Number> & w,
1033  std::vector<dof_id_type> & row_dofs,
1034  bool asymmetric_constraint_rows = true) const;
1035 
1042  void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1043 
1057  void enforce_constraints_exactly (const System & system,
1059  bool homogeneous = false) const;
1060 
1067  void enforce_adjoint_constraints_exactly (NumericVector<Number> & v,
1068  unsigned int q) const;
1069 
1070 
1071 
1072 #ifdef LIBMESH_ENABLE_PERIODIC
1073 
1074  //--------------------------------------------------------------------
1075  // PeriodicBoundary-specific methods
1076 
1080  void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1081 
1088  void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1089 
1094  bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1095 
1097  {
1098  return _periodic_boundaries.get();
1099  }
1100 
1101 #endif // LIBMESH_ENABLE_PERIODIC
1102 
1103 
1104 #ifdef LIBMESH_ENABLE_DIRICHLET
1105 
1106  //--------------------------------------------------------------------
1107  // DirichletBoundary-specific methods
1108 
1112  void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1113 
1119  void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1120  unsigned int q);
1121 
1125  void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1126 
1131  void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1132  unsigned int q);
1133 
1135  {
1136  return _dirichlet_boundaries.get();
1137  }
1138 
1140  {
1141  return _dirichlet_boundaries.get();
1142  }
1143 
1144  bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1145 
1146  const DirichletBoundaries *
1147  get_adjoint_dirichlet_boundaries(unsigned int q) const;
1148 
1150  get_adjoint_dirichlet_boundaries(unsigned int q);
1151 
1152 #endif // LIBMESH_ENABLE_DIRICHLET
1153 
1154 
1155 #ifdef LIBMESH_ENABLE_AMR
1156 
1157  //--------------------------------------------------------------------
1158  // AMR-specific methods
1159 
1168  // void augment_send_list_for_projection(const MeshBase &);
1169 
1176  void old_dof_indices (const Elem * const elem,
1177  std::vector<dof_id_type> & di,
1178  const unsigned int vn = libMesh::invalid_uint) const;
1182  dof_id_type n_old_dofs() const { return _n_old_dfs; }
1183 
1189  void constrain_p_dofs (unsigned int var,
1190  const Elem * elem,
1191  unsigned int s,
1192  unsigned int p);
1193 
1194 #endif // LIBMESH_ENABLE_AMR
1195 
1199  void reinit (MeshBase & mesh);
1200 
1204  void clear ();
1205 
1209  void print_info(std::ostream & os=libMesh::out) const;
1210 
1214  std::string get_info() const;
1215 
1230 
1234  unsigned int sys_number() const;
1235 
1236 private:
1237 
1245  void _dof_indices (const Elem * const elem,
1246  int p_level,
1247  std::vector<dof_id_type> & di,
1248  const unsigned int v,
1249  const Node * const * nodes,
1250  unsigned int n_nodes
1251 #ifdef DEBUG
1252  ,
1253  std::size_t & tot_size
1254 #endif
1255  ) const;
1256 
1260  UniquePtr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh) const;
1261 
1265  void invalidate_dofs(MeshBase & mesh) const;
1266 
1270  DofObject * node_ptr(MeshBase & mesh, dof_id_type i) const;
1271 
1275  DofObject * elem_ptr(MeshBase & mesh, dof_id_type i) const;
1276 
1280  typedef DofObject * (DofMap::*dofobject_accessor)
1281  (MeshBase & mesh, dof_id_type i) const;
1282 
1286  template<typename iterator_type>
1287  void set_nonlocal_dof_objects(iterator_type objects_begin,
1288  iterator_type objects_end,
1289  MeshBase & mesh,
1290  dofobject_accessor objects);
1291 
1300  void distribute_local_dofs_var_major (dof_id_type & next_free_dof,
1301  MeshBase & mesh);
1302 
1314  void distribute_local_dofs_node_major (dof_id_type & next_free_dof,
1315  MeshBase & mesh);
1316 
1317  /*
1318  * A utility method for obtaining a set of elements to ghost along
1319  * with merged coupling matrices.
1320  */
1321  static void
1322  merge_ghost_functor_outputs (GhostingFunctor::map_type & elements_to_ghost,
1323  std::set<CouplingMatrix *> & temporary_coupling_matrices,
1324  const std::set<GhostingFunctor *>::iterator & gf_begin,
1325  const std::set<GhostingFunctor *>::iterator & gf_end,
1326  const MeshBase::const_element_iterator & elems_begin,
1327  const MeshBase::const_element_iterator & elems_end,
1328  processor_id_type p);
1329 
1334  void add_neighbors_to_send_list(MeshBase & mesh);
1335 
1336 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1337 
1348  void build_constraint_matrix (DenseMatrix<Number> & C,
1349  std::vector<dof_id_type> & elem_dofs,
1350  const bool called_recursively=false) const;
1351 
1367  void build_constraint_matrix_and_vector (DenseMatrix<Number> & C,
1368  DenseVector<Number> & H,
1369  std::vector<dof_id_type> & elem_dofs,
1370  int qoi_index = -1,
1371  const bool called_recursively=false) const;
1372 
1377  void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
1378 
1383  void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
1384 
1390  void add_constraints_to_send_list();
1391 
1392 #endif // LIBMESH_ENABLE_CONSTRAINTS
1393 
1397  std::vector<Variable> _variables;
1398 
1402  std::vector<VariableGroup> _variable_groups;
1403 
1407  const unsigned int _sys_number;
1408 
1413 
1419  std::vector<SparseMatrix<Number> * > _matrices;
1420 
1424  std::vector<dof_id_type> _first_df;
1425 
1429  std::vector<dof_id_type> _end_df;
1430 
1435  std::vector<dof_id_type> _first_scalar_df;
1436 
1441  std::vector<dof_id_type> _send_list;
1442 
1447 
1451  void (*_extra_sparsity_function)(SparsityPattern::Graph &,
1452  std::vector<dof_id_type> & n_nz,
1453  std::vector<dof_id_type> & n_oz,
1454  void *);
1459 
1464 
1468  void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
1469 
1474 
1482 
1490 
1499  std::set<GhostingFunctor *> _algebraic_ghosting_functors;
1500 
1512  std::set<GhostingFunctor *> _coupling_functors;
1513 
1519 
1525 
1532  std::vector<dof_id_type> * _n_nz;
1533 
1538  std::vector<dof_id_type> * _n_oz;
1539 
1543  dof_id_type _n_dfs;
1544 
1549  dof_id_type _n_SCALAR_dofs;
1550 
1551 #ifdef LIBMESH_ENABLE_AMR
1552 
1556  dof_id_type _n_old_dfs;
1557 
1561  std::vector<dof_id_type> _first_old_df;
1562 
1566  std::vector<dof_id_type> _end_old_df;
1567 
1572  std::vector<dof_id_type> _first_old_scalar_df;
1573 
1574 #endif
1575 
1576 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1577 
1582 
1584 
1586 #endif
1587 
1588 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1589 
1593 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1594 
1595 
1596 #ifdef LIBMESH_ENABLE_PERIODIC
1597 
1602 #endif
1603 
1604 #ifdef LIBMESH_ENABLE_DIRICHLET
1605 
1609  void check_dirichlet_bcid_consistency (const MeshBase & mesh,
1610  const DirichletBoundary & boundary) const;
1616 
1621  std::vector<DirichletBoundaries *> _adjoint_dirichlet_boundaries;
1622 #endif
1623 
1625 
1632 };
1633 
1634 
1635 // ------------------------------------------------------------
1636 // Dof Map inline member functions
1637 inline
1638 unsigned int DofMap::sys_number() const
1639 {
1640  return _sys_number;
1641 }
1642 
1643 
1644 
1645 inline
1646 const VariableGroup & DofMap::variable_group (const unsigned int g) const
1647 {
1648  libmesh_assert_less (g, _variable_groups.size());
1649 
1650  return _variable_groups[g];
1651 }
1652 
1653 
1654 
1655 inline
1656 const Variable & DofMap::variable (const unsigned int c) const
1657 {
1658  libmesh_assert_less (c, _variables.size());
1659 
1660  return _variables[c];
1661 }
1662 
1663 
1664 
1665 inline
1666 Order DofMap::variable_order (const unsigned int c) const
1667 {
1668  libmesh_assert_less (c, _variables.size());
1669 
1670  return _variables[c].type().order;
1671 }
1672 
1673 
1674 
1675 inline
1676 Order DofMap::variable_group_order (const unsigned int vg) const
1677 {
1678  libmesh_assert_less (vg, _variable_groups.size());
1679 
1680  return _variable_groups[vg].type().order;
1681 }
1682 
1683 
1684 
1685 inline
1686 const FEType & DofMap::variable_type (const unsigned int c) const
1687 {
1688  libmesh_assert_less (c, _variables.size());
1689 
1690  return _variables[c].type();
1691 }
1692 
1693 
1694 
1695 inline
1696 const FEType & DofMap::variable_group_type (const unsigned int vg) const
1697 {
1698  libmesh_assert_less (vg, _variable_groups.size());
1699 
1700  return _variable_groups[vg].type();
1701 }
1702 
1703 
1704 
1705 inline
1707 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1708  node
1709 #endif
1710  ) const
1711 {
1712 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1713  if (_node_constraints.count(node))
1714  return true;
1715 #endif
1716 
1717  return false;
1718 }
1719 
1720 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1721 
1722 inline
1723 bool DofMap::is_constrained_dof (const dof_id_type dof) const
1724 {
1725  if (_dof_constraints.count(dof))
1726  return true;
1727 
1728  return false;
1729 }
1730 
1731 
1732 inline
1733 bool DofMap::has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1734 {
1735  AdjointDofConstraintValues::const_iterator it =
1736  _adjoint_constraint_values.find(qoi_num);
1737  if (it == _adjoint_constraint_values.end())
1738  return false;
1739  if (it->second.empty())
1740  return false;
1741 
1742  return true;
1743 }
1744 
1745 
1746 inline
1748  const dof_id_type dof) const
1749 {
1750  AdjointDofConstraintValues::const_iterator it =
1751  _adjoint_constraint_values.find(qoi_num);
1752  if (it != _adjoint_constraint_values.end())
1753  {
1754  DofConstraintValueMap::const_iterator rhsit =
1755  it->second.find(dof);
1756  if (rhsit == it->second.end())
1757  return 0;
1758  else
1759  return rhsit->second;
1760  }
1761 
1762  return 0;
1763 }
1764 
1765 
1766 
1767 inline
1769 {
1770  return _primal_constraint_values;
1771 }
1772 
1773 
1774 
1775 #else
1776 
1777 //--------------------------------------------------------------------
1778 // Constraint-specific methods get inlined into nothing if
1779 // constraints are disabled, so there's no reason for users not to
1780 // use them.
1781 
1783  std::vector<dof_id_type> &,
1784  bool) const {}
1785 
1787  std::vector<dof_id_type> &,
1788  std::vector<dof_id_type> &,
1789  bool) const {}
1790 
1792  std::vector<dof_id_type> &,
1793  bool) const {}
1794 
1797  std::vector<dof_id_type> &,
1798  bool) const {}
1799 
1802  std::vector<dof_id_type> &,
1803  bool) const {}
1804 
1805 inline void DofMap::enforce_constraints_exactly (const System &,
1807  bool = false) const {}
1808 
1810  unsigned int) const {}
1811 
1812 #endif // LIBMESH_ENABLE_CONSTRAINTS
1813 
1814 } // namespace libMesh
1815 
1816 #endif // LIBMESH_DOF_MAP_H
std::vector< VariableGroup > _variable_groups
Definition: dof_map.h:1402
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:178
bool _implicit_neighbor_dofs_initialized
Definition: dof_map.h:1630
dof_id_type end_old_dof(const processor_id_type proc) const
Definition: dof_map.h:598
const unsigned int _sys_number
Definition: dof_map.h:1407
bool _implicit_neighbor_dofs
Definition: dof_map.h:1631
DofConstraintValueMap & get_primal_constraint_values()
Definition: dof_map.h:1768
UniquePtr< DefaultCoupling > _default_coupling
Definition: dof_map.h:1481
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:1458
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1686
Maps between boundary ids and PeriodicBoundaryBase objects.
dof_id_type end_old_dof() const
Definition: dof_map.h:601
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:1441
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:1446
const class libmesh_nullptr_t libmesh_nullptr
DofConstraints::const_iterator constraint_rows_begin() const
Definition: dof_map.h:813
Class for specifying Dirichlet boundary conditions as constraints.
std::set< GhostingFunctor * > _algebraic_ghosting_functors
Definition: dof_map.h:1499
std::vector< dof_id_type > _end_old_df
Definition: dof_map.h:1566
processor_id_type dof_owner(const dof_id_type dof) const
Definition: dof_map.h:584
unsigned int block_size() const
Definition: dof_map.h:498
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:1656
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const bool forbid_constraint_overwrite=true)
Definition: dof_map.h:805
UniquePtr< DefaultCoupling > _default_evaluating
Definition: dof_map.h:1489
dof_id_type n_dofs() const
Definition: dof_map.h:510
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1646
const FEType & variable_group_type(const unsigned int vg) const
Definition: dof_map.h:1696
std::vector< dof_id_type > _first_old_df
Definition: dof_map.h:1561
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:1435
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:1585
libmesh_assert(j)
std::vector< dof_id_type > * _n_nz
Definition: dof_map.h:1532
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
AugmentSendList * _augment_send_list
Definition: dof_map.h:1463
std::vector< dof_id_type > * _n_oz
Definition: dof_map.h:1538
bool need_full_sparsity_pattern
Definition: dof_map.h:1518
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:167
UniquePtr< SparsityPattern::Build > _sp
Definition: dof_map.h:1524
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:1723
bool is_constrained_node(const Node *node) const
Definition: dof_map.h:1706
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:1572
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type _n_SCALAR_dofs
Definition: dof_map.h:1549
PeriodicBoundaries * get_periodic_boundaries()
Definition: dof_map.h:1096
NodeConstraints::const_iterator node_constraint_rows_end() const
Definition: dof_map.h:844
DirichletBoundaries * get_dirichlet_boundaries()
Definition: dof_map.h:1139
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:1134
CouplingMatrix * _dof_coupling
Definition: dof_map.h:1229
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:1747
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition: dof_map.h:838
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:1621
unsigned int sys_number() const
Definition: dof_map.h:1638
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:1473
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_end() const
Definition: dof_map.h:317
std::vector< SparseMatrix< Number > * > _matrices
Definition: dof_map.h:1419
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:819
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:828
UniquePtr< DirichletBoundaries > _dirichlet_boundaries
Definition: dof_map.h:1615
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:822
dof_id_type n_old_dofs() const
Definition: dof_map.h:1182
DofConstraintValueMap _primal_constraint_values
Definition: dof_map.h:1583
std::vector< Variable > _variables
Definition: dof_map.h:1397
Order variable_order(const unsigned int c) const
Definition: dof_map.h:1666
DofConstraints _stashed_dof_constraints
Definition: dof_map.h:1581
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:1556
std::set< GhostingFunctor * > _coupling_functors
Definition: dof_map.h:1512
UniquePtr< PeriodicBoundaries > _periodic_boundaries
Definition: dof_map.h:1601
std::vector< dof_id_type > _end_df
Definition: dof_map.h:1429
dof_id_type n_SCALAR_dofs() const
Definition: dof_map.h:515
std::vector< dof_id_type > _first_df
Definition: dof_map.h:1424
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Definition: dof_map.h:1733
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:1412
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:1676
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:728
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:1543
NodeConstraints _node_constraints
Definition: dof_map.h:1592
Defines the coupling between variables of a System.