Skip to content
Snippets Groups Projects
Commit dd813c18 authored by Sander, Oliver's avatar Sander, Oliver
Browse files

Port to the new dune-functions function space basis interface

parent ad0f48e7
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,6 @@ class LocalGeodesicFEFDStiffness ...@@ -14,7 +14,6 @@ class LocalGeodesicFEFDStiffness
{ {
// grid types // grid types
typedef typename Basis::GridView GridView; typedef typename Basis::GridView GridView;
typedef typename Basis::LocalView::Tree::FiniteElement LocalFiniteElement;
typedef typename GridView::ctype DT; typedef typename GridView::ctype DT;
typedef typename TargetSpace::ctype RT; typedef typename TargetSpace::ctype RT;
typedef typename GridView::template Codim<0>::Entity Entity; typedef typename GridView::template Codim<0>::Entity Entity;
...@@ -37,18 +36,16 @@ public: ...@@ -37,18 +36,16 @@ public:
{} {}
/** \brief Compute the energy at the current configuration */ /** \brief Compute the energy at the current configuration */
virtual RT energy (const Entity& element, virtual RT energy (const typename Basis::LocalView& localView,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution) const const std::vector<TargetSpace>& localSolution) const
{ {
return localEnergy_->energy(element,localFiniteElement,localSolution); return localEnergy_->energy(localView,localSolution);
} }
/** \brief Assemble the element gradient of the energy functional /** \brief Assemble the element gradient of the energy functional
The default implementation in this class uses a finite difference approximation */ The default implementation in this class uses a finite difference approximation */
virtual void assembleGradient(const Entity& element, virtual void assembleGradient(const typename Basis::LocalView& localView,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& solution, const std::vector<TargetSpace>& solution,
std::vector<typename TargetSpace::TangentVector>& gradient) const; std::vector<typename TargetSpace::TangentVector>& gradient) const;
...@@ -64,8 +61,7 @@ public: ...@@ -64,8 +61,7 @@ public:
\f] \f]
We compute that using a finite difference approximation. We compute that using a finite difference approximation.
*/ */
virtual void assembleGradientAndHessian(const Entity& e, virtual void assembleGradientAndHessian(const typename Basis::LocalView& localView,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution, const std::vector<TargetSpace>& localSolution,
std::vector<typename TargetSpace::TangentVector>& localGradient); std::vector<typename TargetSpace::TangentVector>& localGradient);
...@@ -76,8 +72,7 @@ public: ...@@ -76,8 +72,7 @@ public:
template <class Basis, class TargetSpace, class field_type> template <class Basis, class TargetSpace, class field_type>
void LocalGeodesicFEFDStiffness<Basis, TargetSpace, field_type>:: void LocalGeodesicFEFDStiffness<Basis, TargetSpace, field_type>::
assembleGradient(const Entity& element, assembleGradient(const typename Basis::LocalView& localView,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution, const std::vector<TargetSpace>& localSolution,
std::vector<typename TargetSpace::TangentVector>& localGradient) const std::vector<typename TargetSpace::TangentVector>& localGradient) const
{ {
...@@ -118,7 +113,7 @@ assembleGradient(const Entity& element, ...@@ -118,7 +113,7 @@ assembleGradient(const Entity& element,
forwardSolution[i] = ATargetSpace::exp(localASolution[i], forwardCorrection); forwardSolution[i] = ATargetSpace::exp(localASolution[i], forwardCorrection);
backwardSolution[i] = ATargetSpace::exp(localASolution[i], backwardCorrection); backwardSolution[i] = ATargetSpace::exp(localASolution[i], backwardCorrection);
field_type foo = (localEnergy_->energy(element,localFiniteElement,forwardSolution) - localEnergy_->energy(element,localFiniteElement, backwardSolution)) / (2*eps); field_type foo = (localEnergy_->energy(localView,forwardSolution) - localEnergy_->energy(localView, backwardSolution)) / (2*eps);
#ifdef MULTIPRECISION #ifdef MULTIPRECISION
localGradient[i][j] = foo.template convert_to<double>(); localGradient[i][j] = foo.template convert_to<double>();
#else #else
...@@ -142,8 +137,7 @@ assembleGradient(const Entity& element, ...@@ -142,8 +137,7 @@ assembleGradient(const Entity& element,
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
template <class Basis, class TargetSpace, class field_type> template <class Basis, class TargetSpace, class field_type>
void LocalGeodesicFEFDStiffness<Basis, TargetSpace, field_type>:: void LocalGeodesicFEFDStiffness<Basis, TargetSpace, field_type>::
assembleGradientAndHessian(const Entity& element, assembleGradientAndHessian(const typename Basis::LocalView& localView,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution, const std::vector<TargetSpace>& localSolution,
std::vector<typename TargetSpace::TangentVector>& localGradient) std::vector<typename TargetSpace::TangentVector>& localGradient)
{ {
...@@ -176,7 +170,7 @@ assembleGradientAndHessian(const Entity& element, ...@@ -176,7 +170,7 @@ assembleGradientAndHessian(const Entity& element,
// Precompute negative energy at the current configuration // Precompute negative energy at the current configuration
// (negative because that is how we need it as part of the 2nd-order fd formula) // (negative because that is how we need it as part of the 2nd-order fd formula)
field_type centerValue = -localEnergy_->energy(element, localFiniteElement, localASolution); field_type centerValue = -localEnergy_->energy(localView, localASolution);
// Precompute energy infinitesimal corrections in the directions of the local basis vectors // Precompute energy infinitesimal corrections in the directions of the local basis vectors
std::vector<Dune::array<field_type,blocksize> > forwardEnergy(nDofs); std::vector<Dune::array<field_type,blocksize> > forwardEnergy(nDofs);
...@@ -196,8 +190,8 @@ assembleGradientAndHessian(const Entity& element, ...@@ -196,8 +190,8 @@ assembleGradientAndHessian(const Entity& element,
forwardSolution[i] = ATargetSpace::exp(localASolution[i],epsXi); forwardSolution[i] = ATargetSpace::exp(localASolution[i],epsXi);
backwardSolution[i] = ATargetSpace::exp(localASolution[i],minusEpsXi); backwardSolution[i] = ATargetSpace::exp(localASolution[i],minusEpsXi);
forwardEnergy[i][i2] = localEnergy_->energy(element, localFiniteElement, forwardSolution); forwardEnergy[i][i2] = localEnergy_->energy(localView, forwardSolution);
backwardEnergy[i][i2] = localEnergy_->energy(element, localFiniteElement, backwardSolution); backwardEnergy[i][i2] = localEnergy_->energy(localView, backwardSolution);
} }
...@@ -254,8 +248,8 @@ assembleGradientAndHessian(const Entity& element, ...@@ -254,8 +248,8 @@ assembleGradientAndHessian(const Entity& element,
backwardSolutionXiEta[j] = ATargetSpace::exp(localASolution[j],minusEpsEta); backwardSolutionXiEta[j] = ATargetSpace::exp(localASolution[j],minusEpsEta);
} }
field_type forwardValue = localEnergy_->energy(element, localFiniteElement, forwardSolutionXiEta) - forwardEnergy[i][i2] - forwardEnergy[j][j2]; field_type forwardValue = localEnergy_->energy(localView, forwardSolutionXiEta) - forwardEnergy[i][i2] - forwardEnergy[j][j2];
field_type backwardValue = localEnergy_->energy(element, localFiniteElement, backwardSolutionXiEta) - backwardEnergy[i][i2] - backwardEnergy[j][j2]; field_type backwardValue = localEnergy_->energy(localView, backwardSolutionXiEta) - backwardEnergy[i][i2] - backwardEnergy[j][j2];
field_type foo = 0.5 * (forwardValue - 2*centerValue + backwardValue) / (eps*eps); field_type foo = 0.5 * (forwardValue - 2*centerValue + backwardValue) / (eps*eps);
#ifdef MULTIPRECISION #ifdef MULTIPRECISION
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment