27 public Scan<Connector> {
36 public Scan<Connector> {
45 public Scan<Connector> {
72 inline ListElm(T* elm, ListElm<T>* lnk = 0) : lnk_(lnk), elm_(elm) {};
74 inline ListElm<T>** linkp() {
return &lnk_;};
75 inline ListElm<T>* link()
const {
return lnk_;};
76 inline T* elm()
const {
return elm_;}
81 template<
class ListNode>
87 inline ListHead(ListNode* root = 0) : root_(root) {};
90 {ListNode* foo = root_; root_ = root_->link();
delete foo;}
93 inline ListNode** rootp() {
return &root_;};
94 inline ListNode* root()
const {
return root_;};
97 typedef ListElm<Connector0> Cntr0LstEl;
98 typedef ListElm<Connector1> Cntr1LstEl;
99 typedef ListElm<Connector2> Cntr2LstEl;
100 typedef ListElm<Cell1> Cell1LstEl;
101 typedef ListElm<Cell2> Cell2LstEl;
102 typedef ListElm<Cell3> Cell3LstEl;
104 typedef ListHead<Cntr0LstEl> Cntr0Lst;
105 typedef ListHead<Cntr1LstEl> Cntr1Lst;
106 typedef ListHead<Cntr2LstEl> Cntr2Lst;
107 typedef ListHead<Cell1LstEl> Cell1Lst;
108 typedef ListHead<Cell2LstEl> Cell2Lst;
109 typedef ListHead<Cell3LstEl> Cell3Lst;
124 const Communicator& com_;
126 Mesh(
const Communicator& com) : com_(com) {};
129 inline const Communicator& comm()
const {
return com_;};
132 virtual uint nglobcell()
const = 0;
135 virtual uint nloccell()
const = 0;
141 virtual Scan<Cell>* globscan() = 0;
147 virtual Scan<Cell>* locscan() = 0;
150 virtual std::ostream&
info(std::ostream& os)
const;
158 class Mesh1 :
public Mesh {
161 class LocalS :
public Scan<Cell1> {
164 Array<unique_ptr<Cell1> > *cell_;
166 inline LocalS(uint n, Array<unique_ptr<Cell1> > *cell)
167 : n_(n), idx_(0), cell_(cell) {};
168 inline LocalS(
const LocalS& scan) : n_(scan.n_), idx_(scan.idx_),
169 cell_(scan.cell_) {};
170 inline bool eos()
const {
return idx_ == n_;};
171 inline Cell1&
operator++(
int) {
return *((*cell_)[idx_++]);};
176 class GlobalS :
public Scan<Cell1> {
179 Array<unique_ptr<Cell1> > *cell_;
181 inline GlobalS(uint n, Array<unique_ptr<Cell1> > *cell)
182 : n_(n), idx_(0), cell_(cell) {
185 inline GlobalS(
const GlobalS& scan) {
188 inline bool eos()
const {
return 1;};
189 inline Cell1&
operator++(
int) {
return *((*cell_)[idx_++]);};
195 class CapS :
public Scan<T> {
199 inline CapS(ListElm<T>* cntr) : cntr_(cntr) {};
200 inline CapS(
const CapS<T>& scan) : cntr_(scan.cntr_) {};
201 inline bool eos()
const {
return (!cntr_);};
203 ListElm<T>* foo = cntr_; cntr_ = cntr_->link();
204 return *(foo->elm());};
205 inline Scan<T>*
clone()
const {
return new CapS(*
this);};
214 Array<unique_ptr<Connector0> >* cntr0_;
218 Array<unique_ptr<Connector1> >* cntr1_;
220 Array<unique_ptr<Cell1> >* cell_;
223 Array<unique_ptr<concepts::Map1d> >* map_;
227 Array<Cntr0Lst>* cap0_;
229 Array<Cell1Lst>* cap1_;
250 inline Mesh1(Array<unique_ptr<Connector0> >* cntr0,
251 Array<unique_ptr<Connector1> >* cntr1,
252 Array<unique_ptr<Cell1> >* cell, uint ngcell,
253 Array<unique_ptr<concepts::Map1d> >* map,
254 Array<Cntr0Lst>* cap0, Array<Cell1Lst>* cap1,
255 const Communicator& com);
259 inline uint nglobcell()
const {
return ngcell_;};
261 inline uint nloccell()
const {
return nlcell_;};
264 inline concepts::Scan1* globscan() {
return new GlobalS(nlcell_, cell_);};
267 inline concepts::Scan1* locscan() {
return new LocalS(nlcell_, cell_);};
273 return new CapS<Connector0>((*cap0_)[i].root());
279 return new CapS<Cell1>((*cap1_)[i].root());
283 std::ostream&
info(std::ostream& os)
const;
287 Mesh1::Mesh1(Array<unique_ptr<Connector0> >* cntr0,
288 Array<unique_ptr<Connector1> >* cntr1,
289 Array<unique_ptr<Cell1> >* cell, uint ngcell,
290 Array<unique_ptr<concepts::Map1d> >* map,
291 Array<Cntr0Lst>* cap0, Array<Cell1Lst>* cap1,
292 const Communicator& com)
293 : Mesh(com), ngcell_(ngcell), nlcell_(cell->cursize()), cntr0_(cntr0),
294 ncntr0_(cntr0->cursize()), cntr1_(cntr1), cell_(cell), map_(map),
295 nmap_(map ? map->cursize() : 0), cap0_(cap0), cap1_(cap1) {
301 delete cell_;
delete map_;
302 delete cntr1_;
delete cntr0_;
310 class Mesh2 :
public Mesh {
313 class LocalS :
public Scan<Cell2> {
316 Array<unique_ptr<Cell2> > *cell_;
318 inline LocalS(uint n, Array<unique_ptr<Cell2> > *cell)
319 : n_(n), idx_(0), cell_(cell) {};
320 inline LocalS(
const LocalS& scan) : n_(scan.n_), idx_(scan.idx_),
321 cell_(scan.cell_) {};
322 inline bool eos()
const {
return idx_ == n_;};
323 inline Cell2& operator++(
int) {
return *((*cell_)[idx_++]);};
328 class GlobalS :
public Scan<Cell2> {
331 Array<unique_ptr<Cell2> > *cell_;
333 inline GlobalS(uint n, Array<unique_ptr<Cell2> > *cell)
334 : n_(n), idx_(0), cell_(cell) {
337 inline GlobalS(
const GlobalS& scan) {
340 inline bool eos()
const {
return 1;};
341 inline Cell2& operator++(
int) {
return *((*cell_)[idx_++]);};
347 class CapS :
public Scan<T> {
351 inline CapS(ListElm<T>* cntr) : cntr_(cntr) {};
352 inline CapS(
const CapS<T>& scan) : cntr_(scan.cntr_) {};
353 inline bool eos()
const {
return (!cntr_);};
354 inline T& operator++(
int) {
355 ListElm<T>* foo = cntr_; cntr_ = cntr_->link();
356 return *(foo->elm());};
357 inline Scan<T>* clone()
const {
return new CapS(*
this);};
367 Array<unique_ptr<Connector0> >* cntr0_;
370 Array<unique_ptr<Connector1> >* cntr1_;
374 Array<unique_ptr<Connector2> >* cntr2_;
376 Array<unique_ptr<Cell2> >* cell_;
379 Array<unique_ptr<concepts::Map2d> >* map_;
383 Array<Cntr0Lst>* cap0_;
385 Array<Cntr1Lst>* cap1_;
387 Array<Cell2Lst>* cap2_;
414 inline Mesh2(Array<unique_ptr<Connector0> >* cntr0,
415 Array<unique_ptr<Connector1> >* cntr1,
416 Array<unique_ptr<Connector2> >* cntr2,
417 Array<unique_ptr<Cell2> >* cell, uint ngcell,
418 Array<unique_ptr<concepts::Map2d> >* map,
419 Array<Cntr0Lst>* cap0, Array<Cntr1Lst>* cap1,
420 Array<Cell2Lst>* cap2,
const Communicator& com);
424 inline uint nglobcell()
const {
return ngcell_;};
426 inline uint nloccell()
const {
return nlcell_;};
429 inline concepts::Scan2* globscan() {
return new GlobalS(nlcell_, cell_);};
432 inline concepts::Scan2* locscan() {
return new LocalS(nlcell_, cell_);};
438 return new CapS<Connector0>((*cap0_)[i].root());
444 return new CapS<Connector1>((*cap1_)[i].root());
450 return new CapS<Cell2>((*cap2_)[i].root());
454 std::ostream& info(std::ostream& os)
const;
458 Mesh2::Mesh2(Array<unique_ptr<Connector0> >* cntr0,
459 Array<unique_ptr<Connector1> >* cntr1,
460 Array<unique_ptr<Connector2> >* cntr2,
461 Array<unique_ptr<Cell2> >* cell, uint ngcell,
462 Array<unique_ptr<concepts::Map2d> >* map,
463 Array<Cntr0Lst>* cap0, Array<Cntr1Lst>* cap1,
464 Array<Cell2Lst>* cap2,
const Communicator& com)
465 : Mesh(com), ngcell_(ngcell), nlcell_(cell->cursize()), cntr0_(cntr0),
466 ncntr0_(cntr0->cursize()), cntr1_(cntr1), ncntr1_(cntr1->cursize()),
467 cntr2_(cntr2), cell_(cell), map_(map), nmap_(map ? map->cursize() : 0),
468 cap0_(cap0), cap1_(cap1), cap2_(cap2) {
472 delete cap2_;
delete cap1_;
delete cap0_;
473 delete cell_;
delete map_;
474 delete cntr2_;
delete cntr1_;
delete cntr0_;
482 class Mesh3 :
public Mesh {
488 Array<unique_ptr<Cell3> > *cell_;
490 inline LocalS(uint n, Array<unique_ptr<Cell3> > *cell)
491 : n_(n), idx_(0), cell_(cell) {};
492 inline LocalS(
const LocalS& scan) : n_(scan.n_), idx_(scan.idx_),
493 cell_(scan.cell_) {};
494 inline bool eos()
const {
return idx_ == n_;};
495 inline Cell3& operator++(
int) {
return *((*cell_)[idx_++]);};
503 Array<unique_ptr<Cell3> > *cell_;
505 inline GlobalS(uint n, Array<unique_ptr<Cell3> > *cell)
506 : n_(n), idx_(0), cell_(cell) {
509 inline GlobalS(
const GlobalS& scan) {
512 inline bool eos()
const {
return 1;};
513 inline Cell3& operator++(
int) {
return *((*cell_)[idx_++]);};
519 class CapS :
public Scan<T> {
523 inline CapS(ListElm<T>* cntr) : cntr_(cntr) {};
524 inline CapS(
const CapS<T>& scan) : cntr_(scan.cntr_) {};
525 inline bool eos()
const {
return (!cntr_);};
526 inline T& operator++(
int) {
527 ListElm<T>* foo = cntr_; cntr_ = cntr_->link();
528 return *(foo->elm());};
538 Array<unique_ptr<Connector0> >* cntr0_;
541 Array<unique_ptr<Connector1> >* cntr1_;
544 Array<unique_ptr<Connector2> >* cntr2_;
548 Array<unique_ptr<Connector3> >* cntr3_;
550 Array<unique_ptr<Cell3> >* cell_;
553 Array<unique_ptr<concepts::Map3d> >* map_;
557 Array<Cntr0Lst>* cap0_;
559 Array<Cntr1Lst>* cap1_;
561 Array<Cntr2Lst>* cap2_;
563 Array<Cell3Lst>* cap3_;
596 inline Mesh3(Array<unique_ptr<Connector0> >* cntr0,
597 Array<unique_ptr<Connector1> >* cntr1,
598 Array<unique_ptr<Connector2> >* cntr2,
599 Array<unique_ptr<Connector3> >* cntr3,
600 Array<unique_ptr<Cell3> >* cell, uint ngcell,
601 Array<unique_ptr<concepts::Map3d> >* map,
602 Array<Cntr0Lst>* cap0, Array<Cntr1Lst>* cap1,
603 Array<Cntr2Lst>* cap2, Array<Cell3Lst>* cap3_,
604 const Communicator& com);
608 inline uint nglobcell()
const {
return ngcell_;};
610 inline uint nloccell()
const {
return nlcell_;};
613 inline concepts::Scan3* globscan() {
return new GlobalS(nlcell_, cell_);};
616 inline concepts::Scan3* locscan() {
return new LocalS(nlcell_, cell_);};
622 return new CapS<Connector0>((*cap0_)[i].root());
628 return new CapS<Connector1>((*cap1_)[i].root());
634 return new CapS<Connector2>((*cap2_)[i].root());
640 return new CapS<Cell3>((*cap3_)[i].root());
644 std::ostream& info(std::ostream& os)
const;
648 Mesh3::Mesh3(Array<unique_ptr<Connector0> >* cntr0,
649 Array<unique_ptr<Connector1> >* cntr1,
650 Array<unique_ptr<Connector2> >* cntr2,
651 Array<unique_ptr<Connector3> >* cntr3,
652 Array<unique_ptr<Cell3> >* cell, uint ngcell,
653 Array<unique_ptr<concepts::Map3d> >* map,
654 Array<Cntr0Lst>* cap0, Array<Cntr1Lst>* cap1,
655 Array<Cntr2Lst>* cap2, Array<Cell3Lst>* cap3,
656 const Communicator& com)
657 : Mesh(com), ngcell_(ngcell), nlcell_(cell->cursize()), cntr0_(cntr0),
658 ncntr0_(cntr0->cursize()), cntr1_(cntr1), ncntr1_(cntr1->cursize()),
659 cntr2_(cntr2), ncntr2_(cntr2->cursize()), cntr3_(cntr3), cell_(cell),
660 map_(map), nmap_(map ? map->cursize() : 0), cap0_(cap0), cap1_(cap1),
661 cap2_(cap2), cap3_(cap3) {
665 delete cap3_;
delete cap2_;
delete cap1_;
delete cap0_;
666 delete cell_;
delete map_;
667 delete cntr3_;
delete cntr2_;
delete cntr1_;
delete cntr0_;