3#ifndef DUNE_RAVIARTTHOMASPREBASIS_HH
4#define DUNE_RAVIARTTHOMASPREBASIS_HH
11#include <dune/localfunctions/utility/polynomialbasis.hh>
15 template <
unsigned int dim,
class Field>
16 struct RTPreBasisFactory;
17 template <
unsigned int dim,
class Field>
18 struct RTPreBasisFactoryTraits
20 static const unsigned int dimension = dim;
22 typedef MonomialBasisProvider<dim,Field> MBasisFactory;
23 typedef typename MBasisFactory::Object MBasis;
24 typedef StandardEvaluator<MBasis> EvalMBasis;
25 typedef PolynomialBasisWithMatrix<EvalMBasis,SparseCoeffMatrix<Field,dim> > Basis;
27 typedef const Basis Object;
28 typedef unsigned int Key;
29 typedef RTPreBasisFactory<dim,Field> Factory;
32 template <
class Topology,
class Field >
35 template <
unsigned int dim,
class Field>
36 struct RTPreBasisFactory
37 :
public TopologyFactory< RTPreBasisFactoryTraits< dim, Field > >
39 typedef RTPreBasisFactoryTraits< dim, Field > Traits;
40 static const unsigned int dimension = dim;
41 typedef typename Traits::Object Object;
42 typedef typename Traits::Key Key;
43 template <
unsigned int dd,
class FF>
44 struct EvaluationBasisFactory
46 typedef MonomialBasisProvider<dd,FF> Type;
48 template<
class Topology >
49 static Object *createObject (
const Key &order )
51 RTVecMatrix<Topology,Field> vecMatrix(order);
52 typename Traits::MBasis *mbasis = Traits::MBasisFactory::template create<Topology>(order+1);
53 typename std::remove_const<Object>::type *tmBasis =
54 new typename std::remove_const<Object>::type(*mbasis);
55 tmBasis->fill(vecMatrix);
59 template <
class Topology,
class Field>
62 static const unsigned int dim = Topology::dimension;
63 typedef MultiIndex<dim,Field> MI;
64 typedef MonomialBasis<Topology,MI> MIBasis;
65 RTVecMatrix(
unsigned int order)
67 MIBasis basis(order+1);
68 FieldVector< MI, dim > x;
69 for(
unsigned int i = 0; i < dim; ++i )
71 std::vector< MI > val( basis.size() );
72 basis.evaluate( x, val );
75 unsigned int notHomogen = 0;
77 notHomogen = basis.sizes()[order-1];
78 unsigned int homogen = basis.sizes()[order]-notHomogen;
79 row_ = (notHomogen*dim+homogen*(dim+1))*dim;
80 row1_ = basis.sizes()[order]*dim*dim;
81 mat_ =
new Field*[row_];
83 for (
unsigned int i=0; i<notHomogen+homogen; ++i)
85 for (
unsigned int r=0; r<dim; ++r)
87 for (
unsigned int rr=0; rr<dim; ++rr)
89 mat_[row] =
new Field[col_];
90 for (
unsigned int j=0; j<col_; ++j)
100 for (
unsigned int i=0; i<homogen; ++i)
102 for (
unsigned int r=0; r<dim; ++r)
104 mat_[row] =
new Field[col_];
105 for (
unsigned int j=0; j<col_; ++j)
110 MI xval = val[notHomogen+i];
112 for (w=homogen+notHomogen; w<val.size(); ++w)
120 assert(w<val.size());
127 for (
unsigned int i=0; i<rows(); ++i) {
132 unsigned int cols()
const {
135 unsigned int rows()
const {
138 template <
class Vector>
139 void row(
const unsigned int row, Vector &vec )
const
141 const unsigned int N = cols();
142 assert( vec.size() == N );
143 for (
unsigned int i=0; i<N; ++i)
146 unsigned int row_,col_,row1_;
Dune namespace.
Definition: alignedallocator.hh:10
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157
A unique label for each type of element that can occur in a grid.