Loading...
Searching...
No Matches
riesz.h
Go to the documentation of this file.
#ifndef _RHEO_RIESZ_H
#define _RHEO_RIESZ_H
#include "rheolef/field.h"
#include "rheolef/band.h"
#include "rheolef/test.h"
#include "rheolef/integrate.h"
namespace rheolef {
// --------------------------------------------------------------------------
// implementation
// --------------------------------------------------------------------------
namespace details {
// --------------------------------------------------------------------------
// generic implementation
// --------------------------------------------------------------------------
// scalar-valued function
template <class T, class M, class Geo, class Function>
field_basic<T,M>
riesz_function_internal (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
std::false_type)
{
test_basic<T,M,vf_tag_01> v (Xh);
return integrate (dom, f*v, qopt);
}
// vector-valued function
template <class T, class M, class Geo, class Function>
field_basic<T,M>
riesz_function_internal (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
std::true_type)
{
test_basic<T,M,vf_tag_01> v (Xh);
return integrate (dom, dot(f,v), qopt);
}
// --------------------------------------------------------------------------
// switch between compile-time return type:
// --------------------------------------------------------------------------
template <class T, class M, class Geo, class Function>
field_basic<T,M>
riesz_tag2 (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
const T&)
{
return riesz_function_internal (Xh, f, qopt, dom, std::false_type());
}
template <class T, class M, class Geo, class Function>
field_basic<T,M>
riesz_tag2 (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
const point_basic<T>&)
{
return riesz_function_internal (Xh, f, qopt, dom, std::true_type());
}
template <class T, class M, class Geo, class Function>
field_basic<T,M>
riesz_tag2 (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
const undeterminated_basic<T>&)
{
if (Xh.valued_tag() == space_constant::scalar) {
return riesz_function_internal (Xh, f, qopt, dom, std::false_type());
} else {
return riesz_function_internal (Xh, f, qopt, dom, std::true_type());
}
}
// --------------------------------------------------------------------------
// f: switch between constant or function
// --------------------------------------------------------------------------
// f is a function:
template <class T, class M, class Geo, class Function>
typename
std::enable_if<
is_field_function<Function>::value
,field_basic<T,M>
>::type
riesz_tag (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
std::false_type)
{
using result_type = typename field_function_traits<Function>::result_type;
return riesz_tag2 (Xh, f, qopt, dom, result_type());
}
// f is an expression
template <class T, class M, class Geo, class Function>
typename
std::enable_if<
! is_field_function<Function>::value
,field_basic<T,M>
>::type
riesz_tag (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt,
const Geo& dom,
std::false_type)
{
using result_type = typename Function::result_type;
return riesz_tag2 (Xh, f, qopt, dom, result_type());
}
// f is a constant:
// thanks to a wrapper class, we go to the first case
template <class T, class M, class Geo, class Constant>
field_basic<T,M>
riesz_tag (
const space_basic<T,M>& Xh,
const Constant& value,
const quadrature_option& qopt,
const Geo& dom,
std::true_type)
{
typedef typename field_basic<T,M>::float_type float_type;
typedef typename constant_promote<Constant>::type constant_type; // int to Float, but conserve point_basic<T> & tensor
return riesz_tag (Xh, f_constant<point_basic<float_type>,constant_type>(value),
qopt, dom, std::false_type());
}
} // namespace details
/*Class:riesz
NAME: @code{riesz} - approximate a Riesz representer
@findex riesz
@cindex riesz representer
@cindex quadrature formula
@clindex space
@clindex field
SYNOPSIS:
The @code{riesz} function is now obsolete: it has been now suppersetted by the @code{integrate} function
@pxref{integrate algorithm}.
@example
template <class Expr>
field riesz (space, Expr expr);
field riesz (space, Expr expr, quadrature_option);
field riesz (space, Expr expr, domain);
field riesz (space, Expr expr, domain, quadrature_option);
@end example
The domain can be also provided by its name as a string.
The old-fashioned code:
NOTE:
The @code{riesz} function is now obsolete: it has been now suppersetted by the @code{integrate} function
@pxref{integrate algorithm}.
The old-fashioned code:
@example
field l1h = riesz (Xh, f);
field l2h = riesz (Xh, f, "boundary");
@end example
writes now:
@example
test v (Xh);
field l1h = integrate (f*v);
field l2h = integrate ("boundary", f*v);
@end example
The @code{riesz} function is still present in the library for backward compatibility purpose.
DESCRIPTION:
Let @code{f} be any continuous function, its Riesz representer in the finite
element space @code{Xh} on the domain @code{Omega} is defind by:
@example
/
|
dual(lh,vh) = | f(x) vh(x) dx
|
/ Omega
@end example
for all @code{vh} in @code{Xh}, where @code{dual} denotes the duality
between @code{Xh} and its dual. As @code{Xh} is a finite dimensional space,
its dual is identified as @code{Xh} and the duality product as the Euclidian one.
The Riesz representer is thus the @code{lh} field of @code{Xh} where
its i-th degree of freedom is:
@example
/
|
dual(lh,vh) = | f(x) phi_i(x) dx
|
/ Omega
@end example
where phi_i is the i-th basis function in @code{Xh}.
The integral is evaluated by using a quadrature formula.
By default the quadrature formule is the Gauss one with
the order equal to @code{2*k-1} where $@code{k} is the polynomial degree in @code{Xh}.
Alternative quadrature formula and order is available
by passing an optional variable to riesz.
@noindent
The function @code{riesz} implements the
approximation of the Riesz representer
by using some quadrature formula for the evaluation of the integrals.
Its argument can be any function, class-function or linear or nonlinear
expressions mixing fields and continuous functions.
@cindex integrate
@findex integrate
EXAMPLE:
@noindent
The following code compute the Riesz representant, denoted
by @code{lh} of f(x), and the integral of f over the domain omega:
@example
Float f(const point& x);
...
space Xh (omega_h, "P1");
field lh = riesz (Xh, f);
Float int_f = dual(lh, 1);
@end example
OPTIONS:
An optional argument specifies the quadrature formula used
for the computation of the integral.
The domain of integration is by default the mesh associated to
the finite element space.
An alternative domain @code{dom}, e.g. a part of
the boundary can be supplied as an extra argument.
This domain can be also a @code{band} associated to
the banded level set method.
End: */
//<riesz:
template <class T, class M, class Function>
inline
field_basic<T,M>
riesz (
const space_basic<T,M>& Xh,
const Function& f,
const quadrature_option& qopt
= quadrature_option())
//>riesz:
{
return details::riesz_tag (Xh, f, qopt, Xh.get_geo(),
typename details::is_constant<Function>::type());
}
//<riesz:
template <class T, class M, class Function>
field_basic<T,M>
riesz (
const space_basic<T,M>& Xh,
const Function& f,
const geo_basic<T,M>& dom,
const quadrature_option& qopt
= quadrature_option())
//>riesz:
{
return details::riesz_tag (Xh, f, qopt, dom,
typename details::is_constant<Function>::type());
}
//<riesz:
template <class T, class M, class Function>
field_basic<T,M>
riesz (
const space_basic<T,M>& Xh,
const Function& f,
std::string dom_name,
const quadrature_option& qopt
= quadrature_option())
//>riesz:
{
const geo_basic<T,M>& omega = Xh.get_geo();
return riesz (Xh, f, omega[dom_name], qopt);
}
//<riesz:
template <class T, class M, class Function>
field_basic<T,M>
riesz (
const space_basic<T,M>& Xh,
const Function& f,
const band_basic<T,M>& gh,
const quadrature_option& qopt
= quadrature_option())
//>riesz:
{
return details::riesz_tag (Xh, f, qopt, gh,
typename details::is_constant<Function>::type());
}
}// namespace rheolef
#endif // _RHEO_RIESZ_H
gh
field gh(Float epsilon, Float t, const field &uh, const test &v)
Definition burgers_diffusion_operators.icc:37
rheolef::field_basic
Definition field.h:219
rheolef::field_basic::float_type
typename float_traits< T >::type float_type
Definition field.h:228
rheolef::geo_basic
generic mesh with rerefence counting
Definition geo.h:1089
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition integrate_option.h:125
rheolef::point_basic
Definition point.h:86
rheolef::space_basic
the finite element space
Definition space.h:382
rheolef::test_basic
Definition test.h:207
T
Expr1::float_type T
Definition field_expr.h:230
rheolef::details::riesz_tag
std::enable_if< is_field_function< Function >::value, field_basic< T, M > >::type riesz_tag(const space_basic< T, M > &Xh, const Function &f, const quadrature_option &qopt, const Geo &dom, std::false_type)
Definition riesz.h:113
rheolef::details::dot
rheolef::details::is_vec dot
rheolef::details::riesz_tag2
field_basic< T, M > riesz_tag2(const space_basic< T, M > &Xh, const Function &f, const quadrature_option &qopt, const Geo &dom, const T &)
Definition riesz.h:68
rheolef::details::riesz_function_internal
field_basic< T, M > riesz_function_internal(const space_basic< T, M > &Xh, const Function &f, const quadrature_option &qopt, const Geo &dom, std::false_type)
Definition riesz.h:40
rheolef::space_constant::scalar
@ scalar
Definition space_constant.h:134
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::riesz
field_basic< T, M > riesz(const space_basic< T, M > &Xh, const Function &f, const quadrature_option &qopt=quadrature_option())
Definition riesz.h:258
rheolef::integrate
std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr >::value &&!is_undeterminated< Result >::value, Result >::type integrate(const geo_basic< T, M > &omega, const Expr &expr, const integrate_option &iopt, Result dummy=Result())
see the integrate page for the full documentation
Definition integrate.h:211
f
Definition cavity_dg.h:29
rheolef::details::constant_promote::type
Constant type
Definition space_constant.h:349
rheolef::details::f_constant
Definition space_constant.h:295
rheolef::details::field_function_traits
Definition field_concept.h:154
rheolef::details::is_constant
Definition space_constant.h:317
rheolef::details::result_type
Definition space_constant.h:337
rheolef::undeterminated_basic
helper for generic field value_type: T, point_basic<T> or tensor_basic<T>
Definition undeterminated.h:32