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

Do not hardwire the local interpolation rule in the embedded global function

Make them a parameter instead.  This allows to switch more easily between
geodesic finite elements and projected finite elements.
parent a425feca
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
#include <dune/gfe/localgeodesicfefunction.hh>
namespace Dune { namespace Dune {
namespace GFE { namespace GFE {
...@@ -17,7 +15,7 @@ namespace Dune { ...@@ -17,7 +15,7 @@ namespace Dune {
* \tparam B - The global basis type. * \tparam B - The global basis type.
* \tparam TargetSpace - The manifold that this functions takes its values in. * \tparam TargetSpace - The manifold that this functions takes its values in.
*/ */
template<class B, class TargetSpace> template<class B, class LocalInterpolationRule, class TargetSpace>
class EmbeddedGlobalGFEFunction class EmbeddedGlobalGFEFunction
: public VirtualGridViewFunction<typename B::GridView, typename TargetSpace::CoordinateType> : public VirtualGridViewFunction<typename B::GridView, typename TargetSpace::CoordinateType>
{ {
...@@ -29,7 +27,6 @@ public: ...@@ -29,7 +27,6 @@ public:
typedef typename GridView::template Codim<0>::Entity Element; typedef typename GridView::template Codim<0>::Entity Element;
typedef typename GridView::Grid::ctype ctype; typedef typename GridView::Grid::ctype ctype;
typedef LocalGeodesicFEFunction<GridView::dimension, ctype, LocalFiniteElement, TargetSpace> LocalGFEFunction;
typedef typename TargetSpace::EmbeddedTangentVector EmbeddedTangentVector; typedef typename TargetSpace::EmbeddedTangentVector EmbeddedTangentVector;
//! Dimension of the grid. //! Dimension of the grid.
...@@ -82,8 +79,8 @@ public: ...@@ -82,8 +79,8 @@ public:
localCoeff[i] = coefficients_[localIndexSet.index(i)]; localCoeff[i] = coefficients_[localIndexSet.index(i)];
// create local gfe function // create local gfe function
LocalGFEFunction localGFE(localView.tree().finiteElement(),localCoeff); LocalInterpolationRule localInterpolationRule(localView.tree().finiteElement(),localCoeff);
return localGFE.evaluate(local).globalCoordinates(); return localInterpolationRule.evaluate(local).globalCoordinates();
} }
/** \brief Evaluate the derivative of the function at local coordinates. */ /** \brief Evaluate the derivative of the function at local coordinates. */
...@@ -110,10 +107,10 @@ public: ...@@ -110,10 +107,10 @@ public:
localCoeff[i] = coefficients_[localIndexSet.index(i)]; localCoeff[i] = coefficients_[localIndexSet.index(i)];
// create local gfe function // create local gfe function
LocalGFEFunction localGFE(localView.tree().finiteElement(),localCoeff); LocalInterpolationRule localInterpolationRule(localView.tree().finiteElement(),localCoeff);
// use it to evaluate the derivative // use it to evaluate the derivative
Dune::FieldMatrix<ctype, embeddedDim, gridDim> refJac = localGFE.evaluateDerivative(local); Dune::FieldMatrix<ctype, embeddedDim, gridDim> refJac = localInterpolationRule.evaluateDerivative(local);
Dune::FieldMatrix<ctype, embeddedDim, gridDim> out =0.0; Dune::FieldMatrix<ctype, embeddedDim, gridDim> out =0.0;
//transform the gradient //transform the gradient
......
...@@ -15,8 +15,9 @@ ...@@ -15,8 +15,9 @@
#include <dune/gfe/rotation.hh> #include <dune/gfe/rotation.hh>
#include <dune/gfe/unitvector.hh> #include <dune/gfe/unitvector.hh>
#include <dune/gfe/realtuple.hh> #include <dune/gfe/realtuple.hh>
#include <dune/gfe/localgeodesicfefunction.hh>
#include <dune/gfe/localprojectedfefunction.hh>
#include <dune/gfe/embeddedglobalgfefunction.hh> #include <dune/gfe/embeddedglobalgfefunction.hh>
#include <dune/gfe/cosseratvtkwriter.hh>
// grid dimension // grid dimension
const int dim = 2; const int dim = 2;
...@@ -39,6 +40,10 @@ void measureDiscreteEOC(const GridView gridView, ...@@ -39,6 +40,10 @@ void measureDiscreteEOC(const GridView gridView,
FEBasis feBasis(gridView); FEBasis feBasis(gridView);
FEBasis referenceFEBasis(referenceGridView); FEBasis referenceFEBasis(referenceGridView);
typedef LocalGeodesicFEFunction<GridView::dimension, double, typename FEBasis::LocalView::Tree::FiniteElement, TargetSpace> LocalInterpolationRule;
//typedef GFE::LocalProjectedFEFunction<GridView::dimension, double, typename FEBasis::LocalView::Tree::FiniteElement, TargetSpace> LocalInterpolationRule;
std::cout << "Using local interpolation: " << className<LocalInterpolationRule>() << std::endl;
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// Read the data whose error is to be measured // Read the data whose error is to be measured
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
...@@ -61,7 +66,7 @@ void measureDiscreteEOC(const GridView gridView, ...@@ -61,7 +66,7 @@ void measureDiscreteEOC(const GridView gridView,
x[i] = TargetSpace(embeddedX[i]); x[i] = TargetSpace(embeddedX[i]);
// The numerical solution, as a grid function // The numerical solution, as a grid function
GFE::EmbeddedGlobalGFEFunction<FEBasis, TargetSpace> numericalSolution(feBasis, x); GFE::EmbeddedGlobalGFEFunction<FEBasis, LocalInterpolationRule, TargetSpace> numericalSolution(feBasis, x);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Read the reference configuration // Read the reference configuration
...@@ -80,7 +85,7 @@ void measureDiscreteEOC(const GridView gridView, ...@@ -80,7 +85,7 @@ void measureDiscreteEOC(const GridView gridView,
referenceX[i] = TargetSpace(embeddedReferenceX[i]); referenceX[i] = TargetSpace(embeddedReferenceX[i]);
// The reference solution, as a grid function // The reference solution, as a grid function
GFE::EmbeddedGlobalGFEFunction<FEBasis, TargetSpace> referenceSolution(referenceFEBasis, referenceX); GFE::EmbeddedGlobalGFEFunction<FEBasis, LocalInterpolationRule, TargetSpace> referenceSolution(referenceFEBasis, referenceX);
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Measure the discretization error // Measure the discretization error
...@@ -190,6 +195,10 @@ void measureAnalyticalEOC(const GridView gridView, ...@@ -190,6 +195,10 @@ void measureAnalyticalEOC(const GridView gridView,
typedef Dune::Functions::PQkNodalBasis<GridView, order> FEBasis; typedef Dune::Functions::PQkNodalBasis<GridView, order> FEBasis;
FEBasis feBasis(gridView); FEBasis feBasis(gridView);
typedef LocalGeodesicFEFunction<GridView::dimension, double, typename FEBasis::LocalView::Tree::FiniteElement, TargetSpace> LocalInterpolationRule;
//typedef GFE::LocalProjectedFEFunction<GridView::dimension, double, typename FEBasis::LocalView::Tree::FiniteElement, TargetSpace> LocalInterpolationRule;
std::cout << "Using local interpolation: " << className<LocalInterpolationRule>() << std::endl;
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// Read the data whose error is to be measured // Read the data whose error is to be measured
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
...@@ -222,7 +231,7 @@ void measureAnalyticalEOC(const GridView gridView, ...@@ -222,7 +231,7 @@ void measureAnalyticalEOC(const GridView gridView,
auto referenceSolution = module.get("fdf").toC<std::shared_ptr<FBase>>(); auto referenceSolution = module.get("fdf").toC<std::shared_ptr<FBase>>();
// The numerical solution, as a grid function // The numerical solution, as a grid function
GFE::EmbeddedGlobalGFEFunction<FEBasis, TargetSpace> numericalSolution(feBasis, x); GFE::EmbeddedGlobalGFEFunction<FEBasis, LocalInterpolationRule, TargetSpace> numericalSolution(feBasis, x);
// QuadratureRule for the integral of the L^2 error // QuadratureRule for the integral of the L^2 error
QuadratureRuleKey quadKey(dim,6); QuadratureRuleKey quadKey(dim,6);
......
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