Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
domain_indirect.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_DOMAIN_INDIRECT_H
2#define _RHEOLEF_DOMAIN_INDIRECT_H
23
24/*Class:domain_indirect
25NAME: @code{domain_indirect} - a named part of a finite element mesh
26@cindex mesh boundary
27@clindex domain_indirect
28DESCRIPTION:
29 @noindent
30 The @code{domain_indirect} class defines a container for a part of a
31 finite element mesh.
32 This describes the connectivity of edges or faces.
33 This class is useful for boundary condition setting.
34IMPLEMENTATION NOTE:
35 The @code{domain} class is split into two parts.
36 The first one is the @code{domain_indirect} class, that contains the main
37 renumbering features: it acts as a indirect on a @code{geo} class(@pxref{geo class}).
38 The second one is the @code{domain} class, that simply contains two
39 smart_pointers: one on a @code{domain_indirect} and the second on the
40 @code{geo} where renumbering is acting.
41 Thus, the domain class develops a complete @code{geo}-like interface,
42 via the @code{geo_abstract_rep} pure virtual class derivation,
43 and can be used by the @code{space} class (@pxref{space class}).
44 The split between domain_indirect and domain is necessary,
45 because the @code{geo} class contains a list of domain_indirect.
46 It cannot contains a list of @code{domain} classes, that refers
47 to the geo class itself: a loop in reference counting
48 leads to a blocking situation in the automatic deallocation.
49
50DATE: 12 may 1997
51End:
52*/
53
54#include "rheolef/disarray.h"
55#include "rheolef/geo_element.h"
56#include "rheolef/geo_element_indirect.h"
57#include "rheolef/index_set.h"
58
59namespace rheolef {
60
61// foward declarations:
62template <class U, class M> class geo_abstract_rep;
63template <class U, class M> class geo_rep;
64template <class U, class M> class geo_basic;
65
66// ==================================================================================
67// 1) domain_indirect
68// representation: domain_indirect_base_rep<M> and domain_indirect_rep<M>
69// ==================================================================================
70template <class M>
71class domain_indirect_base_rep : public disarray<geo_element_indirect,M> {
72public:
73
74// typedefs:
75
81
82// allocators:
83
85 void resize (size_type n) { base::resize (n); }
86
87 // build from a table of element indexes
88 domain_indirect_base_rep (const std::string& name, size_type map_dim,
89 const communicator& comm,
90 const std::vector<size_type>& ie_list);
91 void build_from_list (const std::string& name, size_type map_dim,
92 const communicator& comm,
93 const std::vector<size_type>& ie_list);
94
95 // c := a union b with c=*this
96 void build_union (
99
100// accessors & modifiers:
101
102 size_type size() const { return base::size(); }
103 size_type dis_size() const { return base::dis_size(); }
104
105 const_iterator_ioige ioige_begin() const { return base::begin(); }
106 const_iterator_ioige ioige_end() const { return base::end(); }
107 iterator_ioige ioige_begin() { return base::begin(); }
108 iterator_ioige ioige_end() { return base::end(); }
109
110 const geo_element_indirect& oige (size_type ioige) const { return base::operator[] (ioige); }
111
112 std::string name () const { return _name; }
113 size_type map_dimension () const { return _map_dim; }
114 void set_name (std::string name) { _name = name; }
115 void set_map_dimension (size_type map_dim) { _map_dim = map_dim; }
116 bool is_broken() const { return _is_broken; }
117 void set_broken(bool b) { _is_broken = b; }
118protected:
119// data:
120 std::string _name;
122 bool _is_broken; // for e.g. "sides" or "internal_sides"
123};
124template <class M>
125inline
128 _name(),
129 _map_dim(0),
130 _is_broken(false)
131{
132}
133template<class M>
134inline
136 const std::string& name,
137 size_type map_dim,
138 const communicator& comm,
139 const std::vector<size_type>& ie_list)
141 _name(),
142 _map_dim(),
143 _is_broken(false)
144{
145 build_from_list (name, map_dim, comm, ie_list);
146}
147// ---------------------------------------------------------------------
148template <class M> class domain_indirect_rep {};
149
150template<>
152public:
153
154// typedefs:
155
161
162// allocators:
163
165
167 const std::string& name,
168 size_type map_dim,
169 const communicator& comm,
170 const std::vector<size_type>& ie_list)
171 : domain_indirect_base_rep<sequential>(name, map_dim, comm, ie_list) {}
172
173 void resize (size_type n) { base::resize (n); }
174
175 // c := a union b with c=*this
176 void build_union (
179
180// accessors:
181
182 size_type size() const { return base::size(); }
183 size_type dis_size() const { return base::dis_size(); }
184
185 const_iterator_ioige ioige_begin() const { return base::ioige_begin(); }
186 const_iterator_ioige ioige_end() const { return base::ioige_end(); }
187 iterator_ioige ioige_begin() { return base::ioige_begin(); }
188 iterator_ioige ioige_end() { return base::ioige_end(); }
189
190 const geo_element_indirect& oige (size_type ioige) const {
191 return base::oige (ioige); }
192
193 void set_name (std::string name) { base::set_name(name); }
194 void set_map_dimension (size_type map_dim) { base::set_map_dimension(map_dim); }
195 std::string name () const { return base::name(); }
196 size_type map_dimension () const { return base::map_dimension(); }
197 bool is_broken() const { return base::is_broken(); }
198 void set_broken(bool b) { base::set_broken(b); }
199
200// i/o:
201
202 template<class U>
203 void build_from_data (
204 const geo_rep<U,sequential>& omega,
206 d_tmp,
207 std::vector<index_set>* ball);
208
209 template <class U>
210 idiststream& get (
211 idiststream& ips,
212 const geo_rep<U,sequential>& omega,
213 std::vector<index_set>* ball);
214
215 odiststream& put (odiststream& ops) const;
216};
217// c := a union b with c=*this
218inline
219void
226// ---------------------------------------------------------------------
227#ifdef _RHEOLEF_HAVE_MPI
228template<>
230public:
231
232// typedefs:
233
239
240// allocators:
241
243
244 template<class T>
247 const std::string& name,
248 size_type map_dim,
249 const communicator& comm,
250 const std::vector<size_type>& ie_list);
251
252 template<class T>
253 void init_ios (const geo_abstract_rep<T,distributed>& omega);
254
255 // c := a union b with c=*this
256 template<class T>
257 void build_union (
258 const geo_basic<T,distributed>& omega,
261
262// accessors & modifiers:
263
264 size_type size() const { return base::size(); }
265 size_type dis_size() const { return base::dis_size(); }
266
267 const geo_element_indirect& oige (size_type ioige) const {
268 return base::oige (ioige); }
269
270 void set_name (std::string name) { base::set_name(name); }
271 void set_map_dimension (size_type map_dim) { base::set_map_dimension(map_dim); }
272 std::string name () const { return base::name(); }
273 size_type map_dimension () const { return base::map_dimension(); }
274 bool is_broken() const { return base::is_broken(); }
275 void set_broken(bool b) { base::set_broken(b); }
276
277// distributed specific acessors:
278
279 const distributor& ini_ownership () const { return _ini_ioige2dis_ioige.ownership(); }
280 size_type ioige2ini_dis_ioige (size_type ioige) const { return _ioige2ini_dis_ioige [ioige]; }
281 size_type ini_ioige2dis_ioige (size_type ini_ioige) const { return _ini_ioige2dis_ioige [ini_ioige]; }
282
283// i/o:
284
285 template <class U>
286 idiststream& get (idiststream& ips, const geo_rep<U,distributed>& omega);
287 template <class U>
288 odiststream& put (odiststream& ops, const geo_rep<U,distributed>& omega) const;
289
290protected:
291 template <class U1,class M1> friend class geo_rep; // for geo_rep::build_from_domain
292// data:
295};
296inline
299 _ioige2ini_dis_ioige(),
300 _ini_ioige2dis_ioige()
301{
302}
303template<class T>
304inline
307 const std::string& name,
308 size_type map_dim,
309 const communicator& comm,
310 const std::vector<size_type>& ie_list)
311 : domain_indirect_base_rep<distributed>(name, map_dim, comm, ie_list),
312 _ioige2ini_dis_ioige(),
313 _ini_ioige2dis_ioige()
314{
315 init_ios (omega);
316}
317// c := a union b with c=*this
318template<class T>
319inline
320void
322 const geo_basic<T,distributed>& omega,
325{
326 base::build_union (a,b);
327 init_ios (omega.data());
328}
329#endif // _RHEOLEF_HAVE_MPI
330// ====================================================================
331// 2) wrapper: domain_indirect_basic<M>
332// ====================================================================
334template <class M = rheo_default_memory_model>
336public:
337};
338typedef domain_indirect_basic<rheo_default_memory_model> domain_indirect;
339// ---------------------------------------------------------------------
340//<verbatim:
341template <>
342class domain_indirect_basic<sequential> : public smart_pointer<domain_indirect_rep<sequential> > {
343public:
344
345// typedefs:
346
352
353// allocators:
354
356
357 template <class T>
360 const std::string& name,
361 size_type map_dim,
362 const communicator& comm,
363 const std::vector<size_type>& ie_list);
364
365 template <class T>
367 const geo_basic<T,sequential>& omega,
368 const std::string& name,
369 size_type map_dim,
370 const communicator& comm,
371 const std::vector<size_type>& ie_list);
372
373 template <class U>
376 d_tmp,
377 const geo_basic<U, sequential>& omega,
378 std::vector<index_set>* ball);
379
380 void resize (size_type n);
381
382// accessors:
383
384 size_type size() const;
385 size_type dis_size() const;
386 const distributor& ownership() const;
387
388 const_iterator_ioige ioige_begin() const;
389 const_iterator_ioige ioige_end() const;
390 iterator_ioige ioige_begin();
391 iterator_ioige ioige_end();
392
393 const geo_element_indirect& oige (size_type ioige) const;
394
395 void set_name (std::string name);
396 void set_map_dimension (size_type map_dim);
397 std::string name () const;
398 size_type map_dimension () const;
399 bool is_broken() const;
400 void set_broken(bool b);
401
402// i/o:
403
404 odiststream& put (odiststream&) const;
405 template <class T>
406 idiststream& get (idiststream& ips, const geo_rep<T,sequential>& omega, std::vector<index_set> *ball);
407};
408//>verbatim:
409inline
414template<class T>
415inline
417 const geo_basic<T,sequential>& omega,
418 const std::string& name,
419 size_type map_dim,
420 const communicator& comm,
421 const std::vector<size_type>& ie_list)
422 : smart_pointer<rep> (new_macro(rep(name, map_dim, comm, ie_list)))
423{
424}
425template<class T>
426inline
429 const std::string& name,
430 size_type map_dim,
431 const communicator& comm,
432 const std::vector<size_type>& ie_list)
433 : smart_pointer<rep> (new_macro(rep(name, map_dim, comm, ie_list)))
434{
435}
436inline
437void
439{
440 return base::data().resize (n);
441}
442inline
443domain_indirect_basic<sequential>::size_type
445{
446 return base::data().size();
447}
448inline
449domain_indirect_basic<sequential>::size_type
451{
452 return base::data().dis_size();
453}
454inline
455const distributor&
457{
458 return base::data().ownership();
459}
460inline
463{
464 return base::data().oige (ioige);
465}
466inline
467domain_indirect_basic<sequential>::const_iterator_ioige
469{
470 return base::data().ioige_begin();
471}
472inline
473domain_indirect_basic<sequential>::const_iterator_ioige
475{
476 return base::data().ioige_end();
477}
478inline
479domain_indirect_basic<sequential>::iterator_ioige
481{
482 return base::data().ioige_begin();
483}
484inline
485domain_indirect_basic<sequential>::iterator_ioige
487{
488 return base::data().ioige_end();
489}
490inline
491std::string
493{
494 return base::data().name();
495}
496inline
497domain_indirect_basic<sequential>::size_type
499{
500 return base::data().map_dimension();
501}
502inline
503bool
505{
506 return base::data().is_broken();
507}
508inline
509void
511{
512 base::data().set_broken(b);
513}
514inline
515void
517{
518 return base::data().set_name (name);
519}
520inline
521void
523{
524 return base::data().set_map_dimension (map_dim);
525}
526inline
529{
530 return base::data().put (ops);
531}
532template<class T>
533inline
536 idiststream& ips,
537 const geo_rep<T,sequential>& omega,
538 std::vector<index_set> *ball)
539{
540 return base::data().template get (ips, omega, ball);
541}
542// union:
543template<class T>
544inline
545domain_indirect_basic<sequential>
547 const geo_basic<T,sequential>& omega,
548 const domain_indirect_basic<sequential>& a,
549 const domain_indirect_basic<sequential>& b)
550{
551 domain_indirect_basic<sequential> c;
552 c.data().build_union (a.data(), b.data());
553 return c;
554}
555// ---------------------------------------------------------------------
556#ifdef _RHEOLEF_HAVE_MPI
557//<verbatim:
558template <>
559class domain_indirect_basic<distributed> : public smart_pointer<domain_indirect_rep<distributed> > {
560public:
561
562// typedefs:
563
569
570// allocators:
571
573 template<class T>
575 const geo_basic<T,distributed>& omega,
576 const std::string& name,
577 size_type map_dim,
578 const communicator& comm,
579 const std::vector<size_type>& ie_list);
580
581 template<class T>
584 const std::string& name,
585 size_type map_dim,
586 const communicator& comm,
587 const std::vector<size_type>& ie_list);
588
589// accessors/modifiers:
590
591 size_type size() const;
592 size_type dis_size() const;
593 const distributor& ownership() const;
594
595 const geo_element_indirect& oige (size_type ioige) const;
596
597 void set_name (std::string name);
598 void set_map_dimension (size_type map_dim);
599 std::string name () const;
600 size_type map_dimension () const;
601 bool is_broken() const;
602 void set_broken(bool b);
603
604// distributed specific acessors:
605
606 const_iterator_ioige ioige_begin() const;
607 const_iterator_ioige ioige_end() const;
608 iterator_ioige ioige_begin();
609 iterator_ioige ioige_end();
610
611 const distributor& ini_ownership() const;
612 size_type ioige2ini_dis_ioige (size_type ioige) const;
613 size_type ini_ioige2dis_ioige (size_type ini_ioige) const;
614
615// i/o:
616
617 template <class T>
618 idiststream& get (idiststream& ips, const geo_rep<T,distributed>& omega);
619 template <class T>
620 odiststream& put (odiststream& ops, const geo_rep<T,distributed>& omega) const;
621};
622//>verbatim:
623
624inline
629template<class T>
630inline
632 const geo_basic<T,distributed>& omega,
633 const std::string& name,
634 size_type map_dim,
635 const communicator& comm,
636 const std::vector<size_type>& ie_list)
637 : smart_pointer<rep> (new_macro(rep(omega.data(), name, map_dim, comm, ie_list)))
638{
639}
640template<class T>
641inline
644 const std::string& name,
645 size_type map_dim,
646 const communicator& comm,
647 const std::vector<size_type>& ie_list)
648 : smart_pointer<rep> (new_macro(rep(omega, name, map_dim, comm, ie_list)))
649{
650}
651inline
652domain_indirect_basic<distributed>::size_type
654{
655 return base::data().size();
656}
657inline
658domain_indirect_basic<distributed>::size_type
660{
661 return base::data().dis_size();
662}
663inline
664const distributor&
666{
667 return base::data().ownership();
668}
669template<class T>
670inline
673 idiststream& ips,
674 const geo_rep<T,distributed>& omega)
675{
676 return base::data().template get (ips, omega);
677}
678template<class T>
679inline
682 odiststream& ops,
683 const geo_rep<T,distributed>& omega) const
684{
685 return base::data().template put (ops, omega);
686}
687inline
688std::string
690{
691 return base::data().name();
692}
693inline
694domain_indirect_basic<distributed>::size_type
696{
697 return base::data().map_dimension();
698}
699inline
700void
702{
703 return base::data().set_name (name);
704}
705inline
706void
708{
709 return base::data().set_map_dimension (map_dim);
710}
711inline
712bool
714{
715 return base::data().is_broken();
716}
717inline
718void
720{
721 base::data().set_broken(b);
722}
723inline
726{
727 return base::data().oige (ioige);
728}
729inline
730domain_indirect_basic<distributed>::const_iterator_ioige
732{
733 return base::data().ioige_begin();
734}
735inline
736domain_indirect_basic<distributed>::const_iterator_ioige
738{
739 return base::data().ioige_end();
740}
741inline
742domain_indirect_basic<distributed>::iterator_ioige
744{
745 return base::data().ioige_begin();
746}
747inline
748domain_indirect_basic<distributed>::iterator_ioige
750{
751 return base::data().ioige_end();
752}
753inline
754const distributor&
756{
757 return base::data().ini_ownership();
758}
759inline
760domain_indirect_basic<distributed>::size_type
762{
763 return base::data().ioige2ini_dis_ioige (ioige);
764}
765inline
766domain_indirect_basic<distributed>::size_type
768{
769 return base::data().ini_ioige2dis_ioige (ini_ioige);
770}
771// union:
772template<class T>
773inline
774domain_indirect_basic<distributed>
776 const geo_basic<T,distributed>& omega,
777 const domain_indirect_basic<distributed>& a,
778 const domain_indirect_basic<distributed>& b)
779{
780 domain_indirect_basic<distributed> c;
781 c.data().build_union (omega, a.data(), b.data());
782 return c;
783}
784
785#endif // _RHEOLEF_HAVE_MPI
786
787} // namespace rheolef
788#endif // _RHEOLEF_DOMAIN_INDIRECT_H
see the disarray page for the full documentation
Definition disarray.h:497
rep::base::const_iterator const_iterator
Definition disarray.h:503
rep::base::size_type size_type
Definition disarray.h:501
see the distributor page for the full documentation
Definition distributor.h:69
void build_from_list(const std::string &name, size_type map_dim, const communicator &comm, const std::vector< size_type > &ie_list)
void build_union(const domain_indirect_base_rep< M > &a, const domain_indirect_base_rep< M > &b)
geo_element_indirect::orientation_type orientation_type
geo_element_indirect::size_type size_type
void set_map_dimension(size_type map_dim)
base::const_iterator const_iterator_ioige
const_iterator_ioige ioige_begin() const
domain_indirect_base_rep(const std::string &name, size_type map_dim, const communicator &comm, const std::vector< size_type > &ie_list)
const_iterator_ioige ioige_end() const
const geo_element_indirect & oige(size_type ioige) const
disarray< geo_element_indirect, M > base
domain_indirect_rep< distributed > rep
domain_indirect_rep< sequential > rep
the finite element boundary domain
size_type ioige2ini_dis_ioige(size_type ioige) const
disarray< size_type, distributed > _ioige2ini_dis_ioige
disarray< size_type, distributed > _ini_ioige2dis_ioige
size_type ini_ioige2dis_ioige(size_type ini_ioige) const
base::const_iterator_ioige const_iterator_ioige
domain_indirect_base_rep< distributed > base
const geo_element_indirect & oige(size_type ioige) const
domain_indirect_rep(const std::string &name, size_type map_dim, const communicator &comm, const std::vector< size_type > &ie_list)
domain_indirect_base_rep< sequential > base
base::const_iterator_ioige const_iterator_ioige
const_iterator_ioige ioige_begin() const
const geo_element_indirect & oige(size_type ioige) const
abstract interface class
Definition geo.h:401
generic mesh with rerefence counting
Definition geo.h:1089
sequential mesh representation
Definition geo.h:778
idiststream: see the diststream page for the full documentation
Definition diststream.h:336
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
see the smart_pointer page for the full documentation
domain_indirect_basic< rheo_default_memory_model > domain_indirect
This file is part of Rheolef.
void put(std::ostream &out, std::string name, const tiny_matrix< T > &a)
Definition tiny_lu.h:155
domain_indirect_basic< sequential > build_union(const geo_basic< T, sequential > &omega, const domain_indirect_basic< sequential > &a, const domain_indirect_basic< sequential > &b)
Expr1::memory_type M