~ubuntu-branches/ubuntu/trusty/rheolef/trusty-proposed

« back to all changes in this revision

Viewing changes to nfem/basis/basis.h

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2010-06-12 09:08:59 UTC
  • Revision ID: james.westby@ubuntu.com-20100612090859-8gpm2gc7j3ab43et
Tags: upstream-5.89
ImportĀ upstreamĀ versionĀ 5.89

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _RHEO_BASIS_H
 
2
#define _RHEO_BASIS_H
 
3
///
 
4
/// This file is part of Rheolef.
 
5
///
 
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
7
///
 
8
/// Rheolef is free software; you can redistribute it and/or modify
 
9
/// it under the terms of the GNU General Public License as published by
 
10
/// the Free Software Foundation; either version 2 of the License, or
 
11
/// (at your option) any later version.
 
12
///
 
13
/// Rheolef is distributed in the hope that it will be useful,
 
14
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
/// GNU General Public License for more details.
 
17
///
 
18
/// You should have received a copy of the GNU General Public License
 
19
/// along with Rheolef; if not, write to the Free Software
 
20
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
21
/// 
 
22
/// =========================================================================
 
23
#include "rheolef/basis_rep.h"
 
24
#include "rheolef/smart_pointer.h"
 
25
 
 
26
/*Class:basis
 
27
NAME: @code{basis} - polynomial basis
 
28
@cindex  polynomial basis
 
29
@clindex basis
 
30
@cindex  reference element
 
31
@clindex reference_element
 
32
SYNOPSYS:
 
33
  @noindent
 
34
  The @code{basis} class defines functions that evaluates a polynomial
 
35
  basis and its derivatives on a point. The polynomial basis
 
36
  is designated by a string, e.g. "P0", "P1", "P2", "bubble",...
 
37
  indicating the basis. The basis depends also of the reference element:
 
38
  triangle, square, tetrahedron (@pxref{reference_element internal}).
 
39
  For instance, on a square, the "P1"
 
40
  string designates the common Q1 four-nodes basis on the reference square.
 
41
 
 
42
  @noindent
 
43
  The nodes associated to the Lagrange polynomial basis
 
44
  are also available by its associated accessor.
 
45
 
 
46
IMPLEMENTATION NOTE:
 
47
  @noindent
 
48
  The @code{basis} class 
 
49
  is a @pxref{smart_pointer internal}) class on a @code{basis_rep} class that is a pure virtual base class 
 
50
  for effective bases, e.g. basis_P1, basis_P1, etc.
 
51
AUTHORS:
 
52
    LMC-IMAG, 38041 Grenoble cedex 9, France
 
53
   | Pierre.Saramito@imag.fr
 
54
DATE:   7 january 2004
 
55
End:
 
56
*/
 
57
 
 
58
//<basis:
 
59
class basis : public smart_pointer<basis_rep> {
 
60
public:
 
61
 
 
62
// typedefs:
 
63
 
 
64
    typedef size_t size_type;
 
65
 
 
66
// allocators:
 
67
 
 
68
    basis (std::string name = "");
 
69
 
 
70
// accessors:
 
71
 
 
72
    std::string name() const;
 
73
    size_type   degree() const;
 
74
    size_type   size (reference_element hat_K) const;
 
75
 
 
76
    Float eval(
 
77
        reference_element hat_K,
 
78
        size_type         i_dof_local,
 
79
        const point&      hat_x) const;
 
80
    
 
81
    point grad_eval(
 
82
        reference_element hat_K,
 
83
        size_type         i_dof_local,
 
84
        const point&      hat_x) const;
 
85
 
 
86
    void eval(
 
87
        reference_element    hat_K,
 
88
        const point&         hat_x,
 
89
        std::vector<Float>&  values) const;
 
90
    
 
91
    void grad_eval(
 
92
        reference_element    hat_K,
 
93
        const point&         hat_x,
 
94
        std::vector<point>&  values) const;
 
95
    
 
96
    void hat_node(
 
97
        reference_element    hat_K,
 
98
        std::vector<point>&  hat_node) const;
 
99
 
 
100
    void dump(std::ostream& out = std::cerr) const;
 
101
};
 
102
//>basis:
 
103
// -----------------------------------------------------------
 
104
// inlined
 
105
// -----------------------------------------------------------
 
106
inline
 
107
basis::basis(std::string name)
 
108
 : smart_pointer<basis_rep> (basis_rep::make_ptr(name))
 
109
{
 
110
}
 
111
inline
 
112
std::string
 
113
basis::name() const
 
114
{
 
115
    return data().name();
 
116
}
 
117
inline
 
118
basis::size_type 
 
119
basis::degree() const
 
120
{
 
121
    return data().degree();
 
122
}
 
123
inline
 
124
basis::size_type
 
125
basis::size (reference_element hat_K) const
 
126
{
 
127
    return data().size (hat_K);
 
128
}
 
129
inline
 
130
Float 
 
131
basis::eval(
 
132
        reference_element hat_K,
 
133
        size_type         i_dof_local,
 
134
        const point&      hat_x) const
 
135
{
 
136
    return data().eval (hat_K, i_dof_local, hat_x);
 
137
}
 
138
inline
 
139
point 
 
140
basis::grad_eval(
 
141
        reference_element hat_K,
 
142
        size_type         i_dof_local,
 
143
        const point&      hat_x) const
 
144
{
 
145
    return data().grad_eval (hat_K, i_dof_local, hat_x);
 
146
}
 
147
inline
 
148
void
 
149
basis::eval(
 
150
        reference_element    hat_K,
 
151
        const point&         hat_x,
 
152
        std::vector<Float>&  values) const
 
153
{
 
154
    return data().eval (hat_K, hat_x, values);
 
155
}
 
156
inline
 
157
void
 
158
basis::grad_eval(
 
159
        reference_element    hat_K,
 
160
        const point&         hat_x,
 
161
        std::vector<point>&  values) const
 
162
{
 
163
    return data().grad_eval (hat_K, hat_x, values);
 
164
}
 
165
inline
 
166
void
 
167
basis::hat_node(
 
168
        reference_element    hat_K,
 
169
        std::vector<point>&  hat_node) const
 
170
{
 
171
    return data().hat_node (hat_K, hat_node);
 
172
}
 
173
inline
 
174
void
 
175
basis::dump(std::ostream& out) const
 
176
{
 
177
    out << "basis " << name() << std::endl;
 
178
}
 
179
#endif // _RHEO_BASIS_H