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

Remove the BSplineBasis implementation

Development continues in dune-functions
parent 9fe2dd26
Branches
No related tags found
No related merge requests found
install(FILES
bsplinebasis.hh
conformingbasis.hh
dgpqkbasis.hh
dofconstraints.hh
......
SUBDIRS =
functionspacebasesdir = $(includedir)/dune/fufem/functionspacebases
functionspacebases_HEADERS = bsplinebasis.hh \
conformingbasis.hh \
functionspacebases_HEADERS = conformingbasis.hh \
dofconstraints.hh \
dunefunctionsbasis.hh \
extensionbasis.hh \
......
This diff is collapsed.
......@@ -5,7 +5,6 @@ set(GRID_BASED_TESTS
basisinterpolatortest
basisinterpolationmatrixtest
boundarypatchtest
bsplinebasistest
coarsegridfunctionwrappertest
composedfunctiontest
functionintegratortest
......
......@@ -5,7 +5,6 @@ TESTS = arithmetictest\
basisinterpolatortest \
basisinterpolationmatrixtest \
boundarypatchtest \
bsplinebasistest \
coarsegridfunctionwrappertest \
composedfunctiontest \
constantfunctiontest \
......@@ -78,11 +77,6 @@ boundarypatchtest_CPPFLAGS = $(COMMON_CPPFLAGS) $(GRID_CPPFLAGS)
boundarypatchtest_LDADD = $(COMMON_LDADD) $(GRID_LDADD)
boundarypatchtest_LDFLAGS = $(COMMON_LDFLAGS) $(GRID_LDFLAGS)
bsplinebasistest_SOURCES = bsplinebasistest.cc
bsplinebasistest_CPPFLAGS = $(COMMON_CPPFLAGS)
bsplinebasistest_LDADD = $(COMMON_LDADD)
bsplinebasistest_LDFLAGS = $(COMMON_LDFLAGS)
coarsegridfunctionwrappertest_SOURCES = coarsegridfunctionwrappertest.cc
coarsegridfunctionwrappertest_CPPFLAGS = $(COMMON_CPPFLAGS) $(GRID_CPPFLAGS)
coarsegridfunctionwrappertest_LDADD = $(COMMON_LDADD) $(GRID_LDADD)
......
#include "config.h"
/** \file
* \brief Unit tests for the BSplineBasis class
*/
#include <dune/grid/yaspgrid.hh>
#include <dune/grid/io/file/vtk.hh>
#include <dune/localfunctions/test/test-localfe.hh>
#include <dune/fufem/functions/vtkbasisgridfunction.hh>
#include <dune/fufem/functionspacebases/bsplinebasis.hh>
using namespace Dune;
template <class Basis>
void test(const Basis& basis, bool isPartitionOfUnity)
{
typedef typename Basis::GridView GridView;
GridView gridView = basis.getGridView();
static const int dim = GridView::dimension;
// Test the LocalFiniteElement
for (auto it = gridView.template begin<0>(); it!=gridView.template end<0>(); ++it)
{
typedef typename Basis::LocalFiniteElement LocalFiniteElementType;
const LocalFiniteElementType& lFE = basis.getLocalFiniteElement(*it);
// The general LocalFiniteElement unit test from dune/localfunctions/test/test-localfe.hh
// LocalInterpolation is not implemented yet
testFE(lFE,DisableLocalInterpolation);
}
// Make sure the basis is a partition of unity
if (isPartitionOfUnity)
{
for (auto it = gridView.template begin<0>(); it!=gridView.template end<0>(); ++it)
{
typedef typename Basis::LocalFiniteElement LocalFiniteElementType;
const LocalFiniteElementType& lFE = basis.getLocalFiniteElement(*it);
const QuadratureRule<double,dim>& quad = QuadratureRules<double,dim>::rule(it->type(), 3);
std::vector<FieldVector<double,1> > values;
for (size_t i=0; i<quad.size(); i++)
{
lFE.localBasis().evaluateFunction(quad[i].position(), values);
double sum = std::accumulate(values.begin(), values.end(), 0.0);
if (std::abs(sum-1.0) > 1e-5)
DUNE_THROW(Exception, "B-Spline basis is no partition of unity!");
}
}
}
// Write all global basis functions as VTK files, so we can look at them
for (size_t i=0; i<basis.size(); i++)
{
std::vector<FieldVector<double,1> > c(basis.size());
std::fill(c.begin(), c.end(), 0.0);
c[i] = 1.0;
SubsamplingVTKWriter<GridView> vtkWriter(gridView,2);
typedef VTKBasisGridFunction<Basis,std::vector<FieldVector<double,1> > > VTKBSplineFunction;
std::shared_ptr<VTKBSplineFunction> vtkFunction = std::make_shared<VTKBSplineFunction> (basis,c, "value");
vtkWriter.addVertexData(vtkFunction);
vtkWriter.write("bsplineglobalbasis_" + std::to_string(i));
}
}
int main(int argc, char* argv[]) try
{
//////////////////////////////////////////////////
// Test on a 1d grid
//////////////////////////////////////////////////
{
FieldVector<double,1> upper = {1};
std::array<int,1> elements = {5};
YaspGrid<1> grid1d(upper,elements);
typedef YaspGrid<1>::LeafGridView GridView;
GridView gridView = grid1d.leafGridView();
// Create corresponding knot vector
std::vector<double> knotVector(elements[0]+1);
for (size_t i=0; i<knotVector.size(); i++)
knotVector[i] = i * upper[0] / elements[0];
// Create B-spline spaces of different order, and test it
for (int order=0; order<3; order++)
{
typedef Fufem::BSplineBasis<GridView> BasisType;
BasisType bSplineBasis(gridView, knotVector, order);
// Test it
test(bSplineBasis,
true); // This basis is no partition of unity
}
}
//////////////////////////////////////////////////
// Test on a 2d grid
//////////////////////////////////////////////////
{
FieldVector<double,2> upper = {1,1};
std::array<int,2> elements = {5,5};
YaspGrid<2> grid2d(upper,elements);
typedef YaspGrid<2>::LeafGridView GridView;
GridView gridView = grid2d.leafGridView();
// Create corresponding knot vector
std::vector<double> knotVector(elements[0]+1);
for (size_t i=0; i<knotVector.size(); i++)
knotVector[i] = i * upper[0] / elements[0];
// Create B-spline spaces of different order, and test it
for (int order=0; order<3; order++)
{
typedef Fufem::BSplineBasis<GridView> BasisType;
BasisType bSplineBasis(gridView, knotVector, order);
// Test it
test(bSplineBasis,
true); // This basis is a partition of unity
}
}
//////////////////////////////////////////////////
// Test on a 1d grid
//////////////////////////////////////////////////
{
FieldVector<double,3> upper = {1,1,1};
std::array<int,3> elements = {5,5,5};
YaspGrid<3> grid3d(upper,elements);
typedef YaspGrid<3>::LeafGridView GridView;
GridView gridView = grid3d.leafGridView();
// Create corresponding knot vector
std::vector<double> knotVector(elements[0]+1);
for (size_t i=0; i<knotVector.size(); i++)
knotVector[i] = i * upper[0] / elements[0];
// Create B-spline spaces of different order, and test it
for (int order=0; order<3; order++)
{
typedef Fufem::BSplineBasis<GridView> BasisType;
BasisType bSplineBasis(gridView, knotVector, order);
// Test it
test(bSplineBasis,
true); // This basis is a partition of unity
}
}
} catch (Exception e) {
std::cout << e << std::endl;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment