1#ifndef HLDO_SPHERE_OPERATORS_WHITNEY_TWO_HODGE_LAPLACE_H
2#define HLDO_SPHERE_OPERATORS_WHITNEY_TWO_HODEE_LAPLACE_H
10#include <lf/assemble/assembler.h>
11#include <lf/assemble/coomatrix.h>
12#include <lf/assemble/dofhandler.h>
13#include <lf/mesh/entity.h>
14#include <lf/mesh/hybrid2d/mesh.h>
15#include <lf/mesh/hybrid2d/mesh_factory.h>
16#include <lf/mesh/mesh_interface.h>
17#include <lf/quad/quad.h>
18#include <load_vector_provider.h>
19#include <mass_matrix_provider.h>
20#include <rot_whitney_one_div_matrix_provider.h>
21#include <sphere_triag_mesh_builder.h>
22#include <whitney_one_mass_matrix_provider.h>
23#include <whitney_two_vector_provider.h>
53template <
typename SCALAR>
64 f_([](Eigen::Matrix<double, 3, 1> x) -> SCALAR { return 0; }),
65 phi_(Eigen::VectorXd::Zero(0)) {
67 std::unique_ptr<lf::mesh::MeshFactory> factory =
68 std::make_unique<lf::mesh::hybrid2d::MeshFactory>(3);
70 std::shared_ptr<projects::hldo_sphere::mesh::SphereTriagMeshBuilder>
71 sphere = std::make_shared<
78 mesh_p_ = sphere->Build();
113 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<double>>(
114 0, dof_handler_div, dof_handler_div, matrix_dot_provider, coo_A_11);
116 lf::assemble::AssembleMatrixLocally<lf::assemble::COOMatrix<double>>(
117 0, dof_handler_const, dof_handler_div, matrix_curl_provider, coo_A_12);
121 n_dofs_div + n_dofs_const);
122 full_matrix.setZero();
126 const std::vector<Eigen::Triplet<double>> triplets_A_11 =
129 const std::vector<Eigen::Triplet<double>> triplets_A_12 =
133 for (Eigen::Triplet<double> triplet : triplets_A_11) {
134 int col = triplet.col();
135 int row = triplet.row();
136 SCALAR val = triplet.value();
137 full_matrix.AddToEntry(row, col, val);
141 for (Eigen::Triplet<double> triplet : triplets_A_12) {
142 int row = triplet.row();
143 int col = triplet.col() + n_dofs_div;
144 SCALAR val = triplet.value();
147 full_matrix.AddToEntry(row, col, val);
150 full_matrix.AddToEntry(col, row, -val);
153 coo_matrix_ = full_matrix;
160 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> phi(n_dofs_const);
168 Eigen::Matrix<SCALAR, Eigen::Dynamic, 1> full_vec(n_dofs_div +
171 full_vec.tail(n_dofs_const) = phi;
184 void SetMesh(std::shared_ptr<const lf::mesh::Mesh> mesh_p) {
189 "Mesh must be Triangular, unsupported cell " << tria->
RefEl());
193 LF_ASSERT_MSG(mesh_p->DimWorld() == 3,
194 "World Dimension must be 3 but is" << mesh_p->DimWorld());
210 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)> &f) {
237 std::shared_ptr<const lf::mesh::Mesh>
mesh_p_;
238 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)>
f_;
240 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 kTria()
Returns the reference triangle.
Interface class representing a topological entity in a cellular complex
Element matrix provider for rotated whitney one form.
Element matrix provider for the Whitney one mass matrix that is the dot product of two Whitney one ba...
Element vector provider for piecewise constant whitney two 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 two form.
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_
lf::assemble::COOMatrix< SCALAR > GetGalerkinMatrix()
returns the Galerkin Matrix
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > phi_
void SetLoadFunction(std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> &f)
Sets the load function.
std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> f_
void Compute()
Computes the Galerkin LSE.
lf::assemble::COOMatrix< SCALAR > coo_matrix_
WhitneyTwoHodgeLaplace()
Constructor initializes basic mesh (Octaeder with radius 1.0) initializes zerovalued function f.
Eigen::Matrix< SCALAR, Eigen::Dynamic, 1 > GetLoadVector()
returns the Loadvector
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.