Debian Codegraph @

dune/localfunctions/orthonormal/orthonormalbasis.hh

raw
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_ORTHONORMALBASIS_HH
6 #define DUNE_ORTHONORMALBASIS_HH
7
8 #include <sstream>
9
10 #include <dune/localfunctions/utility/polynomialbasis.hh>
11 #include <dune/localfunctions/orthonormal/orthonormalcompute.hh>
12
13 namespace Dune
14 {
15
16 // OrthonormalBasisFactory
17 // -----------------------
18 template< int dim, class D, class R, class SF, class CF = typename ComputeField< SF, 512 >::Type >
19 struct OrthonormalBasisFactory
20 {
21 static const unsigned int dimension = dim;
22 typedef D Domain;
23 typedef R Range;
24 typedef SF StorageField;
25 typedef CF ComputeField;
26
27 template <unsigned int dd, class FF>
28 struct EvaluationBasisFactory
29 {
30 typedef MonomialBasisProvider<dd,FF> Type;
31 };
32
33 typedef typename EvaluationBasisFactory< dimension, StorageField >::Type MonomialBasisProviderType;
34 typedef typename MonomialBasisProviderType::Object MonomialBasisType;
35
36 typedef SparseCoeffMatrix< StorageField, 1 > CoefficientMatrix;
37 typedef StandardEvaluator< MonomialBasisType > Evaluator;
38 typedef PolynomialBasis< Evaluator, CoefficientMatrix, Domain, Range > Basis;
39
40 typedef unsigned int Key;
41 typedef const Basis Object;
42
43 static constexpr GeometryType SimplexGeometry = GeometryTypes::simplex(dim);
44
45 template< GeometryType::Id geometryId >
46 static Object *create ( const unsigned int order )
47 {
48 const MonomialBasisType &monomialBasis = *MonomialBasisProviderType::template create< SimplexGeometry >( order );
49
50 static CoefficientMatrix _coeffs;
51 if( _coeffs.size() <= monomialBasis.size() )
52 {
53 ONBCompute::ONBMatrix< geometryId, ComputeField > matrix( order );
54 _coeffs.fill( matrix );
55 }
56
57 return new Basis( monomialBasis, _coeffs, monomialBasis.size() );
58 }
59 static void release( Object *object ) { delete object; }
60 };
61
62 }
63
64 #endif // #ifndef DUNE_ORTHONORMALBASIS_HH