1#ifndef HLDO_SPHERE_OPERATORS_WHITNEY_ONE_HODGE_LAPLACE_H
2#define HLDO_SPHERE_OPERATORS_WHITNEY_ONE_HODGE_LAPLACE_H
7#include <lf/assemble/assembler.h>
8#include <lf/assemble/coomatrix.h>
9#include <lf/assemble/dofhandler.h>
10#include <lf/mesh/entity.h>
11#include <lf/mesh/hybrid2d/mesh.h>
12#include <lf/mesh/hybrid2d/mesh_factory.h>
13#include <lf/mesh/mesh_interface.h>
14#include <lf/quad/quad.h>
15#include <load_vector_provider.h>
16#include <mass_matrix_provider.h>
17#include <sphere_triag_mesh_builder.h>
18#include <whitney_one_curl_curl_matrix_provider.h>
19#include <whitney_one_grad_matrix_provider.h>
20#include <whitney_one_vector_provider.h>
53template <
typename SCALAR>
65 std::unique_ptr<lf::mesh::MeshFactory> factory =
66 std::make_unique<lf::mesh::hybrid2d::MeshFactory>(3);
68 std::shared_ptr<projects::hldo_sphere::mesh::SphereTriagMeshBuilder>
69 sphere = std::make_shared<
78 auto f = [](Eigen::Matrix<double, 3, 1> x) -> Eigen::Matrix<SCALAR, 3, 1> {
79 return Eigen::Matrix<SCALAR, 3, 1>::Zero();
117 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<double>>(
118 0, dof_handler_curl, dof_handler_curl, matrix_curl_provider, coo_A_11);
120 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<double>>(
121 0, dof_handler_bary, dof_handler_curl, matrix_grad_provider, coo_A_21);
123 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<double>>(
124 0, dof_handler_bary, dof_handler_bary, matrix_mass_provider, coo_A_22);
128 n_dofs_curl + n_dofs_bary);
129 full_matrix.setZero();
133 const std::vector<Eigen::Triplet<double>> triplets_A_11 =
135 const std::vector<Eigen::Triplet<double>> triplets_A_21 =
137 const std::vector<Eigen::Triplet<double>> triplets_A_22 =
141 for (Eigen::Triplet<double> triplet : triplets_A_11) {
142 int col = triplet.col();
143 int row = triplet.row();
144 SCALAR val = triplet.value();
145 full_matrix.AddToEntry(row, col, val);
149 for (Eigen::Triplet<double> triplet : triplets_A_21) {
150 int col = triplet.col() + n_dofs_curl;
151 int row = triplet.row();
152 SCALAR val = triplet.value();
155 full_matrix.AddToEntry(row, col, -val);
158 full_matrix.AddToEntry(col, row, val);
162 for (Eigen::Triplet<double> triplet : triplets_A_22) {
163 int col = triplet.col() + n_dofs_curl;
164 int row = triplet.row() + n_dofs_curl;
165 SCALAR val = triplet.value();
166 full_matrix.AddToEntry(row, col, val);
176 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> phi(n_dofs_curl);
183 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> full_vec(n_dofs_curl +
186 full_vec.head(n_dofs_curl) = phi;
199 void SetMesh(std::shared_ptr<const lf::mesh::Mesh> mesh_p) {
204 "Mesh must be Triangular, unsupported cell " << tria->
RefEl());
208 LF_ASSERT_MSG(mesh_p->DimWorld() == 3,
209 "World Dimension must be 3 but is" << mesh_p->DimWorld());
228 const Eigen::Matrix<double, 3, 1> &)> &f) {
255 std::shared_ptr<const lf::mesh::Mesh>
mesh_p_;
256 std::function<Eigen::Matrix<SCALAR, 3, 1>(
257 const Eigen::Matrix<double, 3, 1> &)>
260 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1>
phi_;
A temporary data structure for matrix in COO format.
void setZero()
Erase all entries of the matrix.
TripletVec & triplets()
Gives access to the vector of triplets.
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.
An elment matrix provider computed with the Whitney one forms, vector valued basis function.
Element matrix provider Whitney one forms, surface vector fields.
Element vector provider for Whitney one forms.
A mesh builder for regular 3-Sphere.
void setRefinementLevel(lf::base::size_type n)
Set the refinement level.
Computes the Galerkin LSE for the Hodge Laplacian of the whitney one form.
lf::assemble::COOMatrix< SCALAR > GetGalerkinMatrix()
returns the Galerkin Matrix
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > phi_
lf::assemble::COOMatrix< SCALAR > coo_matrix_
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > GetLoadVector()
returns the Loadvector
void SetLoadFunction(std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> &f)
Sets the load function.
WhitneyOneHodgeLaplace()
Constructor initializes basic mesh (Octaeder with radius 1.0) initializes zerovalued function f.
void SetMesh(std::shared_ptr< const lf::mesh::Mesh > mesh_p)
Sets the mesh and creates dof_handler.
std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f_
std::shared_ptr< const lf::mesh::Mesh > mesh_p_
void Compute()
Computes the Galerkin LSE.
void AssembleVectorLocally(dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)
entity-local assembly of (right-hand-side) vectors from element vectors
lf::base::size_type size_type
Implementation of the thesis Hogde Laplacians and Dirac Operators on the surface of the 3-Sphere.