From: David Wells Date: Mon, 23 Jun 2025 15:21:30 +0000 (-0400) Subject: DerivativeForm: add the first fundamental form. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b5ae41332b4acebfcd56ec6ff74581c4882d947;p=dealii.git DerivativeForm: add the first fundamental form. --- diff --git a/include/deal.II/base/derivative_form.h b/include/deal.II/base/derivative_form.h index d57bb2724a..b17047e64d 100644 --- a/include/deal.II/base/derivative_form.h +++ b/include/deal.II/base/derivative_form.h @@ -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::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 +inline Tensor<2, dim, Number> +DerivativeForm::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 inline DerivativeForm<1, dim, spacedim, Number> DerivativeForm::covariant_form() const @@ -411,13 +432,7 @@ DerivativeForm::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()))); } }