1#include "dirac_operator_source_problem.h"
8 : coo_matrix_(
lf::assemble::COOMatrix<
complex>(1, 1)) {
10 std::unique_ptr<lf::mesh::MeshFactory> factory =
11 std::make_unique<lf::mesh::hybrid2d::MeshFactory>(3);
13 std::shared_ptr<projects::hldo_sphere::mesh::SphereTriagMeshBuilder> sphere =
14 std::make_shared<projects::hldo_sphere::mesh::SphereTriagMeshBuilder>(
16 sphere->setRefinementLevel(0);
23 phi_ = Eigen::Matrix<complex, Eigen::Dynamic, 1>(1);
25 mu_ = Eigen::Matrix<complex, Eigen::Dynamic, 1>(1);
28 auto f_0 = [](Eigen::Matrix<double, 3, 1> x) ->
complex {
return 0; };
29 auto f_1 = [](Eigen::Matrix<double, 3, 1> x) -> Eigen::Matrix<complex, 3, 1> {
30 return Eigen::Matrix<complex, 3, 1>::Zero();
32 auto f_2 = [](Eigen::Matrix<double, 3, 1> x) ->
complex {
return 0; };
48 Eigen::Matrix<complex, Eigen::Dynamic, 1> phi =
67 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<complex>>(
68 0, dof_handler_zero, dof_handler_zero, mass_matrix_provider_zero,
71 for (Eigen::Triplet<complex> triplet : coo_mass_mat_zero.
triplets()) {
72 int col = triplet.col();
73 int row = triplet.row();
74 complex val = std::complex<double>(0., 1.) *
k_ * triplet.value();
80 mass_matrix_provider_one;
87 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<complex>>(
88 0, dof_handler_one, dof_handler_one, mass_matrix_provider_one,
91 for (Eigen::Triplet<complex> triplet : coo_mass_mat_one.
triplets()) {
92 int col = triplet.col() + n_dofs_zero;
93 int row = triplet.row() + n_dofs_zero;
94 complex val = std::complex<double>(0., 1.) *
k_ * triplet.value();
100 mass_matrix_provider_two;
107 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<complex>>(
108 0, dof_handler_two, dof_handler_two, mass_matrix_provider_two,
111 for (Eigen::Triplet<complex> triplet : coo_mass_mat_two.
triplets()) {
114 int col = triplet.col() + n_dofs_zero + n_dofs_one;
115 int row = triplet.row() + n_dofs_zero + n_dofs_one;
116 complex val = std::complex<double>(0., 1.) *
k_ * triplet.value();
124 Eigen::SparseLU<Eigen::SparseMatrix<complex>> solver;
126 sparse_mat.makeCompressed();
127 solver.analyzePattern(sparse_mat);
128 solver.factorize(sparse_mat);
129 if (solver.info() != Eigen::Success) {
130 throw std::runtime_error(
"Could not decompose the matrix");
137 std::shared_ptr<const lf::mesh::Mesh> mesh_p) {
142 "Mesh must be Triangular, unsupported cell " << tria->
RefEl());
146 LF_ASSERT_MSG(mesh_p->DimWorld() == 3,
147 "World Dimension must be 3 but is" << mesh_p->DimWorld());
155 LF_ASSERT_MSG(index < 3 && index >= 0,
156 "Index must be in {0,1,2}, given " << index);
160 n(0) =
mesh_p_->NumEntities(2);
162 n(1) =
mesh_p_->NumEntities(1);
164 n(2) =
mesh_p_->NumEntities(0);
166 return mu_.segment(s(index), n(index)).real();
void setZero()
Erase all entries of the matrix.
Eigen::SparseMatrix< Scalar > makeSparse() const
Create an Eigen::SparseMatrix out of the COO format.
TripletVec & triplets()
Gives access to the vector of triplets.
void AddToEntry(gdof_idx_t i, gdof_idx_t j, SCALAR increment)
Add a value to the specified entry.
A general (interface) class for DOF handling, see Lecture Document Paragraph 2.7.4....
virtual size_type NumDofs() const =0
total number of dof's handled by the object
static constexpr RefEl kSegment()
Returns the (1-dimensional) reference segment.
constexpr RefEl(RefElType type) noexcept
Create a RefEl from a lf::base::RefElType enum.
static constexpr RefEl kPoint()
Returns the (0-dimensional) reference point.
static constexpr RefEl kTria()
Returns the reference triangle.
Interface class representing a topological entity in a cellular complex
Element Matrix Provider for the mass matrix using picewise linear barycentric basis functions.
Element matrix provider for the Whitney one mass matrix that is the dot product of two Whitney one ba...
Element matrix provider for the bilinear form with cellwise constant basis functions.
Computes the Galerkin LSE for the Dirac Operator and the load vector.
void SetMesh(std::shared_ptr< const lf::mesh::Mesh > mesh_p)
Sets the mesh and creates dof_handler.
lf::assemble::COOMatrix< complex > GetGalerkinMatrix()
returns the Galerkin Matrix
Eigen::Matrix< complex, Eigen::Dynamic, 1 > GetLoadVector()
returns the Loadvector
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_
void Compute()
Computes the Galerkin LSE for the dirac operator source problem.
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f2_
Eigen::Matrix< complex, Eigen::Dynamic, 1 > mu_
Eigen::Matrix< double, Eigen::Dynamic, 1 > GetMu(int index)
retunrs the basis expansion coefficiants for the solution of the source problem
Eigen::Matrix< complex, Eigen::Dynamic, 1 > phi_
DiracOperatorSourceProblem()
Constructor creates basic mesh (Octaeder with radius 1.0)
void Solve()
solves the linear systems build in Compute
std::function< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f1_
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f0_
std::shared_ptr< const lf::mesh::Mesh > mesh_p_
void SetMesh(std::shared_ptr< const lf::mesh::Mesh > mesh_p)
Sets the mesh.
lf::base::size_type size_type
std::complex< double > complex
Implementation of the thesis Hogde Laplacians and Dirac Operators on the surface of the 3-Sphere.