15template <
class EleType>
53 const Eigen::Matrix<EleType, -1, 1>& v,
size_t level) {
54 Eigen::Matrix<EleType, -1, 1> result =
get_P(level) * v;
65 const Eigen::Matrix<EleType, -1, 1>& v,
size_t level) {
66 Eigen::Matrix<EleType, -1, 1> result =
get_R(level) * v;
70 const Eigen::SparseMatrix<EleType>&
get_P(
size_t level)
const {
74 const Eigen::SparseMatrix<EleType>&
get_R(
size_t level)
const {
98template <
class EleType>
109 Eigen::SparseMatrix<EleType> P(n_h_dofs, n_H_dofs);
114 std::vector<Eigen::Triplet<EleType>> P_coefficients;
115 P_coefficients.reserve(nnz);
117 for (
size_t j = 0; j < n_H_dofs; ++j) {
119 P_coefficients.push_back(Eigen::Triplet<EleType>(i, j, 0.5));
121 if (i + 1 < n_h_dofs)
122 P_coefficients.push_back(Eigen::Triplet<EleType>(i + 1, j, 1.0));
124 if (i + 2 < n_h_dofs)
125 P_coefficients.push_back(Eigen::Triplet<EleType>(i + 2, j, 0.5));
129 P.setFromTriplets(P_coefficients.begin(), P_coefficients.end());
132 Eigen::SparseMatrix<EleType> R(n_H_dofs, n_h_dofs);
133 R.reserve(P.nonZeros());
Base class for interpolators that implement prolongation and restriction as linear operators construc...
Definition interpolator.hpp:16
void set_level_to_P(size_t level, Eigen::SparseMatrix< EleType > &P)
Definition interpolator.hpp:78
InterpolatorBase(size_t n_levels)
Definition interpolator.hpp:22
virtual void make_operators(size_t n_h_dofs, size_t n_H_dofs, size_t level)=0
Construct P and R matrices based on dofs and level information.
std::vector< Eigen::SparseMatrix< EleType > > level_to_P
Definition interpolator.hpp:18
std::vector< Eigen::SparseMatrix< EleType > > level_to_R
Definition interpolator.hpp:19
const Eigen::SparseMatrix< EleType > & get_R(size_t level) const
Definition interpolator.hpp:74
void set_level_to_R(size_t level, Eigen::SparseMatrix< EleType > &R)
Definition interpolator.hpp:83
Eigen::Matrix< EleType, -1, 1 > restriction(const Eigen::Matrix< EleType, -1, 1 > &v, size_t level)
Restriction operator on v.
Definition interpolator.hpp:64
const Eigen::SparseMatrix< EleType > & get_P(size_t level) const
Definition interpolator.hpp:70
Eigen::Matrix< EleType, -1, 1 > prolongation(const Eigen::Matrix< EleType, -1, 1 > &v, size_t level)
Prolongation operator on v and updating result inplace.
Definition interpolator.hpp:52
InterpolatorBase()
Construct a new Interpolator Base object.
Definition interpolator.hpp:34
Interface for linear interpolation.
Definition interpolator.hpp:99
const size_t n_elements_per_columns
Definition interpolator.hpp:101
void make_operators(size_t n_h_dofs, size_t n_H_dofs, size_t level)
Construct P and R matrices based on dofs and level information.
Definition interpolator.hpp:106