11#include <lf/assemble/assemble.h>
12#include <lf/base/base.h>
13#include <lf/geometry/geometry.h>
14#include <lf/mesh/hybrid2d/hybrid2d.h>
15#include <lf/mesh/test_utils/test_meshes.h>
16#include <lf/mesh/utils/utils.h>
17#include <lf/uscalfe/uscalfe.h>
23#include <Eigen/Sparse>
38 template <
typename DIFF_COEFF,
typename NONLOC_BC>
41 double T,
unsigned int m,
double lambda, DIFF_COEFF &&c, NONLOC_BC &&h,
42 const Eigen::MatrixXd &L);
48 const Eigen::VectorXd &mu);
49 Eigen::VectorXd
Evolution(
const Eigen::VectorXd &cap,
50 const Eigen::VectorXd &mu);
54 const std::shared_ptr<lf::uscalfe::UniformScalarFESpace<double>>
fe_space_;
67 Eigen::SparseMatrix<double>
A_;
69 Eigen::SparseMatrix<double>
M_;
71 Eigen::SparseLU<Eigen::SparseMatrix<double>>
solver1;
72 Eigen::SparseLU<Eigen::SparseMatrix<double>>
solver2;
75template <
typename FUNCTOR>
78 std::map<lf::base::RefEl, lf::quad::QuadRule> quadrules, FUNCTOR &&f,
81 LF_ASSERT_MSG(mesh.
DimMesh() >= codim,
"Illegal codim = " << codim);
83 using value_t = std::invoke_result_t<FUNCTOR, Eigen::VectorXd>;
91 auto tmp = quadrules.find(entity->RefEl());
92 if (tmp != quadrules.end()) {
98 const Eigen::MatrixXd &zeta_ref{qr.Points()};
100 const Eigen::MatrixXd zeta{geo.Global(zeta_ref)};
102 const Eigen::VectorXd &w_ref{qr.Weights()};
104 const Eigen::VectorXd gram_dets{geo.IntegrationElement(zeta_ref)};
106 for (
int l = 0; l < P; ++l) {
107 sum_var += w_ref[l] * f(zeta.col(l)) * gram_dets[l];
110 LF_VERIFY_MSG(
false,
"Missing quadrature rule for " << entity->RefEl());
119template <
typename DIFF_COEFF,
typename NONLOC_BC>
120std::pair<Eigen::SparseMatrix<double>, Eigen::SparseMatrix<double>>
122 NONLOC_BC &&h,
const Eigen::MatrixXd &L) {
123 std::pair<Eigen::SparseMatrix<double>, Eigen::SparseMatrix<double>> A_M;
125 std::shared_ptr<const lf::mesh::Mesh> mesh = dofh.
Mesh();
128 std::make_shared<lf::uscalfe::FeSpaceLagrangeO1<double>>(mesh);
132 return bd_flags(edge);
139 auto one = [](
const Eigen::Vector2d & ) ->
double {
return 1.0; };
140 auto zero = [](
const Eigen::Vector2d & ) ->
double {
return 0.0; };
149 elMat_Stiff(fe_space, mf_c, mf_zero);
152 elMat_Mass(fe_space, mf_zero, mf_one);
154 decltype(edges_predicate)>
155 elMat_Edge(fe_space, mf_h, edges_predicate);
161 Eigen::SparseMatrix<double> A_sps = A_COO.
makeSparse();
162 Eigen::SparseMatrix<double> M(N_dofs, N_dofs);
165 Eigen::MatrixXd A_ds(A_sps);
166 Eigen::MatrixXd A_ds1 = A_ds - L;
168 Eigen::SparseMatrix<double> A(N_dofs, N_dofs);
169 A = A_ds1.sparseView();
171 A_M = std::make_pair(A, M);
177template <
typename DIFF_COEFF,
typename NONLOC_BC>
180 double T,
unsigned m,
double lambda, DIFF_COEFF &&c, NONLOC_BC &&h,
181 const Eigen::MatrixXd &L)
182 : fe_space_(fe_space), T_(T), m_(m), lambda_(lambda) {
185 std::pair<Eigen::SparseMatrix<double>, Eigen::SparseMatrix<double>>
187 A_ = galerkinpair.first;
188 M_ = galerkinpair.second;
191 kappa_ = 1.0 - 0.5 * sqrt(2.0);
195 LF_VERIFY_MSG(
solver1.info() == Eigen::Success,
"LU decomposition failed");
197 LF_VERIFY_MSG(
solver2.info() == Eigen::Success,
"LU decomposition failed");
Eigen::SparseMatrix< double > A_
StrangSplit & operator=(const StrangSplit &&)=delete
StrangSplit(std::shared_ptr< lf::uscalfe::UniformScalarFESpace< double > > &fe_space, double T, unsigned int m, double lambda, DIFF_COEFF &&c, NONLOC_BC &&h, const Eigen::MatrixXd &L)
StrangSplit(StrangSplit &&)=delete
StrangSplit(const StrangSplit &)=delete
Eigen::SparseLU< Eigen::SparseMatrix< double > > solver2
Eigen::SparseMatrix< double > M_
Eigen::VectorXd Evolution(const Eigen::VectorXd &cap, const Eigen::VectorXd &mu)
virtual ~StrangSplit()=default
StrangSplit & operator=(const StrangSplit &)=delete
Eigen::SparseLU< Eigen::SparseMatrix< double > > solver1
Eigen::VectorXd diffusionEvolutionOperator(bool firstcall, const Eigen::VectorXd &mu)
const std::shared_ptr< lf::uscalfe::UniformScalarFESpace< double > > fe_space_
A temporary data structure for matrix in COO format.
Eigen::SparseMatrix< Scalar > makeSparse() const
Create an Eigen::SparseMatrix out of the COO format.
A general (interface) class for DOF handling, see Lecture Document Paragraph 2.7.4....
virtual std::shared_ptr< const lf::mesh::Mesh > Mesh() const =0
Acess to underlying mesh object.
virtual size_type NumDofs() const =0
total number of dof's handled by the object
Interface class for shape information on a mesh cell in the spirit of parametric finite element metho...
Interface class representing a topological entity in a cellular complex
Abstract interface for objects representing a single mesh.
virtual unsigned DimMesh() const =0
The dimension of the manifold described by the mesh, or equivalently the maximum dimension of the ref...
virtual nonstd::span< const Entity *const > Entities(unsigned codim) const =0
All entities of a given codimension.
MeshFunction wrapper for a simple function of physical coordinates.
Represents a Quadrature Rule over one of the Reference Elements.
base::size_type NumPoints() const
Return the total number of quadrature points (num of columns of points/weights)
Quadrature-based computation of local mass matrix for an edge.
Class for local quadrature based computations for Lagrangian finite elements and second-order scalar ...
void AssembleMatrixLocally(dim_t codim, const DofHandler &dof_handler_trial, const DofHandler &dof_handler_test, ENTITY_MATRIX_PROVIDER &entity_matrix_provider, TMPMATRIX &matrix)
Assembly function for standard assembly of finite element matrices.
unsigned int size_type
general type for variables related to size of arrays
std::pair< Eigen::SparseMatrix< double >, Eigen::SparseMatrix< double > > assembleGalerkinMatrices(const lf::assemble::DofHandler &dofh, DIFF_COEFF &&c, NONLOC_BC &&h, const Eigen::MatrixXd &L)
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
lf::assemble::size_type size_type