17#include "strangsplitting.h"
22int main(
int ,
char** ) {
24 auto mesh_factory = std::make_unique<lf::mesh::hybrid2d::MeshFactory>(2);
25 std::filesystem::path here = __FILE__;
28 auto mesh_file = (here.parent_path() /
"/meshes/threecircles.msh").
string();
31 std::shared_ptr<const lf::mesh::Mesh> mesh_p = reader.mesh();
33 std::shared_ptr<lf::uscalfe::UniformScalarFESpace<double>> fe_space =
34 std::make_shared<lf::uscalfe::FeSpaceLagrangeO1<double>>(mesh_p);
39 std::cout <<
"N_dofs :" << N_dofs << std::endl;
42 Eigen::VectorXd u0(N_dofs);
48 auto c = [](
const Eigen::Vector2d & ) ->
double {
55 double lambda = 0.0042;
68 auto boundary_nodes = [&bd_flags, &dofh](
unsigned int idx) ->
bool {
69 return bd_flags(dofh.Entity(idx));
75 return bd_flags_edge(edge);
78 auto h = [fe_space, mesh_p, edge_pred](
const Eigen::Vector2d& x) ->
double {
82 auto g_1 = [&x](
const Eigen::Vector2d& y) ->
double {
89 auto g_2 = [&x](
const Eigen::Vector2d& y) ->
double {
91 if ((x - y).norm() <= 1.75) {
98 auto g_3 = [&x](
const Eigen::Vector2d& y) ->
double {
100 if (1.25 <= (x - y).norm() && (x - y).norm() <= 1.75) {
118 Eigen::MatrixXd L(N_dofs, N_dofs);
119 for (
int j = 0; j < N_dofs; j++) {
120 if (boundary_nodes(j)) {
121 auto L_j = [fe_space, &dofh, N_dofs, edge_pred,
122 j](
const Eigen::Vector2d& x) ->
double {
124 auto g_1_j = [&x](
const Eigen::Vector2d& y) ->
double {
125 double tmp_res = 0.0;
131 auto g_2_j = [&x](
const Eigen::Vector2d& y) ->
double {
132 double tmp_res = 0.0;
133 if ((x - y).norm() <= 1.75) {
140 auto g_3_j = [&x](
const Eigen::Vector2d& y) ->
double {
141 double tmp_res = 0.0;
142 if (1.25 <= (x - y).norm() && (x - y).norm() <= 1.75) {
148 Eigen::VectorXd L1(N_dofs);
154 edgeVec_y(fe_space, mf_g, edge_pred);
160 Eigen::VectorXd L2(N_dofs);
166 edgeVec_x(fe_space, mf_L, edge_pred);
173 L.col(j) = Eigen::VectorXd::Zero(N_dofs);
183 unsigned int m = 100;
188 Eigen::VectorXd cap(N_dofs);
190 cap = 0.8 * Eigen::VectorXd::Ones(N_dofs);
193 StrangSplit StrangSplitter(fe_space, T, m, lambda, c, h, L);
195 Eigen::MatrixXd sol(N_dofs, 20);
197 sol.col(0) = StrangSplitter.Evolution(cap, u0);
198 std::cout <<
"sol1" << std::endl;
199 sol.col(1) = StrangSplitter.Evolution(cap, sol.col(0));
200 std::cout <<
"sol2" << std::endl;
201 sol.col(2) = StrangSplitter.Evolution(cap, sol.col(1));
202 std::cout <<
"sol3" << std::endl;
203 sol.col(3) = StrangSplitter.Evolution(cap, sol.col(2));
204 std::cout <<
"sol4" << std::endl;
205 sol.col(4) = StrangSplitter.Evolution(cap, sol.col(3));
206 std::cout <<
"sol5" << std::endl;
210 for (
int k = 1; k < 6; k++) {
211 std::stringstream filename;
212 filename <<
"sol" << k <<
".vtk";
215 auto nodal_data = lf::mesh::utils::make_CodimMeshDataSet<double>(mesh_p, 2);
216 for (
int global_idx = 0; global_idx < N_dofs; global_idx++) {
217 nodal_data->operator()(dofh.Entity(global_idx)) =
218 sol.col(k - 1)[global_idx];
221 vtk_writer.WritePointData(
"sol", *nodal_data);
A general (interface) class for DOF handling, see Lecture Document Paragraph 2.7.4....
static constexpr RefEl kSegment()
Returns the (1-dimensional) reference segment.
static constexpr RefEl kTria()
Returns the reference triangle.
Reads a Gmsh *.msh file into a mesh::MeshFactory and provides a link between mesh::Entity objects and...
Write a mesh along with mesh data into a vtk file.
Interface class representing a topological entity in a cellular complex
MeshFunction wrapper for a simple function of physical coordinates.
auto squaredNorm(const A &a)
Pointwise squared norm of another mesh function.
Local edge contributions to element vector.
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
QuadRule make_TriaQR_EdgeMidpointRule()
edge midpoint quadrature rule for reference triangles
auto localQuadFunction(const lf::mesh::Mesh &mesh, std::map< lf::base::RefEl, lf::quad::QuadRule > quadrules, FUNCTOR &&f, unsigned int codim, const std::function< bool(const lf::mesh::Entity &)> &pred)
CodimMeshDataSet< bool > flagEntitiesOnBoundary(const std::shared_ptr< const Mesh > &mesh_p, lf::base::dim_t codim)
flag entities of a specific co-dimension located on the boundary
QuadRule make_QuadRule(base::RefEl ref_el, unsigned degree)
Returns a QuadRule object for the given Reference Element and Degree.
lf::assemble::size_type size_type