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

« back to all changes in this revision

Viewing changes to nfem/basis/H3.cc

  • 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
// file automatically generated by "basis_symbolic_hermite_cxx.cc"
 
2
///
 
3
/// This file is part of Rheolef.
 
4
///
 
5
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
6
///
 
7
/// Rheolef is free software; you can redistribute it and/or modify
 
8
/// it under the terms of the GNU General Public License as published by
 
9
/// the Free Software Foundation; either version 2 of the License, or
 
10
/// (at your option) any later version.
 
11
///
 
12
/// Rheolef is distributed in the hope that it will be useful,
 
13
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
/// GNU General Public License for more details.
 
16
///
 
17
/// You should have received a copy of the GNU General Public License
 
18
/// along with Rheolef; if not, write to the Free Software
 
19
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
20
///
 
21
/// =========================================================================
 
22
#include "H3.h"
 
23
using namespace std;
 
24
class basis_H3_p {
 
25
public:
 
26
  typedef size_t size_type;
 
27
  static Float eval(
 
28
    size_type    i_dof_local,
 
29
    const point& hat_x);
 
30
  static point grad_eval(
 
31
    size_type    i_dof_local,
 
32
    const point& hat_x);
 
33
  static void eval(
 
34
    const point&   hat_x,
 
35
    vector<Float>& values);
 
36
  static void grad_eval(
 
37
    const point&   hat_x,
 
38
    vector<point>& values);
 
39
  static void hat_node(
 
40
    vector<point>& hat_node);
 
41
};
 
42
class basis_H3_e {
 
43
public:
 
44
  typedef size_t size_type;
 
45
  static Float eval(
 
46
    size_type    i_dof_local,
 
47
    const point& hat_x);
 
48
  static point grad_eval(
 
49
    size_type    i_dof_local,
 
50
    const point& hat_x);
 
51
  static void eval(
 
52
    const point&   hat_x,
 
53
    vector<Float>& values);
 
54
  static void grad_eval(
 
55
    const point&   hat_x,
 
56
    vector<point>& values);
 
57
  static void hat_node(
 
58
    vector<point>& hat_node);
 
59
};
 
60
Float
 
61
basis_H3_p::eval(
 
62
  size_type    i_dof_local,
 
63
  const point& hat_x)
 
64
{
 
65
  typedef Float T;
 
66
  T val = 0;
 
67
  switch (i_dof_local) {
 
68
    case 0: {
 
69
      val = 1.0;
 
70
      return val;
 
71
    }
 
72
    default : {
 
73
      error_macro ("eval: invalid i_dof_local = " << i_dof_local);
 
74
      return 0;
 
75
    }
 
76
  }
 
77
}
 
78
point
 
79
basis_H3_p::grad_eval(
 
80
  size_type    i_dof_local,
 
81
  const point& hat_x)
 
82
{
 
83
  typedef Float T;
 
84
  point val;
 
85
  switch (i_dof_local) {
 
86
    case 0: {
 
87
      return val;
 
88
    }
 
89
    default : {
 
90
      error_macro ("grad_eval: invalid i_dof_local = " << i_dof_local);
 
91
      return point();
 
92
    }
 
93
  }
 
94
}
 
95
void
 
96
basis_H3_p::eval(
 
97
  const point&   hat_x,
 
98
  vector<Float>& values)
 
99
{
 
100
  values.resize(1);
 
101
  typedef Float T;
 
102
  values[0] = 1.0;
 
103
}
 
104
void
 
105
basis_H3_p::grad_eval(
 
106
  const point&   hat_x,
 
107
  vector<point>& values)
 
108
{
 
109
  values.resize(1);
 
110
  typedef Float T;
 
111
}
 
112
void
 
113
basis_H3_p::hat_node(
 
114
  vector<point>& x)
 
115
{
 
116
  x.resize(1);
 
117
  x[0] = point();
 
118
}
 
119
Float
 
120
basis_H3_e::eval(
 
121
  size_type    i_dof_local,
 
122
  const point& hat_x)
 
123
{
 
124
  typedef Float T;
 
125
  T val = 0;
 
126
  switch (i_dof_local) {
 
127
    case 0: {
 
128
      val =  2.0*(hat_x[0]*hat_x[0]*hat_x[0])+-3.0*(hat_x[0]*hat_x[0])+1.0;
 
129
      return val;
 
130
    }
 
131
    case 1: {
 
132
      val =  3.0*(hat_x[0]*hat_x[0])+-2.0*(hat_x[0]*hat_x[0]*hat_x[0]);
 
133
      return val;
 
134
    }
 
135
    case 2: {
 
136
      val =  hat_x[0]+(hat_x[0]*hat_x[0]*hat_x[0])+-2.0*(hat_x[0]*hat_x[0]);
 
137
      return val;
 
138
    }
 
139
    case 3: {
 
140
      val = -(hat_x[0]*hat_x[0])+(hat_x[0]*hat_x[0]*hat_x[0]);
 
141
      return val;
 
142
    }
 
143
    default : {
 
144
      error_macro ("eval: invalid i_dof_local = " << i_dof_local);
 
145
      return 0;
 
146
    }
 
147
  }
 
148
}
 
149
point
 
150
basis_H3_e::grad_eval(
 
151
  size_type    i_dof_local,
 
152
  const point& hat_x)
 
153
{
 
154
  typedef Float T;
 
155
  point val;
 
156
  switch (i_dof_local) {
 
157
    case 0: {
 
158
      val[0] =  6.0*(hat_x[0]*hat_x[0])+-6.0*hat_x[0];
 
159
      return val;
 
160
    }
 
161
    case 1: {
 
162
      val[0] =  6.0*hat_x[0]+-6.0*(hat_x[0]*hat_x[0]);
 
163
      return val;
 
164
    }
 
165
    case 2: {
 
166
      val[0] =  3.0*(hat_x[0]*hat_x[0])+-4.0*hat_x[0]+1.0;
 
167
      return val;
 
168
    }
 
169
    case 3: {
 
170
      val[0] =  -2.0*hat_x[0]+3.0*(hat_x[0]*hat_x[0]);
 
171
      return val;
 
172
    }
 
173
    default : {
 
174
      error_macro ("grad_eval: invalid i_dof_local = " << i_dof_local);
 
175
      return point();
 
176
    }
 
177
  }
 
178
}
 
179
void
 
180
basis_H3_e::eval(
 
181
  const point&   hat_x,
 
182
  vector<Float>& values)
 
183
{
 
184
  values.resize(4);
 
185
  typedef Float T;
 
186
  values[0] =  -3.0*(hat_x[0]*hat_x[0])+2.0*(hat_x[0]*hat_x[0]*hat_x[0])+1.0;
 
187
  values[1] =  -2.0*(hat_x[0]*hat_x[0]*hat_x[0])+3.0*(hat_x[0]*hat_x[0]);
 
188
  values[2] =  hat_x[0]+-2.0*(hat_x[0]*hat_x[0])+(hat_x[0]*hat_x[0]*hat_x[0]);
 
189
  values[3] =  (hat_x[0]*hat_x[0]*hat_x[0])-(hat_x[0]*hat_x[0]);
 
190
}
 
191
void
 
192
basis_H3_e::grad_eval(
 
193
  const point&   hat_x,
 
194
  vector<point>& values)
 
195
{
 
196
  values.resize(4);
 
197
  typedef Float T;
 
198
  values[0][0] =  6.0*(hat_x[0]*hat_x[0])+-6.0*hat_x[0];
 
199
  values[1][0] =  -6.0*(hat_x[0]*hat_x[0])+6.0*hat_x[0];
 
200
  values[2][0] =  -4.0*hat_x[0]+3.0*(hat_x[0]*hat_x[0])+1.0;
 
201
  values[3][0] =  3.0*(hat_x[0]*hat_x[0])+-2.0*hat_x[0];
 
202
}
 
203
void
 
204
basis_H3_e::hat_node(
 
205
  vector<point>& x)
 
206
{
 
207
  x.resize(4);
 
208
  x[0] = point(0.0);
 
209
  x[1] = point(1.0);
 
210
  x[2] = point(0.0);
 
211
  x[3] = point(1.0);
 
212
}
 
213
basis_H3::~basis_H3()
 
214
{
 
215
}
 
216
basis_H3::size_type
 
217
basis_H3::degree () const
 
218
{
 
219
    return 3;
 
220
}
 
221
basis_H3::size_type
 
222
basis_H3::size (
 
223
    reference_element hat_K) const
 
224
{
 
225
    switch (hat_K.type()) {
 
226
      case reference_element::p: {
 
227
        return 1;
 
228
      }
 
229
      case reference_element::e: {
 
230
        return 4;
 
231
      }
 
232
      default : {
 
233
        error_macro ("size: unsupported `" << hat_K.name() << "' element type");
 
234
        return 0;
 
235
      }
 
236
    }
 
237
}
 
238
Float
 
239
basis_H3::eval(
 
240
    reference_element hat_K,
 
241
    size_type         i_dof_local,
 
242
    const point&      hat_x) const
 
243
{
 
244
    switch (hat_K.type()) {
 
245
      case reference_element::p: {
 
246
      return basis_H3_p::eval (i_dof_local,hat_x);
 
247
      }
 
248
      case reference_element::e: {
 
249
      return basis_H3_e::eval (i_dof_local,hat_x);
 
250
      }
 
251
      default : {
 
252
        error_macro ("eval: unsupported `" << hat_K.name() << "' element type");
 
253
        return 0;
 
254
      }
 
255
    }
 
256
}
 
257
point
 
258
basis_H3::grad_eval(
 
259
    reference_element hat_K,
 
260
    size_type         i_dof_local,
 
261
    const point&      hat_x) const
 
262
{
 
263
    switch (hat_K.type()) {
 
264
      case reference_element::p: {
 
265
      return basis_H3_p::grad_eval (i_dof_local,hat_x);
 
266
      }
 
267
      case reference_element::e: {
 
268
      return basis_H3_e::grad_eval (i_dof_local,hat_x);
 
269
      }
 
270
      default : {
 
271
        error_macro ("grad_eval: unsupported `" << hat_K.name() << "' element type");
 
272
        return point();
 
273
      }
 
274
    }
 
275
}
 
276
void
 
277
basis_H3::eval(
 
278
    reference_element hat_K,
 
279
    const point&      hat_x,
 
280
    vector<Float>&    values) const
 
281
{
 
282
    switch (hat_K.type()) {
 
283
      case reference_element::p: {
 
284
      return basis_H3_p::eval (hat_x, values);
 
285
      }
 
286
      case reference_element::e: {
 
287
      return basis_H3_e::eval (hat_x, values);
 
288
      }
 
289
      default : {
 
290
        error_macro ("eval: unsupported `" << hat_K.name() << "' element type");
 
291
      }
 
292
    }
 
293
}
 
294
void
 
295
basis_H3::grad_eval(
 
296
    reference_element hat_K,
 
297
    const point&      hat_x,
 
298
    vector<point>&    values) const
 
299
{
 
300
    switch (hat_K.type()) {
 
301
      case reference_element::p: {
 
302
      return basis_H3_p::grad_eval (hat_x, values);
 
303
      }
 
304
      case reference_element::e: {
 
305
      return basis_H3_e::grad_eval (hat_x, values);
 
306
      }
 
307
      default : {
 
308
        error_macro ("grad_eval: unsupported `" << hat_K.name() << "' element type");
 
309
      }
 
310
    }
 
311
}
 
312
void
 
313
basis_H3::hat_node(
 
314
    reference_element hat_K,
 
315
    vector<point>&    hat_node) const
 
316
{
 
317
    switch (hat_K.type()) {
 
318
      case reference_element::p: {
 
319
      return basis_H3_p::hat_node (hat_node);
 
320
      }
 
321
      case reference_element::e: {
 
322
      return basis_H3_e::hat_node (hat_node);
 
323
      }
 
324
      default : {
 
325
        error_macro ("hat_node: unsupported `" << hat_K.name() << "' element type");
 
326
      }
 
327
    }
 
328
}
 
329
basis_rep* make_H3(void) { return new_macro(basis_H3); }