Dune Core Modules (2.6.0)

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#include <dune/geometry/topologyfactory.hh>
9
10#include <dune/localfunctions/utility/basismatrix.hh>
11
12namespace Dune
13{
14 struct Identity
15 {
16 template <class T>
17 static T apply( const T &t )
18 {
19 return t;
20 }
21 };
22 /************************************************
23 * Class for providing a factory for basis
24 * functions over the set of reference elements.
25 * Is based on the TopologyFactory but additionally
26 * provides rebindes of the field type.
27 * The user provides factories for the pre basis and the
28 * interpolations. The default construction process of
29 * the basis is performed in this class.
30 ************************************************/
31 template< class PreBFactory,
32 class InterpolFactory,
33 unsigned int dim, unsigned int dimR,
34 class SF, class CF,
35 class PreBasisKeyExtractor = Identity >
36 struct DefaultBasisFactory;
37
38 template< class PreBFactory,
39 class InterpolFactory,
40 unsigned int dim, unsigned int dimR,
41 class SF, class CF,
42 class PreBasisKeyExtractor >
43 struct DefaultBasisFactoryTraits
44 {
45 static const unsigned int dimension = dim;
46 static const unsigned int dimRange = dimR;
47
48 typedef PreBFactory PreBasisFactory;
49 typedef typename PreBasisFactory::Object PreBasis;
50 typedef InterpolFactory InterpolationFactory;
51 typedef typename InterpolationFactory::Object Interpolation;
52
53 typedef typename PreBasisFactory::template EvaluationBasisFactory<dim,SF>::Type MonomialBasisFactory;
54 typedef typename MonomialBasisFactory::Object MonomialBasis;
55 typedef StandardEvaluator< MonomialBasis > Evaluator;
56 typedef PolynomialBasisWithMatrix< Evaluator, SparseCoeffMatrix< SF, dimRange > > Basis;
57
58 typedef const Basis Object;
59 typedef typename InterpolationFactory::Key Key;
60 typedef DefaultBasisFactory<PreBFactory,InterpolFactory,dim,dimR,SF,CF,PreBasisKeyExtractor> Factory;
61 };
62
63 template< class PreBFactory,
64 class InterpolFactory,
65 unsigned int dim, unsigned int dimR,
66 class SF, class CF,
67 class PreBasisKeyExtractor >
68 struct DefaultBasisFactory
69 : public TopologyFactory<
70 DefaultBasisFactoryTraits< PreBFactory,InterpolFactory,dim,dimR,SF,CF,PreBasisKeyExtractor >
71 >
72 {
73 typedef DefaultBasisFactoryTraits< PreBFactory,InterpolFactory,dim,dimR,SF,CF,PreBasisKeyExtractor > Traits;
74 static const unsigned int dimension = Traits::dimension;
75 static const unsigned int dimRange = Traits::dimRange;
76 typedef SF StorageField;
77 typedef CF ComputeField;
78 typedef typename Traits::Basis Basis;
79 typedef typename Traits::PreBasisFactory PreBasisFactory;
80
81 typedef typename Traits::Object Object;
82 typedef typename Traits::Key Key;
83 template <unsigned int dd, class FF>
84 struct EvaluationBasisFactory
85 {
86 typedef typename Traits::PreBasisFactory::template EvaluationBasisFactory<dd,FF>::Type
87 Type;
88 };
89
90 template< class Topology >
91 static Object *createObject ( const Key &key )
92 {
93 const typename PreBasisFactory::Key preBasisKey = PreBasisKeyExtractor::apply(key);
94 const typename Traits::PreBasis *preBasis = Traits::PreBasisFactory::template create<Topology>( preBasisKey );
95 const typename Traits::Interpolation *interpol = Traits::InterpolationFactory::template create<Topology>( key );
96 BasisMatrix< typename Traits::PreBasis,
97 typename Traits::Interpolation,
98 ComputeField > matrix( *preBasis, *interpol );
99
100 const typename Traits::MonomialBasis *monomialBasis = Traits::MonomialBasisFactory::template create< Topology >( preBasis->order() );
101
102 Basis *basis = new Basis( *monomialBasis );
103
104 basis->fill( matrix );
105
106 Traits::InterpolationFactory::release(interpol);
107 Traits::PreBasisFactory::release(preBasis);
108
109 return basis;
110 }
112 static void release( Object *object)
113 {
114 const typename Traits::MonomialBasis *monomialBasis = &(object->basis());
115 delete object;
116 Traits::MonomialBasisFactory::release( monomialBasis );
117 }
118 };
119}
120
121#endif // #ifndef DUNE_DEFAULTBASISFACTORY_HH
A few common exception classes.
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
Dune namespace.
Definition: alignedallocator.hh:10
static void release(Object *object)
release the object returned by the create methods
Definition: topologyfactory.hh:60
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)