1#include "piecewise_const_element_matrix_provider.h"
3#include <lf/uscalfe/lagr_fe.h>
15 : sigma_(sigma), boundary_(boundary), modified_(modified) {}
20 const auto *geom = entity.
Geometry();
24 const Eigen::Matrix<double, 2, 3> normals =
28 const Eigen::MatrixXd ref_grads =
31 const Eigen::MatrixXd J_inv_trans =
32 geom->JacobianInverseGramian(Eigen::VectorXd::Zero(2));
33 const Eigen::Matrix<double, 2, 3> grads = J_inv_trans * ref_grads;
34 Eigen::Matrix<double, 2, 3> basis_funct;
35 basis_funct << grads.row(1), -grads.row(0);
37 Eigen::MatrixXd elem_mat = Eigen::MatrixXd::Zero(6, 6);
39 elem_mat.block(0, 0, 3, 3).setZero();
42 for (
int basis_func_idx = 0; basis_func_idx < 3; ++basis_func_idx) {
43 for (
int edge_idx = 0; edge_idx < 3; ++edge_idx) {
45 t << -normals(1, edge_idx), normals(0, edge_idx);
46 elem_mat(edge_idx + 3, basis_func_idx) =
47 basis_funct.col(basis_func_idx).transpose() * t;
50 elem_mat.block(0, 3, 3, 3) = elem_mat.block(3, 0, 3, 3).transpose();
52 for (
int edge_idx = 0; edge_idx < 3; ++edge_idx) {
53 const auto &edge = *edges[edge_idx];
54 elem_mat(edge_idx + 3, edge_idx + 3) = -1 /
sigma_;
56 elem_mat(edge_idx + 3, edge_idx + 3) /=
64 elem_mat(edge_idx + 3, edge_idx + 3) /= 2;
const Eigen::MatrixXd & NodeCoords() const
Get the coordinates of the nodes of this reference element.
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
virtual const geometry::Geometry * Geometry() const =0
Describes the geometry of this entity.
virtual nonstd::span< const Entity *const > SubEntities(unsigned rel_codim) const =0
Return all sub entities of this entity that have the given codimension (w.r.t. this entity!...
virtual base::RefEl RefEl() const =0
Describes the reference element type of this entity.
Linear Lagrange finite element on triangular reference element.
Eigen::Matrix< SCALAR, Eigen::Dynamic, Eigen::Dynamic > GradientsReferenceShapeFunctions(const Eigen::MatrixXd &refcoords) const override
Computation of the gradients of all reference shape functions in a number of points.
PiecewiseConstElementMatrixProvider(double sigma, const lf::mesh::utils::MeshDataSet< bool > &boundary, bool modified=false)
Constructor.
const lf::mesh::utils::MeshDataSet< bool > & boundary_
Eigen::MatrixXd Eval(const lf::mesh::Entity &entity) const
Compute the element matrix for some entity of a mesh.
double Volume(const Geometry &geo)
Compute the (approximate) volume (area) of a shape.
Eigen::Matrix< double, 2, 3 > computeOutwardNormals(const lf::mesh::Entity &entity)
Compute the outward pointing normals of a triangle.