Skip to content
Snippets Groups Projects
Commit 6b1053e3 authored by oliver.sander_at_tu-dresden.de's avatar oliver.sander_at_tu-dresden.de
Browse files

Merge branch 'implement-prebasis-factories' into 'master'

Implement prebasis factories

See merge request staging/dune-functions!100
parents b0827eec dbf48424
No related branches found
No related tags found
No related merge requests found
...@@ -291,6 +291,46 @@ protected: ...@@ -291,6 +291,46 @@ protected:
namespace BasisBuilder {
namespace Imp {
template<std::size_t k>
class LagrangeDGPreBasisFactory
{
public:
static const std::size_t requiredMultiIndexSize = 1;
template<class MultiIndex, class GridView>
auto makePreBasis(const GridView& gridView) const
{
return LagrangeDGPreBasis<GridView, k, MultiIndex>(gridView);
}
};
} // end namespace BasisBuilder::Imp
/**
* \brief Create a pre-basis factory that can create a LagrangeDG pre-basis
*
* \ingroup FunctionSpaceBasesImplementations
*
* \tparam k The polynomial order of the ansatz functions
*/
template<std::size_t k>
auto lagrangeDG()
{
return Imp::LagrangeDGPreBasisFactory<k>();
}
} // end namespace BasisBuilder
// ***************************************************************************** // *****************************************************************************
// This is the actual global basis implementation based on the reusable parts. // This is the actual global basis implementation based on the reusable parts.
// ***************************************************************************** // *****************************************************************************
......
...@@ -285,6 +285,43 @@ protected: ...@@ -285,6 +285,43 @@ protected:
namespace BasisBuilder {
namespace Imp {
class PQ1PreBasisFactory
{
public:
static const std::size_t requiredMultiIndexSize = 1;
template<class MultiIndex, class GridView>
auto makePreBasis(const GridView& gridView) const
{
return PQ1PreBasis<GridView, MultiIndex>(gridView);
}
};
} // end namespace BasisBuilder::Imp
/**
* \brief Create a pre-basis factory that can create a PQ_1 pre-basis
*
* \ingroup FunctionSpaceBasesImplementations
*
* \tparam k The polynomial order of ansatz functions
*/
auto pq1Nodal()
{
return Imp::PQ1PreBasisFactory();
}
} // end namespace BasisBuilder
/** \brief Nodal basis of a scalar first-order Lagrangian finite element space /** \brief Nodal basis of a scalar first-order Lagrangian finite element space
* *
* \ingroup FunctionSpaceBasesImplementations * \ingroup FunctionSpaceBasesImplementations
......
...@@ -7,6 +7,10 @@ dune_add_test(SOURCES brezzidouglasmarinibasistest.cc) ...@@ -7,6 +7,10 @@ dune_add_test(SOURCES brezzidouglasmarinibasistest.cc)
dune_add_test(SOURCES gridviewfunctionspacebasistest.cc) dune_add_test(SOURCES gridviewfunctionspacebasistest.cc)
dune_add_test(SOURCES lagrangedgbasistest.cc)
dune_add_test(SOURCES pq1nodalbasistest.cc)
dune_add_test(SOURCES taylorhoodbasistest.cc) dune_add_test(SOURCES taylorhoodbasistest.cc)
dune_add_test(SOURCES rannacherturekbasistest.cc) dune_add_test(SOURCES rannacherturekbasistest.cc)
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <dune/common/exceptions.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/functions/functionspacebases/lagrangedgbasis.hh>
#include <dune/functions/functionspacebases/test/basistest.hh>
using namespace Dune;
using namespace Dune::Functions;
int main (int argc, char* argv[])
{
Dune::MPIHelper::instance(argc, argv);
Dune::TestSuite test;
// Generate grid for testing
const int dim = 2;
typedef YaspGrid<dim> GridType;
FieldVector<double,dim> l(1);
std::array<int,dim> elements = {{10, 10}};
GridType grid(l,elements);
// check LagrangeDGBasis created 'manually'
{
typedef GridType::LeafGridView GridView;
const GridView& gridView = grid.leafGridView();
LagrangeDGBasis<GridView,2> basis(gridView);
test.subTest(checkBasis(basis));
}
// check LagrangeDGBasis created using basis builder mechanism
{
using namespace Functions::BasisBuilder;
auto basis = makeBasis(grid.leafGridView(), lagrangeDG<2>());
test.subTest(checkBasis(basis));
}
return test.exit();
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include <config.h>
#include <iostream>
#include <dune/common/exceptions.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/functions/functionspacebases/pq1nodalbasis.hh>
#include <dune/functions/functionspacebases/test/basistest.hh>
using namespace Dune;
using namespace Dune::Functions;
int main (int argc, char* argv[])
{
Dune::MPIHelper::instance(argc, argv);
Dune::TestSuite test;
// Generate grid for testing
const int dim = 2;
typedef YaspGrid<dim> GridType;
FieldVector<double,dim> l(1);
std::array<int,dim> elements = {{10, 10}};
GridType grid(l,elements);
// check PQ1NodalBasis created 'manually'
{
typedef GridType::LeafGridView GridView;
const GridView& gridView = grid.leafGridView();
PQ1NodalBasis<GridView> basis(gridView);
test.subTest(checkBasis(basis));
}
// check PQ1NodalBasis created using basis builder mechanism
{
using namespace Functions::BasisBuilder;
auto basis = makeBasis(grid.leafGridView(), pq1Nodal());
test.subTest(checkBasis(basis));
}
return test.exit();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment