/usr/include/rheolef/riesz.h is in librheolef-dev 6.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | #ifndef _RHEO_RIESZ_H
#define _RHEO_RIESZ_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
#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_type& 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_type& 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_type& 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_type& 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_type& 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_type& 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_type& 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_type& 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
SYNOPSYS:
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_type);
field riesz (space, Expr expr, domain);
field riesz (space, Expr expr, domain, quadrature_option_type);
@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_type& qopt
= quadrature_option_type())
//>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_type& qopt
= quadrature_option_type())
//>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_type& qopt
= quadrature_option_type())
//>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_type& qopt
= quadrature_option_type())
//>riesz:
{
return details::riesz_tag (Xh, f, qopt, gh,
typename details::is_constant<Function>::type());
}
}// namespace rheolef
#endif // _RHEO_RIESZ_H
|