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

Introduce a base class for local energies

Currently, all implementations of variational problems inherit
from LocalGeodesicFEStiffness, which requires gradient and Hessian
implementations.  However, most of these implementations really
only implement the energy, and leave computations of first and
second derivatives to algorithmic differentiation.  To make
this clearer, this patch introduces an abstract base class
LocalEnergy for all implementations that really only have
an energy.
parent 24e3b9a1
No related branches found
No related tags found
No related merge requests found
#ifndef DUNE_GFE_LOCALENERGY_HH
#define DUNE_GFE_LOCALENERGY_HH
#include <vector>
namespace Dune {
namespace GFE {
/** \brief Base class for energies defined by integrating over one grid element */
template<class Basis, class TargetSpace>
class LocalEnergy
{
public:
/** \brief Compute the energy
*
* \param localView Local view specifying the current element and the FE space there
* \param coefficients The coefficients of a FE function on the current element
*/
virtual typename TargetSpace::ctype
energy (const typename Basis::LocalView& localView,
const std::vector<TargetSpace>& localSolution) const = 0;
};
} // namespace GFE
} // namespace Dune
#endif // DUNE_GFE_LOCALENERGY_HH
......@@ -12,6 +12,7 @@
#include <dune/common/fmatrix.hh>
#include <dune/istl/matrix.hh>
#include <dune/gfe/localenergy.hh>
#include <dune/gfe/localgeodesicfestiffness.hh>
#define ADOLC_VECTOR_MODE
......@@ -41,7 +42,7 @@ public:
//! Dimension of the embedding space
enum { embeddedBlocksize = TargetSpace::EmbeddedTangentVector::dimension };
LocalGeodesicFEADOLCStiffness(const LocalGeodesicFEStiffness<Basis, ATargetSpace>* energy)
LocalGeodesicFEADOLCStiffness(const Dune::GFE::LocalEnergy<Basis, ATargetSpace>* energy)
: localEnergy_(energy)
{}
......@@ -65,7 +66,7 @@ public:
const std::vector<TargetSpace>& localSolution,
std::vector<typename TargetSpace::TangentVector>& localGradient);
const LocalGeodesicFEStiffness<Basis, ATargetSpace>* localEnergy_;
const Dune::GFE::LocalEnergy<Basis, ATargetSpace>* localEnergy_;
};
......
......@@ -4,9 +4,11 @@
#include <dune/common/fmatrix.hh>
#include <dune/istl/matrix.hh>
#include <dune/gfe/localenergy.hh>
template<class Basis, class TargetSpace>
class LocalGeodesicFEStiffness
: public Dune::GFE::LocalEnergy<Basis,TargetSpace>
{
// grid types
typedef typename Basis::GridView GridView;
......
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