LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
dirac_operator.h
1#ifndef HLDO_SPHERE_OPERATORS_DIRAC_OPERATOR_H
2#define HLDO_SPHERE_OPERATORS_DIRAC_OPERATOR_H
3
8#include <lf/assemble/assembler.h>
9#include <lf/assemble/coomatrix.h>
10#include <lf/assemble/dofhandler.h>
11#include <lf/mesh/entity.h>
12#include <lf/mesh/hybrid2d/mesh.h>
13#include <lf/mesh/hybrid2d/mesh_factory.h>
14#include <lf/mesh/mesh_interface.h>
15#include <lf/quad/quad.h>
16#include <load_vector_provider.h>
17#include <rot_whitney_one_div_matrix_provider.h>
18#include <sphere_triag_mesh_builder.h>
19#include <whitney_one_grad_matrix_provider.h>
20#include <whitney_one_vector_provider.h>
21#include <whitney_two_vector_provider.h>
22
23#include <Eigen/Dense>
24#include <cmath>
25#include <iomanip>
26#include <iostream>
27
28namespace projects::hldo_sphere {
29
30namespace operators {
31
32using complex = std::complex<double>;
33
61 public:
68 DiracOperator() : coo_matrix_(lf::assemble::COOMatrix<complex>(1, 1)) {
69 // create mesh factory for basic mesh only because empty values do not
70 // complile
71 std::unique_ptr<lf::mesh::MeshFactory> factory =
72 std::make_unique<lf::mesh::hybrid2d::MeshFactory>(3);
73 std::shared_ptr<projects::hldo_sphere::mesh::SphereTriagMeshBuilder>
74 sphere = std::make_shared<
76 std::move(factory));
77 sphere->setRefinementLevel(0);
78 sphere->setRadius(1);
79 mesh_p_ = sphere->Build();
80
81 // create basic function everyting 0 valued by default
82 auto f_0 = [](Eigen::Matrix<double, 3, 1> x) -> complex { return 0; };
83 auto f_1 =
84 [](Eigen::Matrix<double, 3, 1> x) -> Eigen::Matrix<complex, 3, 1> {
85 return Eigen::Matrix<complex, 3, 1>::Zero();
86 };
87 auto f_2 = [](Eigen::Matrix<double, 3, 1> x) -> complex { return 0; };
88 f0_ = f_0;
89 f1_ = f_1;
90 f2_ = f_2;
91 }
92
100 void Compute();
101
109 void SetMesh(std::shared_ptr<const lf::mesh::Mesh> mesh_p);
110
118 std::function<complex(const Eigen::Matrix<double, 3, 1> &)> f0,
119 std::function<
120 Eigen::Matrix<complex, 3, 1>(const Eigen::Matrix<double, 3, 1> &)>
121 f1,
122 std::function<complex(const Eigen::Matrix<double, 3, 1> &)> f2) {
123 f0_ = f0;
124 f1_ = f1;
125 f2_ = f2;
126 }
127
137 Eigen::Matrix<complex, Eigen::Dynamic, 1> GetLoadVector() { return phi_; }
138
149
150 private:
151 std::shared_ptr<const lf::mesh::Mesh> mesh_p_;
152 std::function<complex(const Eigen::Matrix<double, 3, 1> &)> f0_;
153 std::function<Eigen::Matrix<complex, 3, 1>(
154 const Eigen::Matrix<double, 3, 1> &)>
156 std::function<complex(const Eigen::Matrix<double, 3, 1> &)> f2_;
158 Eigen::Matrix<complex, Eigen::Dynamic, 1> phi_;
159};
160
161} // namespace operators
162
163} // namespace projects::hldo_sphere
164
165#endif // HLDO_SPHERE_OPERATORS_WHITNEY_ONE_HODGE_LAPLACE_H
void setRefinementLevel(lf::base::size_type n)
Set the refinement level.
Computes the Galerkin LSE for the Dirac Operator and the load vector.
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f0_
void SetMesh(std::shared_ptr< const lf::mesh::Mesh > mesh_p)
Sets the mesh and creates dof_handler.
std::shared_ptr< const lf::mesh::Mesh > mesh_p_
Eigen::Matrix< complex, Eigen::Dynamic, 1 > phi_
lf::assemble::COOMatrix< complex > GetGalerkinMatrix()
returns the Galerkin Matrix
Eigen::Matrix< complex, Eigen::Dynamic, 1 > GetLoadVector()
returns the Loadvector
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f2_
std::function< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f1_
void SetLoadFunctions(std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f0, std::function< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f1, std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f2)
Sets the load functions.
void Compute()
Computes the Galerkin LSE.
lf::assemble::COOMatrix< complex > coo_matrix_
DiracOperator()
Constructor creates basic mesh (Octaeder with radius 1.0) and zero valued functions f.
Definition: assemble.h:30
std::complex< double > complex
Implementation of the thesis Hogde Laplacians and Dirac Operators on the surface of the 3-Sphere.
Definition: assemble.h:15