Dune Core Modules (2.6.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>
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::create( Dune::GeometryType( basis.basis().topologyId(),dimension ),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 /*
43 std::vector< FieldVector<
44 LFETensor<Field,dimension,deriv>,PrintBasis::dimRange> >
45 y( size );
46 */
47 std::vector< FieldVector<
48 FieldVector<Field,LFETensor<Field,dimension,deriv>::size>,
49 PrintBasis::dimRange> > y( size );
50
52 for( int i = 0; i < dimension; ++i )
53 x[ i ].set( i, 1 );
54 printBasis.template evaluateSingle<deriv>( x, y );
55 for (unsigned int i=0; i<size; ++i)
56 {
57 out << "$\\varphi_" << i << "(a,b,c)$&$=$&$" << std::endl;
58 out << "( ";
59 for (unsigned int r=0; r<PrintBasis::dimRange; ++r)
60 out << y[i][r] << (r<PrintBasis::dimRange-1 ? " , $ \\\\ && $" : " )$ \\\\");
61 out << std::endl;
62 }
63 MIBasisFactory::release(miBasis);
64 }
65 // template <int deriv,class BasisFactory,class PrintField=typename BasisFactory::StorageField>
66 template <int deriv,class BasisFactory,class PrintField>
67 void basisPrint(std::ostream &out,
68 typename BasisFactory::Key &key)
69 {
70 typename BasisFactory::Object *basis = BasisFactory::create(key);
71 basisPrint<deriv,BasisFactory,PrintField>(out,*basis);
72 BasisFactory::release(basis);
73 }
74}
75
76
77#endif // BASISPRINT
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)