3#ifndef DUNE_LOCALFUNCTIONS_NEDELEC_NEDELECSIMPLEX_NEDELECSIMPLEXPREBASIS_HH
4#define DUNE_LOCALFUNCTIONS_NEDELEC_NEDELECSIMPLEX_NEDELECSIMPLEXPREBASIS_HH
11#include <dune/localfunctions/utility/polynomialbasis.hh>
15 template < GeometryType::Id geometryId,
class Field >
16 struct NedelecVecMatrix;
18 template <
unsigned int dim,
class Field>
19 struct NedelecPreBasisFactory
21 typedef MonomialBasisProvider<dim,Field> MBasisFactory;
22 typedef typename MBasisFactory::Object MBasis;
23 typedef StandardEvaluator<MBasis> EvalMBasis;
24 typedef PolynomialBasisWithMatrix<EvalMBasis,SparseCoeffMatrix<Field,dim> > Basis;
26 typedef const Basis Object;
27 typedef std::size_t Key;
29 template <
unsigned int dd,
class FF>
30 struct EvaluationBasisFactory
32 typedef MonomialBasisProvider<dd,FF> Type;
35 template< GeometryType::Id geometryId >
36 static Object *create ( Key order )
48 NedelecVecMatrix<geometryId,Field> vecMatrix(order);
49 MBasis *mbasis = MBasisFactory::template create<geometryId>(order+1);
50 std::remove_const_t<Object>* tmBasis =
new std::remove_const_t<Object>(*mbasis);
51 tmBasis->fill(vecMatrix);
54 static void release( Object *
object ) {
delete object; }
57 template <GeometryType::Id geometryId,
class Field>
58 struct NedelecVecMatrix
61 static const unsigned int dim = geometry.dim();
62 typedef MultiIndex<dim,Field> MI;
63 typedef MonomialBasis<geometryId,MI> MIBasis;
64 NedelecVecMatrix(std::size_t order)
85 if( dim!=2 && dim!=3 || !geometry.isSimplex())
88 MIBasis basis(order+1);
89 FieldVector< MI, dim > x;
96 for(
unsigned int i = 0; i < dim; ++i )
98 std::vector< MI > val( basis.size() );
101 basis.evaluate( x, val );
106 unsigned int notHomogen = 0;
108 notHomogen = basis.sizes()[order-1];
111 unsigned int homogen = basis.sizes()[order]-notHomogen;
139 row_ = (notHomogen*dim+homogen*(dim+1))*dim;
143 int homogenTwoVariables = 0;
144 for(
int w = notHomogen; w<notHomogen + homogen; w++)
146 homogenTwoVariables++;
147 row_ = (notHomogen*dim+homogen*(dim+2) + homogenTwoVariables)*dim;
150 mat_ =
new Field*[row_];
156 for (
unsigned int i=0; i<notHomogen+homogen; ++i)
158 for (
unsigned int r=0; r<dim; ++r)
160 for (
unsigned int rr=0; rr<dim; ++rr)
163 mat_[row] =
new Field[col_];
164 for (
unsigned int j=0; j<col_; ++j)
177 for (
unsigned int i=0; i<homogen; ++i)
180 MI xval = val[notHomogen+i];
183 for (
unsigned int r=0; r<dim; ++r)
186 mat_[row+r] =
new Field[col_];
187 for (
unsigned int j=0; j<col_; ++j)
195 for (
int w=homogen+notHomogen; w<val.size(); ++w)
197 if (val[w] == xval*x[0])
199 if (val[w] == xval*x[1])
206 int skipLastDim = xval.z(0)>0;
212 for (
unsigned int r=0; r<dim*(dim-skipLastDim); ++r)
215 mat_[row+r] =
new Field[col_];
216 for (
unsigned int j=0; j<col_; ++j)
228 for (
unsigned int r=0; r<dim - skipLastDim; ++r)
230 int index = (r+dim-1)%dim;
231 for (
int w=homogen+notHomogen; w<val.size(); ++w)
233 if (val[w] == xval*x[index])
235 if (val[w] == xval*x[r])
236 mat_[row+index][w] = -1.;
247 for (
unsigned int i=0; i<rows(); ++i) {
253 unsigned int cols()
const {
257 unsigned int rows()
const {
261 template <
class Vector>
262 void row(
const unsigned int row, Vector &vec )
const
264 const unsigned int N = cols();
265 assert( vec.size() == N );
266 for (
unsigned int i=0; i<N; ++i)
270 unsigned int row_,col_;
Default exception for dummy implementations.
Definition: exceptions.hh:261
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:130
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignedallocator.hh:11
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.