13#ifndef RESIDUAL_ERROREST_HH
14#define RESIDUAL_ERROREST_HH
20 template <
class LocalInd,
class Evaluators,
class RT,
class TestFunctions,
class Cache>
23 static const int dim = boost::fusion::result_of::value_at_c<Evaluators,0>::type::Space::dim;
28 TestFunctions
const& tf_,
30 Cache
const& cacheNeigh_):
34 modarg.gradient[0]=outernormal_;
37 template <
class Variable>
41 boost::fusion::at_c<Variable::id>(
tf.vars).value(boost::fusion::at_c<Variable::spaceIndex>(
evaluators));
47 TestFunctions
const&
tf;
52 template <
class LocalInd,
class Evaluators,
class RT,
class TestFunctions,
class Cache,
class BoundaryCache>
55 static const int dim = boost::fusion::result_of::value_at_c<Evaluators,0>::type::Space::dim;
59 RT
const & integrationElement_,
61 TestFunctions
const& tf_,
63 BoundaryCache
const& cacheBoundary_):
67 modarg.gradient[0]=outernormal_;
72 template <
class Variable>
78 boost::fusion::at_c<Variable::id>(
tf.vars).value(boost::fusion::at_c<Variable::spaceIndex>(
evaluators));
84 TestFunctions
const&
tf;
89 template <
class LocalInd,
class Evaluators,
class RT,
class TestFunctions,
class Cache>
92 static const int dim = boost::fusion::result_of::value_at_c<Evaluators,0>::type::Space::dim;
95 RT
const & integrationElement,
97 TestFunctions
const& tf_,
105 template <
class Variable>
109 boost::fusion::at_c<Variable::id>(
tf.vars).value(boost::fusion::at_c<Variable::spaceIndex>(
evaluators));
115 TestFunctions
const&
tf;
131 template <
class ErrorDescriptions,
class F,
class FS,
class TestFunctions,
class Spaces,
class TestSpaces>
133 boost::fusion::result_of::size<ErrorDescriptions>::type::value> >& ind,
134 ErrorDescriptions
const& varDesc,
137 TestFunctions
const& tf,
138 Spaces
const& spaces,
139 TestSpaces
const& testSpaces)
142 using namespace Dune;
148 typedef typename Grid::ctype CoordType;
149 int const dim = Grid::dimension;
151 IndexSet
const& indexSet = at_c<0>(spaces)->grid().leafIndexSet();
153 ind.resize(indexSet.size(0));
155 for(
int i=0; i<ind.size(); ++i)
156 for(
int j=0; j<ind[i].N(); ++j)
161 SfCache sfCache,sfCacheN,sfCacheT;
165 typedef typename result_of::as_vector<
166 typename result_of::transform<Spaces, GetEvaluators<SfCache> >::type
169 typedef typename result_of::as_vector<
170 typename result_of::transform<TestSpaces, GetEvaluators<SfCache> >::type
171 >::type TestEvaluators;
178 typedef typename IndexSet::template Codim<0>::template Partition<All_Partition>::Iterator CellIterator;
179 typedef typename CellIterator::Entity::LeafIntersectionIterator LII;
180 typedef typename CellIterator::Entity Entity;
182 typename F::DomainCache domainCache(f.createDomainCache(2));
183 typename FS::DomainCache domainCacheSimpl(fs.createDomainCache(2+8));
184 typename FS::DomainCache domainCacheNeigh(fs.createDomainCache(2+8));
185 typename FS::BoundaryCache boundaryCache(fs.createBoundaryCache(6));
189 CellIterator end = indexSet.template end<0,All_Partition>();
190 for (CellIterator ci=indexSet.template begin<0,All_Partition>(); ci!=end; ++ci) {
192 domainCache.moveTo(*ci);
193 domainCacheSimpl.moveTo(*ci);
197 int shapeFunctionMaxOrder =
maxOrder(evaluators);
198 shapeFunctionMaxOrder =
std::max(shapeFunctionMaxOrder,
maxOrder(testEvaluators));
199 int p = f.integrationOrder(*ci,shapeFunctionMaxOrder,
false);
200 int pb = f.integrationOrder(*ci,shapeFunctionMaxOrder,
true);
201 pb=shapeFunctionMaxOrder+2;
204 GeometryType gti = ci->type();
208 size_t nQuadPosi = qri.size();
209 for (
size_t g=0; g<nQuadPosi; ++g) {
214 domainCache.evaluateAt(quadPos,evaluators);
215 CoordType weightTimesDetJac(ci->geometry().integrationElement(quadPos));
216 weightTimesDetJac *= qri[g].weight();
218 (ind[indexSet.index(*ci)],weightTimesDetJac,testEvaluators, tf,domainCache));
221 LII faceEnd = ci->ileafend();
222 for (LII face=ci->ileafbegin(); face!=faceEnd; ++face) {
223 if(face.neighbor()) {
225 typename LII::EntityPointer o=face.outside();
226 domainCacheNeigh.moveTo(*o);
229 }
else if(face.boundary())
231 boundaryCache.moveTo(face);
233 GeometryType gt=face.intersectionSelfLocal().type();
234 QuadratureRule<CoordType, dim-1>
const& qr=QuadratureRules<CoordType,dim-1>::rule(gt,pb);
235 size_t nQuadPos=qr.size();
236 for(
size_t g=0; g<nQuadPos; ++g){
237 FieldVector<CoordType, dim-1>
const& quadPos = qr[g].position();
241 domainCacheSimpl.evaluateAt(quadPosInSelf,evaluators);
243 outerNormal *= qr[g].weight();
249 domainCacheNeigh.evaluateAt(quadPosInNeigh,evaluatorsNeigh);
252 typename FS::DomainCache>(ind[indexSet.index(*ci)],outerNormal,testEvaluators, tf,domainCacheSimpl,domainCacheNeigh));
254 }
else if(face.boundary())
256 boundaryCache.evaluateAt(quadPos,evaluators);
258 CoordType weightTimesDetJac = face.intersectionGlobal().integrationElement(quadPos);
259 weightTimesDetJac *= qr[g].weight();
262 typename FS::DomainCache,
typename FS::BoundaryCache>(ind[indexSet.index(*ci)],outerNormal, weightTimesDetJac,
263 testEvaluators, tf,domainCacheSimpl,boundaryCache));
A boost::fusion functor for creating an evaluator from the space, using a shape function cache that i...
This class caches values and derivatives of shape functions at quadrature points.
void residualTimesTestFunction(std::vector< Dune::FieldVector< typename SpaceType< Spaces, 0 >::type::RT, boost::fusion::result_of::size< ErrorDescriptions >::type::value > > &ind, ErrorDescriptions const &varDesc, F const &f, FS const &fs, TestFunctions const &tf, Spaces const &spaces, TestSpaces const &testSpaces)
Evaluates strong residual, applied to some test-function <f(x), tf>
void moveEvaluatorsToIntegrationPoint(Evaluators &evals, Dune::FieldVector< CoordType, dim > const &x, Dune::QuadratureRule< CoordType, subDim > const &qr, int ip, int subId)
Moves all provided evaluators to the given integration point, evaluating the shape functions there.
int maxOrder(Evaluators const &evals)
Computes the maximum ansatz order used in a collection of evaluators.
typename boost::fusion::result_of::as_vector< typename boost::fusion::result_of::transform< Spaces, GetEvaluatorTypes >::type >::type Evaluators
the heterogeneous sequence type of Evaluators for the given spaces
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
void moveEvaluatorsToCell(Evaluators &evals, Cell const &cell)
Moves all provided evaluators to the given cell.
Evaluators const & evaluators
void operator()(Variable const &) const
BoundaryCache const & cacheBoundary
BoundaryJumpsTimesTestFunction(LocalInd &localInd_, Dune::FieldVector< RT, dim >const &outernormal_, RT const &integrationElement_, Evaluators const &evaluators_, TestFunctions const &tf_, Cache const &cache_, BoundaryCache const &cacheBoundary_)
VariationalArg< RT, dim > modargB
VariationalArg< RT, dim > modarg
GradientJumpsTimesTestFunction(LocalInd &localInd_, Dune::FieldVector< RT, dim >const &outernormal_, Evaluators const &evaluators_, TestFunctions const &tf_, Cache const &cache_, Cache const &cacheNeigh_)
void operator()(Variable const &) const
VariationalArg< RT, dim > modarg
Evaluators const & evaluators
Extracts the type of FE space with given index from set of spaces.
Evaluators const & evaluators
void operator()(Variable const &) const
StrongResidualsTimesTestFunction(LocalInd &localInd_, RT const &integrationElement, Evaluators const &evaluators_, TestFunctions const &tf_, Cache const &cache_)
VariationalArg< RT, dim > modarg
A class defining elementary information about a single variable.
ValueType value
The shape function's value, a vector of dimension components