1#ifndef THESIS_EXPERIMENTS_HODGE_LAPLACIAN_H
2#define THESIS_EXPERIMENTS_HODGE_LAPLACIAN_H
11#include <hodge_laplacians_source_problems.h>
12#include <lf/io/vtk_writer.h>
13#include <lf/mesh/hybrid2d/mesh_factory.h>
14#include <lf/mesh/utils/tp_triag_mesh_builder.h>
15#include <lf/mesh/utils/utils.h>
16#include <lf/quad/quad.h>
17#include <lf/refinement/refinement.h>
18#include <lf/uscalfe/uscalfe.h>
19#include <mesh_function_whitney_one.h>
20#include <mesh_function_whitney_two.h>
21#include <mesh_function_whitney_zero.h>
23#include <results_processing.h>
24#include <sphere_triag_mesh_builder.h>
43template <
typename SCALAR>
63 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)> u_zero,
65 Eigen::Matrix<SCALAR, 3, 1>(
const Eigen::Matrix<double, 3, 1> &)>
67 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)> u_two,
68 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)> f_zero,
70 Eigen::Matrix<SCALAR, 3, 1>(
const Eigen::Matrix<double, 3, 1> &)>
72 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)> f_two,
73 double &k, std::string name)
92 void Compute(std::vector<unsigned> refinement_levels,
93 std::vector<double> ks) {
94 int nl = refinement_levels.size();
101 solutions.
levels = refinement_levels;
102 solutions.
mesh = std::vector<std::shared_ptr<const lf::mesh::Mesh>>(nl);
114 std::unique_ptr<lf::mesh::MeshFactory> factory =
115 std::make_unique<lf::mesh::hybrid2d::MeshFactory>(3);
124 std::chrono::steady_clock::time_point start_time_total =
125 std::chrono::steady_clock::now();
127 for (
unsigned il = 0; il < nl; ++il) {
128 unsigned lvl = refinement_levels[il];
130 solutions.
solutions[il].mu_zero.resize(nk);
131 solutions.
solutions[il].mu_one.resize(nk);
132 solutions.
solutions[il].mu_two.resize(nk);
134 for (
int ik = 0; ik < nk; ik++) {
136 std::cout <<
"\nStart computation of refinement_level " << lvl
137 <<
" and k = " <<
k_ << std::flush;
140 std::chrono::steady_clock::time_point start_time =
141 std::chrono::steady_clock::now();
145 const std::shared_ptr<lf::mesh::Mesh> mesh = sphere.
Build();
148 std::chrono::steady_clock::time_point end_time =
149 std::chrono::steady_clock::now();
151 std::chrono::duration_cast<std::chrono::milliseconds>(end_time -
156 std::cout <<
" -> Built Mesh " << elapsed_sec <<
" [s] " << std::flush;
158 solutions.
mesh[lvl] = mesh;
161 lse_builder.SetMesh(mesh);
162 lse_builder.SetK(
k_);
165 start_time = std::chrono::steady_clock::now();
168 lse_builder.Compute();
171 end_time = std::chrono::steady_clock::now();
172 elapsed_sec = std::chrono::duration_cast<std::chrono::milliseconds>(
173 end_time - start_time)
177 std::cout <<
" -> Computed LSE " << elapsed_sec <<
" [s] "
181 start_time = std::chrono::steady_clock::now();
187 end_time = std::chrono::steady_clock::now();
189 elapsed_sec = std::chrono::duration_cast<std::chrono::milliseconds>(
190 end_time - start_time)
194 std::cout <<
" -> Solved System " << elapsed_sec <<
" [s] "
198 solutions.
solutions[lvl].mu_zero[ik] = lse_builder.GetMuZero();
200 std::get<0>(lse_builder.GetMuOne());
202 std::get<1>(lse_builder.GetMuTwo());
207 std::chrono::steady_clock::time_point end_time_total =
208 std::chrono::steady_clock::now();
209 double elapsed_sec_total =
210 std::chrono::duration_cast<std::chrono::milliseconds>(end_time_total -
215 std::cout <<
"\nTotal computation time for all levels " << elapsed_sec_total
224 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)>
u_zero_;
225 std::function<Eigen::Matrix<SCALAR, 3, 1>(
226 const Eigen::Matrix<double, 3, 1> &)>
228 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)>
u_two_;
229 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)>
f_zero_;
230 std::function<Eigen::Matrix<SCALAR, 3, 1>(
231 const Eigen::Matrix<double, 3, 1> &)>
233 std::function<SCALAR(
const Eigen::Matrix<double, 3, 1> &)>
f_two_;
Creates and solves the discretised Hodge Laplacian source problems for a given list of levels and val...
std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> f_zero_
HodgeLaplacianExperiment(std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> u_zero, std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> u_one, std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> u_two, std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> f_zero, std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f_one, std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> f_two, double &k, std::string name)
Constructor setting all the functions and the reference k.
void Compute(std::vector< unsigned > refinement_levels, std::vector< double > ks)
Solves the hodge laplacian source problems for the tensor product of passed refinement levels and ks.
std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> u_two_
std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> u_zero_
std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f_one_
std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> f_two_
std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> u_one_
A mesh builder for regular 3-Sphere.
void setRefinementLevel(lf::base::size_type n)
Set the refinement level.
void setRadius(double r)
Sets the radius.
std::shared_ptr< lf::mesh::Mesh > Build()
Build the mesh.
Creates and solves the discretised Hodge Laplacian source problems.
void SetLoadFunctions(std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> &f0, std::function< Eigen::Matrix< SCALAR, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> &f1, std::function< SCALAR(const Eigen::Matrix< double, 3, 1 > &)> &f2)
Sets the load functions.
Wrapper classes for experiments.
void process_results(std::string name, ProblemSolutionWrapper< SCALAR > &results, U_ZERO &u_zero, U_ONE &u_one, U_TWO &u_two, double &k)
Generate vtk files containing meshdata and a csv table with results.
stores solutions for several k and one refinement level
stores solutions and setupinformation for a list of refinement levels and k values
std::vector< std::shared_ptr< const lf::mesh::Mesh > > mesh
std::vector< ProblemSolution< SCALAR > > solutions
std::vector< unsigned > levels