13#ifndef FUNCTIONSPACE_HH
14#define FUNCTIONSPACE_HH
34#include <boost/mpl/int.hpp>
35#include <boost/mpl/range_c.hpp>
36#include <boost/multi_array.hpp>
37#include <boost/signals2.hpp>
38#include <boost/type_traits/remove_pointer.hpp>
39#include <boost/type_traits/remove_reference.hpp>
41#include <boost/fusion/algorithm.hpp>
42#include <boost/fusion/sequence.hpp>
44#include "dune/common/config.h"
46#include "dune/common/fmatrixev.hh"
47#include "dune/geometry/quadraturerules.hh"
48#include "dune/istl/bvector.hh"
60 template <
class LocalToGlobalMapper>
class FEFunctionSpace;
62 template <
template <
class,
class>
class,
class,
class>
class BoundaryMapper;
65 namespace FunctionSpace_Detail
67 template <
class Mapper>
68 struct IsBoundaryMapperStruct : std::false_type {};
69 template<
template <
class,
class>
class DomainMapper,
class Scalar,
class GridView>
70 struct IsBoundaryMapperStruct<BoundaryMapper<DomainMapper,Scalar,GridView>> : std::true_type {};
72 template <
class Mapper>
73 constexpr bool isBoundaryMapper() {
74 return IsBoundaryMapperStruct<Mapper>::value;
77 template <
class Mapper>
78 struct ChooseDomainMapperStruct {
81 template<
template <
class,
class>
class DomainMapper,
class Scalar,
class GridView>
82 struct ChooseDomainMapperStruct<BoundaryMapper<DomainMapper,Scalar,GridView>> {
83 using type = DomainMapper<Scalar,GridView>;
86 template<
class Mapper>
87 using ChooseDomainMapper =
typename ChooseDomainMapperStruct<Mapper>::type;
91 bool gridViewsAreSame(
typename Grid::LeafGridView gv1,
typename Grid::LeafGridView gv2) {
92 return &(gv1.grid()) == &(gv2.grid());
96 bool gridViewsAreSame(
typename Grid::LevelGridView gv1,
typename Grid::LevelGridView gv2) {
97 return (gv1.template begin<0>()->level() == gv2.template begin<0>()->level()) && (&(gv1.grid()) == &(gv2.grid()));
102 enum CoefficientTransfer { START, FINISH };
130 template <
class Spaces,
int Idx>
133 using type = std::remove_pointer_t<typename boost::fusion::result_of::value_at_c<Spaces,Idx>::type>;
157 template <
class Cell,
class ctype>
158 std::pair<Cell,Dune::FieldVector<ctype,Cell::dimension>>
161 ctype
const tol = 100*std::numeric_limits<ctype>::epsilon();
165 using namespace Dune;
167 if (level <= cell.level())
169 while (level < cell.level())
171 xi = cell.geometryInFather().global(xi);
172 cell = cell.father();
178 while (cell.level()<level && !cell.isLeaf())
180 for (
Cell const& c: descendantElements(cell,cell.level()+1))
182 auto xiC = c.geometryInFather().local(xi);
193 return std::make_pair(cell,xi);
212 template <
class Gr
idView>
215 const double tol = 1e-12 ;
217 using namespace Dune;
220 auto coarseIterator = std::find_if(gv.grid().levelGridView(0).template begin<0>(), gv.grid().levelGridView(0).template end<0>(),
223 return checkInside(cell.type(),cell.geometry().local(global)) < tol;
226 if (coarseIterator == gv.grid().levelGridView(0).template end<0>())
228 std::ostringstream msg;
229 msg <<
"findCell(): global point << " << global <<
" is not contained in any level 0 cell in the grid!";
239 for(
int level = 0; level <= gv.grid().maxLevel(); level++ )
244 for (
auto hi = ci.hbegin(level+1); hi != ci.hend(level+1) ; ++hi)
245 if(
checkInside(hi->type(),hi->geometry().local(global)) < tol )
247 ci =
typename GridView::Grid::template Codim<0>::Entity(*hi);
256 std::cerr <<
"findCell() at " << __FILE__ <<
':' << __LINE__ <<
'\n'
257 <<
"Global point << " << global
258 <<
" is not contained in any cell in the grid!\n"
259 <<
" last found on " << lastFound <<
" of " << gv.grid().maxLevel() <<
"\n";
313 template <
class FunctionSpace,
int m>
324 using ctype =
typename GridView::ctype;
390 data(fs.degreesOfFreedom()),
sp(&fs), transferMe(*this)
393 transferConnection =
sp->requestToRefine.connect(transferMe);
400 transferConnection =
sp->requestToRefine.connect(transferMe);
405 transferConnection.disconnect();
432 interpolateGlobally<PlainAverage>(*
this,fse);
449 data = std::move(fse.data);
450 fse.transferConnection.disconnect();
453 interpolateGlobally<PlainAverage>(*
this,fse);
466 template <
class OtherSpace>
469 interpolateGlobally<PlainAverage>(*
this,f);
483 template <
template <
class,
class>
class DomainMapper>
486 bool hasEquivalentUnderlyingMapper = !FunctionSpace_Detail::isBoundaryMapper<typename Space::Mapper>();
487 hasEquivalentUnderlyingMapper = (hasEquivalentUnderlyingMapper && std::is_same<DomainMapper<Scalar,typename Space::GridView>,
typename Space::Mapper>
::value);
488 hasEquivalentUnderlyingMapper = (hasEquivalentUnderlyingMapper &&
space().mapper().maxOrder()==bf.space().mapper().maxOrder());
489 hasEquivalentUnderlyingMapper = (hasEquivalentUnderlyingMapper && FunctionSpace_Detail::gridViewsAreSame<typename Space::GridView::Grid>(
space().gridView(),bf.space().gridView()));
490 if(hasEquivalentUnderlyingMapper) {
493 for(
typename StorageType::size_type vi=0;vi<
size();++vi) {
495 if(restrictedIndex.first) {
496 data[vi] = bf[restrictedIndex.second];
504 interpolateGlobally<PlainAverage>(*
this,df);
517 template <
class Mapper>
518 std::enable_if_t<std::is_same<Mapper,FunctionSpace_Detail::ChooseDomainMapper<typename Space::Mapper>>
::value,
Self&>
521 bool hasEquivalentUnderlyingMapper = FunctionSpace_Detail::isBoundaryMapper<typename Space::Mapper>();
522 hasEquivalentUnderlyingMapper = (hasEquivalentUnderlyingMapper &&
space().mapper().maxOrder()==f.space().mapper().maxOrder());
523 hasEquivalentUnderlyingMapper = (hasEquivalentUnderlyingMapper && FunctionSpace_Detail::gridViewsAreSame<typename Space::GridView::Grid>(
space().gridView(),f.space().gridView()));
524 if (hasEquivalentUnderlyingMapper)
526 typename Space::Mapper
const& boundaryMapper =
space().mapper();
527 for(
typename StorageType::size_type vi=0;vi<f.size();++vi)
529 std::pair<bool,typename StorageType::size_type> restrictedIndex = boundaryMapper.unrestrictedToRestrictedIndex(vi);
530 if (restrictedIndex.first)
531 data[restrictedIndex.second] = f[vi];
535 interpolateGlobally<PlainAverage>(*
this,f);
554 template <
class Functor>
574 template <
class Space,
class Functor>
588 assert(
data.size()==v.size());
627 Self tmp(
space()); tmp = f; *
this += tmp;
637 template <
class OtherSpace>
640 Self tmp(
space()); tmp = f; *
this += tmp;
656 for (
int i=0; i<
data.N(); ++i)
672 Self tmp(
space()); tmp = f; *
this -= tmp;
682 template <
class OtherSpace>
685 Self tmp(
space()); tmp = f; *
this -= tmp;
694 assert(
data.size()==v.size());
719 template <
class OtherSpace>
756 size_t esize = evaluator.size();
758 for (
size_t i=0; i<esize; ++i)
761 auto const& sfVal = evaluator.evalData[i].value;
762 for (
int n=0; n<m; ++n)
763 for (
int l=0; l<Space::sfComponents; ++l)
764 y[n*Space::sfComponents+l] += coeff[n]*sfVal[l];
779 typename Space::Evaluator eval(
space());
781 eval.evaluateAt(local);
795 auto xi = cell.geometry().local(x);
797 return value(cell,xi);
811 size_t esize = evaluator.size();
812 for (
size_t i=0; i<esize; ++i)
814 auto const& coeff =
data[evaluator.globalIndices()[i]];
815 auto const& sfGrad = evaluator.evalData[i].derivative;
816 for (
int n=0; n<m; ++n)
817 for (
int l=0; l<Space::sfComponents; ++l)
818 dy[n*Space::sfComponents+l] += coeff[n] * sfGrad[l];
833 typename Space::Evaluator eval(
space());
835 eval.evaluateAt(local);
849 return derivative(ci,ci.geometry().local(global));
863 assert(evaluator.derivatives() >= 2);
865 size_t esize = evaluator.size();
866 for (
size_t i=0; i<esize; ++i) {
868 auto const& sfHess = evaluator.evalData[i].hessian;
869 for (
int n=0; n<m; ++n)
870 for (
int l=0; l<Space::sfComponents; ++l) {
871 auto hess = sfHess[l];
873 ddy[n*Space::sfComponents+l] += hess;
889 typename Space::Evaluator eval(
space(),
nullptr,2);
891 eval.evaluateAt(local);
904 return hessian(ci,ci.geometry().local(global));
966 return space().mapper().shapefunctions(cell).order();
972 [[deprecated]]
int order(SFS
const& sfs)
const
984 std::unique_ptr<Dune::BlockVector<StorageValueType>> newCoeff = transferMatrix.
apply(
data);
996 TransferMe(
Self& fe) : myFSE(fe) {}
998 TransferMe(TransferMe
const& other)
1002 void operator()(
typename TransferData<Space>::TransferMatrix
const*
transfer)
1008 future = std::async(std::launch::async,[
transfer,f=&myFSE]() { f->transfer(*
transfer); });
1012 assert(future.valid());
1019 std::future<void> future;
1029 TransferMe transferMe;
1030 boost::signals2::connection transferConnection;
1038 template <
class Space,
int m,
class OutIter>
1044 template <
class Space,
int m,
class InIter>
1050 namespace FunctionSpace_Detail
1054 template <
class FEFunction>
1059 FEFunction
const&
get()
const {
1064 FEFunction
const& f;
1067 template <
template <
class,
class>
class DomainMapper,
typename Scalar,
typename GridView,
int m>
1085 DomainFESpace space;
1115 template <
class LocalToGlobalMapper>
1122 using GridView =
typename LocalToGlobalMapper::GridView;
1124 typedef typename GridView::Grid
Grid;
1129 typedef typename LocalToGlobalMapper::Scalar
Scalar;
1144 static int const dim = Grid::dimension;
1234 space(space_), sf(nullptr), cache(cache_), sfValues(nullptr), combiner_(nullptr),
1235 globIdx(space.
mapper().initGlobalIndexRange()), sortedIdx(space.
mapper().initSortedIndexRange()),
1236 deriv(deriv_), currentCell(nullptr)
1244 space(eval.space), sf(eval.sf), sfSize(eval.sfSize), cache(eval.cache), sfValues(eval.sfValues), lastQr(eval.lastQr), lastSubId(eval.lastSubId), combiner_(nullptr),
1245 globIdx(eval.globIdx), sortedIdx(eval.sortedIdx), deriv(eval.deriv), currentXloc(eval.currentXloc), currentCell(nullptr)
1248 combiner_ = std::make_unique<typename Mapper::Combiner>(*eval.combiner_);
1249 if (eval.currentCell)
1250 currentCell = std::make_unique<Cell>(*eval.currentCell);
1258 assert(&space==&eval.space);
1260 sfSize = eval.sfSize();
1262 sfValues = eval.sfValues;
1265 converter = eval.converter;
1266 if (eval.combiner_) {
1267 combiner_ = std::make_unique<typename Mapper::Combiner>(*eval.combiner_);
1271 globIdx = eval.globIdx;
1272 sortedIdx = eval.sortedIdx;
1275 currentXloc = eval.currentXloc;
1276 if (eval.currentCell) {
1277 currentCell = std::make_unique<Cell>(*eval.currentCell);
1279 currentCell.reset();
1299 sf = &space.
mapper().shapefunctions(index);
1300 sfSize = sf->size();
1303 currentCell = std::make_unique<Cell>(
cell);
1305 converter.moveTo(*currentCell);
1307 combiner_ = std::make_unique<typename Mapper::Combiner>(space.
mapper().combiner(*currentCell,index));
1309 globIdx = space.
mapper().globalIndices(index);
1310 sortedIdx = space.
mapper().sortedIndices(index);
1334 template <
int subDim>
1341 if(FunctionSpace_Detail::isBoundaryMapper<Mapper>())
1344 if (sfValues && lastQr==&qr && lastSubId==subId)
1349 sfValues = &cache->
evaluate(*sf,qr,subId);
1363 converter.setLocalPosition(xi);
1366 for (
int i=0; i<sfSize; ++i)
1370 typename Mapper::ShapeFunctionSet::value_type
const& sfun = (*sf)[i];
1372 converter.global(SfArg(sfun.evaluateFunction(xi),sfun.evaluateDerivative(xi)),1) :
1373 converter.global(SfArg(sfun.evaluateFunction(xi),sfun.evaluateDerivative(xi),sfun.evaluate2ndDerivative(xi)),2) );
1375 combiner_->rightTransform(
evalData);
1386 template <
int subDim>
1394 converter.setLocalPosition(x);
1397 for (
int i=0; i<sfSize; ++i)
1401 auto const& localData = cache->
evaluate(*sf,qr,ip,subId);
1403 for (
int i=0; i<sfSize; ++i)
1407 combiner_->rightTransform(
evalData);
1432 int order()
const {
return sf->order(); }
1438 typename Mapper::Combiner
const&
combiner()
const {
return *combiner_; }
1465 assert(currentCell);
1466 return *currentCell;
1481 typename Mapper::ShapeFunctionSet
const* sf;
1487 typename Mapper::Converter converter;
1488 std::unique_ptr<typename Mapper::Combiner> combiner_;
1493 std::unique_ptr<Cell> currentCell;
1521 template <
typename... Args>
1526 , m_gridView(gridView_)
1527 , mapper_(m_gridView,args...)
1528 , rtf(*this,gridman)
1548 , rtf(*this,gridman)
1557 gridman(fs.gridman),
1558 m_gridView(fs.m_gridView),
1567 refConnection.disconnect();
1601 LocalToGlobalMapper
const &
mapper()
const {
return mapper_; }
1606 LocalToGlobalMapper &
mapper() {
return mapper_; }
1640 std::vector<std::pair<size_t,SfValueType>> ic;
1645 for (
size_t j=0; j<esize; ++j)
1649 ic.push_back(std::make_pair(i,c));
1666 std::vector<std::pair<size_t,SfValueType>>
1688 std::vector<std::pair<size_t,SfValueType>>
1692 auto xi = cell.geometry().local(x);
1701 struct ReactToRefinement
1704 : mySpace(space), gm(gm_) {};
1706 ReactToRefinement(ReactToRefinement
const& rtr)
1707 : mySpace(rtr.mySpace)
1716 assert(!future.valid());
1717 if (!mySpace.requestToRefine.empty())
1718 future = std::async(std::launch::async,
1719 [&]() { transferData.reset(
new TransferData<Self>(mySpace)); });
1728 mySpace.mapper().update();
1729 if(!mySpace.requestToRefine.empty())
1731 assert(transferData!=0);
1732 assert(!future.valid());
1733 future = std::async(std::launch::async,
1735 transferMatrix = transferData->transferMatrix();
1736 transferData.reset();
1737 mySpace.requestToRefine(transferMatrix.get());
1745 mySpace.requestToRefine(
nullptr);
1746 transferMatrix.reset();
1752 GridManagerBase<Grid>& gm;
1753 std::unique_ptr<TransferData<Self>> transferData;
1754 std::unique_ptr<typename TransferData<Self>::TransferMatrix> transferMatrix;
1755 std::future<void> future;
1758 GridManagerBase<Grid>& gridman;
1760 LocalToGlobalMapper mapper_;
1761 ReactToRefinement rtf;
1762 boost::signals2::connection refConnection;
1792 template <
class Cache>
1796 GetEvaluators(Cache* cache_, std::map<void const*,int>
const& deriv_ = std::map<void const*,int>()):
1797 cache(cache_), deriv(deriv_)
1800 template <
class Space>
1803 auto it = deriv.find(space);
1804 int derivatives = it==deriv.end()? 1: it->second;
1805 return typename Space::Evaluator(*space,cache,derivatives);
1810 std::map<void const*,int>
const& deriv;
1822 template <
class Space>
1837 template <
class Spaces,
class ShapeFunctionCache>
1839 std::map<void const*,int>
const& deriv = std::map<void const*,int>())
1842 return boost::fusion::as_vector(boost::fusion::transform(spaces,[&](
auto const* space)
1844 auto it = deriv.find(space);
1845 int derivatives = it==deriv.end()? 1: it->second;
1846 return space->evaluator(cache,derivatives);
1855 template <
class Spaces>
1857 typename boost::fusion::result_of::transform<Spaces,GetEvaluatorTypes>::type
1868 template<
class Evaluators>
1877 static int const sidx = VD::spaceIndex;
1878 typedef typename boost::fusion::result_of::value_at_c<Evaluators, sidx>::type::VarArg
type;
1887 template <
class Evaluators,
class Cell>
1890 boost::fusion::for_each(evals,[&cell](
auto& eval) { eval.moveTo(cell); });
1899 template <
class Evaluators,
class Cell,
class Index>
1902 boost::fusion::for_each(evals,[&cell,idx](
auto& eval) { eval.moveTo(cell,idx); });
1911 template <
class Evaluator,
class QuadratureRule>
1914 boost::fusion::for_each(evals,[&qr,subId](
auto& eval) { eval.useQuadratureRule(qr,subId); });
1928 template <
class Evaluators,
class CoordType,
int dim,
int subDim>
1932 boost::fusion::for_each(evals,[&x,&qr,ip,subId](
auto& eval) { eval.evaluateAt(x,qr,ip,subId); });
1941 template <
class Evaluators,
class CoordType,
int dim>
1944 boost::fusion::for_each(evals,[&x](
auto& eval) { eval.evaluateAt(x); });
1953 template <
class Evaluators>
1956 auto getOrder = [](
auto const& eval) ->
int {
return eval.order(); };
1957 auto max = [](
auto a,
auto b) ->
int {
return std::max(a,b); };
1958 return boost::fusion::fold(boost::fusion::transform(evals,getOrder),0,
max);
A local to global mapper implementation for boundary spaces, with functions defined on the domain bou...
A representation of a finite element function space defined over a domain covered by a grid.
FEFunctionSpace(GridManagerBase< Grid > &gridman_, Mapper &&m)
Constructs a finite element space from a directly given mapper.
std::vector< std::pair< size_t, SfValueType > > linearCombination(Cell< GridView > const &cell, LocalPosition< GridView > const &xi) const
Returns the coefficients of the linear combination of global DoFs that define the value at the given ...
GridView::Grid Grid
Type of grid.
static int const continuity
Tells how often elements are globally continuously differentiable.
GridManagerBase< Grid > & gridManager() const
Access to the GridManager.
GridView::IndexSet IndexSet
Type of IndexSet.
LocalToGlobalMapper::Scalar Scalar
typename Evaluator::VarArg::ValueType SfValueType
type of shape function values
LocalToGlobalMapper Mapper
corresponding mapper
Element_t< m > element() const
Creates a new function in this function space.
typename LocalToGlobalMapper::GridView GridView
Type of grid view.
size_t degreesOfFreedom() const
Returns the dimension of the function space, i.e. the number of degrees of freedom of a one-component...
Evaluator evaluator(ShapeFunctionCache< Grid, Scalar > *cache=nullptr, int deriv=1) const
Creates a new evaluator for this space.
std::vector< std::pair< size_t, SfValueType > > linearCombination(Evaluator const &evaluator) const
Returns the coefficients of the linear combination of global DoFs that define the value at the positi...
Grid const & grid() const
Provides access to the grid on which this finite element space is defined.
FEFunctionSpace(GridManagerBase< Grid > &gridMan, GridView const &gridView_, Args... args)
Constructs a finite element space from a GridManager, a grid view, and possibly extra arguments passe...
GridView const & gridView() const
Provides access to the index set defining the potential support of the space.
static int const dim
Grid dimension.
Scalar field_type
The scalar field type on which the linear (function) space is based. This is provided for consistency...
boost::signals2::signal< void(typename TransferData< Self >::TransferMatrix const *) > requestToRefine
Signal for refinement.
Grid::ctype ctype
Coordinate Type.
static int const sfComponents
The number of components of shape functions.
FEFunctionSpace(FEFunctionSpace< LocalToGlobalMapper > const &fs)
Copy constructor.
std::vector< std::pair< size_t, SfValueType > > linearCombination(GlobalPosition< GridView > const &x) const
Returns the coefficients of the linear combination of global DoFs that define the value at the given ...
static int const dimworld
spatial dimension
IndexSet const & indexSet() const
Provides access to the index set defining the part of the grid on which the space is defined.
LocalToGlobalMapper & mapper()
Provides read-write access to the node manager.
LocalToGlobalMapper const & mapper() const
Provides read access to the node manager.
ToDomainRepresentation(BoundaryFEFunction const &f_)
DomainFEFunction const & get() const
FEFunction const & get() const
ToDomainRepresentation(FEFunction const &f_)
A class for representing finite element functions.
int order(SFS const &sfs) const
Self & axpy(Scalar a, StorageType const &v)
Computes for coefficient vectors.
Self & operator+=(Self const &f)
Addition of a function from the same (type of) space. Note that despite the same type the function sp...
Dune::BlockVector< StorageValueType > data
Self & operator=(Scalar val)
Sets all coefficients to the given value.
FunctionSpaceElement(Space const &fs)
Constructor.
Self & operator+=(StorageType const &v)
Addition of coefficient vectors.
Self & operator=(FunctionSpaceElement< FEFunctionSpace< BoundaryMapper< DomainMapper, Scalar, typename Space::GridView > >, m > const &bf)
Assignment from an FE function which is restricted to the boundary to a suitable FE function.
DerivativeType derivative(Cell< GridView > const &cell, LocalPosition< GridView > const &local) const
Evaluates the derivative of the FE function at the given local position inside the given cell.
Self & operator+=(Scalar val)
Addition of a constant value to the coefficient vector. Note that this does in general not add a cons...
ValueType value(Cell< GridView > const &cell, LocalPosition< GridView > const &local) const
Evaluates the FE function at the specified local position in the given cell.
Self & operator=(FunctionSpaceElement< OtherSpace, m > const &f)
Assignment from functions belonging to other function spaces.
int order(Cell< GridView > const &cell) const
The polynomial order of the function on the provided cell.
HessianType hessian(GlobalPosition< GridView > const &global) const
Evaluates the FE function's Hessian at the specified global position.
typename Space::field_type field_type
scalar field type
Self & operator=(FunctionViewAdaptor< Space, Functor > const &f)
Assignment from a function view adaptor.
StorageValueType const & operator[](size_t i) const
EXPERIMENTAL Provides read-only access to the coefficients of the finite element basis functions.
FunctionSpaceElement(Self const &fse)
Copy constructor.
Self & operator=(Self &&fse)
Move assignment.
HessianType hessian(Cell< GridView > const &cell, LocalPosition< GridView > const &local) const
Evaluates the Hessian of the FE function at the given local position inside the given cell.
std::enable_if_t< std::is_same< Mapper, FunctionSpace_Detail::ChooseDomainMapper< typename Space::Mapper > >::value, Self & > operator=(FunctionSpaceElement< FEFunctionSpace< Mapper >, m > const &f)
Assignment from a suitable FE function to an FE function which is restricted to the boundary.
StorageType const & coefficients() const
Provides read-only access to the coefficients of the finite element basis functions.
Self & operator-=(StorageType const &v)
Subtraction of coefficient vectors.
Dune::FieldVector< Scalar, m > StorageValueType
type of the elements of the data vector
Self & operator+=(FunctionSpaceElement< OtherSpace, m > const &f)
Addition of a function from a different function space, but with the same number of components.
static int const components
components at each point of evaluation
Self & operator=(StorageType const &v)
Assignment from vector of coefficients.
ValueType value(GlobalPosition< GridView > const &x) const
Evaluates the FE function at the specified global position.
DerivativeType derivative(GlobalPosition< GridView > const &global) const
Evaluates the FE function's gradient at the specified global position.
Self & operator=(Self const &fse)
Copy assignment.
DerivativeType derivative(typename FunctionSpace::Evaluator const &evaluator) const
Evaluates the derivative of the FE function wrt global coordinates at the position used to construct ...
FunctionSpaceElement< Space, m > Self
own type
Self & axpy(Scalar a, FunctionSpaceElement< OtherSpace, m > const &f)
Computes for a function x from a different function space, but with the same number of components.
typename GridView::ctype ctype
the scalar type used for spatial coordinates
Self & operator=(WeakFunctionViewAdaptor< Functor > const &f)
Assignment from a weak function view adaptor.
Self & operator-=(FunctionSpaceElement< OtherSpace, m > const &f)
Subtraction of a function from a different function space, but with the same number of components.
HessianType hessian(typename FunctionSpace::Evaluator const &evaluator) const
Evaluates the Hessian of the FE function at the position used to construct the evaluator.
Self & operator=(StorageValueType const &a)
Sets all coefficients to the given value. As StorageValueType is a vector one value for each componen...
Dune::FieldMatrix< Scalar, components, Space::dimworld > DerivativeType
return type of the function derivative (...)
void transfer(typename TransferData< Space >::TransferMatrix const &transferMatrix)
typename Space::GridView GridView
the grid view this function is defined on
StorageValueType & operator[](size_t i)
EXPERIMENTAL Provides access to the coefficients of the finite element basis functions.
Space const & space() const
Provides access to the FEFunctionSpace to which this function belongs.
ValueType value(typename Space::Evaluator const &evaluator) const
Evaluates the FE function at the position used to construct the evaluator.
Dune::FieldVector< Scalar, components > ValueType
return type of the function value(...)
typename Space::SfValueType SfValueType
type of shape function values
Dune::BlockVector< StorageValueType > StorageType
type of the data vector
int size() const
Number of coefficient blocks.
FunctionSpace Space
FEFunctionSpace, this function is an element of.
Space::Scalar Scalar
scalar field type
Self & axpy(Scalar a, Self const &f)
Computes for a function x from the same (type of) space. Note that despite the same type the functio...
int dim() const
Number of scalar degrees of freedom.
Self & operator-=(Self const &f)
Subtraction of a function from the same (type of) space.
Self & operator*=(Scalar a)
Scaling.
StorageType & coefficients()
Provides access to the coefficients of the finite element basis functions.
An adaptor that allows to turn lambda functions into function views.
A boost::fusion functor for extracting the evaluator type from a pointer to a FE space....
Space::Evaluator operator()(Space const *)
A boost::fusion functor for creating an evaluator from the space, using a shape function cache that i...
Space::Evaluator operator()(Space const *space) const
GetEvaluators(Cache *cache_, std::map< void const *, int > const &deriv_=std::map< void const *, int >())
A boost::fusion functor for creating a variational arg from the space, using a shape function cache t...
Grid const & grid() const
Returns a const reference on the owned grid.
An exception that can be thrown whenever a key lookup fails.
LocalDataType< nComp >::type evaluate(ShapeFunctionSet< typename G::ctype, G::dimension, T, nComp > const &sfs, Dune::QuadratureRule< typename G::ctype, subDim > const &qr, int ip, int subId)
Returns the values of all shape functions at given integration point.
A class for representing tensors of arbitrary static rank and extents.
Matrix that transforms a data vector v_1 corresponding to the old grid to a data vector v_2 correspon...
std::unique_ptr< Dune::BlockVector< StorageValue > > apply(Dune::BlockVector< StorageValue > const &oldCoeff) const
Transforms oldCoeff, which lives on the old grid to an equivalent vector that lives on the new grid.
An adaptor that turns callables (e.g., lambdas) into weak function views.
void useQuadratureRuleInEvaluators(Evaluator &evals, QuadratureRule const &qr, int subId)
Tells all evaluators to use the given quadrature rule on the given subentity.
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.
auto getEvaluators(Spaces const &spaces, ShapeFunctionCache *cache, std::map< void const *, int > const &deriv=std::map< void const *, int >())
returns a heterogeneous sequence of evaluators for the given spaces
OutIter vectorToSequence(FunctionSpaceElement< Space, m > const &v, OutIter iter)
Writes the coefficients into a flat sequence. <Space,m>
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
void interpolateGlobally(FSElement &fse, Function const &fu)
Interpolates FunctionSpaceElement to FunctionSpaceElement.
void interpolateGloballyWeak(Target &target, Source const &fu)
Interpolates WeakFunctionViews to FunctionSpaceElement.
ProblemType
A type for describing the nature of a PDE problem.
typename GridView::template Codim< 0 >::Entity Cell
The type of cells (entities of codimension 0) in the grid view.
boost::signals2::signal< void(Status)> informAboutRefinement
A signal that is emitted thrice on grid modifications, once before adaptation takes place and twice a...
Status
The argument type of the signal that is emitted before and after grid adaptation.
std::pair< Cell, Dune::FieldVector< ctype, Cell::dimension > > findCellOnLevel(Cell cell, Dune::FieldVector< ctype, Cell::dimension > xi, int level=std::numeric_limits< int >::max())
Returns a descendant or ancestor cell of the given cell containing the specified local coordinate.
Cell< GridView > findCell(GridView const &gv, GlobalPosition< GridView > global)
Returns a cell of the given grid containing the specified global coordinate.
@ BeforeRefinementComplete
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
LocalCoordinate::field_type checkInside(Dune::GeometryType const >, LocalCoordinate const &x)
Checks whether a point is inside or outside the reference element, and how much.
OutIter vectorToSequence(double x, OutIter iter)
void moveEvaluatorsToCell(Evaluators &evals, Cell const &cell)
Moves all provided evaluators to the given cell.
InIter vectorFromSequence(FunctionSpaceElement< Space, m > &v, InIter in)
DEPRECATED use Element_t<m> instead.
FunctionSpaceElement< Self, m > type
A helper class that stores all informations necessary to evaluate FE functions at a certain point.
void evaluateAt(Dune::FieldVector< ctype, dim > const &xi)
Evaluates the shape functions at the given local coordinate.
void useQuadratureRule(Dune::QuadratureRule< typename Grid::ctype, subDim > const &qr, int subId)
Tells the evaluator that subsequent calls to evaluateAt(x,qr,ip,subId) refer to the given quadrature ...
Self Space
The type of function space we belong to.
SortedIndexRange sortedIndices() const
Provides access to (global,local) index pairs sorted ascendingly by global index.
VariationalArg< Scalar, dimworld, sfComponents > VarArg
The type of variational test/ansatz arguments storing value and derivatives/hessians of restricted an...
int derivatives() const
The number of derivatives that can be evaluated.
int order() const
Returns the polynomial order of the shape functions.
static int const sfComponents
The number of components of the shape functions.
Evaluator(Self const &space_, ShapeFunctionCache< Grid, Scalar > *cache_=nullptr, int deriv_=1)
Construct a shape function evaluator for a given space, possibly using the given shape function cache...
Mapper::Combiner const & combiner() const
Returns the algebraic combiner associated to the cell.
Mapper::SortedIndexRange SortedIndexRange
A range of sorted (global index, local index) pairs.
Dune::FieldVector< ctype, dim > const & xloc() const
Returns the local coordinates of the current evaluation point.
IndexSet::IndexType IndexType
GridView const & gridView() const
The grid view on which the space is defined.
Mapper::ShapeFunctionSet const & shapeFunctions() const
Returns the shape function set.
void moveTo(Cell const &cell)
A convenience overload, looking up the cell index itself.
Cell const & cell() const
Returns the cell containing the current evaluation point.
Mapper::GlobalIndexRange GlobalIndexRange
The type of ranges of global indices.
Kaskade::Cell< GridView > Cell
The type of cells in the grid.
LocalToGlobalMapper const & mapper() const
GlobalIndexRange globalIndices() const
Provides access to the global indices.
std::vector< VarArg > evalData
The container holding values and gradients of the global ansatz functions at the evaluation point.
Evaluator & operator=(Evaluator const &eval)
Assignment.
void evaluateAt(Dune::FieldVector< ctype, dim > const &x, Dune::QuadratureRule< typename Grid::ctype, subDim > const &qr, int ip, int subId)
Evaluates the shape functions at the given integration point of the given quadrature rule....
Evaluator(Evaluator const &eval)
Copy constructor.
void moveTo(Cell const &cell, IndexType const index)
Tells the evaluator that subsequent calls refer to the given cell.
boost::fusion::result_of::value_at_c< Evaluators, sidx >::type::VarArg type
Extracts the type of FE space with given index from set of spaces.
std::remove_pointer_t< typename boost::fusion::result_of::value_at_c< Spaces, Idx >::type > type
A class that stores values, gradients, and Hessians of evaluated shape functions.
Dune::FieldVector< Scalar, components > ValueType
type of variational argument's value