DUNE PDELab (git)

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