DUNE PDELab (2.8)

defaultbasisfactory.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_DEFAULTBASISFACTORY_HH
4#define DUNE_DEFAULTBASISFACTORY_HH
5
6#include <fstream>
8
9#include <dune/localfunctions/utility/basismatrix.hh>
10
11namespace Dune
12{
13 struct Identity
14 {
15 template <class T>
16 static T apply( const T &t )
17 {
18 return t;
19 }
20 };
21 /************************************************
22 * Class for providing a factory for basis
23 * functions over the set of reference elements.
24 * Is based on the TopologyFactory but additionally
25 * provides rebindes of the field type.
26 * The user provides factories for the pre basis and the
27 * interpolations. The default construction process of
28 * the basis is performed in this class.
29 ************************************************/
30 template< class PreBFactory,
31 class InterpolFactory,
32 unsigned int dim, unsigned int dimR,
33 class SF, class CF,
34 class PreBasisKeyExtractor = Identity >
35 struct DefaultBasisFactory
36 {
37 static const unsigned int dimension = dim;
38 static const unsigned int dimRange = dimR;
39 typedef SF StorageField;
40 typedef CF ComputeField;
41 typedef PreBFactory PreBasisFactory;
42 typedef typename PreBasisFactory::Object PreBasis;
43 typedef InterpolFactory InterpolationFactory;
44 typedef typename InterpolationFactory::Object Interpolation;
45 typedef typename PreBasisFactory::template EvaluationBasisFactory<dim,SF>::Type MonomialBasisFactory;
46 typedef typename MonomialBasisFactory::Object MonomialBasis;
47 typedef StandardEvaluator< MonomialBasis > Evaluator;
48 typedef PolynomialBasisWithMatrix< Evaluator, SparseCoeffMatrix< SF, dimRange > > Basis;
49
50 typedef const Basis Object;
51 typedef typename InterpolationFactory::Key Key;
52 template <unsigned int dd, class FF>
53 struct EvaluationBasisFactory
54 {
55 typedef typename PreBasisFactory::template EvaluationBasisFactory<dd,FF>::Type
56 Type;
57 };
58
59 template< GeometryType::Id geometryId >
60 static Object *create ( const Key &key )
61 {
62 const typename PreBasisFactory::Key preBasisKey = PreBasisKeyExtractor::apply(key);
63 const PreBasis *preBasis = PreBasisFactory::template create<geometryId>( preBasisKey );
64 const Interpolation *interpol = InterpolationFactory::template create<geometryId>( key );
65 BasisMatrix< PreBasis, Interpolation, ComputeField > matrix( *preBasis, *interpol );
66
67 const MonomialBasis *monomialBasis = MonomialBasisFactory::template create< geometryId >( preBasis->order() );
68
69 Basis *basis = new Basis( *monomialBasis );
70
71 basis->fill( matrix );
72
73 InterpolationFactory::release(interpol);
74 PreBasisFactory::release(preBasis);
75
76 return basis;
77 }
79 static void release( Object *object)
80 {
81 const MonomialBasis *monomialBasis = &(object->basis());
82 delete object;
83 MonomialBasisFactory::release( monomialBasis );
84 }
85 };
86}
87
88#endif // #ifndef DUNE_DEFAULTBASISFACTORY_HH
A few common exception classes.
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)