11 #ifndef BEMBEL_SRC_ANSATZSPACE_FUNCTIONEVALUATOR_HPP_
12 #define BEMBEL_SRC_ANSATZSPACE_FUNCTIONEVALUATOR_HPP_
20 template <
typename Derived>
30 ansatz_space_ = other.ansatz_space_;
32 polynomial_degree_plus_one_squared_ =
33 other.polynomial_degree_plus_one_squared_;
37 init_FunctionEvaluator(ansatz_space);
43 Eigen::Dynamic, 1> &fun) {
44 init_FunctionEvaluator(ansatz_space, fun);
51 ansatz_space_ = ansatz_space;
52 auto polynomial_degree = ansatz_space_.get_polynomial_degree();
53 polynomial_degree_plus_one_squared_ =
54 (polynomial_degree + 1) * (polynomial_degree + 1);
55 reordering_vector_ = ansatz_space_.get_superspace()
58 .computeReorderingVector();
61 void init_FunctionEvaluator(
64 Eigen::Dynamic, 1> &fun) {
65 ansatz_space_ = ansatz_space;
67 auto polynomial_degree = ansatz_space_.get_polynomial_degree();
68 polynomial_degree_plus_one_squared_ =
69 (polynomial_degree + 1) * (polynomial_degree + 1);
70 reordering_vector_ = ansatz_space_.get_superspace()
73 .computeReorderingVector();
81 getFunctionSpaceOutputDimension<LinearOperatorTraits<Derived>::Form>(), 1>
82 evaluateOnPatch(
int patch,
const Eigen::Vector2d &ref_point)
const {
83 const int elements_per_direction =
84 (1 << ansatz_space_.get_refinement_level());
85 const int elements_per_patch =
86 elements_per_direction * elements_per_direction;
87 const double h = 1. / ((double)(elements_per_direction));
88 const int x_idx_ = std::floor(ref_point(0) / h);
89 const int y_idx_ = std::floor(ref_point(1) / h);
90 const int x_idx = std::min(std::max(x_idx_, 0), elements_per_direction - 1);
91 const int y_idx = std::min(std::max(y_idx_, 0), elements_per_direction - 1);
93 x_idx + elements_per_direction * y_idx + patch * elements_per_patch;
94 const int et_idx = reordering_vector_[tp_idx];
96 ansatz_space_.get_superspace().get_mesh().get_element_tree();
98 std::advance(it, et_idx);
102 ansatz_space_.get_superspace().get_geometry()[patch].updateSurfacePoint(
104 return evaluate(element, sp);
108 getFunctionSpaceOutputDimension<LinearOperatorTraits<Derived>::Form>(), 1>
111 ansatz_space_.get_superspace(), polynomial_degree_plus_one_squared_,
113 fun_.block(polynomial_degree_plus_one_squared_ * element.id_, 0,
114 polynomial_degree_plus_one_squared_,
120 return eval_.evalDiv(
121 ansatz_space_.get_superspace(), polynomial_degree_plus_one_squared_,
123 fun_.block(polynomial_degree_plus_one_squared_ * element.
id_, 0,
124 polynomial_degree_plus_one_squared_,
136 getFunctionSpaceVectorDimension<LinearOperatorTraits<Derived>::Form>();
137 auto longfun = (ansatz_space_.get_transformation_matrix() * fun).eval();
139 Eigen::Map<Eigen::Matrix<typename LinearOperatorTraits<Derived>::Scalar,
140 Eigen::Dynamic, vec_dim>>(
141 longfun.data(), longfun.rows() / vec_dim, vec_dim);
147 std::vector<int> reordering_vector_;
151 getFunctionSpaceVectorDimension<LinearOperatorTraits<Derived>::Form>()>
153 int polynomial_degree_plus_one_squared_;
The AnsatzSpace is the class that handles the assembly of the discrete basis.
This class organizes an element structure on a Geometry object and handles refinement.
ElementTreeNode::const_iterator cpbegin() const
Returns an iterator to the beginning of the sequence represented by the leafs as ElementTreeNodes of ...
The ElementTreeNode corresponds to an element in the element tree.
int id_
radius of the element
Eigen::Vector2d mapToReferenceElement(const Eigen::Vector2d &in) const
Maps a point in the reference domain of a patch to the reference element of this element.
The FunctionEvaluator provides means to evaluate coefficient vectors as functions on the geometry.
Eigen::Matrix< double, 12, 1 > SurfacePoint
typedef of SurfacePoint
Routines for the evalutation of pointwise errors.
constexpr int getFunctionSpaceVectorDimension()
struct containing specifications on the linear operator has to be specialized or derived for any part...