Commit 18b54d5b authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

rewritten gradient of discretefunction to overcome lambda problem

parent efb2ca41
......@@ -200,6 +200,17 @@ public:
return localView_.element();
}
Geometry const& geometry() const
{
assert( bound_ );
return geometry_.value();
}
LocalView const& localView() const
{
return localView_;
}
protected:
DiscreteFunction globalFunction_;
Type type_;
......@@ -219,30 +230,27 @@ public:
using Range = typename Super::Range;
using Domain = typename Super::Domain;
using Super::DerivativeLocalFunctionBase;
using Super::globalFunction_;
using Super::geometry_;
using Super::subTree_;
using Super::localView_;
// adopt constructor from base class
using DerivativeLocalFunctionBase<tag::gradient>::DerivativeLocalFunctionBase;
/// Evaluate Gradient at bound element in local coordinates
Range operator()(Domain const& x) const
{
assert( Super::bound_ );
assert( this->bound_ );
Range dy(0);
auto&& coefficients = *globalFunction_.dofVector_;
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*subTree_, [&,this](auto const& node, auto const& tp)
auto&& coefficients = *this->globalFunction_.dofVector_;
auto&& nodeToRangeEntry = this->globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*this->subTree_, [&,this](auto const& node, auto const& tp)
{
auto localBasis = makeLocalToGlobalBasisAdapter(node, geometry_.value());
auto localBasis = makeLocalToGlobalBasisAdapter(node, this->geometry());
auto const& gradients = localBasis.gradientsAt(x);
// Get range entry associated to this node
auto re = Dune::Functions::flatVectorView(nodeToRangeEntry(node, tp, dy));
for (std::size_t i = 0; i < localBasis.size(); ++i) {
auto&& multiIndex = localView_.index(node.localIndex(i));
auto&& multiIndex = this->localView().index(node.localIndex(i));
// Get coefficient associated to i-th shape function
auto c = Dune::Functions::flatVectorView(coefficients[multiIndex]);
......@@ -276,11 +284,8 @@ public:
using Range = typename Super::Range;
using Domain = typename Super::Domain;
using Super::DerivativeLocalFunctionBase;
using Super::globalFunction_;
using Super::geometry_;
using Super::subTree_;
using Super::localView_;
// adopt constructor from base class
using DerivativeLocalFunctionBase<tag::divergence>::DerivativeLocalFunctionBase;
/// Evaluate divergence at bound element in local coordinates
Range operator()(Domain const& x) const
......@@ -299,13 +304,13 @@ private:
{
static_assert(Size_v<Range> == 1, "Implemented for scalar coefficients only.");
assert( Super::bound_ );
assert( this->bound_ );
Range dy(0);
auto&& coefficients = *globalFunction_.dofVector_;
auto&& node = *subTree_;
auto&& coefficients = *this->globalFunction_.dofVector_;
auto&& node = *this->subTree_;
auto localBasis = makeLocalToGlobalBasisAdapter(node.child(0), geometry_.value());
auto localBasis = makeLocalToGlobalBasisAdapter(node.child(0), this->geometry());
auto const& gradients = localBasis.gradientsAt(x);
auto re = Dune::Functions::flatVectorView(dy);
......@@ -315,7 +320,7 @@ private:
assert(int(grad.size()) == GridView::dimensionworld);
for (std::size_t j = 0; j < GridView::dimensionworld; ++j) {
auto&& multiIndex = localView_.index(node.child(j).localIndex(i));
auto&& multiIndex = this->localView().index(node.child(j).localIndex(i));
re[0] += coefficients[multiIndex] * grad[j];
}
}
......@@ -335,32 +340,28 @@ public:
using Range = typename Super::Range;
using Domain = typename Super::Domain;
using Super::DerivativeLocalFunctionBase;
using Super::globalFunction_;
using Super::geometry_;
using Super::subTree_;
using Super::localView_;
using DerivativeLocalFunctionBase<tag::partial>::DerivativeLocalFunctionBase;
/// Evaluate partial derivative at bound element in local coordinates
Range operator()(Domain const& x) const
{
assert( Super::bound_ );
assert( this->bound_ );
Range dy(0);
std::size_t comp = Super::type_.comp;
std::size_t comp = this->type_.comp;
auto&& coefficients = *globalFunction_.dofVector_;
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*subTree_, [&,this](auto const& node, auto const& tp)
auto&& coefficients = *this->globalFunction_.dofVector_;
auto&& nodeToRangeEntry = this->globalFunction_.nodeToRangeEntry_;
for_each_leaf_node(*this->subTree_, [&,this](auto const& node, auto const& tp)
{
auto localBasis = makeLocalToGlobalBasisAdapter(node, geometry_.value());
auto localBasis = makeLocalToGlobalBasisAdapter(node, this->geometry());
auto const& partial = localBasis.partialsAt(x, comp);
// Get range entry associated to this node
auto re = Dune::Functions::flatVectorView(nodeToRangeEntry(node, tp, dy));
for (std::size_t i = 0; i < localBasis.size(); ++i) {
auto&& multiIndex = localView_.index(node.localIndex(i));
auto&& multiIndex = this->localView().index(node.localIndex(i));
// Get coefficient associated to i-th shape function
auto c = Dune::Functions::flatVectorView(coefficients[multiIndex]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment