1#ifndef HLDO_SPHERE_EXPERIMENTS_DIRAC_OPERATOR_EXAMPLE_H
2#define HLDO_SPHERE_EXPERIMENTS_DIRAC_OPERATOR_EXAMPLE_H
11#include <dirac_operator_source_problem.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>
64 std::function<
complex(
const Eigen::Matrix<double, 3, 1> &)> u_zero,
66 Eigen::Matrix<complex, 3, 1>(
const Eigen::Matrix<double, 3, 1> &)>
68 std::function<
complex(
const Eigen::Matrix<double, 3, 1> &)> u_two,
69 std::function<
complex(
const Eigen::Matrix<double, 3, 1> &)> f_zero,
71 Eigen::Matrix<complex, 3, 1>(
const Eigen::Matrix<double, 3, 1> &)>
73 std::function<
complex(
const Eigen::Matrix<double, 3, 1> &)> f_two,
74 double &k, std::string name)
93 void Compute(std::vector<unsigned> refinement_levels,
94 std::vector<double> ks) {
95 int nl = refinement_levels.size();
102 solutions.
levels = refinement_levels;
103 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.GetMu(0);
199 solutions.
solutions[lvl].mu_one[ik] = lse_builder.GetMu(1);
200 solutions.
solutions[lvl].mu_two[ik] = lse_builder.GetMu(2);
205 std::chrono::steady_clock::time_point end_time_total =
206 std::chrono::steady_clock::now();
207 double elapsed_sec_total =
208 std::chrono::duration_cast<std::chrono::milliseconds>(end_time_total -
213 std::cout <<
"\nTotal computation time for all levels " << elapsed_sec_total
223 std::function<Eigen::Matrix<complex, 3, 1>(
224 const Eigen::Matrix<double, 3, 1> &)>
228 std::function<Eigen::Matrix<complex, 3, 1>(
229 const Eigen::Matrix<double, 3, 1> &)>
Creates and solves the discretised Dirac Operator source problems for a given list of levels and valu...
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> u_two_
std::function< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> u_one_
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f_zero_
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< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f_one_
DiracOperatorExperiment(std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> u_zero, std::function< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> u_one, std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> u_two, std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f_zero, std::function< Eigen::Matrix< complex, 3, 1 >(const Eigen::Matrix< double, 3, 1 > &)> f_one, std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f_two, double &k, std::string name)
Constructor setting all the functions and the reference k.
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> f_two_
std::function< complex(const Eigen::Matrix< double, 3, 1 > &)> u_zero_
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.
Computes the Galerkin LSE for the Dirac Operator source problem.
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.
Wrapper classes for experiments.
std::complex< double > complex
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