5#ifndef DUNE_LOCALFUNCTIONS_NEDELEC_NEDELECSIMPLEX_NEDELECSIMPLEXPREBASIS_HH
6#define DUNE_LOCALFUNCTIONS_NEDELEC_NEDELECSIMPLEX_NEDELECSIMPLEXPREBASIS_HH
13#include <dune/localfunctions/utility/polynomialbasis.hh>
17 template < GeometryType::Id geometryId,
class Field >
18 struct NedelecVecMatrix;
20 template <
unsigned int dim,
class Field>
21 struct NedelecPreBasisFactory
23 typedef MonomialBasisProvider<dim,Field> MBasisFactory;
24 typedef typename MBasisFactory::Object MBasis;
25 typedef StandardEvaluator<MBasis> EvalMBasis;
26 typedef PolynomialBasisWithMatrix<EvalMBasis,SparseCoeffMatrix<Field,dim> > Basis;
28 typedef const Basis Object;
29 typedef std::size_t Key;
31 template <
unsigned int dd,
class FF>
32 struct EvaluationBasisFactory
34 typedef MonomialBasisProvider<dd,FF> Type;
37 template< GeometryType::Id geometryId >
38 static Object *create ( Key order )
50 NedelecVecMatrix<geometryId,Field> vecMatrix(order);
51 MBasis *mbasis = MBasisFactory::template create<geometryId>(order+1);
52 std::remove_const_t<Object>* tmBasis =
new std::remove_const_t<Object>(*mbasis);
53 tmBasis->fill(vecMatrix);
56 static void release( Object *
object ) {
delete object; }
59 template <GeometryType::Id geometryId,
class Field>
60 struct NedelecVecMatrix
63 static const unsigned int dim = geometry.dim();
64 typedef MultiIndex<dim,Field> MI;
65 typedef MonomialBasis<geometryId,MI> MIBasis;
66 NedelecVecMatrix(std::size_t order)
87 if( (dim!=2 && dim!=3) || !geometry.isSimplex())
90 MIBasis basis(order+1);
91 FieldVector< MI, dim > x;
98 for(
unsigned int i = 0; i < dim; ++i )
100 std::vector< MI > val( basis.size() );
103 basis.evaluate( x, val );
108 unsigned int notHomogen = 0;
110 notHomogen = basis.sizes()[order-1];
113 unsigned int homogen = basis.sizes()[order]-notHomogen;
141 row_ = (notHomogen*dim+homogen*(dim+1))*dim;
145 int homogenTwoVariables = 0;
146 for(
int w = notHomogen; w<notHomogen + homogen; w++)
148 homogenTwoVariables++;
149 row_ = (notHomogen*dim+homogen*(dim+2) + homogenTwoVariables)*dim;
152 mat_ =
new Field*[row_];
158 for (
unsigned int i=0; i<notHomogen+homogen; ++i)
160 for (
unsigned int r=0; r<dim; ++r)
162 for (
unsigned int rr=0; rr<dim; ++rr)
165 mat_[row] =
new Field[col_];
166 for (
unsigned int j=0; j<col_; ++j)
179 for (
unsigned int i=0; i<homogen; ++i)
182 MI xval = val[notHomogen+i];
185 for (
unsigned int r=0; r<dim; ++r)
188 mat_[row+r] =
new Field[col_];
189 for (
unsigned int j=0; j<col_; ++j)
197 for (
int w=homogen+notHomogen; w<val.size(); ++w)
199 if (val[w] == xval*x[0])
201 if (val[w] == xval*x[1])
208 int skipLastDim = xval.z(0)>0;
214 for (
unsigned int r=0; r<dim*(dim-skipLastDim); ++r)
217 mat_[row+r] =
new Field[col_];
218 for (
unsigned int j=0; j<col_; ++j)
230 for (
unsigned int r=0; r<dim - skipLastDim; ++r)
232 int index = (r+dim-1)%dim;
233 for (
int w=homogen+notHomogen; w<val.size(); ++w)
235 if (val[w] == xval*x[index])
237 if (val[w] == xval*x[r])
238 mat_[row+index][w] = -1.;
249 for (
unsigned int i=0; i<rows(); ++i) {
255 unsigned int cols()
const {
259 unsigned int rows()
const {
263 template <
class Vector>
264 void row(
const unsigned int row, Vector &vec )
const
266 const unsigned int N = cols();
267 assert( vec.size() == N );
268 for (
unsigned int i=0; i<N; ++i)
272 unsigned int row_,col_;
Default exception for dummy implementations.
Definition: exceptions.hh:263
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:159
A unique label for each type of element that can occur in a grid.