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

Port EmbeddedGlobalGFEFunction to the dune-functions basis interface

It is still no function in the dune-functions sense, but at least the
basis parameter needs to be a dune-functions basis now, rather than
a deprecated dune-fufem basis.
parent 5541cb79
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ class EmbeddedGlobalGFEFunction ...@@ -24,7 +24,7 @@ class EmbeddedGlobalGFEFunction
public: public:
typedef B Basis; typedef B Basis;
typedef typename Basis::LocalFiniteElement LocalFiniteElement; typedef typename Basis::LocalView::Tree::FiniteElement LocalFiniteElement;
typedef typename Basis::GridView GridView; typedef typename Basis::GridView GridView;
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;
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
//! Create global function by a global basis and the corresponding coefficient vector //! Create global function by a global basis and the corresponding coefficient vector
EmbeddedGlobalGFEFunction(const Basis& basis, const std::vector<TargetSpace>& coefficients) : EmbeddedGlobalGFEFunction(const Basis& basis, const std::vector<TargetSpace>& coefficients) :
VirtualGridViewFunction<typename B::GridView, typename TargetSpace::CoordinateType>(basis.getGridView()), VirtualGridViewFunction<typename B::GridView, typename TargetSpace::CoordinateType>(basis.gridView()),
basis_(basis), basis_(basis),
coefficients_(coefficients) coefficients_(coefficients)
{} {}
...@@ -56,16 +56,21 @@ public: ...@@ -56,16 +56,21 @@ public:
/** \brief Evaluate the function at local coordinates. */ /** \brief Evaluate the function at local coordinates. */
typename TargetSpace::CoordinateType operator()(const Element& element, const Dune::FieldVector<ctype,gridDim>& local) const typename TargetSpace::CoordinateType operator()(const Element& element, const Dune::FieldVector<ctype,gridDim>& local) const
{ {
int numOfBaseFct = basis_.getLocalFiniteElement(element).localBasis().size(); auto localView = basis_.localView();
auto localIndexSet = basis_.localIndexSet();
localView.bind(element);
localIndexSet.bind(localView);
auto numOfBaseFct = localIndexSet.size();
// Extract local coefficients // Extract local coefficients
std::vector<TargetSpace> localCoeff(numOfBaseFct); std::vector<TargetSpace> localCoeff(numOfBaseFct);
for (int i=0; i<numOfBaseFct; i++) for (size_t i=0; i<numOfBaseFct; i++)
localCoeff[i] = coefficients_[basis_.index(element,i)]; localCoeff[i] = coefficients_[localIndexSet.index(i)];
// create local gfe function // create local gfe function
LocalGFEFunction localGFE(basis_.getLocalFiniteElement(element),localCoeff); LocalGFEFunction localGFE(localView.tree().finiteElement(),localCoeff);
return localGFE.evaluate(local).globalCoordinates(); return localGFE.evaluate(local).globalCoordinates();
} }
...@@ -79,16 +84,21 @@ public: ...@@ -79,16 +84,21 @@ public:
/** \brief Evaluate the derivative of the function at local coordinates. */ /** \brief Evaluate the derivative of the function at local coordinates. */
Dune::FieldMatrix<ctype, embeddedDim, gridDim> derivative(const Element& element, const Dune::FieldVector<ctype,gridDim>& local) const Dune::FieldMatrix<ctype, embeddedDim, gridDim> derivative(const Element& element, const Dune::FieldVector<ctype,gridDim>& local) const
{ {
int numOfBaseFct = basis_.getLocalFiniteElement(element).localBasis().size(); auto localView = basis_.localView();
auto localIndexSet = basis_.localIndexSet();
localView.bind(element);
localIndexSet.bind(localView);
int numOfBaseFct = localIndexSet.size();
// Extract local coefficients // Extract local coefficients
std::vector<TargetSpace> localCoeff(numOfBaseFct); std::vector<TargetSpace> localCoeff(numOfBaseFct);
for (int i=0; i<numOfBaseFct; i++) for (int i=0; i<numOfBaseFct; i++)
localCoeff[i] = coefficients_[basis_.index(element,i)]; localCoeff[i] = coefficients_[localIndexSet.index(i)];
// create local gfe function // create local gfe function
LocalGFEFunction localGFE(basis_.getLocalFiniteElement(element),localCoeff); LocalGFEFunction localGFE(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 = localGFE.evaluateDerivative(local);
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
#include <dune/functions/functionspacebases/pqknodalbasis.hh> #include <dune/functions/functionspacebases/pqknodalbasis.hh>
#include <dune/fufem/boundarypatch.hh>
#include <dune/fufem/functiontools/basisinterpolator.hh>
#include <dune/fufem/functiontools/boundarydofs.hh>
#include <dune/fufem/functionspacebases/dunefunctionsbasis.hh>
#include <dune/fufem/discretizationerror.hh> #include <dune/fufem/discretizationerror.hh>
#include <dune/fufem/dunepython.hh> #include <dune/fufem/dunepython.hh>
...@@ -43,10 +39,6 @@ void measureDiscreteEOC(const GridView gridView, ...@@ -43,10 +39,6 @@ void measureDiscreteEOC(const GridView gridView,
FEBasis feBasis(gridView); FEBasis feBasis(gridView);
FEBasis referenceFEBasis(referenceGridView); FEBasis referenceFEBasis(referenceGridView);
using FufemFEBasis = DuneFunctionsBasis<FEBasis>;
FufemFEBasis fufemReferenceFEBasis(referenceFEBasis);
FufemFEBasis fufemFEBasis(feBasis);
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// Read the data whose error is to be measured // Read the data whose error is to be measured
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
...@@ -69,7 +61,7 @@ void measureDiscreteEOC(const GridView gridView, ...@@ -69,7 +61,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<FufemFEBasis, TargetSpace> numericalSolution(fufemFEBasis, x); GFE::EmbeddedGlobalGFEFunction<FEBasis, TargetSpace> numericalSolution(feBasis, x);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Read the reference configuration // Read the reference configuration
...@@ -88,7 +80,7 @@ void measureDiscreteEOC(const GridView gridView, ...@@ -88,7 +80,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<FufemFEBasis, TargetSpace> referenceSolution(fufemReferenceFEBasis, referenceX); GFE::EmbeddedGlobalGFEFunction<FEBasis, TargetSpace> referenceSolution(referenceFEBasis, referenceX);
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Measure the discretization error // Measure the discretization error
...@@ -225,9 +217,6 @@ void measureAnalyticalEOC(const GridView gridView, ...@@ -225,9 +217,6 @@ void measureAnalyticalEOC(const GridView gridView,
// Measure the discretization error // Measure the discretization error
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
using FufemFEBasis = DuneFunctionsBasis<FEBasis>;
FufemFEBasis fufemFEBasis(feBasis);
// Read reference solution and its derivative into a PythonFunction // Read reference solution and its derivative into a PythonFunction
typedef VirtualDifferentiableFunction<FieldVector<double, dim>, typename TargetSpace::CoordinateType> FBase; typedef VirtualDifferentiableFunction<FieldVector<double, dim>, typename TargetSpace::CoordinateType> FBase;
...@@ -235,7 +224,7 @@ void measureAnalyticalEOC(const GridView gridView, ...@@ -235,7 +224,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<FufemFEBasis, TargetSpace> numericalSolution(fufemFEBasis, x); GFE::EmbeddedGlobalGFEFunction<FEBasis, 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);
......
...@@ -274,7 +274,7 @@ int main (int argc, char *argv[]) try ...@@ -274,7 +274,7 @@ int main (int argc, char *argv[]) try
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<FufemFEBasis, TargetSpace> numericalSolution(feBasis, x); GFE::EmbeddedGlobalGFEFunction<FEBasis, 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