dune-localfunctions
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
localfunctions
utility
basisprint.hh
Go to the documentation of this file.
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 BASISPRINT
6
#define BASISPRINT
7
#include <
dune/localfunctions/utility/multiindex.hh
>
8
#include <
dune/localfunctions/utility/polynomialbasis.hh
>
9
namespace
Dune
{
10
/**********************************************
11
* Methods for printing a PolynomialBasis.
12
* Is achieved by using the MultiIndex class as
13
* Field type and printing the results.
14
* The basis and higher order derivatives can be
15
* printed. This could be the basis for printing
16
* routings providing C++ or matlab methods
17
* for computing the basisfunctions for given
18
* orders or reference elements.
19
**********************************************/
20
// default argument does not work for gcc 4.1.2
21
// template <int deriv,class BasisFactory,class PrintField=typename BasisFactory::StorageField>
22
template
<
int
deriv,
class
BasisFactory,
class
Pr
int
Field,GeometryType::Id geometryId>
23
void
basisPrint
(std::ostream &out,
24
typename
BasisFactory::Object &basis)
25
{
26
typedef
typename
BasisFactory::Object Basis;
27
const
int
dimension = Basis::dimension;
28
29
typedef
MultiIndex< dimension, PrintField >
Field;
30
typedef
typename
BasisFactory::template EvaluationBasisFactory<dimension,Field>::Type
31
MIBasisFactory;
32
typedef
typename
MIBasisFactory::Object MIBasis;
33
typedef
typename
Basis::CoefficientMatrix CMatrix;
34
typedef
PolynomialBasis<StandardEvaluator<MIBasis>
, CMatrix, double,
double
> PrintBasis;
35
36
MIBasis *miBasis = MIBasisFactory::template create<geometryId>( basis.basis().order());
37
PrintBasis printBasis(*miBasis,basis.matrix(),basis.size());
38
39
unsigned
int
size = printBasis.size();
40
41
out <<
"% Number of base functions: "
<< size << std::endl;
42
out <<
"% Derivative order: "
<< deriv << std::endl;
43
44
std::vector< FieldVector<
45
FieldVector<Field,LFETensor<Field,dimension,deriv>::size>,
46
PrintBasis::dimRange> > y( size );
47
48
FieldVector< Field, dimension > x;
49
for
(
int
i = 0; i < dimension; ++i )
50
x[ i ].set( i, 1 );
51
printBasis.template evaluateSingle<deriv>( x, y );
52
for
(
unsigned
int
i=0; i<size; ++i)
53
{
54
out <<
"$\\varphi_"
<< i <<
"(a,b,c)$&$=$&$"
<< std::endl;
55
out <<
"( "
;
56
for
(
unsigned
int
r=0; r<PrintBasis::dimRange; ++r)
57
out << y[i][r] << (r<PrintBasis::dimRange-1 ?
" , $ \\\\ && $"
:
" )$ \\\\"
);
58
out << std::endl;
59
}
60
MIBasisFactory::release(miBasis);
61
}
62
63
template
<
int
deriv,
class
BasisFactory,
class
Pr
int
Field=
typename
BasisFactory::StorageField>
64
void
basisPrint
(std::ostream &out,
65
typename
BasisFactory::Key &key)
66
{
67
typename
BasisFactory::Object *basis = BasisFactory::create(key);
68
basisPrint<deriv,BasisFactory,PrintField>
(out,*basis);
69
BasisFactory::release(basis);
70
}
71
}
72
73
74
#endif
// BASISPRINT
multiindex.hh
polynomialbasis.hh
Dune
Definition
bdfmcube.hh:18
Dune::basisPrint
void basisPrint(std::ostream &out, typename BasisFactory::Object &basis)
Definition
basisprint.hh:23
Dune::MultiIndex
Definition
multiindex.hh:38
Dune::PolynomialBasis
Definition
polynomialbasis.hh:63
Generated by
1.17.0