libMesh
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"
27 #include "libmesh/reference_counted_object.h"
28 #include "libmesh/libmesh.h" // libMesh::invalid_uint
29 #include "libmesh/variable.h"
30 #include "libmesh/threads.h"
31 #include "libmesh/threads_allocators.h"
32 #include "libmesh/elem_range.h"
33 #include "libmesh/ghosting_functor.h"
34 #include "libmesh/sparsity_pattern.h"
35 #include "libmesh/parallel_object.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 #ifdef LIBMESH_ENABLE_DEPRECATED
560  dof_id_type last_dof(const processor_id_type proc) const
561  {
562  libmesh_deprecated();
563  libmesh_assert_less (proc, _end_df.size());
564  return cast_int<dof_id_type>(_end_df[proc] - 1);
565  }
566 
567  dof_id_type last_dof() const
568  { return this->last_dof(this->processor_id()); }
569 #endif
570 
577  dof_id_type end_dof(const processor_id_type proc) const
578  { libmesh_assert_less (proc, _end_df.size()); return _end_df[proc]; }
579 
580  dof_id_type end_dof() const
581  { return this->end_dof(this->processor_id()); }
582 
586  processor_id_type dof_owner(const dof_id_type dof) const
587  { std::vector<dof_id_type>::const_iterator ub =
588  std::upper_bound(_end_df.begin(), _end_df.end(), dof);
589  libmesh_assert (ub != _end_df.end());
590  return (ub - _end_df.begin());
591  }
592 
593 #ifdef LIBMESH_ENABLE_AMR
594 
600  dof_id_type end_old_dof(const processor_id_type proc) const
601  { libmesh_assert_less (proc, _end_old_df.size()); return _end_old_df[proc]; }
602 
603  dof_id_type end_old_dof() const
604  { return this->end_old_dof(this->processor_id()); }
605 
606 #endif //LIBMESH_ENABLE_AMR
607 
612  void dof_indices (const Elem * const elem,
613  std::vector<dof_id_type> & di) const;
614 
620  void dof_indices (const Elem * const elem,
621  std::vector<dof_id_type> & di,
622  const unsigned int vn,
623  int p_level = -12345) const;
624 
629  void dof_indices (const Node * const node,
630  std::vector<dof_id_type> & di) const;
631 
636  void dof_indices (const Node * const node,
637  std::vector<dof_id_type> & di,
638  const unsigned int vn) const;
639 
648  void SCALAR_dof_indices (std::vector<dof_id_type> & di,
649  const unsigned int vn,
650  const bool old_dofs=false) const;
651 
659  bool semilocal_index (dof_id_type dof_index) const;
660 
668  bool all_semilocal_indices (const std::vector<dof_id_type> & dof_indices) const;
669 
675  template <typename DofObjectSubclass>
676  bool is_evaluable(const DofObjectSubclass & obj,
677  unsigned int var_num = libMesh::invalid_uint) const;
678 
686  void set_implicit_neighbor_dofs(bool implicit_neighbor_dofs);
687 
694  bool use_coupled_neighbor_dofs(const MeshBase & mesh) const;
695 
706  void extract_local_vector (const NumericVector<Number> & Ug,
707  const std::vector<dof_id_type> & dof_indices,
708  DenseVectorBase<Number> & Ue) const;
709 
714  void local_variable_indices(std::vector<dof_id_type> & idx,
715  const MeshBase & mesh,
716  unsigned int var_num) const;
717 
718 #ifdef LIBMESH_ENABLE_CONSTRAINTS
719 
720  //--------------------------------------------------------------------
721  // Constraint-specific methods
726  dof_id_type n_constrained_dofs() const;
727 
732  dof_id_type n_local_constrained_dofs() const;
733 
734 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
735 
739  dof_id_type n_constrained_nodes() const
740  { return cast_int<dof_id_type>(_node_constraints.size()); }
741 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
742 
748  void create_dof_constraints (const MeshBase &, Real time=0);
749 
753  void allgather_recursive_constraints (MeshBase &);
754 
758  void scatter_constraints (MeshBase &);
759 
773  void gather_constraints (MeshBase & mesh,
774  std::set<dof_id_type> & unexpanded_dofs,
775  bool look_for_constrainees);
776 
784  void process_constraints (MeshBase &);
785 
790  void add_constraint_row (const dof_id_type dof_number,
791  const DofConstraintRow & constraint_row,
792  const Number constraint_rhs,
793  const bool forbid_constraint_overwrite);
794 
805  void add_adjoint_constraint_row (const unsigned int qoi_index,
806  const dof_id_type dof_number,
807  const DofConstraintRow & constraint_row,
808  const Number constraint_rhs,
809  const bool forbid_constraint_overwrite);
810 
816  void add_constraint_row (const dof_id_type dof_number,
817  const DofConstraintRow & constraint_row,
818  const bool forbid_constraint_overwrite = true)
819  { add_constraint_row(dof_number, constraint_row, 0., forbid_constraint_overwrite); }
820 
824  DofConstraints::const_iterator constraint_rows_begin() const
825  { return _dof_constraints.begin(); }
826 
830  DofConstraints::const_iterator constraint_rows_end() const
831  { return _dof_constraints.end(); }
832 
834  {
835  libmesh_assert(_stashed_dof_constraints.empty());
836  _dof_constraints.swap(_stashed_dof_constraints);
837  }
838 
840  {
841  libmesh_assert(_dof_constraints.empty());
842  _dof_constraints.swap(_stashed_dof_constraints);
843  }
844 
845 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
846 
849  NodeConstraints::const_iterator node_constraint_rows_begin() const
850  { return _node_constraints.begin(); }
851 
855  NodeConstraints::const_iterator node_constraint_rows_end() const
856  { return _node_constraints.end(); }
857 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
858 
863  bool is_constrained_dof (const dof_id_type dof) const;
864 
869  bool has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const;
870 
876  Number has_heterogenous_adjoint_constraint (const unsigned int qoi_num,
877  const dof_id_type dof) const;
878 
883  DofConstraintValueMap & get_primal_constraint_values();
884 
889  bool is_constrained_node (const Node * node) const;
890 
897  void print_dof_constraints(std::ostream & os=libMesh::out,
898  bool print_nonlocal=false) const;
899 
905  std::string get_local_constraints(bool print_nonlocal=false) const;
906 
907 
916  std::pair<Real, Real> max_constraint_error(const System & system,
918 
919 #endif // LIBMESH_ENABLE_CONSTRAINTS
920 
921  //--------------------------------------------------------------------
922  // Constraint-specific methods
923  // Some of these methods are enabled (but inlined away to nothing)
924  // when constraints are disabled at configure-time. This is to
925  // increase API compatibility of user code with different library
926  // builds.
927 
941  void constrain_element_matrix (DenseMatrix<Number> & matrix,
942  std::vector<dof_id_type> & elem_dofs,
943  bool asymmetric_constraint_rows = true) const;
944 
951  void constrain_element_matrix (DenseMatrix<Number> & matrix,
952  std::vector<dof_id_type> & row_dofs,
953  std::vector<dof_id_type> & col_dofs,
954  bool asymmetric_constraint_rows = true) const;
955 
959  void constrain_element_vector (DenseVector<Number> & rhs,
960  std::vector<dof_id_type> & dofs,
961  bool asymmetric_constraint_rows = true) const;
962 
971  void constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
972  DenseVector<Number> & rhs,
973  std::vector<dof_id_type> & elem_dofs,
974  bool asymmetric_constraint_rows = true) const;
975 
999  void heterogenously_constrain_element_matrix_and_vector (DenseMatrix<Number> & matrix,
1000  DenseVector<Number> & rhs,
1001  std::vector<dof_id_type> & elem_dofs,
1002  bool asymmetric_constraint_rows = true,
1003  int qoi_index = -1) const;
1004 
1026  void heterogenously_constrain_element_vector (const DenseMatrix<Number> & matrix,
1027  DenseVector<Number> & rhs,
1028  std::vector<dof_id_type> & elem_dofs,
1029  bool asymmetric_constraint_rows = true,
1030  int qoi_index = -1) const;
1031 
1032 
1033 
1042  void constrain_element_dyad_matrix (DenseVector<Number> & v,
1043  DenseVector<Number> & w,
1044  std::vector<dof_id_type> & row_dofs,
1045  bool asymmetric_constraint_rows = true) const;
1046 
1053  void constrain_nothing (std::vector<dof_id_type> & dofs) const;
1054 
1068  void enforce_constraints_exactly (const System & system,
1070  bool homogeneous = false) const;
1071 
1078  void enforce_adjoint_constraints_exactly (NumericVector<Number> & v,
1079  unsigned int q) const;
1080 
1081 
1082 
1083 #ifdef LIBMESH_ENABLE_PERIODIC
1084 
1085  //--------------------------------------------------------------------
1086  // PeriodicBoundary-specific methods
1087 
1091  void add_periodic_boundary (const PeriodicBoundaryBase & periodic_boundary);
1092 
1099  void add_periodic_boundary (const PeriodicBoundaryBase & boundary, const PeriodicBoundaryBase & inverse_boundary);
1100 
1105  bool is_periodic_boundary (const boundary_id_type boundaryid) const;
1106 
1108  {
1109  return _periodic_boundaries.get();
1110  }
1111 
1112 #endif // LIBMESH_ENABLE_PERIODIC
1113 
1114 
1115 #ifdef LIBMESH_ENABLE_DIRICHLET
1116 
1117  //--------------------------------------------------------------------
1118  // DirichletBoundary-specific methods
1119 
1123  void add_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1124 
1130  void add_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1131  unsigned int q);
1132 
1136  void remove_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary);
1137 
1142  void remove_adjoint_dirichlet_boundary (const DirichletBoundary & dirichlet_boundary,
1143  unsigned int q);
1144 
1146  {
1147  return _dirichlet_boundaries.get();
1148  }
1149 
1151  {
1152  return _dirichlet_boundaries.get();
1153  }
1154 
1155  bool has_adjoint_dirichlet_boundaries(unsigned int q) const;
1156 
1157  const DirichletBoundaries *
1158  get_adjoint_dirichlet_boundaries(unsigned int q) const;
1159 
1161  get_adjoint_dirichlet_boundaries(unsigned int q);
1162 
1163 #endif // LIBMESH_ENABLE_DIRICHLET
1164 
1165 
1166 #ifdef LIBMESH_ENABLE_AMR
1167 
1168  //--------------------------------------------------------------------
1169  // AMR-specific methods
1170 
1179  // void augment_send_list_for_projection(const MeshBase &);
1180 
1187  void old_dof_indices (const Elem * const elem,
1188  std::vector<dof_id_type> & di,
1189  const unsigned int vn = libMesh::invalid_uint) const;
1193  dof_id_type n_old_dofs() const { return _n_old_dfs; }
1194 
1200  void constrain_p_dofs (unsigned int var,
1201  const Elem * elem,
1202  unsigned int s,
1203  unsigned int p);
1204 
1205 #endif // LIBMESH_ENABLE_AMR
1206 
1210  void reinit (MeshBase & mesh);
1211 
1215  void clear ();
1216 
1220  void print_info(std::ostream & os=libMesh::out) const;
1221 
1225  std::string get_info() const;
1226 
1241 
1245  unsigned int sys_number() const;
1246 
1247 private:
1248 
1256  void _dof_indices (const Elem & elem,
1257  int p_level,
1258  std::vector<dof_id_type> & di,
1259  const unsigned int v,
1260  const Node * const * nodes,
1261  unsigned int n_nodes
1262 #ifdef DEBUG
1263  ,
1264  std::size_t & tot_size
1265 #endif
1266  ) const;
1267 
1271  UniquePtr<SparsityPattern::Build> build_sparsity(const MeshBase & mesh) const;
1272 
1276  void invalidate_dofs(MeshBase & mesh) const;
1277 
1281  DofObject * node_ptr(MeshBase & mesh, dof_id_type i) const;
1282 
1286  DofObject * elem_ptr(MeshBase & mesh, dof_id_type i) const;
1287 
1291  typedef DofObject * (DofMap::*dofobject_accessor)
1292  (MeshBase & mesh, dof_id_type i) const;
1293 
1297  template<typename iterator_type>
1298  void set_nonlocal_dof_objects(iterator_type objects_begin,
1299  iterator_type objects_end,
1300  MeshBase & mesh,
1301  dofobject_accessor objects);
1302 
1311  void distribute_local_dofs_var_major (dof_id_type & next_free_dof,
1312  MeshBase & mesh);
1313 
1325  void distribute_local_dofs_node_major (dof_id_type & next_free_dof,
1326  MeshBase & mesh);
1327 
1328  /*
1329  * A utility method for obtaining a set of elements to ghost along
1330  * with merged coupling matrices.
1331  */
1332  static void
1333  merge_ghost_functor_outputs (GhostingFunctor::map_type & elements_to_ghost,
1334  std::set<CouplingMatrix *> & temporary_coupling_matrices,
1335  const std::set<GhostingFunctor *>::iterator & gf_begin,
1336  const std::set<GhostingFunctor *>::iterator & gf_end,
1337  const MeshBase::const_element_iterator & elems_begin,
1338  const MeshBase::const_element_iterator & elems_end,
1339  processor_id_type p);
1340 
1345  void add_neighbors_to_send_list(MeshBase & mesh);
1346 
1347 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1348 
1359  void build_constraint_matrix (DenseMatrix<Number> & C,
1360  std::vector<dof_id_type> & elem_dofs,
1361  const bool called_recursively=false) const;
1362 
1378  void build_constraint_matrix_and_vector (DenseMatrix<Number> & C,
1379  DenseVector<Number> & H,
1380  std::vector<dof_id_type> & elem_dofs,
1381  int qoi_index = -1,
1382  const bool called_recursively=false) const;
1383 
1388  void find_connected_dofs (std::vector<dof_id_type> & elem_dofs) const;
1389 
1394  void find_connected_dof_objects (std::vector<const DofObject *> & objs) const;
1395 
1401  void add_constraints_to_send_list();
1402 
1403 #endif // LIBMESH_ENABLE_CONSTRAINTS
1404 
1408  std::vector<Variable> _variables;
1409 
1413  std::vector<VariableGroup> _variable_groups;
1414 
1418  const unsigned int _sys_number;
1419 
1424 
1430  std::vector<SparseMatrix<Number> * > _matrices;
1431 
1435  std::vector<dof_id_type> _first_df;
1436 
1440  std::vector<dof_id_type> _end_df;
1441 
1446  std::vector<dof_id_type> _first_scalar_df;
1447 
1452  std::vector<dof_id_type> _send_list;
1453 
1458 
1462  void (*_extra_sparsity_function)(SparsityPattern::Graph &,
1463  std::vector<dof_id_type> & n_nz,
1464  std::vector<dof_id_type> & n_oz,
1465  void *);
1470 
1475 
1479  void (*_extra_send_list_function)(std::vector<dof_id_type> &, void *);
1480 
1485 
1493 
1501 
1510  std::set<GhostingFunctor *> _algebraic_ghosting_functors;
1511 
1523  std::set<GhostingFunctor *> _coupling_functors;
1524 
1530 
1536 
1543  std::vector<dof_id_type> * _n_nz;
1544 
1549  std::vector<dof_id_type> * _n_oz;
1550 
1554  dof_id_type _n_dfs;
1555 
1560  dof_id_type _n_SCALAR_dofs;
1561 
1562 #ifdef LIBMESH_ENABLE_AMR
1563 
1567  dof_id_type _n_old_dfs;
1568 
1572  std::vector<dof_id_type> _first_old_df;
1573 
1577  std::vector<dof_id_type> _end_old_df;
1578 
1583  std::vector<dof_id_type> _first_old_scalar_df;
1584 
1585 #endif
1586 
1587 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1588 
1593 
1595 
1597 #endif
1598 
1599 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1600 
1604 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1605 
1606 
1607 #ifdef LIBMESH_ENABLE_PERIODIC
1608 
1613 #endif
1614 
1615 #ifdef LIBMESH_ENABLE_DIRICHLET
1616 
1620  void check_dirichlet_bcid_consistency (const MeshBase & mesh,
1621  const DirichletBoundary & boundary) const;
1627 
1632  std::vector<DirichletBoundaries *> _adjoint_dirichlet_boundaries;
1633 #endif
1634 
1636 
1643 };
1644 
1645 
1646 // ------------------------------------------------------------
1647 // Dof Map inline member functions
1648 inline
1649 unsigned int DofMap::sys_number() const
1650 {
1651  return _sys_number;
1652 }
1653 
1654 
1655 
1656 inline
1657 const VariableGroup & DofMap::variable_group (const unsigned int g) const
1658 {
1659  libmesh_assert_less (g, _variable_groups.size());
1660 
1661  return _variable_groups[g];
1662 }
1663 
1664 
1665 
1666 inline
1667 const Variable & DofMap::variable (const unsigned int c) const
1668 {
1669  libmesh_assert_less (c, _variables.size());
1670 
1671  return _variables[c];
1672 }
1673 
1674 
1675 
1676 inline
1677 Order DofMap::variable_order (const unsigned int c) const
1678 {
1679  libmesh_assert_less (c, _variables.size());
1680 
1681  return _variables[c].type().order;
1682 }
1683 
1684 
1685 
1686 inline
1687 Order DofMap::variable_group_order (const unsigned int vg) const
1688 {
1689  libmesh_assert_less (vg, _variable_groups.size());
1690 
1691  return _variable_groups[vg].type().order;
1692 }
1693 
1694 
1695 
1696 inline
1697 const FEType & DofMap::variable_type (const unsigned int c) const
1698 {
1699  libmesh_assert_less (c, _variables.size());
1700 
1701  return _variables[c].type();
1702 }
1703 
1704 
1705 
1706 inline
1707 const FEType & DofMap::variable_group_type (const unsigned int vg) const
1708 {
1709  libmesh_assert_less (vg, _variable_groups.size());
1710 
1711  return _variable_groups[vg].type();
1712 }
1713 
1714 
1715 
1716 inline
1718 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1719  node
1720 #endif
1721  ) const
1722 {
1723 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1724  if (_node_constraints.count(node))
1725  return true;
1726 #endif
1727 
1728  return false;
1729 }
1730 
1731 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1732 
1733 inline
1734 bool DofMap::is_constrained_dof (const dof_id_type dof) const
1735 {
1736  if (_dof_constraints.count(dof))
1737  return true;
1738 
1739  return false;
1740 }
1741 
1742 
1743 inline
1744 bool DofMap::has_heterogenous_adjoint_constraints (const unsigned int qoi_num) const
1745 {
1746  AdjointDofConstraintValues::const_iterator it =
1747  _adjoint_constraint_values.find(qoi_num);
1748  if (it == _adjoint_constraint_values.end())
1749  return false;
1750  if (it->second.empty())
1751  return false;
1752 
1753  return true;
1754 }
1755 
1756 
1757 inline
1759  const dof_id_type dof) const
1760 {
1761  AdjointDofConstraintValues::const_iterator it =
1762  _adjoint_constraint_values.find(qoi_num);
1763  if (it != _adjoint_constraint_values.end())
1764  {
1765  DofConstraintValueMap::const_iterator rhsit =
1766  it->second.find(dof);
1767  if (rhsit == it->second.end())
1768  return 0;
1769  else
1770  return rhsit->second;
1771  }
1772 
1773  return 0;
1774 }
1775 
1776 
1777 
1778 inline
1780 {
1781  return _primal_constraint_values;
1782 }
1783 
1784 
1785 
1786 #else
1787 
1788 //--------------------------------------------------------------------
1789 // Constraint-specific methods get inlined into nothing if
1790 // constraints are disabled, so there's no reason for users not to
1791 // use them.
1792 
1794  std::vector<dof_id_type> &,
1795  bool) const {}
1796 
1798  std::vector<dof_id_type> &,
1799  std::vector<dof_id_type> &,
1800  bool) const {}
1801 
1803  std::vector<dof_id_type> &,
1804  bool) const {}
1805 
1808  std::vector<dof_id_type> &,
1809  bool) const {}
1810 
1813  std::vector<dof_id_type> &,
1814  bool) const {}
1815 
1818  bool = false) const {}
1819 
1821  unsigned int) const {}
1822 
1823 #endif // LIBMESH_ENABLE_CONSTRAINTS
1824 
1825 } // namespace libMesh
1826 
1827 #endif // LIBMESH_DOF_MAP_H
std::vector< VariableGroup > _variable_groups
The finite element type for each variable.
Definition: dof_map.h:1413
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
bool _implicit_neighbor_dofs_initialized
Bools to indicate if we override the –implicit_neighbor_dofs commandline options.
Definition: dof_map.h:1641
dof_id_type end_old_dof(const processor_id_type proc) const
Definition: dof_map.h:600
const unsigned int _sys_number
The number of the system we manage DOFs for.
Definition: dof_map.h:1418
bool _implicit_neighbor_dofs
Definition: dof_map.h:1642
DofConstraintValueMap & get_primal_constraint_values()
Definition: dof_map.h:1779
UniquePtr< DefaultCoupling > _default_coupling
The default coupling GhostingFunctor, used to implement standard libMesh sparsity pattern constructio...
Definition: dof_map.h:1492
DefaultCoupling & default_coupling()
Default coupling functor.
Definition: dof_map.h:287
A Node is like a Point, but with more information.
Definition: node.h:52
This abstract base class defines the interface by which library code and user code can report associa...
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_begin() const
Beginning of range of algebraic ghosting functors.
Definition: dof_map.h:311
This helper class can be called on multiple threads to compute the sparsity pattern (or graph) of the...
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
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)
Attach a function pointer to use as a callback to populate the sparsity pattern with extra entries...
Definition: dof_map.h:350
void * _extra_sparsity_context
A pointer associated with the extra sparsity that can optionally be passed in.
Definition: dof_map.h:1469
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1697
The definition of the const_element_iterator struct.
Definition: mesh_base.h:1494
We&#39;re using a class instead of a typedef to allow forward declarations and future flexibility...
dof_id_type end_old_dof() const
Definition: dof_map.h:603
std::set< GhostingFunctor * >::const_iterator coupling_functors_begin() const
Beginning of range of coupling functors.
Definition: dof_map.h:275
std::vector< dof_id_type > _send_list
A list containing all the global DOF indices that affect the solution on my processor.
Definition: dof_map.h:1452
void constrain_element_vector(DenseVector< Number > &rhs, std::vector< dof_id_type > &dofs, bool asymmetric_constraint_rows=true) const
Constrains the element vector.
Definition: dof_map.h:1802
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
DefaultCoupling & default_algebraic_ghosting()
Default algebraic ghosting functor.
Definition: dof_map.h:323
AugmentSparsityPattern * _augment_sparsity_pattern
Function object to call to add extra entries to the sparsity pattern.
Definition: dof_map.h:1457
const class libmesh_nullptr_t libmesh_nullptr
DofConstraints::const_iterator constraint_rows_begin() const
Definition: dof_map.h:824
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
Numeric vector.
Definition: dof_map.h:66
The Node constraint storage format.
Definition: dof_map.h:144
std::set< GhostingFunctor * > _algebraic_ghosting_functors
The list of all GhostingFunctor objects to be used when distributing ghosted vectors.
Definition: dof_map.h:1510
std::vector< dof_id_type > _end_old_df
Last old DOF index (plus 1) on processor p.
Definition: dof_map.h:1577
processor_id_type dof_owner(const dof_id_type dof) const
Definition: dof_map.h:586
unsigned int block_size() const
Definition: dof_map.h:498
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:1667
The libMesh namespace provides an interface to certain functionality in the library.
void add_constraint_row(const dof_id_type dof_number, const DofConstraintRow &constraint_row, const bool forbid_constraint_overwrite=true)
Adds a copy of the user-defined row to the constraint matrix, using a homogeneous right-hand-side for...
Definition: dof_map.h:816
UniquePtr< DefaultCoupling > _default_evaluating
The default algebraic GhostingFunctor, used to implement standard libMesh send_list construction...
Definition: dof_map.h:1500
dof_id_type n_dofs() const
Definition: dof_map.h:510
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1657
const FEType & variable_group_type(const unsigned int vg) const
Definition: dof_map.h:1707
std::vector< dof_id_type > _first_old_df
First old DOF index on processor p.
Definition: dof_map.h:1572
void attach_extra_sparsity_object(DofMap::AugmentSparsityPattern &asp)
Attach an object to use to populate the sparsity pattern with extra entries.
Definition: dof_map.h:335
This is the MeshBase class.
Definition: mesh_base.h:68
std::vector< dof_id_type > _first_scalar_df
First DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
Definition: dof_map.h:1446
dof_id_type first_old_dof() const
Definition: dof_map.h:548
This class implements the default algebraic coupling in libMesh: elements couple to themselves...
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:1596
libmesh_assert(j)
std::vector< dof_id_type > * _n_nz
The number of on-processor nonzeros in my portion of the global matrix.
Definition: dof_map.h:1543
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
AugmentSendList * _augment_send_list
Function object to call to add extra entries to the send list.
Definition: dof_map.h:1474
std::vector< dof_id_type > * _n_oz
The number of off-processor nonzeros in my portion of the global matrix; allocated similar to _n_nz...
Definition: dof_map.h:1549
bool need_full_sparsity_pattern
Default false; set to true if any attached matrix requires a full sparsity pattern.
Definition: dof_map.h:1529
Generic sparse matrix.
Definition: dof_map.h:65
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
UniquePtr< SparsityPattern::Build > _sp
The sparsity pattern of the global matrix, kept around if it might be needed by future additions of t...
Definition: dof_map.h:1535
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:577
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:1734
bool is_constrained_node(const Node *node) const
Definition: dof_map.h:1717
This class defines the notion of a variable in the system.
Definition: variable.h:49
std::vector< dof_id_type > _first_old_scalar_df
First old DOF index for SCALAR variable v, or garbage for non-SCALAR variable v.
Definition: dof_map.h:1583
int8_t boundary_id_type
Definition: id_types.h:51
dof_id_type _n_SCALAR_dofs
The total number of SCALAR dofs associated to all SCALAR variables.
Definition: dof_map.h:1560
PeriodicBoundaries * get_periodic_boundaries()
Definition: dof_map.h:1107
NodeConstraints::const_iterator node_constraint_rows_end() const
Definition: dof_map.h:855
This is the base class for classes which contain information related to any physical process that mig...
Definition: system.h:76
We&#39;re using a class instead of a typedef to allow forward declarations and future flexibility...
DirichletBoundaries * get_dirichlet_boundaries()
Definition: dof_map.h:1150
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
Definition: dof_map.h:1806
std::unordered_map< const Elem *, const CouplingMatrix * > map_type
What elements do we care about and what variables do we care about on each element?
const DirichletBoundaries * get_dirichlet_boundaries() const
Definition: dof_map.h:1145
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
Definition: dof_map.h:1240
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:1758
NodeConstraints::const_iterator node_constraint_rows_begin() const
Definition: dof_map.h:849
void attach_extra_send_list_function(void(*func)(std::vector< dof_id_type > &, void *), void *context=libmesh_nullptr)
Attach a function pointer to use as a callback to populate the send_list with extra entries...
Definition: dof_map.h:373
std::vector< DirichletBoundaries * > _adjoint_dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition: dof_map.h:1632
unsigned int sys_number() const
Definition: dof_map.h:1649
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=libmesh_nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh. ...
Definition: dof_map.h:1816
void * _extra_send_list_context
A pointer associated with the extra send list that can optionally be passed in.
Definition: dof_map.h:1484
This class implements reference counting.
This class forms the base class for all other classes that are expected to be implemented in parallel...
This class defines a logically grouped set of variables in the system.
Definition: variable.h:172
std::set< GhostingFunctor * >::const_iterator algebraic_ghosting_functors_end() const
End of range of algebraic ghosting functors.
Definition: dof_map.h:317
Storage for DofConstraint right hand sides for a particular problem.
Definition: dof_map.h:108
std::vector< SparseMatrix< Number > * > _matrices
Additional matrices handled by this object.
Definition: dof_map.h:1430
Storage for DofConstraint right hand sides for all adjoint problems.
Definition: dof_map.h:119
dof_id_type end_dof() const
Definition: dof_map.h:580
dof_id_type last_dof() const
Definition: dof_map.h:567
DofConstraints::const_iterator constraint_rows_end() const
Definition: dof_map.h:830
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:839
UniquePtr< DirichletBoundaries > _dirichlet_boundaries
Data structure containing Dirichlet functions.
Definition: dof_map.h:1626
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
Constrains the element matrix.
Definition: dof_map.h:1793
void stash_dof_constraints()
Definition: dof_map.h:833
dof_id_type n_old_dofs() const
Definition: dof_map.h:1193
OStreamProxy out
DofConstraintValueMap _primal_constraint_values
Definition: dof_map.h:1594
std::vector< Variable > _variables
The finite element type for each variable.
Definition: dof_map.h:1408
Order variable_order(const unsigned int c) const
Definition: dof_map.h:1677
DofConstraints _stashed_dof_constraints
Definition: dof_map.h:1592
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
A row of the Dof constraint matrix.
Definition: dof_map.h:88
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
Order
defines an enum for polynomial orders.
Definition: enum_order.h:32
dof_id_type _n_old_dfs
Total number of degrees of freedom on old dof objects.
Definition: dof_map.h:1567
std::set< GhostingFunctor * > _coupling_functors
The list of all GhostingFunctor objects to be used when coupling degrees of freedom in matrix sparsit...
Definition: dof_map.h:1523
UniquePtr< PeriodicBoundaries > _periodic_boundaries
Data structure containing periodic boundaries.
Definition: dof_map.h:1612
std::vector< dof_id_type > _end_df
Last DOF index (plus 1) on processor p.
Definition: dof_map.h:1440
dof_id_type n_SCALAR_dofs() const
Definition: dof_map.h:515
std::vector< dof_id_type > _first_df
First DOF index on processor p.
Definition: dof_map.h:1435
bool has_heterogenous_adjoint_constraints(const unsigned int qoi_num) const
Definition: dof_map.h:1744
Scalable allocator to be used in multithreaded code chunks which allocate a lot of dynamic memory...
The base class for defining periodic boundaries.
Defines an abstract dense vector base class for use in Finite Element-type computations.
Definition: dof_map.h:62
std::map< const Node *, Real, std::less< const Node * >, Threads::scalable_allocator< std::pair< const Node *const, Real > > > NodeConstraintRow
A row of the Node constraint mapping.
Definition: dof_map.h:136
MeshBase & _mesh
The mesh that system uses.
Definition: dof_map.h:1423
Defines a dense vector for use in Finite Element-type computations.
std::set< GhostingFunctor * >::const_iterator coupling_functors_end() const
End of range of coupling functors.
Definition: dof_map.h:281
Abstract base class to be used to add user-defined implicit degree of freedom couplings.
Definition: dof_map.h:190
void attach_extra_send_list_object(DofMap::AugmentSendList &asl)
Attach an object to populate the send_list with extra entries.
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:1687
void constrain_element_dyad_matrix(DenseVector< Number > &v, DenseVector< Number > &w, std::vector< dof_id_type > &row_dofs, bool asymmetric_constraint_rows=true) const
Constrains a dyadic element matrix B = v w&#39;.
Definition: dof_map.h:1811
const std::vector< dof_id_type > & get_n_nz() const
Definition: dof_map.h:403
Defines a dense matrix for use in Finite Element-type computations.
Definition: dof_map.h:64
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
The constraint matrix storage format.
Definition: dof_map.h:96
dof_id_type n_constrained_nodes() const
Definition: dof_map.h:739
Abstract base class to be used to add user-defined parallel degree of freedom couplings.
Definition: dof_map.h:207
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogenously constrains the numeric vector v, which represents an adjoint solution defined on the m...
Definition: dof_map.h:1820
dof_id_type last_dof(const processor_id_type proc) const
Definition: dof_map.h:560
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)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:64
dof_id_type _n_dfs
Total number of degrees of freedom.
Definition: dof_map.h:1554
NodeConstraints _node_constraints
Data structure containing DofObject constraints.
Definition: dof_map.h:1603
This class defines a coupling matrix.