LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
prolongation.h
1#ifndef LF_USCALFE_PROLONGATION_H
2#define LF_USCALFE_PROLONGATION_H
3
4#include <lf/assemble/dofhandler.h>
5#include <lf/fe/fe.h>
6#include <lf/mesh/utils/utils.h>
7#include <lf/refinement/mesh_function_transfer.h>
8#include <lf/refinement/mesh_hierarchy.h>
9
10namespace lf::fe {
11
32template <typename SCALAR_COEFF, typename FES_COARSE, typename FES_FINE>
33[[nodiscard]] Eigen::Matrix<SCALAR_COEFF, Eigen::Dynamic, 1> prolongate(
35 std::shared_ptr<FES_COARSE> fespace_coarse,
36 std::shared_ptr<FES_FINE> fespace_fine,
37 const Eigen::Matrix<SCALAR_COEFF, Eigen::Dynamic, 1> &dofs_coarse,
38 lf::base::size_type level_coarse) {
39 // Assert that the FES_* are actually FE spaces
40 using scalar_fe_coarse_t = typename FES_COARSE::Scalar;
41 using scalar_fe_fine_t = typename FES_FINE::Scalar;
42 static_assert(
43 std::is_convertible_v<FES_COARSE &,
45 "Invalid coarse FE space provided");
46 static_assert(std::is_convertible_v<FES_FINE &,
48 "Invalid fine FE space provided");
49 // Obtain the dofhandlers from the fe spaces
50 const lf::assemble::DofHandler &dofh_coarse{fespace_coarse->LocGlobMap()};
51 const lf::assemble::DofHandler &dofh_fine{fespace_fine->LocGlobMap()};
52 const lf::base::size_type N_coarse = dofh_coarse.NumDofs();
53 // Assert correctness of inputs
54 LF_ASSERT_MSG(
55 level_coarse < mh.NumLevels() - 1,
56 "level must not point to or beyond the finest mesh in the hierarchy");
57 LF_ASSERT_MSG(
58 dofs_coarse.size() >= N_coarse,
59 "Too few basis function coefficients provided for coarse FE space");
60 // Construct a mesh function to simplify the point evaluations
61 const lf::fe::MeshFunctionFE mf_coarse(fespace_coarse, dofs_coarse);
62 // Transfer the mesh function to the finer mesh
64 mh, mf_coarse, level_coarse, level_coarse + 1);
65 // Return the nodal projection of this transferred mesh function
66 return lf::fe::NodalProjection(*fespace_fine, mf_fine);
67}
68
69} // namespace lf::fe
70
71#endif // LF_USCALFE_PROLONGATION_H
A general (interface) class for DOF handling, see Lecture Document Paragraph 2.7.4....
Definition dofhandler.h:112
virtual size_type NumDofs() const =0
total number of dof's handled by the object
A MeshFunction representing an element from a ScalarFESpace (e.g. solution of BVP)
Space of scalar valued finite element functions on a Mesh.
A MeshFunction representing interpolation on a lf::refinement::MeshHierarchy.
A hierarchy of nested 2D hybrid meshes created by refinement.
size_type NumLevels() const
number of meshes contained in the hierarchy, 1 for a single mesh
unsigned int size_type
general type for variables related to size of arrays
Definition types.h:20
Collects data structures and algorithms designed for scalar finite element methods primarily meant fo...
Definition fe.h:47
Eigen::Matrix< SCALAR_COEFF, Eigen::Dynamic, 1 > prolongate(const lf::refinement::MeshHierarchy &mh, std::shared_ptr< FES_COARSE > fespace_coarse, std::shared_ptr< FES_FINE > fespace_fine, const Eigen::Matrix< SCALAR_COEFF, Eigen::Dynamic, 1 > &dofs_coarse, lf::base::size_type level_coarse)
Interpolate a vector of DOFs on a finer mesh.
auto NodalProjection(const lf::fe::ScalarFESpace< SCALAR > &fe_space, MF const &u, SELECTOR &&pred=base::PredicateTrue{}) -> Eigen::Vector< decltype(SCALAR{0} *mesh::utils::MeshFunctionReturnType< std::remove_reference_t< MF > >{0}), Eigen::Dynamic >
Computes nodal projection of a mesh function and returns the finite element basis expansion coefficie...
Definition fe_tools.h:198