LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
whitney_one_curl_curl_matrix_provider.cc
1#include "whitney_one_curl_curl_matrix_provider.h"
2
3#include <lf/uscalfe/lagr_fe.h>
4
5#include <cmath>
6#include <iomanip>
7#include <iostream>
8
10
12 const lf::mesh::Entity &entity) const {
13 // Only triangles are supported
14 LF_VERIFY_MSG(entity.RefEl() == lf::base::RefEl::kTria(),
15 "Unsupported cell type " << entity.RefEl());
16
17 // Get the geometry of the entity
18 const auto *geom = entity.Geometry();
19
20 // Compute the global vertex coordinates
21 Eigen::MatrixXd vertices = geom->Global(entity.RefEl().NodeCoords());
22
23 // compute the orientations
24 auto edgeOrientations = entity.RelativeOrientations();
25 Eigen::VectorXd s(3);
26 for (int i = 0; i < 3; i++) {
27 s(i) = lf::mesh::to_sign(edgeOrientations[i]);
28 }
29
30 // fill the element matrix
31 Eigen::MatrixXd elem_mat = Eigen::MatrixXd::Ones(3, 3);
32 for (int i = 0; i < 3; i++) {
33 for (int j = 0; j < 3; j++) {
34 elem_mat(i, j) = s(i) * s(j);
35 }
36 }
37
38 elem_mat *= 1 / lf::geometry::Volume(*geom);
39
40 return elem_mat;
41}
42
43} // namespace projects::hldo_sphere::assemble
const Eigen::MatrixXd & NodeCoords() const
Get the coordinates of the nodes of this reference element.
Definition: ref_el.h:238
static constexpr RefEl kTria()
Returns the reference triangle.
Definition: ref_el.h:158
virtual Eigen::MatrixXd Global(const Eigen::MatrixXd &local) const =0
Map a number of points in local coordinates into the global coordinate system.
Interface class representing a topological entity in a cellular complex
Definition: entity.h:39
virtual const geometry::Geometry * Geometry() const =0
Describes the geometry of this entity.
virtual nonstd::span< const Orientation > RelativeOrientations() const =0
return span of relative orientations of sub-entities of the next higher co-dimension.
virtual base::RefEl RefEl() const =0
Describes the reference element type of this entity.
Eigen::MatrixXd Eval(const lf::mesh::Entity &entity) const
Compute the element matrix for some triangle of a mesh.
double Volume(const Geometry &geo)
Compute the (approximate) volume (area) of a shape.
int to_sign(Orientation o)
Definition: entity.cc:7
Collection of matrix and vector element providers.
Definition: assemble.h:26