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

« back to all changes in this revision

Viewing changes to nfem/plib/space.h

  • Committer: Package Import Robot
  • Author(s): Pierre Saramito
  • Date: 2012-04-06 09:12:21 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120406091221-m58me99p1nxqui49
Tags: 6.0-1
* New upstream release 6.0 (major changes):
  - massively distributed and parallel support
  - full FEM characteristic method (Lagrange-Gakerkin method) support
  - enhanced users documentation 
  - source code supports g++-4.7 (closes: #667356)
* debian/control: dependencies for MPI distributed solvers added
* debian/rules: build commands simplified
* debian/librheolef-dev.install: man1/* to man9/* added
* debian/changelog: package description rewritted (closes: #661689)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "rheolef/geo.h"
25
25
#include "rheolef/geo_domain.h"
26
 
#include "rheolef/element.h"
 
26
#include "rheolef/numbering.h"
 
27
#include "rheolef/space_constitution.h"
27
28
 
28
29
namespace rheolef {
29
30
 
30
 
// =====================================================================
31
 
// space_act = a domain + an act (block, unblock)
32
 
// =====================================================================
33
 
 
34
 
template <class M>
35
 
class space_act {
36
 
public:
37
 
 
38
 
// typedefs:
39
 
 
40
 
    enum act_type {
41
 
        block = 0,
42
 
        unblock = 1
43
 
    };
44
 
 
45
 
// allocators:
46
 
 
47
 
    space_act() : _dom(), _act() {}
48
 
    space_act(const domain_indirect_basic<M>& dom, act_type act)
49
 
        : _dom(dom), _act(act) {}
50
 
    space_act(const space_act<M>& sp)
51
 
        : _dom(sp._dom), _act(sp._act) {}
52
 
 
53
 
// accessors:
54
 
 
55
 
    const domain_indirect_basic<M>& get_domain_indirect() const { return _dom; }
56
 
    act_type                    get_act()         const { return _act; }
57
 
    
58
 
// data:
59
 
protected:
60
 
    domain_indirect_basic<M> _dom;
61
 
    act_type                 _act;
62
 
};
63
 
// =====================================================================
64
 
// space_constitution = a table of acts
65
 
// =====================================================================
66
 
 
67
 
template <class T, class M>
68
 
class space_constitution_rep : public std::vector<space_act<M> > {
69
 
public:
70
 
    typedef std::vector<space_act<M> >     base;
71
 
    typedef typename  base::size_type      size_type;
72
 
    typedef typename  base::const_iterator const_iterator;
73
 
 
74
 
// allocators:
75
 
 
76
 
    space_constitution_rep()
77
 
      : base(), _omega(), _element() {}
78
 
    space_constitution_rep(const geo_basic<T,M>& omega, std::string approx)
79
 
      : base(), _omega(compact(omega)), _element(approx) {}
80
 
    space_constitution_rep (const space_constitution_rep<T,M>& scr)
81
 
      : base(scr), _omega(scr._omega), _element(scr._element)
82
 
    {
83
 
        error_macro ("physical copy of space_constitution_rep: size="<< base::size());
84
 
    }
85
 
 
86
 
// accessors:
87
 
 
88
 
    const geo_basic<T,M>& get_geo() const { return _omega; }
89
 
    const element<T>& get_element() const { return _element; }
90
 
 
91
 
    size_type      size()  const { return base::size(); }
92
 
    const_iterator begin() const { return base::begin(); }
93
 
    const_iterator end()   const { return base::end(); }
94
 
 
95
 
// modifiers
96
 
 
97
 
    void set_geo (const geo_basic<T,M>& omega)  { _omega = omega; }
98
 
    void set_element (const element<T>& elt)    { _element = elt; }
99
 
 
100
 
    void block  (const domain_indirect_basic<M>& dom) {
101
 
        base::push_back (space_act<M> (dom, space_act<M>::block));
102
 
    }
103
 
    void unblock(const domain_indirect_basic<M>& dom) {
104
 
        base::push_back (space_act<M> (dom, space_act<M>::unblock));
105
 
    }
106
 
 
107
 
// comparator:
108
 
 
109
 
    bool operator== (const space_constitution_rep<T,M>& V2) const { return _omega == V2._omega && _element == V2._element; }
110
 
 
111
 
// data:
112
 
protected:
113
 
    geo_basic<T,M>                   _omega;
114
 
    element<T>                       _element;
115
 
};
116
 
template <class T, class M>
117
 
class space_constitution : public smart_pointer<space_constitution_rep<T,M> > {
118
 
public:
119
 
 
120
 
    typedef space_constitution_rep<T,M>   rep;
121
 
    typedef smart_pointer<rep>            base;
122
 
    typedef typename  rep::size_type      size_type;
123
 
    typedef typename  rep::const_iterator const_iterator;
124
 
 
125
 
// allocators:
126
 
 
127
 
    space_constitution()
128
 
     : smart_pointer<rep>(new_macro(rep)) {}
129
 
 
130
 
    space_constitution(const geo_basic<T,M>& omega, std::string approx)
131
 
     : smart_pointer<rep>(new_macro(rep (omega,approx))) {}
132
 
 
133
 
// accessors:
134
 
 
135
 
    const geo_basic<T,M>& get_geo() const { return base::data().get_geo(); }
136
 
    const element<T>& get_element() const { return base::data().get_element(); }
137
 
 
138
 
    size_type      size()  const { return base::data().size(); }
139
 
    const_iterator begin() const { return base::data().begin(); }
140
 
    const_iterator end()   const { return base::data().end(); }
141
 
 
142
 
// comparator:
143
 
 
144
 
    bool operator== (const space_constitution<T,M>& V2) const { return base::data().operator==(V2.data()); }
145
 
 
146
 
// modifiers
147
 
 
148
 
    void set_geo (const geo_basic<T,M>& omega) { base::data().set_geo (omega); }
149
 
    void set_element (const element<T>& elt)   { base::data().set_element (elt); }
150
 
 
151
 
    void block  (const domain_indirect_basic<M>& dom) {
152
 
        base::data().block(dom);
153
 
    }
154
 
    void unblock(const domain_indirect_basic<M>& dom) { base::data().unblock(dom); }
155
 
};
 
31
// forward declarations:
 
32
template <class T, class M> class field_basic;
 
33
template <class T, class M> class space_mult_list;
 
34
template <class T, class M> class space_component;
 
35
template <class T, class M> class space_component_const;
 
36
 
156
37
// =====================================================================
157
38
// a dof = a degree-of-freedom 
158
39
//       = space_pair
193
74
 
194
75
namespace rheolef {
195
76
 
196
 
// forward declaration:
197
 
template <class T, class M> class field_basic;
198
 
 
199
77
// =====================================================================
200
78
// 1) representation: space_base_rep and space_rep
201
79
// =====================================================================
205
83
 
206
84
// typedefs:
207
85
 
208
 
    typedef typename space_pair_type::size_type size_type;
 
86
    typedef typename space_pair_type::size_type  size_type;
 
87
    typedef typename space_constant::valued_type valued_type;
209
88
 
210
89
// allocators:
211
90
 
212
91
    space_base_rep ();
213
 
    space_base_rep (const geo_basic<T,M>& omega, std::string approx);
 
92
    space_base_rep (const space_constitution<T,M>& constit);
 
93
    space_base_rep (const geo_basic<T,M>& omega, std::string approx, std::string valued);
 
94
    space_base_rep (const space_mult_list<T,M>&);
214
95
 
215
96
// accessors:
216
97
 
217
98
    const distributor&  ownership() const { return _idof2blk_iub.ownership(); }
218
 
    size_type                size() const { return ownership().size(); }
219
 
    size_type            dis_size() const { return ownership().dis_size(); }
 
99
    size_type                ndof() const { return ownership().size(); }
 
100
    size_type            dis_ndof() const { return ownership().dis_size(); }
220
101
    const communicator&      comm() const { return ownership().comm(); }
221
102
 
222
 
    const geo_basic<T,M>& get_geo() const { return _constit.get_geo(); }
223
 
    const element<T>& get_element() const { return _constit.get_element(); }
 
103
    const space_constitution<T,M>& get_constitution() const { return _constit; }
 
104
    const geo_basic<T,M>& get_geo()       const { return _constit.get_geo(); }
 
105
    const numbering<T,M>& get_numbering() const { return _constit.get_numbering(); }
 
106
    valued_type           valued_tag()   const { return _constit.valued_tag(); }
 
107
    const std::string&    valued()       const { return _constit.valued(); }
 
108
    size_type             size()   const { return _constit.size(); }
 
109
    space_component<T,M>       operator[] (size_type i_comp);
 
110
    space_component_const<T,M> operator[] (size_type i_comp) const;
224
111
 
225
 
    std::string get_stamp() const; /// e.g. "P1(square)", for field_expr<Expr> checks
 
112
    std::string stamp() const; /// e.g. "P1(square)", for field_expr<Expr> checks
226
113
 
227
114
    void block  (const domain_indirect_basic<M>& dom) { no_freeze_guard(); _constit.block  (dom); }
228
 
    void unblock(const domain_indirect_basic<M>& dom) {no_freeze_guard(); _constit.unblock(dom);}
 
115
    void unblock(const domain_indirect_basic<M>& dom) { no_freeze_guard(); _constit.unblock(dom);}
229
116
 
230
117
    bool                 is_blocked (size_type     idof) const { freeze_guard(); return _idof2blk_iub [idof].is_blocked(); }
231
118
    size_type                   iub (size_type     idof) const { freeze_guard(); return _idof2blk_iub [idof].iub(); }
 
119
    const point_basic<T>& xdof (size_type idof) const { return _xdof [idof]; }
 
120
    const array<point_basic<T>,M >& get_xdofs() const { return _xdof; }
232
121
 
233
122
    const distributor& iu_ownership() const { freeze_guard(); return _iu_ownership; }
234
123
    const distributor& ib_ownership() const { freeze_guard(); return _ib_ownership; }
235
124
 
236
 
    void get_dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const;
237
 
 
238
 
    template <class Function>
239
 
    T momentum (Function f, size_type idof) const;
 
125
    void dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const;
 
126
 
 
127
    template <class Function>
 
128
    T momentum (Function f, size_type idof) const { return f (xdof(idof)); }
 
129
 
 
130
    template <class Function>
 
131
    point_basic<T> vector_momentum (Function f, size_type idof) const { return f (xdof(idof)); }
240
132
 
241
133
    array<size_type, M> build_indirect_array (
242
 
        const domain_indirect_basic<M>& indirect) const;
 
134
        const space_base_rep<T,M>& Wh, const std::string& dom_name) const;
243
135
 
244
136
// comparator:
245
137
 
252
144
protected:
253
145
    template <class T1, class M1> friend class field_basic;
254
146
// internal:
 
147
    void init_xdof();
255
148
    void freeze_guard() const {
256
 
        if (_is_freezed) return;
257
 
        _is_freezed = true;
 
149
        if (_have_freezed) return;
 
150
        _have_freezed = true;
258
151
        freeze_body();
259
152
    }
260
153
    void no_freeze_guard() const {
261
 
        check_macro (!_is_freezed, "freezed space cannot accept new (un)blocked domains");
 
154
        check_macro (!_have_freezed, "freezed space cannot accept new (un)blocked domains");
262
155
    }
263
156
    void base_freeze_body() const;
264
157
    virtual void freeze_body() const { return base_freeze_body(); }
265
 
// data:
266
 
    space_constitution<T,M>          _constit;
267
 
    mutable bool                     _is_freezed;
268
 
    mutable array<space_pair_type,M> _idof2blk_iub;  // pair (is_blocked ; iu_or_ib); use ownership
269
 
    mutable distributor              _iu_ownership;  // unknown values distribution
270
 
    mutable distributor              _ib_ownership;  // blocked values distribution
 
158
// data: lazy initialization (on demand only), thus most are mutable
 
159
    space_constitution<T,M>   _constit;
 
160
    array<point_basic<T>,M >               _xdof;          // nodal approx only
 
161
    mutable bool                           _have_freezed;
 
162
    mutable array<space_pair_type,M>       _idof2blk_iub;  // pair (is_blocked ; iu_or_ib); use ownership
 
163
    mutable distributor                    _iu_ownership;  // unknown values distribution
 
164
    mutable distributor                    _ib_ownership;  // blocked values distribution
271
165
};
272
166
// ---------------------------------------------------------------------
273
 
// momentum/interpolation implementation
274
 
// ---------------------------------------------------------------------
275
 
template <class T, class M>
276
 
template <class Function>
277
 
/* TODO: typename function_traits<Function>::result_type */
278
 
inline
279
 
T
280
 
space_base_rep<T,M>::momentum (
281
 
    Function  f,
282
 
    size_type idof) const
283
 
{
284
 
#ifdef TO_CLEAN
285
 
    // P1 Lagrange only ; TODO: extend
286
 
    const basic_point<T>& x = get_geo().vertex (idof);
287
 
    return f(x);
288
 
#endif // TO_CLEAN
289
 
    basic_point<T> x = get_element().x_dof (idof, get_geo());
290
 
    return f(x);
291
 
}
292
 
// ---------------------------------------------------------------------
293
167
template <class T, class M> class space_rep {};
294
168
 
295
169
template <class T>
303
177
 
304
178
// allocators:
305
179
 
306
 
    space_rep (const geo_basic<T,sequential>& omega = (geo_basic<T,sequential>()), std::string approx = "");
 
180
    space_rep (const space_constitution<T,sequential>& constit);
 
181
    space_rep (const geo_basic<T,sequential>& omega, std::string approx, std::string valued);
 
182
    space_rep (const space_mult_list<T,sequential>&);
307
183
 
308
184
// compatibility with the distributed interface:
309
185
 
313
189
    const distributor& ios_ownership() const { return base::ownership(); }
314
190
    size_type     idof2ios_dis_idof (size_type     idof) const { return idof; }
315
191
    size_type     ios_idof2dis_idof (size_type ios_idof) const { return ios_idof; }
 
192
 
 
193
    // for compatibility with the distributed case:
 
194
    const std::set<size_type>& ext_iu_set() const;
 
195
    const std::set<size_type>& ext_ib_set() const;
316
196
};
317
197
// ---------------------------------------------------------------------
318
198
#ifdef _RHEOLEF_HAVE_MPI
327
207
 
328
208
// allocators:
329
209
 
330
 
    space_rep (const geo_basic<T,distributed>& omega = (geo_basic<T,distributed>()), std::string approx = "");
 
210
    space_rep (const space_constitution<T,distributed>& constit);
 
211
    space_rep (const geo_basic<T,distributed>& omega, std::string approx, std::string valued);
 
212
    space_rep (const space_mult_list<T,distributed>&);
331
213
 
332
214
// accessors:
333
215
 
342
224
#ifdef TO_CLEAN
343
225
    void get_ios_dis_idof (const geo_element& K, std::vector<size_type>& ios_dis_idof) const;
344
226
#endif // TO_CLEAN
 
227
    const std::set<size_type>& ext_iu_set() const { return _ext_iu_set; }
 
228
    const std::set<size_type>& ext_ib_set() const { return _ext_ib_set; }
345
229
 
346
230
protected:
347
231
    template <class T1, class M1> friend class field_basic;
353
237
    void freeze_body() const;
354
238
    void append_external_dof (const geo_basic<T,distributed>& dom, std::set<size_type>& ext_dof_set) const;
355
239
// data:
356
 
    array<size_type>               _idof2ios_dis_idof;   // permut to/from ios dof numbering (before geo part), for i/o
357
 
    array<size_type>               _ios_idof2dis_idof;
 
240
    array<size_type,distributed>   _idof2ios_dis_idof;   // permut to/from ios dof numbering (before geo part), for i/o
 
241
    array<size_type,distributed>   _ios_idof2dis_idof;
358
242
// mutable data, affected by freeze_*()const:
359
 
    mutable map_pair_type          _ext_dis_idof2blk_dis_iub; // same for partition bdry dofs
 
243
    mutable std::set<size_type>    _ext_iu_set;    // external dofs used by field::dis_dof
 
244
    mutable std::set<size_type>    _ext_ib_set;
360
245
};
361
246
#endif // _RHEOLEF_HAVE_MPI
362
247
// ====================================================================
370
255
The @code{space} class contains some numbering 
371
256
for unknowns and blocked degrees of freedoms
372
257
related to a given mesh and polynomial approximation.
 
258
SYNOPSIS:
 
259
@example
 
260
    space Q (omega, "P1");
 
261
    space V (omega, "P2", "vector");
 
262
    space T (omega, "P1d", "tensor");
 
263
@end example
 
264
PRODUCT:
 
265
@example
 
266
    space X = T*V*Q;
 
267
    space Q2 = pow(Q,2);
 
268
@end example
373
269
SEE ALSO: "geo"(3)
374
270
AUTHORS: Pierre.Saramito@imag.fr
375
271
DATE:   14 december 2010
389
285
 
390
286
// typedefs:
391
287
 
392
 
    typedef space_rep<T,sequential> rep;
393
 
    typedef smart_pointer<rep>      base;
394
 
    typedef typename rep::size_type size_type;
 
288
    typedef space_rep<T,sequential>   rep;
 
289
    typedef smart_pointer<rep>        base;
 
290
    typedef typename rep::size_type   size_type;
 
291
    typedef typename rep::valued_type valued_type;
395
292
 
396
293
// allocators:
397
294
 
398
 
    space_basic (const geo_basic<T,sequential>& omega = (geo_basic<T,sequential>()), std::string approx = "");
 
295
    space_basic (const geo_basic<T,sequential>& omega = (geo_basic<T,sequential>()),
 
296
                  std::string approx = "", std::string valued = "scalar");
 
297
    space_basic (const space_mult_list<T,sequential>& expr);
 
298
    space_basic (const space_constitution<T,sequential>& constit);
399
299
 
400
300
// accessors:
401
301
 
406
306
 
407
307
    const distributor&  ownership() const;
408
308
    const communicator& comm() const;
409
 
    size_type           size() const;
410
 
    size_type           dis_size() const;
 
309
    size_type           ndof() const;
 
310
    size_type           dis_ndof() const;
411
311
 
412
312
    const geo_basic<T,sequential>& get_geo() const;
413
 
    const element<T>&   get_element() const;
414
 
    std::string get_stamp() const;
 
313
    const numbering<T,sequential>& get_numbering() const;
 
314
    size_type size() const;
 
315
    valued_type           valued_tag()   const;
 
316
    const std::string&    valued()       const;
 
317
    space_component<T,sequential>       operator[] (size_type i_comp);
 
318
    space_component_const<T,sequential> operator[] (size_type i_comp) const;
 
319
    const space_constitution<T,sequential>& get_constitution() const;
 
320
    size_type degree() const;
 
321
    std::string get_approx() const;
 
322
    std::string stamp() const;
415
323
 
416
 
    void get_dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const;
 
324
    void dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const;
417
325
 
418
326
    const distributor& iu_ownership() const;
419
327
    const distributor& ib_ownership() const;
427
335
    size_type idof2ios_dis_idof (size_type idof) const;
428
336
    size_type ios_idof2dis_idof (size_type ios_idof) const;
429
337
 
 
338
    const point_basic<T>& xdof (size_type idof) const;
 
339
    const array<point_basic<T>,sequential>& get_xdofs() const;
 
340
 
430
341
    template <class Function>
431
342
    T momentum (Function f, size_type idof) const;
432
343
 
433
 
    array<size_type, sequential>
434
 
    build_indirect_array (const geo_basic<T,sequential>& dom) const;
 
344
    template <class Function>
 
345
    point_basic<T> vector_momentum (Function f, size_type idof) const;
 
346
 
 
347
    array<size_type, sequential> build_indirect_array (
 
348
        const space_basic<T,sequential>& Wh, const std::string& dom_name) const;
 
349
 
 
350
    const std::set<size_type>& ext_iu_set() const { return base::data().ext_iu_set(); }
 
351
    const std::set<size_type>& ext_ib_set() const { return base::data().ext_ib_set(); }
435
352
 
436
353
// comparator:
437
354
 
443
360
//>verbatim:
444
361
template<class T>
445
362
inline
446
 
space_basic<T,sequential>::space_basic (const geo_basic<T,sequential>& omega, std::string approx)
447
 
 : base (new_macro(rep(omega, approx)))
 
363
space_basic<T,sequential>::space_basic (
 
364
    const space_constitution<T,sequential>& constit)
 
365
 : base (new_macro(rep(constit)))
 
366
{
 
367
}
 
368
template<class T>
 
369
inline
 
370
space_basic<T,sequential>::space_basic (
 
371
    const geo_basic<T,sequential>& omega,
 
372
    std::string approx,
 
373
    std::string valued)
 
374
 : base (new_macro(rep(omega, approx, valued)))
 
375
{
 
376
}
 
377
template<class T>
 
378
inline
 
379
space_basic<T,sequential>::space_basic (const space_mult_list<T,sequential>& expr)
 
380
 : base (new_macro(rep(expr)))
448
381
{
449
382
}
450
383
template<class T>
471
404
template<class T>
472
405
inline
473
406
typename space_basic<T,sequential>::size_type
474
 
space_basic<T,sequential>::size() const
 
407
space_basic<T,sequential>::ndof() const
475
408
{
476
 
    return base::data().size();
 
409
    return base::data().ndof();
477
410
}
478
411
template<class T>
479
412
inline
480
413
typename space_basic<T,sequential>::size_type
481
 
space_basic<T,sequential>::dis_size() const
 
414
space_basic<T,sequential>::dis_ndof() const
482
415
{
483
 
    return base::data().dis_size();
 
416
    return base::data().dis_ndof();
484
417
}
485
418
template<class T>
486
419
inline
491
424
}
492
425
template<class T>
493
426
inline
494
 
const element<T>&
495
 
space_basic<T,sequential>::get_element() const
496
 
{
497
 
    return base::data().get_element();
498
 
}
499
 
template<class T>
500
 
inline
501
 
std::string
502
 
space_basic<T,sequential>::get_stamp() const
503
 
{
504
 
    return base::data().get_stamp();
 
427
const numbering<T,sequential>&
 
428
space_basic<T,sequential>::get_numbering() const
 
429
{
 
430
    return base::data().get_numbering();
 
431
}
 
432
template<class T>
 
433
inline
 
434
const space_constitution<T,sequential>&
 
435
space_basic<T,sequential>::get_constitution() const
 
436
{
 
437
    return base::data().get_constitution();
 
438
}
 
439
template<class T>
 
440
inline
 
441
typename space_basic<T,sequential>::size_type
 
442
space_basic<T,sequential>::size() const
 
443
{
 
444
    return base::data().size();
 
445
}
 
446
template<class T>
 
447
inline
 
448
const std::string&
 
449
space_basic<T,sequential>::valued() const
 
450
{
 
451
    return base::data().valued();
 
452
}
 
453
template<class T>
 
454
inline
 
455
typename space_basic<T,sequential>::valued_type
 
456
space_basic<T,sequential>::valued_tag() const
 
457
{
 
458
    return base::data().valued_tag();
 
459
}
 
460
template<class T>
 
461
inline
 
462
space_component<T,sequential>
 
463
space_basic<T,sequential>::operator[] (size_type i_comp)
 
464
{
 
465
    return base::data().operator[] (i_comp);
 
466
}
 
467
template<class T>
 
468
inline
 
469
space_component_const<T,sequential>
 
470
space_basic<T,sequential>::operator[] (size_type i_comp) const
 
471
{
 
472
    return base::data().operator[] (i_comp);
 
473
}
 
474
template<class T>
 
475
inline
 
476
typename space_basic<T,sequential>::size_type
 
477
space_basic<T,sequential>::degree() const
 
478
{
 
479
    return get_numbering().degree();
 
480
}
 
481
template<class T>
 
482
inline
 
483
std::string
 
484
space_basic<T,sequential>::get_approx() const
 
485
{
 
486
    return get_numbering().name();
 
487
}
 
488
template<class T>
 
489
inline
 
490
std::string
 
491
space_basic<T,sequential>::stamp() const
 
492
{
 
493
    return base::data().stamp();
505
494
}
506
495
template<class T>
507
496
inline
508
497
void
509
 
space_basic<T,sequential>::get_dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const
 
498
space_basic<T,sequential>::dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const
510
499
{
511
 
    return base::data().get_dis_idof (K, dis_idof);
 
500
    return base::data().dis_idof (K, dis_idof);
512
501
}
513
502
template<class T>
514
503
inline
595
584
    return base::data().unblock (dom);
596
585
}
597
586
template<class T>
 
587
inline
 
588
const point_basic<T>&
 
589
space_basic<T,sequential>::xdof (size_type idof) const
 
590
{
 
591
    return base::data().xdof (idof);
 
592
}
 
593
template<class T>
 
594
inline
 
595
const array<point_basic<T>,sequential>&
 
596
space_basic<T,sequential>::get_xdofs() const
 
597
{
 
598
    return base::data().get_xdofs();
 
599
}
 
600
template<class T>
598
601
template <class Function>
599
602
inline
600
603
T
602
605
{
603
606
    return base::data().momentum (f, idof);
604
607
}
 
608
template<class T>
 
609
template <class Function>
 
610
inline
 
611
point_basic<T>
 
612
space_basic<T,sequential>::vector_momentum (Function f, size_type idof) const
 
613
{
 
614
    return base::data().vector_momentum (f, idof);
 
615
}
605
616
// ---------------------------------------------------------------------
606
617
#ifdef _RHEOLEF_HAVE_MPI
607
618
//<verbatim:
611
622
 
612
623
// typedefs:
613
624
 
614
 
    typedef space_rep<T,distributed> rep;
615
 
    typedef smart_pointer<rep>       base;
616
 
    typedef typename rep::size_type  size_type;
 
625
    typedef space_rep<T,distributed>  rep;
 
626
    typedef smart_pointer<rep>        base;
 
627
    typedef typename rep::size_type   size_type;
 
628
    typedef typename rep::valued_type valued_type;
617
629
 
618
630
// allocators:
619
631
 
620
 
    space_basic (const geo_basic<T,distributed>& omega = (geo_basic<T,distributed>()), std::string approx = "");
 
632
    space_basic (const geo_basic<T,distributed>& omega = (geo_basic<T,distributed>()),
 
633
                  std::string approx = "", std::string valued = "scalar");
 
634
    space_basic (const space_mult_list<T,distributed>&);
 
635
    space_basic (const space_constitution<T,distributed>& constit);
621
636
 
622
637
// accessors:
623
638
 
628
643
 
629
644
    const distributor&  ownership() const;
630
645
    const communicator& comm() const;
631
 
    size_type           size() const;
632
 
    size_type           dis_size() const;
 
646
    size_type           ndof() const;
 
647
    size_type           dis_ndof() const;
633
648
 
634
649
    const geo_basic<T,distributed>& get_geo() const;
635
 
    const element<T>&   get_element() const;
636
 
    std::string get_stamp() const;
 
650
    const numbering<T,distributed>& get_numbering() const;
 
651
    size_type size() const;
 
652
    valued_type           valued_tag()   const;
 
653
    const std::string&    valued()       const;
 
654
    space_component<T,distributed>       operator[] (size_type i_comp);
 
655
    space_component_const<T,distributed> operator[] (size_type i_comp) const;
 
656
    const space_constitution<T,distributed>& get_constitution() const;
 
657
    size_type degree() const;
 
658
    std::string get_approx() const;
 
659
    std::string stamp() const;
637
660
 
638
 
    void get_dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const;
 
661
    void dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const;
639
662
 
640
663
    const distributor& iu_ownership() const;
641
664
    const distributor& ib_ownership() const;
650
673
    size_type idof2ios_dis_idof (size_type idof) const;
651
674
    size_type ios_idof2dis_idof (size_type ios_idof) const;
652
675
 
 
676
    const point_basic<T>& xdof (size_type idof) const;
 
677
    const array<point_basic<T>,distributed>& get_xdofs() const;
 
678
 
653
679
    template <class Function>
654
680
    T momentum (Function f, size_type idof) const;
655
681
 
656
 
    array<size_type, distributed>
657
 
    build_indirect_array (const geo_basic<T,distributed>& dom) const;
 
682
    template <class Function>
 
683
    point_basic<T> vector_momentum (Function f, size_type idof) const;
 
684
 
 
685
    array<size_type, distributed> build_indirect_array (
 
686
        const space_basic<T,distributed>& Wh, const std::string& dom_name) const;
 
687
 
 
688
    const std::set<size_type>& ext_iu_set() const { return base::data().ext_iu_set(); }
 
689
    const std::set<size_type>& ext_ib_set() const { return base::data().ext_ib_set(); }
658
690
 
659
691
// comparator:
660
692
 
667
699
 
668
700
template<class T>
669
701
inline
670
 
space_basic<T,distributed>::space_basic (const geo_basic<T,distributed>& omega, std::string approx)
671
 
 : base (new_macro(rep(omega, approx)))
 
702
space_basic<T,distributed>::space_basic (
 
703
    const space_constitution<T,distributed>& constit)
 
704
 : base (new_macro(rep(constit)))
 
705
{
 
706
}
 
707
template<class T>
 
708
inline
 
709
space_basic<T,distributed>::space_basic (
 
710
    const geo_basic<T,distributed>& omega,
 
711
    std::string approx,
 
712
    std::string valued)
 
713
 : base (new_macro(rep(omega, approx, valued)))
 
714
{
 
715
}
 
716
template<class T>
 
717
inline
 
718
space_basic<T,distributed>::space_basic (const space_mult_list<T,distributed>& expr)
 
719
 : base (new_macro(rep(expr)))
672
720
{
673
721
}
674
722
template<class T>
695
743
template<class T>
696
744
inline
697
745
typename space_basic<T,distributed>::size_type
698
 
space_basic<T,distributed>::size() const
 
746
space_basic<T,distributed>::ndof() const
699
747
{
700
 
    return base::data().size();
 
748
    return base::data().ndof();
701
749
}
702
750
template<class T>
703
751
inline
704
752
typename space_basic<T,distributed>::size_type
705
 
space_basic<T,distributed>::dis_size() const
 
753
space_basic<T,distributed>::dis_ndof() const
706
754
{
707
 
    return base::data().dis_size();
 
755
    return base::data().dis_ndof();
708
756
}
709
757
template<class T>
710
758
inline
715
763
}
716
764
template<class T>
717
765
inline
718
 
const element<T>&
719
 
space_basic<T,distributed>::get_element() const
720
 
{
721
 
    return base::data().get_element();
722
 
}
723
 
template<class T>
724
 
inline
725
 
std::string
726
 
space_basic<T,distributed>::get_stamp() const
727
 
{
728
 
    return base::data().get_stamp();
 
766
const numbering<T,distributed>&
 
767
space_basic<T,distributed>::get_numbering() const
 
768
{
 
769
    return base::data().get_numbering();
 
770
}
 
771
template<class T>
 
772
inline
 
773
const space_constitution<T,distributed>&
 
774
space_basic<T,distributed>::get_constitution() const
 
775
{
 
776
    return base::data().get_constitution();
 
777
}
 
778
template<class T>
 
779
inline
 
780
typename space_basic<T,distributed>::size_type
 
781
space_basic<T,distributed>::size() const
 
782
{
 
783
    return base::data().size();
 
784
}
 
785
template<class T>
 
786
inline
 
787
const std::string&
 
788
space_basic<T,distributed>::valued() const
 
789
{
 
790
    return base::data().valued();
 
791
}
 
792
template<class T>
 
793
inline
 
794
typename space_basic<T,distributed>::valued_type
 
795
space_basic<T,distributed>::valued_tag() const
 
796
{
 
797
    return base::data().valued_tag();
 
798
}
 
799
template<class T>
 
800
inline
 
801
space_component<T,distributed>
 
802
space_basic<T,distributed>::operator[] (size_type i_comp)
 
803
{
 
804
    return base::data().operator[] (i_comp);
 
805
}
 
806
template<class T>
 
807
inline
 
808
space_component_const<T,distributed>
 
809
space_basic<T,distributed>::operator[] (size_type i_comp) const
 
810
{
 
811
    return base::data().operator[] (i_comp);
 
812
}
 
813
template<class T>
 
814
inline
 
815
typename space_basic<T,distributed>::size_type
 
816
space_basic<T,distributed>::degree() const
 
817
{
 
818
    return get_numbering().degree();
 
819
}
 
820
template<class T>
 
821
inline
 
822
std::string
 
823
space_basic<T,distributed>::get_approx() const
 
824
{
 
825
    return get_numbering().name();
 
826
}
 
827
template<class T>
 
828
inline
 
829
std::string
 
830
space_basic<T,distributed>::stamp() const
 
831
{
 
832
    return base::data().stamp();
729
833
}
730
834
template<class T>
731
835
inline
732
836
void
733
 
space_basic<T,distributed>::get_dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const
 
837
space_basic<T,distributed>::dis_idof (const geo_element& K, std::vector<size_type>& dis_idof) const
734
838
{
735
 
    return base::data().get_dis_idof (K, dis_idof);
 
839
    return base::data().dis_idof (K, dis_idof);
736
840
}
737
841
template<class T>
738
842
inline
819
923
    base::data().unblock (dom);
820
924
}
821
925
template<class T>
 
926
inline
 
927
const point_basic<T>&
 
928
space_basic<T,distributed>::xdof (size_type idof) const
 
929
{
 
930
    return base::data().xdof (idof);
 
931
}
 
932
template<class T>
 
933
inline
 
934
const array<point_basic<T>,distributed>&
 
935
space_basic<T,distributed>::get_xdofs() const
 
936
{
 
937
    return base::data().get_xdofs();
 
938
}
 
939
template<class T>
822
940
template <class Function>
823
941
inline
824
942
T
826
944
{
827
945
    return base::data().momentum (f, idof);
828
946
}
 
947
template<class T>
 
948
template <class Function>
 
949
inline
 
950
point_basic<T>
 
951
space_basic<T,distributed>::vector_momentum (Function f, size_type idof) const
 
952
{
 
953
    return base::data().vector_momentum (f, idof);
 
954
}
829
955
#endif // _RHEOLEF_HAVE_MPI
830
956
 
831
957
// only valid when M=sequential or M=distributed => use a macro
833
959
template<class T>                                                                       \
834
960
inline                                                                                  \
835
961
array<typename space_basic<T,M>::size_type, M>                                          \
836
 
space_basic<T,M>::build_indirect_array (const geo_basic<T,M>& dom) const                \
 
962
space_basic<T,M>::build_indirect_array (                                                \
 
963
        const space_basic<T,M>& Wh,                                                     \
 
964
        const std::string& dom_name) const                                              \
837
965
{                                                                                       \
838
 
    if (dom.data().variant() == geo_abstract_base_rep<T>::geo_domain_indirect) {        \
839
 
      const geo_domain_indirect_rep<T,M>& dom_rep                                       \
840
 
       = dynamic_cast<const geo_domain_indirect_rep<T,M>&>(dom.data());                 \
841
 
      return base::data().build_indirect_array (dom_rep.get_indirect());                \
842
 
    }                                                                                   \
843
 
    error_macro ("build_indirect_array: unsupported non domain_indirect geo variant");  \
844
 
    return array<size_type, M>(); /* not  reached */                                    \
 
966
    return base::data().build_indirect_array (Wh.data(), dom_name);                     \
845
967
}
846
968
_RHEOLEF_space_build_indirect_array(sequential)
847
969