DUNE PDELab (git)

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// 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>
9namespace 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 PrintField,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 > 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<
46 PrintBasis::dimRange> > y( size );
47
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 PrintField=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
static constexpr size_type size() noexcept
Obtain the number of elements stored in the vector.
Definition: fvector.hh:193
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)