13#ifndef FEM_INTEGRATION_HH
14#define FEM_INTEGRATION_HH
22#include <dune/geometry/quadraturerules.hh>
30 namespace Integration_Detail
33 template <
class Function,
class Functor>
39 template <
class Cell,
class QuadPo
int,
class Evaluator>
40 void operator()(
Cell const& cell, QuadPoint
const& qp, Evaluator
const& eval)
const
42 g(cell,qp,f.value(eval));
45 template <
class Evaluator>
46 int order(Evaluator
const& eval)
const
72 template <
class Function,
class Functor>
75 Integration_Detail::G<Function,Functor> gWrapper(f,accumulator);
99 template <
class Functor,
class Space>
102 typedef typename Space::Grid Grid;
103 typedef typename Grid::LeafGridView GridView;
104 typedef typename Space::Evaluator Evaluator;
108 GridView
const& gridView = space.grid().leafGridView();
110 Evaluator evaluator(space,&sfCache);
111 for(
auto const& cell : elements(gridView))
113 evaluator.moveTo(cell);
114 Dune::GeometryType gt = cell.type();
115 auto const& qr = Dune::QuadratureRules<typename Grid::ctype,Grid::dimension>::rule(gt,g.order(evaluator));
116 evaluator.useQuadratureRule(qr,0);
118 size_t nQuadPos = qr.size();
119 for (
size_t i=0; i<nQuadPos; ++i)
121 evaluator.evaluateAt(qr[i].position(),qr,i,0);
122 g(cell,qr[i],evaluator);
140 template <
class Functor,
class Function,
class Space>
143 typedef typename Space::Grid Grid;
144 typedef typename Grid::LeafGridView GridView;
145 typedef typename Space::Evaluator Evaluator;
153 typedef typename GridView::template Codim<0>::Iterator CellIterator ;
154 GridView
const& gridView = f.space().grid().leafGridView() ;
156 Evaluator evaluator(space, &sfCache);
158 for (CellIterator ci=gridView.template begin<0,Dune::All_Partition>();
159 ci!=gridView.template end<0,Dune::All_Partition>(); ++ci)
161 evaluator.moveTo(*ci);
163 Dune::GeometryType gt = ci->type();
164 auto const& qr = Dune::QuadratureRules<typename Grid::ctype,Grid::dimension>::rule(gt,f.
order(evaluator));
166 size_t nQuadPos = qr.size();
167 for (
size_t i=0; i<nQuadPos; ++i)
168 g(
typename GridView::template Codim<0>::EntityPointer(ci),qr[i],f.
value(*ci,qr[i].position()));
182 template <
class FEFunction>
184 typename FEFunction::Space::GridView::Intersection
const& intersection,
185 typename FEFunction::Space::Evaluator& evaluator)
187 typename FEFunction::Space::Grid::template Codim<0>::Entity cell = intersection.inside();
188 evaluator.moveTo(cell);
189 typename FEFunction::ValueType
integral(0.0);
190 auto const& refElem = evaluator.shapeFunctions().referenceElement();
191 auto const& qr = Dune::QuadratureRules<typename FEFunction::Space::ctype,FEFunction::Space::dim-1>::rule(intersection.type(),function.order(evaluator));
192 int nQuadPos = qr.size();
193 for (
int i=0; i<nQuadPos; ++i)
195 auto localPositionInCell = refElem.template geometry<1>(intersection.indexInInside()).global(qr[i].position());
196 evaluator.evaluateAt(localPositionInCell,qr,i,intersection.indexInInside());
197 integral += qr[i].weight()*intersection.geometry().integrationElement(qr[i].position())*function.value(evaluator);
210 template <
class FEFunction>
214 typename FEFunction::Space::Evaluator evaluator(function.space(),&sfCache);
215 typename FEFunction::Space::GridView
const& gridView = function.space().gridView();
216 typename FEFunction::ValueType
integral(0.0);
217 forEachBoundaryFace(gridView,[&](
typename FEFunction::Space::GridView::Intersection
const& intersection)
234 template <
template <
class,
class>
class DomainMapper,
typename Scalar,
typename GridView,
int m>
235 typename FunctionSpaceElement<FEFunctionSpace<BoundaryMapper<DomainMapper, Scalar, GridView>>,m>::ValueType
240 typename FEFunction::Space::Evaluator evaluator(function.space(),&sfCache);
241 GridView
const& gridView = function.space().gridView();
243 typename FEFunction::ValueType
integral(0.0);
253 template <
typename Space>
256 typedef typename Space::Grid Grid;
257 typedef typename Space::GridView GridView;
259 typedef typename Grid::template Codim<0>::Entity Cell;
260 typedef Dune::QuadraturePoint<typename Grid::ctype,Grid::dimension> QuadPoint;
261 typedef typename Space::template Element<1>::type::ValueType ValueType;
266 template <
class CellPo
inter>
267 void operator()(CellPointer
const& c, QuadPoint
const& q, ValueType v)
269 v *= q.weight()*c->geometry().integrationElement(q.position());
288 class =
typename Function::Space>
292 auto integrator = [&](
auto const& cell,
auto const& qp,
auto const& val)
294 sum += qp.weight()*cell.geometry().integrationElement(qp.position())*val;
300 template <
class WeakFunctionView,
class Space>
310 template <
typename Space>
311 class [[deprecated("Use
integral() functions directly. Wil be removed after 2019-12-31.")]]
Integral
314 template<
typename Function>
320 template<
typename Function>
332 template<
typename Function>
340 template<
typename Function>
Function is the interface for evaluatable functions .
int order(Cell const &cell) const
ValueType value(Cell const &cell, Dune::FieldVector< typename Cell::Geometry::ctype, Cell::dimension > const &localCoordinate) const
A local to global mapper implementation for boundary spaces, with functions defined on the domain bou...
bool inDomain(typename GridView::Intersection const &face) const
A representation of a finite element function space defined over a domain covered by a grid.
A class for representing finite element functions.
Evaluation class for integrals.
Function::ValueType operator()(Function const &f, typename Function::Space const &space)
Function::ValueType operator()(Function const &f)
void operator()(CellPointer const &c, QuadPoint const &q, ValueType v)
This class caches values and derivatives of shape functions at quadrature points.
A function that supports efficient evaluation via cell and local coordinate.
FEFunctionSpace and FunctionSpaceElement and the like.
void forEachQuadPoint(Function const &f, Functor &accumulator)
Loops over the whole domain occupied by the grid and calls an accumulator for each integration point ...
Function::ValueType integral(Function const &f)
Evaluate integrals of finite element functions.
void forEachQP(Functor &g, Space const &space)
Loops over the whole domain occupied by the grid and calls the functor g for each integration point w...
FEFunction::ValueType integrateOverIntersection(FEFunction const &function, typename FEFunction::Space::GridView::Intersection const &intersection, typename FEFunction::Space::Evaluator &evaluator)
integrateOverIntersection computes the integral of an FE function over a grid intersection (face).
FEFunction::ValueType integrateOverBoundary(FEFunction const &function)
integrateOverBoundary computes the integral of an FE function over the whole boundary of the underlyi...
void forEachBoundaryFace(GridView const &gridView, Functor functor)
iterates over each boundary face and applies functor to face. Each boundary face is visited exactly o...
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
Function::Scalar operator()(Function const &f) const
Evaluation of norm (??? that's not true)
Function::Scalar id(Function const &f) const
Evaluation of integral.