LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Related Symbols | List of all members
lf::mesh::utils::MeshFunctionBinary< OP, A, B > Class Template Reference

A MeshFunction which combines two other mesh functions using a binary operator (advanced use). More...

#include <lf/uscalfe/uscalfe.h>

Public Member Functions

 MeshFunctionBinary (OP op, A a, B b)
 Create a new MeshFunctionBinary.
 
auto operator() (const lf::mesh::Entity &e, const Eigen::MatrixXd &local) const
 

Private Attributes

OP op_
 
a_
 
b_
 

Related Symbols

(Note that these are not member symbols.)

template<MeshFunction A, MeshFunction B>
auto operator+ (const A &a, const B &b) -> MeshFunctionBinary< internal::OperatorAddition, A, B >
 Add's two mesh functions.
 
template<MeshFunction A, MeshFunction B>
auto operator- (const A &a, const B &b) -> MeshFunctionBinary< internal::OperatorSubtraction, A, B >
 Subtracts two mesh functions.
 
template<MeshFunction A, MeshFunction B>
auto operator* (const A &a, const B &b) -> MeshFunctionBinary< internal::OperatorMultiplication, A, B >
 Multiply two mesh functions with each other.
 

Detailed Description

template<class OP, class A, class B>
class lf::mesh::utils::MeshFunctionBinary< OP, A, B >

A MeshFunction which combines two other mesh functions using a binary operator (advanced use).

Template Parameters
OPThe type of operator that combines the mesh functions.
AThe type of the lhs mesh function.
BThe type of the rhs mesh function.

Requirements for OP

The Operator OP must fulfill the following requirements:

Note
Usually there is no need to use MeshFunctionBinary directly. There are a number of operator overloads which use MeshFunctionBinary internally.
The last int argument of operator() can be used to prefer certain overloads over others, e.g. operator()(const std::vector<U>& u, const std::vector<V>& int) takes higher precedence than operator()(const std::vector<U>& u, const std::vector<V>& long)

Definition at line 51 of file mesh_function_binary.h.

Constructor & Destructor Documentation

◆ MeshFunctionBinary()

template<class OP , class A , class B >
lf::mesh::utils::MeshFunctionBinary< OP, A, B >::MeshFunctionBinary ( OP op,
A a,
B b )
inline

Create a new MeshFunctionBinary.

Parameters
opThe operator to apply
aThe lhs mesh function
bThe rhs mesh function.

Definition at line 59 of file mesh_function_binary.h.

Member Function Documentation

◆ operator()()

template<class OP , class A , class B >
auto lf::mesh::utils::MeshFunctionBinary< OP, A, B >::operator() ( const lf::mesh::Entity & e,
const Eigen::MatrixXd & local ) const
inline

Friends And Related Symbol Documentation

◆ operator*()

template<MeshFunction A, MeshFunction B>
auto operator* ( const A & a,
const B & b ) -> MeshFunctionBinary<internal::OperatorMultiplication, A, B>
related

Multiply two mesh functions with each other.

Template Parameters
AThe type of the lhs MeshFunction
BThe type of the rhs MeshFunction
Parameters
athe lhs MeshFunction
bthe rhs MeshFunction
Returns
Return a*b, i.e. a new mesh function which represents the pointwise product of a and b.
Note
if A and B are Eigen::Matrix valued, the resulting MeshFunction will also be Matrix/Vector valued and will represent the Matrix product of a and b.
If you want to apply this operator overload to meshfunctions" which do not reside in the lf::uscalfe namespace, it will not be found by Argument Dependent Lookup (ADL). You can get around this by explicitly importing the operator overload: using lf::uscalfe::operator*;

Example

auto mesh_factory = std::make_unique<mesh::hybrid2d::MeshFactory>(2);
auto gmsh_reader = io::GmshReader(std::move(mesh_factory), "mesh.msh");
// a mesh function which takes the value 1 everywhere
auto mf_one = mesh::utils::MeshFunctionConstant(1.);
// a mesh function which represents the radial vector field (x,y)
auto mf_radial = mesh::utils::MeshFunctionGlobal(
[](const Eigen::Vector2d& x) { return x; });
// a matrix valued mesh function ((x,y),(x^2,y^2))
auto mf_matrix =
mesh::utils::MeshFunctionGlobal([](const Eigen::Vector2d& x) {
return (Eigen::Matrix2d() << x[0], x[1], x[0] * x[0], x[1] * x[1])
.finished();
});
// product of two scalar valued mesh functions:
auto p0 = mf_one * mesh::utils::MeshFunctionConstant(3.);
// product of a scalar valued mesh function with a matrix valued one:
auto p1 = mf_one * mf_matrix;
// product of matrix valued with a vector valued mesh function:
auto p2 = mf_matrix * mf_radial; // will be vector valued
// product of a matrix valued mesh function with itself:
auto p3 = mf_matrix * mf_matrix;

Definition at line 722 of file mesh_function_binary.h.

◆ operator+()

template<MeshFunction A, MeshFunction B>
auto operator+ ( const A & a,
const B & b ) -> MeshFunctionBinary<internal::OperatorAddition, A, B>
related

Add's two mesh functions.

Template Parameters
AType of the lhs MeshFunction
BType of the rhs MeshFunction
Parameters
athe lhs MeshFunction
bthe rhs MeshFunction
Returns
a + b, i.e. a new mesh function which represents the pointwise addition of a and b
Note
the two mesh functions a and b should produce the same type of values, e.g. both should be scalar valued or both matrix/vector/array valued.
If you want to apply this operator overload to meshfunctions" which do not reside in the lf::uscalfe namespace, it will not be found by Argument Dependent Lookup. You can get around this by explictly importing the operator overload: using lf::uscalfe::operator+;

Example

auto mesh_factory = std::make_unique<mesh::hybrid2d::MeshFactory>(2);
auto gmsh_reader = io::GmshReader(std::move(mesh_factory), "mesh.msh");
// a mesh function that takes the value 1 everywhere
auto mf_one = mesh::utils::MeshFunctionConstant(1.);
// a mesh function which represents the function `sin(x)*cos(y)` (x,y are
// global coordinates)
auto mf_trig = mesh::utils::MeshFunctionGlobal(
[](const Eigen::Vector2d& x) { return std::sin(x[0]) * std::cos(x[1]); });
// mesh function `1+sin(x)*cos(y)`
auto mf_one_trig = mf_one + mf_trig;

Definition at line 664 of file mesh_function_binary.h.

◆ operator-()

template<MeshFunction A, MeshFunction B>
auto operator- ( const A & a,
const B & b ) -> MeshFunctionBinary<internal::OperatorSubtraction, A, B>
related

Subtracts two mesh functions.

Template Parameters
AType of the lhs MeshFunction
BType of the rhs MeshFunction
Parameters
athe lhs MeshFunction
bthe rhs MeshFunction
Returns
a - b, i.e. a new mesh function which represents the pointwise difference of a minus b
Note
the two mesh functions a and b should produce the same type of values, e.g. both should be scalar valued or both matrix/vector valued.
If you want to apply this operator overload to meshfunctions" which do not reside in the lf::uscalfe namespace, it will not be found by Argument Dependent Lookup (ADL). You can get around this by explicitly importing the operator overload: using lf::uscalfe::operator-;

Example

auto mesh_factory = std::make_unique<mesh::hybrid2d::MeshFactory>(2);
auto gmsh_reader = io::GmshReader(std::move(mesh_factory), "mesh.msh");
// a mesh function that takes the value 1 everywhere
auto mf_one = mesh::utils::MeshFunctionConstant(1.);
// a mesh function which represents the function `sin(x)*cos(y)` (x,y are
// global coordinates)
auto mf_trig = mesh::utils::MeshFunctionGlobal(
[](const Eigen::Vector2d& x) { return std::sin(x[0]) * std::cos(x[1]); });
// mesh function `1-sin(x)*cos(y)`
auto mf_one_minus_trig = mf_one - mf_trig;

Definition at line 693 of file mesh_function_binary.h.

Member Data Documentation

◆ a_

template<class OP , class A , class B >
A lf::mesh::utils::MeshFunctionBinary< OP, A, B >::a_
private

◆ b_

template<class OP , class A , class B >
B lf::mesh::utils::MeshFunctionBinary< OP, A, B >::b_
private

◆ op_

template<class OP , class A , class B >
OP lf::mesh::utils::MeshFunctionBinary< OP, A, B >::op_
private

The documentation for this class was generated from the following file: