LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
mesh_function_whitney_two.h
1#ifndef HLDO_SPHERE_MESH_FUNCTION_WHITNEY_TWO_H
2#define HLDO_SPHERE_MESH_FUNCTION_WHITNEY_TWO_H
3/*
4 * @file mesh_function_whitney_two.h
5 */
6
7#include <lf/uscalfe/uscalfe.h>
8
10
17template <typename SCALAR>
19 public:
34 MeshFunctionWhitneyTwo(const Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>& mu,
35 const std::shared_ptr<const lf::mesh::Mesh> mesh)
36 : mu_(mu), mesh_(mesh) {
37 // make sure mu has the same size as number of cells
38 lf::base::size_type n = mesh->NumEntities(0);
39 int mu_size = mu.size();
40 LF_VERIFY_MSG(
41 n == mu_size,
42 "Not the right number of basis expansion coefficiants in mu expected: "
43 << n << " given: " << mu_size);
44 };
45
71 std::vector<SCALAR> operator()(const lf::mesh::Entity& e,
72 const Eigen::MatrixXd& local) const {
73 // Only triangles are supported
74 LF_VERIFY_MSG(e.RefEl() == lf::base::RefEl::kTria(),
75 "Unsupported cell type " << e.RefEl());
76
77 // accoring to the lehrfem documentation the mesh index corresponds to the
78 // dofhandler if all basis function are associated with entities off the
79 // same codomain
80 lf::base::size_type global_index = mesh_->Index(e);
81
82 std::vector<SCALAR> vals(local.cols());
83 for (int i = 0; i < local.cols(); i++) {
84 vals[i] = mu_(global_index);
85 }
86
87 return vals;
88 }
89
90 private:
91 const Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>& mu_;
92 const std::shared_ptr<const lf::mesh::Mesh> mesh_;
93};
94
95} // namespace projects::hldo_sphere::post_processing
96#endif // HLDO_SPHERE_MESH_FUNCTION_WHITNEY_TWO_H
static constexpr RefEl kTria()
Returns the reference triangle.
Definition: ref_el.h:158
Interface class representing a topological entity in a cellular complex
Definition: entity.h:39
virtual base::RefEl RefEl() const =0
Describes the reference element type of this entity.
Provides Mesh Function for Whitney two basis expansion coefficients.
MeshFunctionWhitneyTwo(const Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > &mu, const std::shared_ptr< const lf::mesh::Mesh > mesh)
basic constructor
unsigned int size_type
general type for variables related to size of arrays
Definition: base.h:24
Postprocessing such as computing norms and Mesh Functions and plot scripts.