diff --git a/dune/gfe/globalgfetestfunction.hh b/dune/gfe/globalgfetestfunction.hh deleted file mode 100644 index 253bdb57c17bd891edc9d1952965d029f5fc8410..0000000000000000000000000000000000000000 --- a/dune/gfe/globalgfetestfunction.hh +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef GLOBAL_GEODESIC_FINITE_ELEMENT_TEST_FUNCTION_HH -#define GLOBAL_GEODESIC_FINITE_ELEMENT_TEST_FUNCTION_HH - -#include <array> -#include <vector> -#include <dune/istl/bvector.hh> - -#include <dune/common/fvector.hh> -#include <dune/common/fmatrix.hh> - - -/** \brief Global geodesic finite element test function. - * - * \tparam B - The global basis type. - * \tparam TargetSpace - The manifold that this functions takes its values in. - */ -template<class B, class TargetSpace, class CoefficientType> -class GlobalGFETestFunction -{ -public: - typedef B Basis; - -private: - typedef typename Basis::LocalFiniteElement LocalFiniteElement; - typedef typename Basis::GridView GridView; - typedef typename GridView::template Codim<0>::Entity Element; - typedef typename GridView::Grid::ctype ctype; - - typedef typename TargetSpace::TangentVector TangentVector; - typedef typename TargetSpace::EmbeddedTangentVector EmbeddedTangentVector; - - //! Dimension of the grid. - enum { gridDim = GridView::dimension }; - - //! Dimension of the embedded tanget space - enum { embeddedDim = EmbeddedTangentVector::dimension }; - - enum { tangentDim = TargetSpace::TangentVector::dimension }; - -public: - - //! Create global function by a global gfe test basis and the corresponding coefficient vectors - GlobalGFETestFunction(const Basis& basis, const CoefficientType& coefficients) : - basis_(basis), - coefficients_(coefficients) - {} - - /** \brief Evaluate the function at local coordinates. */ - void evaluateLocal(const Element& element, const Dune::FieldVector<ctype,gridDim>& local, EmbeddedTangentVector& out) const; - - /** \brief Evaluate the derivative of the function at local coordinates. */ - void evaluateDerivativeLocal(const Element& element, const Dune::FieldVector<ctype,gridDim>& local, - Dune::FieldMatrix<ctype, embeddedDim, gridDim>& out) const; - - /** \brief Export the basis. */ - const Basis& basis() const {return basis_;} - - /** \brief Export the coefficient vector. */ - const CoefficientType& coefficientVector() const {return coefficients_;} - -private: - const Basis& basis_; - const CoefficientType& coefficients_; - -}; - -template<class Basis, class TargetSpace, class CoefficientType> -void GlobalGFETestFunction<Basis,TargetSpace,CoefficientType>::evaluateLocal(const Element& element, const Dune::FieldVector<ctype,gridDim>& local, - EmbeddedTangentVector& out) const -{ - // values of the test basis functions - std::vector<std::array<EmbeddedTangentVector, tangentDim> > values; - - // create local gfe test function - basis_.getLocalFiniteElement(element).localBasis().evaluateFunction(local, values); - - // multiply values with the corresponding test coefficients and sum them up - out = 0.0; - - for (size_t i=0; i<values.size(); i++) { - int index = basis_.index(element,i); - for (int j=0; j<tangentDim; j++) { - values[i][j] *= coefficients_[index][j]; - out += values[i][j]; - } - } -} -template<class Basis, class TargetSpace , class CoefficientType> -void GlobalGFETestFunction<Basis,TargetSpace,CoefficientType>::evaluateDerivativeLocal(const Element& element, - const Dune::FieldVector<ctype,gridDim>& local, - Dune::FieldMatrix<ctype, embeddedDim, gridDim>& out) const -{ - // jacobians of the test basis function - a lot of dims here... - std::vector<std::array<Dune::FieldMatrix<ctype, embeddedDim, gridDim>, tangentDim> > refJacobians,jacobians; - - // evaluate local gfe test function basis - basis_.getLocalFiniteElement(element).localBasis().evaluateJacobian(local, refJacobians); - - const Dune::FieldMatrix<double,gridDim,gridDim>& jacInvTrans = element.geometry().jacobianInverseTransposed(local); - - //transform the gradients - jacobians.resize(refJacobians.size()); - for (size_t i = 0; i<jacobians.size(); i++) - for (int j=0; j<tangentDim; j++) {// the local basis has a block structure - jacobians[i][j] = 0; - for (size_t comp=0; comp<jacobians[i][j].N(); comp++) - jacInvTrans.umv(refJacobians[i][j][comp], jacobians[i][j][comp]); - } - - // multiply values with the corresponding test coefficients and sum them up - out = 0.0; - - for (int i=0; i<jacobians.size(); i++) { - int index = basis_.index(element,i); - for (int j=0; j<tangentDim; j++) { - jacobians[i][j] *= coefficients_[index][j]; - out += jacobians[i][j]; - } - } -} -#endif diff --git a/dune/gfe/globalgfetestfunctionbasis.hh b/dune/gfe/globalgfetestfunctionbasis.hh deleted file mode 100644 index c466eeeb4d21493e138c1564a8e613b53745fab5..0000000000000000000000000000000000000000 --- a/dune/gfe/globalgfetestfunctionbasis.hh +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef GLOBAL_GFE_TEST_FUNCTION_BASIS_HH -#define GLOBAL_GFE_TEST_FUNCTION_BASIS_HH - -#include <dune/fufem/functionspacebases/functionspacebasis.hh> - -#include <dune/gfe/localgfetestfunctionbasis.hh> - -/** \brief A global basis for the gfe test functions. - * - * The local finite elements are constructed by wrapping the LocalGFETestFunction and using them whenever localBasis() is called. - * The other LocalFiniteElement methods are not wrapped/implemented by now but it shouldn't be too difficult to do so when they are - * needed. - */ -template <class Basis, class TargetSpace> -class GlobalGFETestFunctionBasis : public FunctionSpaceBasis<typename Basis::GridView, typename TargetSpace::EmbeddedTangentVector, LocalGfeTestFunctionFiniteElement<typename Basis::LocalFiniteElement, TargetSpace> > { - -public: - typedef typename Basis::GridView GridView; - typedef LocalGfeTestFunctionFiniteElement<typename Basis::LocalFiniteElement, TargetSpace> LocalFiniteElement; - typedef Basis LagrangeBasis; - typedef FunctionSpaceBasis<GridView, typename TargetSpace::EmbeddedTangentVector, LocalFiniteElement> Base; - typedef typename Base::LinearCombination LinearCombination; -private: - typedef typename GridView::template Codim<0>::Entity Element; - typedef typename GridView::Grid::ctype ctype; - - -public: - GlobalGFETestFunctionBasis(const Basis& basis, const std::vector<TargetSpace>& baseCoefficients) : - Base(basis.getGridView()), - basis_(basis), - baseCoefficients_(baseCoefficients), - lfe_(NULL) - {} - - /** \brief Get the local gfe test function wrapped as a LocalFiniteElement. */ - const LocalFiniteElement& getLocalFiniteElement(const Element& element) const - { - if (lfe_) - delete(lfe_); - - int numOfBasisFct = basis_.getLocalFiniteElement(element).localBasis().size(); - - // Extract local base and test coefficients - std::vector<TargetSpace> localBaseCoeff(numOfBasisFct); - - for (int i=0; i<numOfBasisFct; i++) - localBaseCoeff[i] = baseCoefficients_[basis_.index(element,i)]; - - // create local gfe test function - lfe_ = new LocalFiniteElement(basis_.getLocalFiniteElement(element),localBaseCoeff); - - return *lfe_; - } - - ~GlobalGFETestFunctionBasis() { - if (lfe_) - delete(lfe_); - } - - /** \brief Get the total number of global (block) basis functions. - * Only return the number of Lagrange points. For each Lagrange point there are (tangentDim) local shape functions - */ - size_t size() const - { - return basis_.size(); - } - - /** \brief Get the global index of the (block) basis function. */ - int index(const Element& e, const int i) const - { - return basis_.index(e,i); - } - -private: - //! The global basis determining the weights - const Basis& basis_; - //! The coefficients of the configuration the tangent spaces are from. */ - const std::vector<TargetSpace>& baseCoefficients_; - //! Save the last local finite element - do I need to do this? - mutable LocalFiniteElement* lfe_; -}; - -#endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5c737a114d8c49ce5b359a4b8af58a8294f5160a..8b4c20ff302f3f6ba957e044fa1a5da58899bcaf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,6 @@ set(TESTS averagedistanceassemblertest cosseratenergytest frameinvariancetest - globalgfetestfunctionbasistest harmonicenergytest localgeodesicfefunctiontest localgfetestfunctiontest diff --git a/test/globalgfetestfunctionbasistest.cc b/test/globalgfetestfunctionbasistest.cc deleted file mode 100644 index ee63c3e842b0781f7827f90798549b6bcaeae3a9..0000000000000000000000000000000000000000 --- a/test/globalgfetestfunctionbasistest.cc +++ /dev/null @@ -1,84 +0,0 @@ -#include <config.h> - -#include <fenv.h> -#include <array> -#include <iostream> - -#include <dune/common/fvector.hh> - -#include <dune/fufem/functionspacebases/p1nodalbasis.hh> - -#include <dune/grid/onedgrid.hh> - -#include <dune/gfe/rotation.hh> -#include <dune/gfe/realtuple.hh> -#include <dune/gfe/unitvector.hh> - -#include <dune/gfe/globalgfetestfunctionbasis.hh> - -#include "valuefactory.hh" - -const double eps = 1e-6; - -using namespace Dune; - -template <class TargetSpace, int domainDim> -void test() -{ - std::cout << " --- Testing " << className<TargetSpace>() << ", domain dimension: " << domainDim << " ---" << std::endl; - - std::vector<TargetSpace> testPoints; - ValueFactory<TargetSpace>::get(testPoints); - - int nTestPoints = testPoints.size(); - - // make a 1-D grid - OneDGrid grid(nTestPoints,-2.0,2.0); - - // make global basis - typedef P1NodalBasis<typename OneDGrid::LeafGridView> P1Basis; - P1Basis p1Basis(grid.leafGridView()); - typedef GlobalGFETestFunctionBasis<P1Basis,TargetSpace> GlobalBasis; - GlobalBasis basis(p1Basis,testPoints); - - for (const auto element : elements(grid.leafGridView())) - { - const typename GlobalBasis::LocalFiniteElement& lfe = basis.getLocalFiniteElement(element); - - FieldVector<double,1> stupidTestPoint(0); - std::vector<std::array<typename TargetSpace::EmbeddedTangentVector, TargetSpace::TangentVector::dimension> > values; - lfe.localBasis().evaluateFunction(stupidTestPoint, values); - for(size_t i=0;i<values.size();i++) { - for (auto v : values[i]) - std::cout << v << " "; - std::cout << std::endl; - std::cout<<lfe.localCoefficients().localKey(i)<<std::endl; - } - //int i = basis.index(*eIt,1); - } - -} - - -int main() try -{ - // choke on NaN -- don't enable this by default, as there are - // a few harmless NaN in the loopsolver - //feenableexcept(FE_INVALID); - - std::cout << std::setw(15) << std::setprecision(12); - - test<RealTuple<double,1>, 1>(); - - test<UnitVector<double,2>, 1>(); - test<UnitVector<double,3>, 1>(); - //test<UnitVector<double,2>, 2>(); - //test<UnitVector<double,3>, 2>(); - - test<Rotation<double,3>, 1>(); - //test<Rotation<double,3>, 2>(); - -} catch (Exception& e) { - std::cout << e.what() << std::endl; -} -