]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use Lazy 16532/head
authorMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Mon, 5 Feb 2024 12:03:50 +0000 (13:03 +0100)
committerMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Mon, 5 Feb 2024 17:37:29 +0000 (18:37 +0100)
include/deal.II/base/lazy.h
source/non_matching/quadrature_generator.cc

index 3e8715916d174c64ebf37b7b9f1dd25455ce78e3..712f229e47eb729e939c886dcbcdf3c8cade3274 100644 (file)
@@ -185,7 +185,7 @@ public:
    * Return a reference to the contained object.
    *
    * @pre The object has been initialized with a call to
-   * ensure_initialized() or value_or_initialized().
+   * ensure_initialized() or value_or_initialize().
    */
   T &
   value();
index 2af704b2e22f39187ec903c81adbdb2b62117e4e..7e9ae0dbb312824a4a2bb6defecd75d9e71c1953 100644 (file)
@@ -1473,6 +1473,11 @@ namespace NonMatching
          * Check whether the shape functions are linear.
          */
         bool polynomials_are_hat_functions;
+
+        /**
+         * Linear FE_Q object for FE_Q_iso_Q1 path.
+         */
+        Lazy<std::unique_ptr<FE_Q<dim>>> fe_q1;
       };
 
 
@@ -1518,15 +1523,18 @@ namespace NonMatching
 
             const FiniteElement<dim> *fe = &dof_handler_cell->get_fe();
 
-            const FE_Q<dim> fe_q1(1);
-
             if (const FE_Q_iso_Q1<dim> *fe_q_iso_q1 =
                   dynamic_cast<const FE_Q_iso_Q1<dim> *>(
                     &dof_handler_cell->get_fe()))
               {
                 this->n_subdivisions_per_line = fe_q_iso_q1->get_degree();
-                fe                            = &fe_q1;
-                local_dof_values_subcell.resize(fe_q1.n_dofs_per_cell());
+
+                fe = fe_q1
+                       .value_or_initialize(
+                         []() { return std::make_unique<FE_Q<dim>>(1); })
+                       .get();
+                local_dof_values_subcell.resize(
+                  fe_q1.value()->n_dofs_per_cell());
               }
             else
               this->n_subdivisions_per_line = numbers::invalid_unsigned_int;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.