38
38
#include " libmesh/libmesh_logging.h"
39
39
#include " libmesh/enum_elem_type.h"
40
40
#include " libmesh/mesh_subdivision_support.h"
41
+ #include " libmesh/dof_map_base.h"
41
42
42
43
// TIMPI includes
43
44
#include " timpi/parallel_implementation.h"
@@ -68,7 +69,7 @@ class PeriodicBoundaryBase;
68
69
class PeriodicBoundaries ;
69
70
class System ;
70
71
class NonlinearImplicitSystem ;
71
- class StaticCondensation ;
72
+ class StaticCondensationDofMap ;
72
73
template <typename T> class DenseVectorBase ;
73
74
template <typename T> class DenseVector ;
74
75
template <typename T> class DenseMatrix ;
@@ -175,8 +176,8 @@ class NodeConstraints : public std::map<const Node *,
175
176
* \date 2002-2007
176
177
* \brief Manages the degrees of freedom (DOFs) in a simulation.
177
178
*/
178
- class DofMap : public ReferenceCountedObject <DofMap> ,
179
- public ParallelObject
179
+ class DofMap : public DofMapBase ,
180
+ public ReferenceCountedObject<DofMap>
180
181
{
181
182
public:
182
183
@@ -594,10 +595,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
594
595
*/
595
596
const VariableGroup & variable_group (const unsigned int c) const ;
596
597
597
- /* *
598
- * \returns The variable description object for variable \p c.
599
- */
600
- const Variable & variable (const unsigned int c) const ;
598
+ const Variable & variable (const unsigned int c) const override ;
601
599
602
600
/* *
603
601
* \returns The approximation order for variable \p c.
@@ -627,12 +625,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
627
625
unsigned int n_variable_groups () const
628
626
{ return cast_int<unsigned int >(_variable_groups.size ()); }
629
627
630
- /* *
631
- * \returns The number of variables in the global solution vector. Defaults
632
- * to 1, should be 1 for a scalar equation, 3 for 2D incompressible Navier
633
- * Stokes (u,v,p), etc...
634
- */
635
- unsigned int n_variables () const
628
+ unsigned int n_variables () const override
636
629
{ return cast_int<unsigned int >(_variables.size ()); }
637
630
638
631
/* *
@@ -667,11 +660,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
667
660
return (this ->has_blocked_representation () ? this ->n_variables () : 1 );
668
661
}
669
662
670
- /* *
671
- * \returns The total number of degrees of freedom in the problem.
672
- */
673
- dof_id_type n_dofs () const { return _n_dfs; }
674
-
663
+ using DofMapBase::n_dofs;
675
664
/* *
676
665
* \returns The total number of degrees of freedom for a particular
677
666
* variable \p vn.
@@ -688,12 +677,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
688
677
*/
689
678
dof_id_type n_SCALAR_dofs () const { return _n_SCALAR_dofs; }
690
679
691
- /* *
692
- * \returns The number of degrees of freedom on this processor.
693
- */
694
- dof_id_type n_local_dofs () const
695
- { return this ->n_dofs_on_processor (this ->processor_id ()); }
696
-
680
+ using DofMapBase::n_local_dofs;
697
681
/* *
698
682
* \returns The number of degrees of freedom on this processor for a
699
683
* particular variable \p vn. This is an O(N) operation on serialized or
@@ -706,15 +690,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
706
690
return n;
707
691
}
708
692
709
- /* *
710
- * \returns The number of degrees of freedom on partition \p proc.
711
- */
712
- dof_id_type n_dofs_on_processor (const processor_id_type proc) const
713
- {
714
- libmesh_assert_less (proc, _first_df.size ());
715
- return cast_int<dof_id_type>(_end_df[proc] - _first_df[proc]);
716
- }
717
-
718
693
/* *
719
694
* \returns The number of degrees of freedom on each partition for a
720
695
* particular variable \p vn.
@@ -726,39 +701,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
726
701
return n_local_dofs;
727
702
}
728
703
729
- /* *
730
- * \returns The first dof index that is local to partition \p proc.
731
- */
732
- dof_id_type first_dof (const processor_id_type proc) const
733
- { libmesh_assert_less (proc, _first_df.size ()); return _first_df[proc]; }
734
-
735
- dof_id_type first_dof () const
736
- { return this ->first_dof (this ->processor_id ()); }
737
-
738
- #ifdef LIBMESH_ENABLE_AMR
739
- /* *
740
- * \returns The first old dof index that is local to partition \p proc.
741
- */
742
- dof_id_type first_old_dof (const processor_id_type proc) const
743
- { libmesh_assert_less (proc, _first_old_df.size ()); return _first_old_df[proc]; }
744
-
745
- dof_id_type first_old_dof () const
746
- { return this ->first_old_dof (this ->processor_id ()); }
747
-
748
- #endif // LIBMESH_ENABLE_AMR
749
-
750
- /* *
751
- * \returns The first dof index that is after all indices local to
752
- * processor \p proc.
753
- *
754
- * Analogous to the end() member function of STL containers.
755
- */
756
- dof_id_type end_dof (const processor_id_type proc) const
757
- { libmesh_assert_less (proc, _end_df.size ()); return _end_df[proc]; }
758
-
759
- dof_id_type end_dof () const
760
- { return this ->end_dof (this ->processor_id ()); }
761
-
762
704
/* *
763
705
* \returns The processor id that owns the dof index \p dof
764
706
*/
@@ -769,25 +711,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
769
711
return cast_int<processor_id_type>(ub - _end_df.begin ());
770
712
}
771
713
772
- #ifdef LIBMESH_ENABLE_AMR
773
- /* *
774
- * \returns The first old dof index that is after all indices local
775
- * to processor \p proc.
776
- *
777
- * Analogous to the end() member function of STL containers.
778
- */
779
- dof_id_type end_old_dof (const processor_id_type proc) const
780
- { libmesh_assert_less (proc, _end_old_df.size ()); return _end_old_df[proc]; }
781
-
782
- dof_id_type end_old_dof () const
783
- { return this ->end_old_dof (this ->processor_id ()); }
784
-
785
- #endif // LIBMESH_ENABLE_AMR
786
-
787
- /* *
788
- * Fills the vector \p di with the global degree of freedom indices
789
- * for the element.
790
- */
791
714
void dof_indices (const Elem * const elem,
792
715
std::vector<dof_id_type> & di) const ;
793
716
@@ -799,7 +722,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
799
722
void dof_indices (const Elem * const elem,
800
723
std::vector<dof_id_type> & di,
801
724
const unsigned int vn,
802
- int p_level = -12345 ) const ;
725
+ int p_level = -12345 ) const override ;
803
726
804
727
/* *
805
728
* Retrieves degree of freedom indices for a given \p elem and then performs actions for these
@@ -851,7 +774,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
851
774
*/
852
775
void dof_indices (const Node * const node,
853
776
std::vector<dof_id_type> & di,
854
- const unsigned int vn) const ;
777
+ const unsigned int vn) const override ;
855
778
856
779
/* *
857
780
* Appends to the vector \p di the global degree of freedom indices
@@ -972,6 +895,18 @@ class DofMap : public ReferenceCountedObject<DofMap>,
972
895
const MeshBase & mesh,
973
896
unsigned int var_num) const ;
974
897
898
+ /* *
899
+ * If T == dof_id_type, counts, if T == std::vector<dof_id_type>, fills an
900
+ * array of, those dof indices which belong to the given variable number and
901
+ * live on the current processor.
902
+ */
903
+ template <typename T,
904
+ std::enable_if_t <std::is_same_v<T, dof_id_type> ||
905
+ std::is_same_v<T, std::vector<dof_id_type>>,
906
+ int > = 0 >
907
+ void local_variable_indices (T & idx, unsigned int var_num) const
908
+ { this ->local_variable_indices (idx, this ->_mesh , var_num); }
909
+
975
910
#ifdef LIBMESH_ENABLE_CONSTRAINTS
976
911
977
912
// --------------------------------------------------------------------
@@ -1624,11 +1559,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
1624
1559
std::vector<dof_id_type> & di,
1625
1560
const unsigned int vn = libMesh::invalid_uint) const ;
1626
1561
1627
- /* *
1628
- * \returns The total number of degrees of freedom on old_dof_objects
1629
- */
1630
- dof_id_type n_old_dofs () const { return _n_old_dfs; }
1631
-
1632
1562
#endif // LIBMESH_ENABLE_AMR
1633
1563
1634
1564
/* *
@@ -1655,7 +1585,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
1655
1585
* Free all new memory associated with the object, but restore its
1656
1586
* original state, with the mesh pointer and any default ghosting.
1657
1587
*/
1658
- void clear ();
1588
+ virtual void clear () override ;
1659
1589
1660
1590
/* *
1661
1591
* Prints summary info about the sparsity bandwidth and constraints.
@@ -1702,7 +1632,8 @@ class DofMap : public ReferenceCountedObject<DofMap>,
1702
1632
* constraints or sufficiently many user constraints.
1703
1633
*/
1704
1634
std::unique_ptr<SparsityPattern::Build> build_sparsity (const MeshBase & mesh,
1705
- bool calculate_constrained = false ) const ;
1635
+ bool calculate_constrained = false ,
1636
+ bool use_condensed_system = false ) const ;
1706
1637
1707
1638
/* *
1708
1639
* Describe whether the given variable group should be p-refined. If this API is not called with
@@ -1729,18 +1660,18 @@ class DofMap : public ReferenceCountedObject<DofMap>,
1729
1660
/* *
1730
1661
* Add a static condensation class
1731
1662
*/
1732
- void add_static_condensation (const StaticCondensation & sc) { _sc = ≻ }
1663
+ void create_static_condensation (const MeshBase & mesh, System & system);
1733
1664
1734
1665
/* *
1735
1666
* Checks whether we have static condensation
1736
1667
*/
1737
- bool has_static_condensation () const { return _sc; }
1668
+ bool has_static_condensation () const { return _sc. get () ; }
1738
1669
1739
1670
/* *
1740
1671
* @returns the static condensation class. This should have been already added with a call to \p
1741
1672
* add_static_condensation()
1742
1673
*/
1743
- const StaticCondensation & get_static_condensation () const ;
1674
+ StaticCondensationDofMap & get_static_condensation ();
1744
1675
1745
1676
private:
1746
1677
@@ -2040,16 +1971,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
2040
1971
*/
2041
1972
std::vector<SparseMatrix<Number> * > _matrices;
2042
1973
2043
- /* *
2044
- * First DOF index on processor \p p.
2045
- */
2046
- std::vector<dof_id_type> _first_df;
2047
-
2048
- /* *
2049
- * Last DOF index (plus 1) on processor \p p.
2050
- */
2051
- std::vector<dof_id_type> _end_df;
2052
-
2053
1974
/* *
2054
1975
* First DOF index for SCALAR variable v, or garbage for non-SCALAR
2055
1976
* variable v
@@ -2152,11 +2073,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
2152
2073
*/
2153
2074
std::unique_ptr<SparsityPattern::Build> _sp;
2154
2075
2155
- /* *
2156
- * Total number of degrees of freedom.
2157
- */
2158
- dof_id_type _n_dfs;
2159
-
2160
2076
/* *
2161
2077
* The total number of SCALAR dofs associated to
2162
2078
* all SCALAR variables.
@@ -2165,21 +2081,6 @@ class DofMap : public ReferenceCountedObject<DofMap>,
2165
2081
2166
2082
#ifdef LIBMESH_ENABLE_AMR
2167
2083
2168
- /* *
2169
- * Total number of degrees of freedom on old dof objects
2170
- */
2171
- dof_id_type _n_old_dfs;
2172
-
2173
- /* *
2174
- * First old DOF index on processor \p p.
2175
- */
2176
- std::vector<dof_id_type> _first_old_df;
2177
-
2178
- /* *
2179
- * Last old DOF index (plus 1) on processor \p p.
2180
- */
2181
- std::vector<dof_id_type> _end_old_df;
2182
-
2183
2084
/* *
2184
2085
* First old DOF index for SCALAR variable v, or garbage for
2185
2086
* non-SCALAR variable v
@@ -2256,7 +2157,7 @@ class DofMap : public ReferenceCountedObject<DofMap>,
2256
2157
bool _verify_dirichlet_bc_consistency;
2257
2158
2258
2159
// / Static condensation class
2259
- const StaticCondensation * _sc;
2160
+ std::unique_ptr<StaticCondensationDofMap> _sc;
2260
2161
};
2261
2162
2262
2163
@@ -2780,7 +2681,7 @@ void DofMap::dof_indices (const Elem * const elem,
2780
2681
}
2781
2682
2782
2683
inline
2783
- const StaticCondensation & DofMap::get_static_condensation () const
2684
+ StaticCondensationDofMap & DofMap::get_static_condensation ()
2784
2685
{
2785
2686
libmesh_assert (_sc);
2786
2687
return *_sc;
0 commit comments