~ubuntu-branches/ubuntu/saucy/rheolef/saucy

« back to all changes in this revision

Viewing changes to nfem/plib/form_element.h

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Saramito
  • Date: 2011-03-23 11:14:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110323111426-cjvhey7lxt6077ty
Tags: 5.93-1
* New upstream release (minor changes):
  - some extra warning message deleted in heap_allocator
  - graphic output with mayavi2 fixed
  - add doc refman in .info and .pdf format

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
/// 
22
22
/// =========================================================================
23
23
 
 
24
#include "rheolef/scalar_traits.h"
24
25
#include "rheolef/element.h"
25
26
#include "rheolef/geo.h"
26
27
#include "rheolef/quadrature.h"
29
30
 
30
31
#include <boost/numeric/ublas/matrix.hpp>
31
32
 
32
 
namespace rheolef { 
 
33
namespace rheolef {
33
34
namespace ublas = boost::numeric::ublas;
34
35
 
35
36
/*Class:form_element
63
64
End:
64
65
*/
65
66
 
66
 
template<class T>
 
67
template<class T, class M>
67
68
class form_element_rep {
68
69
public:
69
70
// typedefs:
70
 
    typedef geo_element::size_type  size_type;
71
 
    typedef basic_point<T>          vertex_type;
 
71
    typedef geo_element::size_type          size_type;
 
72
    typedef typename scalar_traits<T>::type float_type;
 
73
    typedef basic_point<float_type>         vertex_type;
 
74
    typedef element<float_type>             element_type;
 
75
    typedef geo_basic<float_type,M>         geo_type;
72
76
 
73
77
// allocators:
74
78
 
75
79
    form_element_rep();
76
80
 
77
81
    form_element_rep(
78
 
        const element<T>&     X,
79
 
        const element<T>&     Y,
80
 
        const geo_basic<T>&   omega);
 
82
        const element_type&     X,
 
83
        const element_type&     Y,
 
84
        const geo_type&         omega);
81
85
 
82
86
    virtual ~form_element_rep();
83
87
    void     initialize_all();
86
90
 
87
91
    virtual void operator() (const geo_element& K, ublas::matrix<T>& m) const = 0;
88
92
    virtual void initialize () = 0;
 
93
    virtual bool is_symmetric () const = 0;
89
94
 
90
95
// accessors:
91
96
 
92
 
    const element<T>& get_first_element() const;
93
 
    const element<T>& get_second_element() const;
 
97
    const element_type& get_first_element() const;
 
98
    const element_type& get_second_element() const;
94
99
 
95
100
    const basis&  get_first_basis() const;
96
101
    const basis&  get_second_basis() const;
99
104
    size_type     n_derivative() const;
100
105
    void          set_n_derivative (size_type n);
101
106
 
102
 
    const vertex_type& par_vertex(size_type par_iv) const;
 
107
    const vertex_type& dis_vertex(size_type dis_iv) const;
103
108
 
104
109
// predefined forms:
105
110
 
194
199
 
195
200
// data:
196
201
protected:
197
 
    element<T>             _X;  // also origin      dof numbering
198
 
    element<T>             _Y;  // also destination dof numbering
199
 
    geo_basic<T>           _omega; // for the access to distributed vertices
 
202
    element_type           _X;  // also origin      dof numbering
 
203
    element_type           _Y;  // also destination dof numbering
 
204
    geo_type               _omega; // for the access to distributed vertices
200
205
 
201
206
    bool                   _initialized;
202
207
    size_type              _n_derivative; // e.g. =2 for grad_grad and =0 for mass
216
221
// internal:
217
222
public:
218
223
    // automatically generated implementation in form_element_make.cc :
219
 
    static form_element_rep<T>* make_ptr (
 
224
    static form_element_rep<T,M>* make_ptr (
220
225
        std::string           name,
221
 
        const element<T>&     X,
222
 
        const element<T>&     Y,
223
 
        const geo_basic<T>&   omega);
 
226
        const element_type&   X,
 
227
        const element_type&   Y,
 
228
        const geo_type&       omega);
224
229
};
225
230
// -----------------------------------------------------------------------
226
231
// inlined
227
232
// -----------------------------------------------------------------------
228
233
 
229
 
template<class T>
 
234
template<class T, class M>
230
235
inline
231
 
form_element_rep<T>::form_element_rep()
 
236
form_element_rep<T,M>::form_element_rep()
232
237
 : _X(),
233
238
   _Y(),
234
239
   _omega(),
240
245
   _tr_p1_table()
241
246
{
242
247
}
243
 
template<class T>
 
248
template<class T, class M>
244
249
inline
245
 
form_element_rep<T>::form_element_rep (
246
 
    const element<T>&     X,
247
 
    const element<T>&     Y,
248
 
    const geo_basic<T>&   omega)
 
250
form_element_rep<T,M>::form_element_rep (
 
251
    const element_type&     X,
 
252
    const element_type&     Y,
 
253
    const geo_type&         omega)
249
254
 : _X (X),
250
255
   _Y (Y),
251
256
   _omega (omega),
257
262
   _tr_p1_table()
258
263
{
259
264
}
260
 
template<class T>
261
 
inline
262
 
form_element_rep<T>::~form_element_rep() 
263
 
{
264
 
}
265
 
template<class T>
266
 
inline
267
 
const typename form_element_rep<T>::vertex_type&
268
 
form_element_rep<T>::par_vertex(size_type par_iv) const
269
 
{
270
 
  return _omega.par_vertex (par_iv);
271
 
}
272
 
template<class T>
273
 
inline
274
 
const element<T>& 
275
 
form_element_rep<T>::get_first_element() const
 
265
template<class T, class M>
 
266
inline
 
267
form_element_rep<T,M>::~form_element_rep() 
 
268
{
 
269
}
 
270
template<class T, class M>
 
271
inline
 
272
const typename form_element_rep<T,M>::vertex_type&
 
273
form_element_rep<T,M>::dis_vertex(size_type dis_iv) const
 
274
{
 
275
  return _omega.dis_vertex (dis_iv);
 
276
}
 
277
template<class T, class M>
 
278
inline
 
279
const typename form_element_rep<T,M>::element_type&
 
280
form_element_rep<T,M>::get_first_element() const
276
281
{
277
282
  return _X;
278
283
}
279
 
template<class T>
 
284
template<class T, class M>
280
285
inline
281
 
const element<T>& 
282
 
form_element_rep<T>::get_second_element() const
 
286
const typename form_element_rep<T,M>::element_type&
 
287
form_element_rep<T,M>::get_second_element() const
283
288
{
284
289
  return _Y;
285
290
}
286
 
template<class T>
287
 
inline
288
 
const basis& 
289
 
form_element_rep<T>::get_first_basis() const
290
 
{
291
 
  return get_first_element().get_basis();
292
 
}
293
 
template<class T>
294
 
inline
295
 
const basis& 
296
 
form_element_rep<T>::get_second_basis() const
297
 
{
298
 
  return get_first_element().get_basis();
299
 
}
300
 
template<class T>
 
291
template<class T, class M>
 
292
inline
 
293
const basis& 
 
294
form_element_rep<T,M>::get_first_basis() const
 
295
{
 
296
  return get_first_element().get_basis();
 
297
}
 
298
template<class T, class M>
 
299
inline
 
300
const basis& 
 
301
form_element_rep<T,M>::get_second_basis() const
 
302
{
 
303
  return get_first_element().get_basis();
 
304
}
 
305
template<class T, class M>
301
306
inline
302
307
const basis&
303
 
form_element_rep<T>::get_p1_transformation () const
 
308
form_element_rep<T,M>::get_p1_transformation () const
304
309
{
305
310
  return get_first_element().get_p1_transformation();
306
311
}
307
 
template<class T>
 
312
template<class T, class M>
308
313
inline
309
 
typename form_element_rep<T>::size_type
310
 
form_element_rep<T>::coordinate_dimension() const
 
314
typename form_element_rep<T,M>::size_type
 
315
form_element_rep<T,M>::coordinate_dimension() const
311
316
{
312
317
  return _omega.dimension();
313
318
}
314
 
template<class T>
 
319
template<class T, class M>
315
320
inline
316
 
typename form_element_rep<T>::size_type
317
 
form_element_rep<T>::n_derivative() const
 
321
typename form_element_rep<T,M>::size_type
 
322
form_element_rep<T,M>::n_derivative() const
318
323
{
319
324
  return _n_derivative;
320
325
}
321
 
template<class T>
 
326
template<class T, class M>
322
327
inline
323
328
void
324
 
form_element_rep<T>::set_n_derivative (size_type n)
 
329
form_element_rep<T,M>::set_n_derivative (size_type n)
325
330
{
326
331
  _n_derivative = n;
327
332
}
387
392
// ----------------------------------------------------------
388
393
 
389
394
//<form_element:
390
 
template <class T>
391
 
class form_element : public smart_pointer<form_element_rep<T> > {
 
395
template <class T, class M>
 
396
class form_element : public smart_pointer<form_element_rep<T,M> > {
392
397
public:
393
398
 
394
399
// typedefs:
395
400
 
396
 
    typedef form_element_rep<T>              data_type;
397
 
    typedef typename data_type::size_type    size_type;
398
 
    typedef typename data_type::vertex_type  vertex_type;
 
401
    typedef form_element_rep<T,M>      rep;
 
402
    typedef smart_pointer<rep>         base;
 
403
    typedef typename rep::size_type    size_type;
 
404
    typedef typename rep::vertex_type  vertex_type;
 
405
    typedef typename rep::element_type element_type;
 
406
    typedef typename rep::geo_type     geo_type;
399
407
 
400
408
// constructors:
401
409
 
402
410
    form_element ();
403
411
    form_element (
404
412
        std::string           name,
405
 
        const element<T>&     X,
406
 
        const element<T>&     Y,
407
 
        const geo_basic<T>&   omega);
 
413
        const element_type&   X,
 
414
        const element_type&   Y,
 
415
        const geo_type&       omega);
408
416
 
409
417
// accessors & modifier:
410
418
 
411
419
    void operator() (const geo_element& K, ublas::matrix<T>& m) const;
 
420
    virtual bool is_symmetric () const;
412
421
 
413
422
#ifdef TODO
414
423
    void set_weight (const field& wh) const;
420
429
// -----------------------------------------------------------
421
430
// inlined
422
431
// -----------------------------------------------------------
423
 
template <class T>
 
432
template <class T, class M>
424
433
inline
425
 
form_element<T>::form_element ()
426
 
 : smart_pointer<data_type> (data_type::make_ptr())
 
434
form_element<T,M>::form_element ()
 
435
 : base (rep::make_ptr())
427
436
{
428
437
}
429
 
template <class T>
 
438
template <class T, class M>
430
439
inline
431
 
form_element<T>::form_element (
 
440
form_element<T,M>::form_element (
432
441
        std::string           name,
433
 
        const element<T>&     X,
434
 
        const element<T>&     Y,
435
 
        const geo_basic<T>&   omega)
436
 
 : smart_pointer<data_type> (data_type::make_ptr(name,X,Y,omega))
 
442
        const element_type&   X,
 
443
        const element_type&   Y,
 
444
        const geo_type&       omega)
 
445
 : base (rep::make_ptr(name,X,Y,omega))
437
446
{
438
447
}
439
 
template <class T>
 
448
template <class T, class M>
440
449
inline
441
450
void
442
 
form_element<T>::operator() (const geo_element& K, ublas::matrix<T>& m) const
443
 
{
444
 
    smart_pointer<data_type>::data().operator() (K, m);
 
451
form_element<T,M>::operator() (const geo_element& K, ublas::matrix<T>& m) const
 
452
{
 
453
    base::data().operator() (K, m);
 
454
}
 
455
template <class T, class M>
 
456
inline
 
457
bool
 
458
form_element<T,M>::is_symmetric () const
 
459
{
 
460
    return base::data().is_symmetric();
445
461
}
446
462
 
447
463
}// namespace rheolef