Skip to content
Snippets Groups Projects
Commit 0f1f50c6 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

LocalGeodesicFEStiffness now gets a basis, instead of GridView and a LocalFiniteElement

Conceptually cleaner, and makes for simpler code.  Most importantly, we will want
to pass the Basis::LocalView to the local assemblers.  For that we need the actual
basis, not just the grid view and local finite element.

[[Imported from SVN: r10082]]
parent 70502704
No related branches found
No related tags found
No related merge requests found
......@@ -16,13 +16,15 @@ namespace GFE {
* The energy is discussed in:
* - Christof Melcher, "Chiral skyrmions in the plane", Proc. of the Royal Society, online DOI DOI: 10.1098/rspa.2014.0394
*/
template<class GridView, class LocalFiniteElement, class field_type>
template<class Basis, class field_type>
class ChiralSkyrmionEnergy
: public LocalGeodesicFEStiffness<GridView,LocalFiniteElement,UnitVector<field_type,3> >
: public LocalGeodesicFEStiffness<Basis,UnitVector<field_type,3> >
{
// various useful types
typedef UnitVector<field_type,3> TargetSpace;
typedef typename GridView::Grid::ctype DT;
typedef typename Basis::GridView GridView;
typedef typename Basis::LocalView::Tree::FiniteElement LocalFiniteElement;
typedef typename GridView::ctype DT;
typedef typename TargetSpace::ctype RT;
typedef typename GridView::template Codim<0>::Entity Entity;
......@@ -49,9 +51,9 @@ public:
field_type kappa_;
};
template <class GridView, class LocalFiniteElement, class field_type>
typename ChiralSkyrmionEnergy<GridView, LocalFiniteElement, field_type>::RT
ChiralSkyrmionEnergy<GridView, LocalFiniteElement, field_type>::
template <class Basis, class field_type>
typename ChiralSkyrmionEnergy<Basis, field_type>::RT
ChiralSkyrmionEnergy<Basis, field_type>::
energy(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localConfiguration) const
......
......@@ -32,15 +32,13 @@ public:
protected:
LocalGeodesicFEStiffness<GridView,
typename Basis::LocalView::Tree::FiniteElement,
TargetSpace>* localStiffness_;
LocalGeodesicFEStiffness<Basis,TargetSpace>* localStiffness_;
public:
/** \brief Constructor for a given grid */
GeodesicFEAssembler(const Basis& basis,
LocalGeodesicFEStiffness<GridView,typename Basis::LocalView::Tree::FiniteElement, TargetSpace>* localStiffness)
LocalGeodesicFEStiffness<Basis, TargetSpace>* localStiffness)
: basis_(basis),
basisIndexSet_(basis_.indexSet()),
localStiffness_(localStiffness)
......
......@@ -7,12 +7,14 @@
#include "localgeodesicfestiffness.hh"
#include "localgeodesicfefunction.hh"
template<class GridView, class LocalFiniteElement, class TargetSpace>
template<class Basis, class TargetSpace>
class HarmonicEnergyLocalStiffness
: public LocalGeodesicFEStiffness<GridView,LocalFiniteElement,TargetSpace>
: public LocalGeodesicFEStiffness<Basis,TargetSpace>
{
// grid types
typedef typename GridView::Grid::ctype DT;
typedef typename Basis::GridView GridView;
typedef typename Basis::LocalView::Tree::FiniteElement LocalFiniteElement;
typedef typename GridView::ctype DT;
typedef typename TargetSpace::ctype RT;
typedef typename GridView::template Codim<0>::Entity Entity;
......@@ -31,9 +33,9 @@ public:
};
template <class GridView, class LocalFiniteElement, class TargetSpace>
typename HarmonicEnergyLocalStiffness<GridView, LocalFiniteElement, TargetSpace>::RT
HarmonicEnergyLocalStiffness<GridView, LocalFiniteElement, TargetSpace>::
template <class Basis, class TargetSpace>
typename HarmonicEnergyLocalStiffness<Basis, TargetSpace>::RT
HarmonicEnergyLocalStiffness<Basis, TargetSpace>::
energy(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution) const
......
......@@ -18,12 +18,14 @@
/** \brief Assembles energy gradient and Hessian with ADOL-C (automatic differentiation)
*/
template<class GridView, class LocalFiniteElement, class TargetSpace>
template<class Basis, class TargetSpace>
class LocalGeodesicFEADOLCStiffness
: public LocalGeodesicFEStiffness<GridView,LocalFiniteElement,TargetSpace>
: public LocalGeodesicFEStiffness<Basis,TargetSpace>
{
// grid types
typedef typename GridView::Grid::ctype DT;
typedef typename Basis::GridView GridView;
typedef typename Basis::LocalView::Tree::FiniteElement LocalFiniteElement;
typedef typename GridView::ctype DT;
typedef typename TargetSpace::ctype RT;
typedef typename GridView::template Codim<0>::Entity Entity;
......@@ -40,7 +42,7 @@ public:
//! Dimension of the embedding space
enum { embeddedBlocksize = TargetSpace::EmbeddedTangentVector::dimension };
LocalGeodesicFEADOLCStiffness(const LocalGeodesicFEStiffness<GridView, LocalFiniteElement, ATargetSpace>* energy)
LocalGeodesicFEADOLCStiffness(const LocalGeodesicFEStiffness<Basis, ATargetSpace>* energy)
: localEnergy_(energy)
{}
......@@ -67,14 +69,14 @@ public:
const std::vector<TargetSpace>& localSolution,
std::vector<typename TargetSpace::TangentVector>& localGradient);
const LocalGeodesicFEStiffness<GridView, LocalFiniteElement, ATargetSpace>* localEnergy_;
const LocalGeodesicFEStiffness<Basis, ATargetSpace>* localEnergy_;
};
template <class GridView, class LocalFiniteElement, class TargetSpace>
typename LocalGeodesicFEADOLCStiffness<GridView, LocalFiniteElement, TargetSpace>::RT
LocalGeodesicFEADOLCStiffness<GridView, LocalFiniteElement, TargetSpace>::
template <class Basis, class TargetSpace>
typename LocalGeodesicFEADOLCStiffness<Basis, TargetSpace>::RT
LocalGeodesicFEADOLCStiffness<Basis, TargetSpace>::
energy(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution) const
......@@ -122,8 +124,8 @@ energy(const Entity& element,
}
template <class GridView, class LocalFiniteElement, class TargetSpace>
void LocalGeodesicFEADOLCStiffness<GridView, LocalFiniteElement, TargetSpace>::
template <class Basis, class TargetSpace>
void LocalGeodesicFEADOLCStiffness<Basis, TargetSpace>::
assembleGradient(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution,
......@@ -170,8 +172,8 @@ assembleGradient(const Entity& element,
// To compute the Hessian we need to compute the gradient anyway, so we may
// as well return it. This saves assembly time.
// ///////////////////////////////////////////////////////////
template <class GridType, class LocalFiniteElement, class TargetSpace>
void LocalGeodesicFEADOLCStiffness<GridType, LocalFiniteElement, TargetSpace>::
template <class Basis, class TargetSpace>
void LocalGeodesicFEADOLCStiffness<Basis, TargetSpace>::
assembleGradientAndHessian(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution,
......
......@@ -7,11 +7,13 @@
#include <dune/istl/matrix.hh>
template<class GridView, class LocalFiniteElement, class TargetSpace>
template<class Basis, class TargetSpace>
class LocalGeodesicFEStiffness
{
// grid types
typedef typename GridView::Grid::ctype DT;
typedef typename Basis::GridView GridView;
typedef typename Basis::LocalView::Tree::FiniteElement LocalFiniteElement;
typedef typename GridView::ctype DT;
typedef typename TargetSpace::ctype RT;
typedef typename GridView::template Codim<0>::Entity Entity;
......@@ -63,8 +65,8 @@ public:
};
template <class GridView, class LocalFiniteElement, class TargetSpace>
void LocalGeodesicFEStiffness<GridView, LocalFiniteElement, TargetSpace>::
template <class Basis, class TargetSpace>
void LocalGeodesicFEStiffness<Basis, TargetSpace>::
assembleGradient(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution,
......@@ -77,8 +79,8 @@ assembleGradient(const Entity& element,
// ///////////////////////////////////////////////////////////
// Compute gradient by finite-difference approximation
// ///////////////////////////////////////////////////////////
template <class GridType, class LocalFiniteElement, class TargetSpace>
void LocalGeodesicFEStiffness<GridType, LocalFiniteElement, TargetSpace>::
template <class Basis, class TargetSpace>
void LocalGeodesicFEStiffness<Basis, TargetSpace>::
assembleGradientAndHessian(const Entity& element,
const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& localSolution,
......
......@@ -177,25 +177,23 @@ int main (int argc, char *argv[]) try
// Assembler using ADOL-C
typedef TargetSpace::rebind<adouble>::other ATargetSpace;
std::shared_ptr<LocalGeodesicFEStiffness<GridType::LeafGridView,FEBasis::LocalView::Tree::FiniteElement,ATargetSpace> > localEnergy;
std::shared_ptr<LocalGeodesicFEStiffness<FEBasis,ATargetSpace> > localEnergy;
std::string energy = parameterSet.get<std::string>("energy");
if (energy == "harmonic")
{
localEnergy.reset(new HarmonicEnergyLocalStiffness<GridType::LeafGridView, FEBasis::LocalView::Tree::FiniteElement, ATargetSpace>);
localEnergy.reset(new HarmonicEnergyLocalStiffness<FEBasis, ATargetSpace>);
} else if (energy == "chiral_skyrmion")
{
localEnergy.reset(new GFE::ChiralSkyrmionEnergy<GridType::LeafGridView, FEBasis::LocalView::Tree::FiniteElement, adouble>(parameterSet.sub("energyParameters")));
localEnergy.reset(new GFE::ChiralSkyrmionEnergy<FEBasis, adouble>(parameterSet.sub("energyParameters")));
} else
DUNE_THROW(Exception, "Unknown energy type '" << energy << "'");
LocalGeodesicFEADOLCStiffness<GridType::LeafGridView,
FEBasis::LocalView::Tree::FiniteElement,
TargetSpace> localGFEADOLCStiffness(localEnergy.get());
LocalGeodesicFEADOLCStiffness<FEBasis,TargetSpace> localGFEADOLCStiffness(localEnergy.get());
GeodesicFEAssembler<FEBasis,TargetSpace> assembler(feBasis, &localGFEADOLCStiffness);
......
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