27
27
#include "libmesh/tensor_value.h"
28
28
#include "libmesh/enum_elem_type.h"
29
29
#include "libmesh/quadrature_gauss.h"
30
+ #include "libmesh/libmesh_singleton.h"
30
31
31
32
namespace {
32
33
// Put this outside a templated class, so we only get 1 warning
@@ -40,14 +41,25 @@ namespace {
40
41
41
42
namespace libMesh
42
43
{
44
+ // ------------------------------------------------------------
45
+ // Whether we cache the node locations on the last element we computed on
46
+ // to try to avoid calling init_shape_functions and compute_shape_functions
47
+ static const bool * caching = nullptr ;
48
+
49
+ class CachingSetup : public Singleton ::Setup
50
+ {
51
+ private :
52
+ void setup () { caching = new bool (!on_command_line ("--disable-caching" )); }
53
+ public :
54
+ ~CachingSetup () { caching = nullptr ; }
55
+ } caching_setup ;
43
56
44
57
45
58
// ------------------------------------------------------------
46
59
// FE class members
47
60
template < unsigned int Dim , FEFamily T >
48
61
FE < Dim ,T > ::FE (const FEType & fet ) :
49
62
FEGenericBase < typename FEOutputType < T > ::type > (Dim ,fet ),
50
- caching (!libMesh ::on_command_line ("-- disable - caching ")),
51
63
last_side (INVALID_ELEM ),
52
64
last_edge (INVALID_ELEM )
53
65
{
@@ -227,7 +239,7 @@ void FE<Dim,T>::reinit(const Elem * elem,
227
239
}
228
240
}
229
241
230
- if (this -> shapes_need_reinit () && caching && !cached_nodes_still_fit )
242
+ if (this -> shapes_need_reinit () && * caching && !cached_nodes_still_fit )
231
243
{
232
244
cached_nodes .resize (elem -> n_nodes ());
233
245
for (auto n : elem -> node_index_range ())
0 commit comments