Skip to content
Snippets Groups Projects
Commit cdd3e768 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Implement the copy constructor for DiscreteFunction

parent 6887ffb9
No related branches found
No related tags found
1 merge request!19Implement the copy constructor for DiscreteFunction
......@@ -10,7 +10,9 @@
#include <dune/typetree/childextraction.hh>
#include <amdis/GridFunctions.hpp>
#include <amdis/LinearAlgebra.hpp>
#include <amdis/typetree/FiniteElementType.hpp>
#include <amdis/typetree/RangeType.hpp>
#include <amdis/typetree/TreePath.hpp>
namespace AMDiS
......
......@@ -29,6 +29,12 @@ public:
, 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
void bind(Element const& element)
{
......@@ -100,6 +106,12 @@ public:
, 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)
{
localView_.bind(element);
......@@ -144,7 +156,7 @@ typename DiscreteFunction<GB,VT,TP>::Range DiscreteFunction<GB,VT,TP>::
LocalFunction::operator()(Domain const& x) const
{
assert( bound_ );
auto y = Range(0);
Range y(0);
auto&& coefficients = *globalFunction_.dofVector_;
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
......@@ -188,9 +200,7 @@ typename DiscreteFunction<GB,VT,TP>::GradientLocalFunction::Range DiscreteFuncti
GradientLocalFunction::operator()(Domain const& x) const
{
assert( bound_ );
Range dy;
for (std::size_t j = 0; j < dy.size(); ++j)
dy[j] = 0;
Range dy(0);
auto&& coefficients = *globalFunction_.dofVector_;
auto&& nodeToRangeEntry = globalFunction_.nodeToRangeEntry_;
......@@ -203,6 +213,7 @@ GradientLocalFunction::operator()(Domain const& x) const
auto&& fe = node.finiteElement();
auto&& localBasis = fe.localBasis();
std::size_t size = localBasis.size();
NodeCache<TYPEOF(node)> localBasisCache(localBasis);
auto const& referenceGradients = localBasisCache.evaluateJacobian(localView_.element().type(),x);
......@@ -218,7 +229,7 @@ GradientLocalFunction::operator()(Domain const& x) const
// 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) {
for (std::size_t i = 0; i < size; ++i) {
auto&& multiIndex = localView_.index(node.localIndex(i));
// Get coefficient associated to i-th shape function
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment