Commit 94bb365d authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'issue/discretefunction_copy_constructor' into 'master'

Implement the copy constructor for DiscreteFunction

See merge request !19
parents 76011132 cdd3e768
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include <dune/typetree/childextraction.hh> #include <dune/typetree/childextraction.hh>
#include <amdis/GridFunctions.hpp> #include <amdis/GridFunctions.hpp>
#include <amdis/LinearAlgebra.hpp>
#include <amdis/typetree/FiniteElementType.hpp> #include <amdis/typetree/FiniteElementType.hpp>
#include <amdis/typetree/RangeType.hpp>
#include <amdis/typetree/TreePath.hpp> #include <amdis/typetree/TreePath.hpp>
namespace AMDiS namespace AMDiS
......
...@@ -29,6 +29,12 @@ public: ...@@ -29,6 +29,12 @@ public:
, subTree_(&child(localView_.tree(), globalFunction_.treePath())) , subTree_(&child(localView_.tree(), globalFunction_.treePath()))
{} {}
LocalFunction(LocalFunction const& other)
: globalFunction_(other.globalFunction_)
, localView_(globalFunction_.basis().localView())
, subTree_(&child(localView_.tree(), globalFunction_.treePath()))
{}
/// \brief Bind the LocalView to the element /// \brief Bind the LocalView to the element
void bind(Element const& element) void bind(Element const& element)
{ {
...@@ -100,6 +106,12 @@ public: ...@@ -100,6 +106,12 @@ public:
, subTree_(&child(localView_.tree(), globalFunction_.treePath())) , subTree_(&child(localView_.tree(), globalFunction_.treePath()))
{} {}
GradientLocalFunction(GradientLocalFunction const& other)
: globalFunction_(other.globalFunction_)
, localView_(globalFunction_.basis().localView())
, subTree_(&child(localView_.tree(), globalFunction_.treePath()))
{}
void bind(Element const& element) void bind(Element const& element)
{ {
localView_.bind(element); localView_.bind(element);
...@@ -144,7 +156,7 @@ typename DiscreteFunction<GB,VT,TP>::Range DiscreteFunction<GB,VT,TP>:: ...@@ -144,7 +156,7 @@ typename DiscreteFunction<GB,VT,TP>::Range DiscreteFunction<GB,VT,TP>::
LocalFunction::operator()(Domain const& x) const LocalFunction::operator()(Domain const& x) const
{ {
assert( bound_ ); assert( bound_ );
auto y = Range(0); Range y(0);
auto&& coefficients = *globalFunction_.dofVector_; auto&& coefficients = *globalFunction_.dofVector_;
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_; auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
...@@ -188,9 +200,7 @@ typename DiscreteFunction<GB,VT,TP>::GradientLocalFunction::Range DiscreteFuncti ...@@ -188,9 +200,7 @@ typename DiscreteFunction<GB,VT,TP>::GradientLocalFunction::Range DiscreteFuncti
GradientLocalFunction::operator()(Domain const& x) const GradientLocalFunction::operator()(Domain const& x) const
{ {
assert( bound_ ); assert( bound_ );
Range dy; Range dy(0);
for (std::size_t j = 0; j < dy.size(); ++j)
dy[j] = 0;
auto&& coefficients = *globalFunction_.dofVector_; auto&& coefficients = *globalFunction_.dofVector_;
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_; auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
...@@ -203,6 +213,7 @@ GradientLocalFunction::operator()(Domain const& x) const ...@@ -203,6 +213,7 @@ GradientLocalFunction::operator()(Domain const& x) const
auto&& fe = node.finiteElement(); auto&& fe = node.finiteElement();
auto&& localBasis = fe.localBasis(); auto&& localBasis = fe.localBasis();
std::size_t size = localBasis.size();
NodeCache<TYPEOF(node)> localBasisCache(localBasis); NodeCache<TYPEOF(node)> localBasisCache(localBasis);
auto const& referenceGradients = localBasisCache.evaluateJacobian(localView_.element().type(),x); auto const& referenceGradients = localBasisCache.evaluateJacobian(localView_.element().type(),x);
...@@ -218,7 +229,7 @@ GradientLocalFunction::operator()(Domain const& x) const ...@@ -218,7 +229,7 @@ GradientLocalFunction::operator()(Domain const& x) const
// Get range entry associated to this node // Get range entry associated to this node
auto re = Dune::Functions::flatVectorView(nodeToRangeEntry(node, tp, dy)); auto re = Dune::Functions::flatVectorView(nodeToRangeEntry(node, tp, dy));
for (std::size_t i = 0; i < localBasis.size(); ++i) { for (std::size_t i = 0; i < size; ++i) {
auto&& multiIndex = localView_.index(node.localIndex(i)); auto&& multiIndex = localView_.index(node.localIndex(i));
// Get coefficient associated to i-th shape function // Get coefficient associated to i-th shape function
......
Supports Markdown
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