Medusa  1.1
Coordinate Free Mehless Method implementation
mm::Operator< Derived > Struct Template Reference

#include <Operators_fwd.hpp>

Detailed Description

template<typename Derived>
struct mm::Operator< Derived >

Base class for a differential operator.

Also doubles as a one-element family.

Template Parameters
DerivedDerived class inheriting, used for CRTP.

Example of custom operator usage. Definition:

template <int dim>
struct Biharmonic : public Operator<Biharmonic<dim>> {
typedef Vec<double, dim> vec;
static std::string type_name() { return format("Biharmonic<%d>", dim); }
template <int k>
double applyAt0(const RBFBasis<Polyharmonic<double, k>, vec>&, int index,
const std::vector<vec>& support, double scale) const {
static_assert(k != -1, "If dynamic k is desired it can be obtained from basis.rbf().");
double r = support[index].norm();
return k*(k-2)*(dim+k-2)*(dim+k-4)*ipow<k-4>(r) / ipow<4>(scale);
}
double applyAt0(const Monomials<vec>& mon, int idx, const std::vector<vec>& q, double s) const {
double result = 0;
std::array<int, dim> orders;
for (int d = 0; d < dim; ++d) { orders[d] = 0; }
for (int d = 0; d < dim; ++d) {
orders[d] = 4;
result += mon.evalOpAt0(idx, Derivative<dim>(orders), q);
orders[d] = 0;
for (int d2 = 0; d2 < d; ++d2) {
orders[d] = 2;
orders[d2] = 2;
result += 2*mon.evalOpAt0(idx, Derivative<dim>(orders), q);
orders[d] = 0;
orders[d2] = 0;
}
}
return result / ipow<4>(s);
}
};

Usage:

typedef Vec<double, dim> vec;
BallShape<vec> b(0.0, 1.0);
double dx = 0.05;
DomainDiscretization<vec> domain = b.discretizeBoundaryWithStep(dx);
auto fn = [=](const vec&) { return dx; };
GeneralFill<vec> fill; fill.seed(1337);
fill(domain, fn);
Monomials<vec> mon(6);
Polyharmonic<double, 5> rbf;
int n = 2*mon.size();
domain.findSupport(FindClosest(n));
RBFFD<Polyharmonic<double, 5>, vec, ScaleToClosest> approx(rbf, mon);
RBFBasis<Polyharmonic<double, 5>, Vec2d> basis(n);
Biharmonic<2> bih;
double val1 = mon.evalOpAt0(0, bih);
double val2 = mon.evalOpAt0(mon.size()-1, bih);
double val3 = basis.evalOpAt0(0, bih, domain.supportNodes(0));
approx.compute(domain.pos(0), domain.supportNodes(0));
auto shape = approx.getShape(bih);

See also custom_operators example in the examples suite.

Definition at line 33 of file Operators_fwd.hpp.

Public Member Functions

std::array< Derived, 1 > operators () const
 Return an iterable of iterators represented by a family. More...
 
template<typename basis_t >
basis_t::scalar_t apply (const basis_t &basis, int index, typename basis_t::vector_t point, const std::vector< typename basis_t::vector_t > &support, typename basis_t::scalar_t scale) const
 Apply this operator to a given basis function. More...
 
template<typename basis_t >
basis_t::scalar_t applyAt0 (const basis_t &basis, int index, const std::vector< typename basis_t::vector_t > &support, typename basis_t::scalar_t scale) const
 Like apply, but with point equal to 0. More...
 

Public Types

typedef Derived operator_t
 Type of the contained operators. More...
 

Member Function Documentation

◆ apply()

template<typename Derived >
template<typename basis_t >
basis_t::scalar_t mm::Operator< Derived >::apply ( const basis_t &  basis,
int  index,
typename basis_t::vector_t  point,
const std::vector< typename basis_t::vector_t > &  support,
typename basis_t::scalar_t  scale 
) const

Apply this operator to a given basis function.

This function should be specialized (overloaded) for more concrete values of basis_t in concrete classes inheriting form this one. It is intended that this function is never called but only serves as a default for demonstration purposes and better error messages.

Template Parameters
basis_tBasis type.
Parameters
basisThe basis \(b\) to apply the operator to.
indexWhich element of the basis to apply the operator to.
pointAt which aldeary shifted and translated point to apply the operator.
supportLocal support domain (already shifted and scaled). These are the values \((x-c)/s\) in the equation below.
scaleLocal scaling factor \(s\)
Returns
Let this operator be called \(L\), the index-th basis function \(b_i\). The function returns \(L b_i((x-c)/s)\). Not that the operator \(L\) is usually something like "derivative wrt. x" and factors of \(s\) appear in the result.
See also
RBFBasis::evalOp, Monomials::evalOp, applyAt0

Definition at line 16 of file Operators.hpp.

◆ applyAt0()

template<typename Derived >
template<typename basis_t >
basis_t::scalar_t mm::Operator< Derived >::applyAt0 ( const basis_t &  basis,
int  index,
const std::vector< typename basis_t::vector_t > &  support,
typename basis_t::scalar_t  scale 
) const

Like apply, but with point equal to 0.

See also
apply, RBFBasis::evalOpAt0, Monomials::evalOpAt0

Definition at line 25 of file Operators.hpp.

◆ operators()

template<typename Derived >
std::array<Derived, 1> mm::Operator< Derived >::operators ( ) const
inline

Return an iterable of iterators represented by a family.

As this is a single operator, the family consists of itself only.

Definition at line 44 of file Operators_fwd.hpp.


The documentation for this struct was generated from the following files:
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
mm::Operator::applyAt0
basis_t::scalar_t applyAt0(const basis_t &basis, int index, const std::vector< typename basis_t::vector_t > &support, typename basis_t::scalar_t scale) const
Like apply, but with point equal to 0.
Definition: Operators.hpp:25
mm::sh::d2
static const shape_flags d2
Indicates to calculate d2 shapes.
Definition: shape_flags.hpp:25
mm::Vec2d
Vec< double, 2 > Vec2d
Convenience typedef for 2d vector of doubles.
Definition: Vec_fwd.hpp:34