LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
check_jacobian_inverse_gramian.cc
1
9#include "check_jacobian_inverse_gramian.h"
10
11#include <gtest/gtest.h>
12
13#include <Eigen/Eigen>
14
16
18 const Eigen::MatrixXd &eval_points) {
19 const size_t num_points = eval_points.cols();
20 const size_t dim_local = geom.DimLocal();
21 const size_t dim_global = geom.DimGlobal();
22
23 Eigen::MatrixXd jacobians = geom.Jacobian(eval_points);
24 Eigen::MatrixXd jacInvGrams = geom.JacobianInverseGramian(eval_points);
25
26 EXPECT_EQ(jacInvGrams.rows(), dim_global)
27 << "JacobianInverseGramian has " << jacInvGrams.rows()
28 << " rows instead of " << dim_global;
29 EXPECT_EQ(jacInvGrams.cols(), num_points * dim_local)
30 << "JacobianInverseGramian has " << jacInvGrams.cols()
31 << " cols instead of " << num_points * dim_local;
32
33 for (int j = 0; j < num_points; ++j) {
34 Eigen::MatrixXd jacInvGram =
35 jacInvGrams.block(0, j * dim_local, dim_global, dim_local);
36 Eigen::MatrixXd jacobian =
37 jacobians.block(0, j * dim_local, dim_global, dim_local);
38
39 EXPECT_TRUE(jacInvGram.isApprox(
40 jacobian * (jacobian.transpose() * jacobian).inverse()))
41 << "JacobianInverseGramian incorrect at point " << eval_points.col(j);
42 }
43}
44
45} // namespace lf::geometry::test_utils
Interface class for shape information on a mesh cell in the spirit of parametric finite element metho...
virtual dim_t DimLocal() const =0
Dimension of the domain of this mapping.
virtual dim_t DimGlobal() const =0
Dimension of the image of this mapping.
virtual Eigen::MatrixXd JacobianInverseGramian(const Eigen::MatrixXd &local) const =0
Evaluate the Jacobian * Inverse Gramian ( ) simultaneously at numPoints.
virtual Eigen::MatrixXd Jacobian(const Eigen::MatrixXd &local) const =0
Evaluate the jacobian of the mapping simultaneously at numPoints points.
Defines the Geometry::test_utils module and provides a number of test functions to check geometry obj...
void checkJacobianInverseGramian(const lf::geometry::Geometry &geom, const Eigen::MatrixXd &eval_points)
Checks if JacobianInverseGramian() is implemented correctly assuming that Jacobian() is correct.