]> https://gitweb.dealii.org/ - dealii.git/commitdiff
DerivativeForm: add the first fundamental form. 18579/head
authorDavid Wells <drwells@email.unc.edu>
Mon, 23 Jun 2025 15:21:30 +0000 (11:21 -0400)
committerDavid Wells <drwells@email.unc.edu>
Wed, 25 Jun 2025 01:04:25 +0000 (21:04 -0400)
include/deal.II/base/derivative_form.h

index d57bb2724a959a7800f8b6c413448cf6e65bf043..b17047e64db6fb74a53469d7fd5229ec2fa24f50 100644 (file)
@@ -165,6 +165,16 @@ public:
   DerivativeForm<1, dim, spacedim, Number>
   covariant_form() const;
 
+
+  /**
+   * Compute the first fundamental form. This is the tensor of dot products of
+   * the columns of the current object.
+   *
+   * @note This function is only defined for `order == 1`.
+   */
+  Tensor<2, dim, Number>
+  first_fundamental_form() const;
+
   /**
    * Determine an estimate for the memory consumption (in bytes) of this
    * object.
@@ -387,18 +397,29 @@ DerivativeForm<order, dim, spacedim, Number>::determinant() const
   else
     {
       Assert(spacedim > dim, ExcMessage("Only for spacedim>dim."));
-      const DerivativeForm<1, spacedim, dim, Number> DF_t = this->transpose();
-      Tensor<2, dim, Number> G; // First fundamental form
-      for (unsigned int i = 0; i < dim; ++i)
-        for (unsigned int j = 0; j < dim; ++j)
-          G[i][j] = DF_t[i] * DF_t[j];
-
-      return (std::sqrt(dealii::determinant(G)));
+      return (std::sqrt(dealii::determinant(first_fundamental_form())));
     }
 }
 
 
 
+template <int order, int dim, int spacedim, typename Number>
+inline Tensor<2, dim, Number>
+DerivativeForm<order, dim, spacedim, Number>::first_fundamental_form() const
+{
+  Assert(order == 1, ExcMessage("Only for order == 1."));
+  const DerivativeForm<1, spacedim, dim, Number> DF_t = this->transpose();
+
+  Tensor<2, dim, Number> G;
+  for (unsigned int i = 0; i < dim; ++i)
+    for (unsigned int j = 0; j < dim; ++j)
+      G[i][j] = DF_t[i] * DF_t[j];
+
+  return G;
+}
+
+
+
 template <int order, int dim, int spacedim, typename Number>
 inline DerivativeForm<1, dim, spacedim, Number>
 DerivativeForm<order, dim, spacedim, Number>::covariant_form() const
@@ -411,13 +432,7 @@ DerivativeForm<order, dim, spacedim, Number>::covariant_form() const
     }
   else
     {
-      const DerivativeForm<1, spacedim, dim, Number> DF_t = this->transpose();
-      Tensor<2, dim, Number> G; // First fundamental form
-      for (unsigned int i = 0; i < dim; ++i)
-        for (unsigned int j = 0; j < dim; ++j)
-          G[i][j] = DF_t[i] * DF_t[j];
-
-      return (this->times_T_t(invert(G)));
+      return (this->times_T_t(invert(first_fundamental_form())));
     }
 }
 

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.