Dune Core Modules (2.8.0)

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