Skip to content
Snippets Groups Projects
Commit f2e5550f authored by Youett, Jonathan's avatar Youett, Jonathan Committed by akbib@FU-BERLIN.DE
Browse files

make localgfetestfunction become what it is: a localgfetestfunctionbasis

create a dune-localfunction conforming class LocalGFETestFunctionFiniteElement.
what's still left open is the implementation of the interpolation class.

[[Imported from SVN: r7952]]
parent 9a85bfb5
No related branches found
No related tags found
No related merge requests found
...@@ -5,34 +5,112 @@ ...@@ -5,34 +5,112 @@
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/array.hh> #include <dune/common/array.hh>
#include <dune/common/geometrytype.hh>
#include <dune/gfe/localgeodesicfefunction.hh> #include <dune/gfe/localgeodesicfefunction.hh>
#include <dune/gfe/tensor3.hh> #include <dune/gfe/tensor3.hh>
#include <dune/gfe/linearalgebra.hh> #include <dune/gfe/linearalgebra.hh>
/** \brief A function defined by simplicial geodesic interpolation #include <dune/localfunctions/common/localfiniteelementtraits.hh>
from the reference element to a Riemannian manifold. #include <dune/localfunctions/common/localbasis.hh>
\tparam dim Dimension of the reference element // forward declaration
\tparam ctype Type used for coordinates on the reference element
\tparam LocalFiniteElement A Lagrangian finite element whose shape functions define the interpolation weights
\tparam TargetSpace The manifold that the function takes its values in
*/
template <int dim, class ctype, class LocalFiniteElement, class TargetSpace> template <int dim, class ctype, class LocalFiniteElement, class TargetSpace>
class LocalGFETestFunction class LocalGFETestFunctionBasis;
template <class LocalFiniteELement, class TargetSpace>
class LocalGFETestFunctionInterpolation;
/** \brief The local gfe test function finite element on simplices
*
* \tparam LagrangeLfe - A Lagrangian finite element whose shape functions define the interpolation weights
* \tparam TargetSpace - The manifold the tangent spaces this basis for from belong to.
*/
template <class LagrangeLfe, class TargetSpace>
class LocalGfeTestFunctionFiniteElement
{ {
typedef LagrangeLfe::Traits::LocalBasisType::Traits LagrangeBasisTraits;
typedef LocalGfeTestFunctionBasis<LagrangeBasisTraits::dimDomain, typename LagrangeBasisTraits::DomainFieldType, LagrangeLfe, TargetSpace> LocalBasis;
typedef LocalGfeTestFunctionInterpolation<LagrangeLfe, TargetSpace> LocalInterpolation;
public:
//! Traits
typedef LocalFiniteElementTraits<LocalBasis,typename LagrangeLfe::Traits::LocalCoefficientsType, LocalInterpolation> Traits;
/** Construct local finite element from the base coefficients and Lagrange local finite element.
*
* \param lfe - The Lagrange local finite element.
* \param baseCoeff - The coefficients of the base points the tangent spaces live at.
*/
LocalGfeTestFunctionFiniteElement(const LagrangeLfe lfe&, const std::vector<TargetSpace> baseCoeff) :
basis_(lfe,baseCoeff),
coefficients(lfe.localCoefficients()),
{
gt_.makeSimplex(LagrangeBasisTraits::dimDomain);
}
/** \brief Get reference to the local basis.*/
const typename Traits::LocalBasisType& localBasis () const
{
return basis_;
}
/** \brief Get reference to the local coefficients. */
const typename Traits::LocalCoefficientsType& localCoefficients () const
{
return coefficients_;
}
/** \brief Get reference to the local interpolation handler. */
const typename Traits::LocalInterpolationType& localInterpolation () const
{
return interpolation_;
}
/** \brief Get the element type this finite element lives on. */
GeometryType type () const
{
return gt;
}
private:
LocalBasis basis_;
typename LagrangeLfe::Traits::LocalCoefficientsType coefficients_;
LocalInterpolation interpolation_;
GeometryType gt_;
};
/** \brief A local basis of the first variations of a given geodesic finite element function.
*
* \tparam dim Dimension of the reference element
* \tparam ctype Type used for coordinates on the reference element
* \tparam LocalFiniteElement A Lagrangian finite element whose shape functions define the interpolation weights
* \tparam TargetSpace The manifold that the function takes its values in
*
* Note that the shapefunctions of this local basis are given blockwise. Each dof corresponds to a local basis of
* the tangent space at that dof. Thus the methods return a vector of arrays.
*/
template <int dim, class ctype, class LocalFiniteElement, class TargetSpace>
class LocalGFETestFunctionBasis
{
typedef typename TargetSpace::EmbeddedTangentVector EmbeddedTangentVector; typedef typename TargetSpace::EmbeddedTangentVector EmbeddedTangentVector;
static const int embeddedDim = EmbeddedTangentVector::dimension; static const int embeddedDim = EmbeddedTangentVector::dimension;
static const int spaceDim = TargetSpace::TangentVector::dimension; static const int spaceDim = TargetSpace::TangentVector::dimension;
public: public :
//! The local basis traits
typedef LocalBasisTraits<ctype, dim, Dune::FieldVector<ctype,dim>,
typename EmbeddedTangentVector::ctype, embeddedDim, Dune::array<EmbeddedTangentVector,spaceDim>,
Dune::array<Dune::FieldMatrix<ctype, embeddedDim, dim>,spaceDim>,1> Traits;
/** \brief Constructor /** \brief Constructor
*/ */
LocalGFETestFunction(const LocalFiniteElement& localFiniteElement, LocalGFETestFunctionBasis(const LocalFiniteElement& localFiniteElement,
const std::vector<TargetSpace>& baseCoefficients) const std::vector<TargetSpace>& baseCoefficients)
: localGFEFunction_(localFiniteElement, baseCoefficients) : localGFEFunction_(localFiniteElement, baseCoefficients)
{} {}
...@@ -43,13 +121,13 @@ public: ...@@ -43,13 +121,13 @@ public:
} }
/** \brief Evaluate all shape functions at the given point */ /** \brief Evaluate all shape functions at the given point */
void evaluateFunction(const Dune::FieldVector<ctype, dim>& local, void evaluateFunction(typename Traits::DomainType& local,
std::vector<Dune::array<typename TargetSpace::EmbeddedTangentVector,spaceDim> >& out) const; std::vector<typename Traits::RangeType>& out) const;
/** \brief Evaluate the derivatives of all shape functions function */ /** \brief Evaluate the derivatives of all shape functions function */
void evaluateJacobian(const Dune::FieldVector<ctype, dim>& local, void evaluateJacobian(const typename Traits::DomainType& in,
std::vector<Dune::array<Dune::FieldMatrix<ctype, EmbeddedTangentVector::dimension, dim>,spaceDim> >& out) const; std::vector<typename Traits::JacobianType>& out) const;
/** \brief Polynomial order */ /** \brief Polynomial order */
unsigned int order() const unsigned int order() const
{ {
...@@ -65,8 +143,8 @@ private: ...@@ -65,8 +143,8 @@ private:
}; };
template <int dim, class ctype, class LocalFiniteElement, class TargetSpace> template <int dim, class ctype, class LocalFiniteElement, class TargetSpace>
void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateFunction(const Dune::FieldVector<ctype, dim>& local, void LocalGFETestFunctionBasis<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateFunction(const typename Traits::DomainType& local,
std::vector<Dune::array<typename TargetSpace::EmbeddedTangentVector, spaceDim> >& out) const std::vector<typename Traits::RangeType>& out) const
{ {
out.resize(size()); out.resize(size());
...@@ -76,9 +154,7 @@ void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateFun ...@@ -76,9 +154,7 @@ void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateFun
/** \todo This call internally keeps computing the value of the gfe function at 'local'. /** \todo This call internally keeps computing the value of the gfe function at 'local'.
* This is expensive. Eventually we should precompute it once and reused the result. */ * This is expensive. Eventually we should precompute it once and reused the result. */
localGFEFunction_.evaluateDerivativeOfValueWRTCoefficient (local, localGFEFunction_.evaluateDerivativeOfValueWRTCoefficient (local, i, derivative);
i,
derivative);
Dune::FieldMatrix<ctype,spaceDim,embeddedDim> basisVectors = localGFEFunction_.coefficients_[i].orthonormalFrame(); Dune::FieldMatrix<ctype,spaceDim,embeddedDim> basisVectors = localGFEFunction_.coefficients_[i].orthonormalFrame();
...@@ -90,8 +166,8 @@ void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateFun ...@@ -90,8 +166,8 @@ void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateFun
} }
template <int dim, class ctype, class LocalFiniteElement, class TargetSpace> template <int dim, class ctype, class LocalFiniteElement, class TargetSpace>
void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateJacobian(const Dune::FieldVector<ctype, dim>& local, void LocalGFETestFunctionBasis<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateJacobian(const typename Traits::DomainType& in,
std::vector<Dune::array<Dune::FieldMatrix<ctype, EmbeddedTangentVector::dimension, dim>,spaceDim> >& out) const std::vector<typename Traits::JacobianType>& out) const
{ {
out.resize(size()); out.resize(size());
...@@ -100,27 +176,27 @@ void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateJac ...@@ -100,27 +176,27 @@ void LocalGFETestFunction<dim,ctype,LocalFiniteElement,TargetSpace>::evaluateJac
/** \todo This call internally keeps computing the value of the gfe function at 'local'. /** \todo This call internally keeps computing the value of the gfe function at 'local'.
* This is expensive. Eventually we should precompute it once and reused the result. */ * This is expensive. Eventually we should precompute it once and reused the result. */
Tensor3< double, embeddedDim, embeddedDim, dim > derivative; Tensor3< double, embeddedDim, embeddedDim, dim > derivative;
localGFEFunction_.evaluateDerivativeOfGradientWRTCoefficient (local, localGFEFunction_.evaluateDerivativeOfGradientWRTCoefficient (local, i, derivative);
i,
derivative);
Dune::FieldMatrix<ctype,spaceDim,embeddedDim> basisVectors = localGFEFunction_.coefficients_[i].orthonormalFrame(); Dune::FieldMatrix<ctype,spaceDim,embeddedDim> basisVectors = localGFEFunction_.coefficients_[i].orthonormalFrame();
for (int j=0; j<spaceDim; j++) { for (int j=0; j<spaceDim; j++) {
out[i][j] = 0; out[i][j] = 0;
// Contract the second index of the derivative with the tangent vector at the i-th Lagrange point. // Contract the second index of the derivative with the tangent vector at the i-th Lagrange point.
// Add that to the result. // Add that to the result.
for (int k=0; k<embeddedDim; k++) for (int k=0; k<embeddedDim; k++)
for (int l=0; l<embeddedDim; l++) for (int l=0; l<embeddedDim; l++)
for (size_t m=0; m<dim; m++) for (size_t m=0; m<dim; m++)
out[i][j][k][m] += derivative[k][l][m] * basisVectors[j][l]; out[i][j][k][m] += derivative[k][l][m] * basisVectors[j][l];
} }
} }
} }
template <class LocalFiniteElement, class TargetSpace>
LocalGFETestFunctionInterpolation
{};
#endif #endif
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