00001
00002
00003
00004 #ifndef bemSpace_hh
00005 #define bemSpace_hh
00006
00007 #include <stack>
00008
00009 #include "toolbox/dynArray.hh"
00010 #include "toolbox/scannerConnectors.hh"
00011 #include "geometry/mesh.hh"
00012 #include "space/space.hh"
00013 #include "bem/element.hh"
00014
00015 namespace bem {
00016
00017
00018
00029 template <class F = concepts::Real>
00030 class Dirac3d : public concepts::Space<F> {
00032 uint dim_;
00034 uint nelm_;
00036 concepts::Joiner<concepts::Element<F>*, 1>* elm_;
00037
00043 void constructor_(concepts::Triangle3d* cell, uint lvl,
00044 concepts::DynArray<uint>& map);
00045
00046 protected:
00047 std::ostream& info(std::ostream& os) const;
00048
00049 public:
00055 Dirac3d(concepts::Mesh2& msh, uint lvl);
00056 virtual ~Dirac3d();
00057
00059 inline uint dim() const {return dim_;}
00061 inline uint nelm() const {return nelm_;}
00063 inline concepts::Scan<concepts::Element<F> >* scan() const;
00064 };
00065
00066 template <class F>
00067 inline std::ostream& Dirac3d<F>::info(std::ostream& os) const {
00068 os << "Dirac3d(dim = " << dim_ << ", nelm = " << nelm_ << ')';
00069 return os;
00070 }
00071
00072 template <class F>
00073 inline concepts::Scan<concepts::Element<F> >* Dirac3d<F>::scan() const {
00074 return new concepts::PListScan<concepts::Element<F> >(*elm_);
00075 }
00076
00077
00078
00089 template <class F = concepts::Real>
00090 class Linear3d : public concepts::Space<F> {
00092 uint dim_;
00094 uint nelm_;
00096 concepts::Joiner<concepts::Element<F>*, 1>* elm_;
00097
00103 void constructor_(concepts::Triangle3d* cell, uint lvl,
00104 concepts::DynArray<uint>& map);
00105
00106 protected:
00107 std::ostream& info(std::ostream& os) const {return info(os, 0);}
00108
00109 public:
00115 Linear3d(concepts::Mesh2& msh, uint lvl);
00116 virtual ~Linear3d();
00117
00119 inline uint dim() const {return dim_;}
00121 inline uint nelm() const {return nelm_;}
00123 inline concepts::Scan<concepts::Element<F> >* scan() const;
00132 std::ostream& info(std::ostream& os, uint mode = 0) const;
00133 };
00134
00135 template <class F>
00136 inline concepts::Scan<concepts::Element<F> >* Linear3d<F>::scan() const {
00137 return new concepts::PListScan<concepts::Element<F> >(*elm_);
00138 }
00139
00140
00141
00152 template <class F = concepts::Real>
00153 class Constant3d : public concepts::Space<F> {
00155 uint dim_;
00157 uint nelm_;
00159 uint elmType_;
00161 concepts::Joiner<concepts::Element<F>*, 1>* elm_;
00162
00167 void constructor_(concepts::Triangle3d* cell, uint lvl);
00168
00169 protected:
00170 std::ostream& info(std::ostream& os) const;
00171
00172 public:
00181 Constant3d(concepts::Mesh2& msh, uint lvl, uint elmType = 0);
00182 virtual ~Constant3d();
00183
00185 uint dim() const {return dim_;}
00187 uint nelm() const {return nelm_;}
00189 inline concepts::Scan<concepts::Element<F> >* scan() const;
00190 };
00191
00192 template <class F>
00193 inline concepts::Scan<concepts::Element<F> >* Constant3d<F>::scan() const {
00194 return new concepts::PListScan<concepts::Element<F> >(*elm_);
00195 }
00196
00197 template <class F>
00198 inline std::ostream& Constant3d<F>::info(std::ostream& os) const {
00199 os << "Constant3d(dim = " << dim_ << ", nelm = " << nelm_ << ')';
00200 return os;
00201 }
00202
00203
00204
00210 struct AdaptiveAdjust {
00212 short l_;
00213
00215 AdaptiveAdjust() : l_(0) {}
00219 AdaptiveAdjust(short l) : l_(l) {}
00220
00222 AdaptiveAdjust& operator=(const AdaptiveAdjust& adj) {
00223 if (this != &adj) l_ = adj.l_;
00224 return *this;
00225 }
00226 };
00227
00228 std::ostream& operator<<(std::ostream& os, const AdaptiveAdjust& adj);
00229
00230
00231
00232 template<class F = concepts::Real>
00233 class AdaptiveSpace :
00234 public concepts::SpaceOnCells<F>,
00235 public concepts::AdaptiveSpace<F, AdaptiveAdjust> {
00236 protected:
00237 std::ostream& info(std::ostream& os) const {
00238 return os << "bem::AdaptiveSpace()";
00239 }
00240 };
00241
00242
00243
00249 template<class F = concepts::Real>
00250 class AdaptConst3d000 : public AdaptiveSpace<F> {
00252 uint dim_;
00254 uint nelm_;
00256 concepts::Joiner<concepts::ElementWithCell<F>*, 1>* elm_;
00257
00259 concepts::Mesh2& msh_;
00261 uint maxlvl_;
00263 uint minlvl_;
00265 concepts::DynArray<concepts::AdaptiveControl<> > ctrl_;
00267 concepts::DynArray<AdaptiveAdjust> adj_;
00269 bool rebuild_;
00270
00280 void rebuild0_(concepts::Connector2& cntr, int l, int& L);
00281 void rebuild1_(concepts::Triangle3d& cell, uint l);
00282
00283 protected:
00284 std::ostream& info(std::ostream& os) const {return info(os, 0);}
00285
00286 public:
00294 AdaptConst3d000(concepts::Mesh2& msh, uint lvl);
00295 ~AdaptConst3d000();
00296
00300 uint dim() const;
00301 uint dim();
00305 uint nelm() const;
00306 uint nelm();
00308 uint maxlevel();
00310 uint minlevel();
00314 concepts::Scan<concepts::ElementWithCell<F> >* scan() const;
00315 concepts::Scan<concepts::ElementWithCell<F> >* scan();
00317 short l(Constant3d001<F>& elm) {
00318 AdaptiveAdjust& adj(adj_[elm.support().key()]);
00319 return adj.l_;
00320 }
00327 void adjust(const concepts::Element<F>& elm,const AdaptiveAdjust& a);
00328 void adjust(const Constant3d001<F>& elm, const AdaptiveAdjust& a);
00338 void rebuild();
00346 std::ostream& info(std::ostream& os, uint mode = 0) const;
00347 };
00348
00349 template<class F>
00350 inline uint AdaptConst3d000<F>::dim() const {
00351 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00352 return dim_;
00353 }
00354
00355 template<class F>
00356 inline uint AdaptConst3d000<F>::dim() {
00357 if (rebuild_) rebuild();
00358 return dim_;
00359 }
00360
00361 template<class F>
00362 inline uint AdaptConst3d000<F>::nelm() const {
00363 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00364 return nelm_;
00365 }
00366
00367 template<class F>
00368 inline uint AdaptConst3d000<F>::nelm() {
00369 if (rebuild_) rebuild();
00370 return nelm_;
00371 }
00372
00373 template<class F>
00374 inline uint AdaptConst3d000<F>::maxlevel() {
00375 if (rebuild_) rebuild();
00376 return maxlvl_;
00377 }
00378
00379 template<class F>
00380 inline uint AdaptConst3d000<F>::minlevel() {
00381 if (rebuild_) rebuild();
00382 return minlvl_;
00383 }
00384
00385 template<class F>
00386 inline concepts::Scan<concepts::ElementWithCell<F> >*
00387 AdaptConst3d000<F>::scan() const {
00388 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00389 return new concepts::PListScan<concepts::ElementWithCell<F> >(*elm_);
00390 }
00391
00392 template<class F>
00393 inline concepts::Scan<concepts::ElementWithCell<F> >*
00394 AdaptConst3d000<F>::scan() {
00395 if (rebuild_) rebuild();
00396 return new concepts::PListScan<concepts::ElementWithCell<F> >(*elm_);
00397 }
00398
00399
00400
00403 class EdgeMap {
00404 friend std::ostream& operator<<(std::ostream& os, const EdgeMap& emp);
00405 public:
00406 inline EdgeMap() : pnl1(0), pnl2(0), lvl(0), prnt(0), tag(0) {};
00407 std::ostream& info(std::ostream& os) const;
00408
00410 concepts::Connector2* pnl1;
00412 concepts::Connector2* pnl2;
00414 ushort lvl;
00416 EdgeMap* prnt;
00423 concepts::uchar tag;
00424 };
00425
00426
00427
00434 template<class F = concepts::Real>
00435 class AdaptConst3d001 : public AdaptiveSpace<F> {
00437 uint dim_;
00439 uint nelm_;
00441 concepts::Joiner<concepts::ElementWithCell<F>*, 1>* elm_;
00442
00444 concepts::Mesh2& msh_;
00446 uint maxlvl_;
00448 uint minlvl_;
00450 concepts::DynArray<concepts::AdaptiveControl<> > ctrl_;
00452 concepts::DynArray<AdaptiveAdjust> adj_;
00454 bool rebuild_;
00458 ushort deltal_;
00460 concepts::DynArray<EdgeMap> edgmap_;
00464 std::stack<EdgeMap*> stk_;
00465
00477 void rebuild0_(concepts::Connector2& cntr, int l, int& L);
00478 void rebuild1_(concepts::Connector2& cntr);
00479 void rebuild2_();
00480 void rebuild3_(concepts::Triangle3d& cell, uint l);
00481
00482 protected:
00483 std::ostream& info(std::ostream& os) const {return info(os, 0);}
00484
00485 public:
00494 AdaptConst3d001(concepts::Mesh2& msh, uint lvl, ushort deltal);
00495 ~AdaptConst3d001();
00496
00500 uint dim() const;
00501 uint dim();
00505 uint nelm() const;
00506 uint nelm();
00508 uint maxlevel();
00510 uint minlevel();
00514 concepts::Scan<concepts::ElementWithCell<F> >* scan() const;
00515 concepts::Scan<concepts::ElementWithCell<F> >* scan();
00517 short l(Constant3d001<F>& elm) {
00518 AdaptiveAdjust& adj(adj_[elm.support().key()]);
00519 return adj.l_;
00520 }
00527 void adjust(const concepts::Element<F>& elm, const AdaptiveAdjust& a);
00528 void adjust(const Constant3d001<F>& elm, const AdaptiveAdjust& a);
00538 void rebuild();
00546 std::ostream& info(std::ostream& os, uint mode = 0) const;
00547 };
00548
00549 template<class F>
00550 inline uint AdaptConst3d001<F>::dim() const {
00551 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00552 return dim_;
00553 }
00554
00555 template<class F>
00556 inline uint AdaptConst3d001<F>::dim() {
00557 if (rebuild_) rebuild();
00558 return dim_;
00559 }
00560
00561 template<class F>
00562 inline uint AdaptConst3d001<F>::nelm() const {
00563 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00564 return nelm_;
00565 }
00566
00567 template<class F>
00568 inline uint AdaptConst3d001<F>::nelm() {
00569 if (rebuild_) rebuild();
00570 return nelm_;
00571 }
00572
00573 template<class F>
00574 inline uint AdaptConst3d001<F>::maxlevel() {
00575 if (rebuild_) rebuild();
00576 return maxlvl_;
00577 }
00578
00579 template<class F>
00580 inline uint AdaptConst3d001<F>::minlevel() {
00581 if (rebuild_) rebuild();
00582 return minlvl_;
00583 }
00584
00585 template<class F>
00586 inline concepts::Scan<concepts::ElementWithCell<F> >*
00587 AdaptConst3d001<F>::scan() const {
00588 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00589 return new concepts::PListScan<concepts::ElementWithCell<F> >(*elm_);
00590 }
00591
00592 template<class F>
00593 inline concepts::Scan<concepts::ElementWithCell<F> >*
00594 AdaptConst3d001<F>::scan() {
00595 if (rebuild_) rebuild();
00596 return new concepts::PListScan<concepts::ElementWithCell<F> >(*elm_);
00597 }
00598
00599
00600
00609 template<class F = concepts::Real>
00610 class AdaptConst3d002 : public AdaptiveSpace<F> {
00612 uint dim_;
00614 uint nelm_;
00616 concepts::Joiner<concepts::ElementWithCell<F>*, 1>* elm_;
00617
00619 concepts::Mesh2& msh_;
00621 uint maxlvl_;
00623 uint minlvl_;
00625 concepts::DynArray<concepts::AdaptiveControl<> > ctrl_;
00627 concepts::DynArray<AdaptiveAdjust> adj_;
00629 bool rebuild_;
00633 ushort deltal_;
00635 ushort deltaL_;
00637 concepts::DynArray<EdgeMap> edgmap_;
00641 std::stack<EdgeMap*> stk_;
00642
00654 void rebuild0_(concepts::Connector2& cntr, int l, int& L);
00655 void rebuild1_(concepts::Connector2& cntr, uint l);
00656 void rebuild2_();
00657 void rebuild3_(concepts::Triangle3d& cell, uint l, ushort tag);
00658
00659 protected:
00660 std::ostream& info(std::ostream& os) const {return info(os, 0);}
00661
00662 public:
00672 AdaptConst3d002(concepts::Mesh2& msh, uint lvl, ushort deltal,
00673 ushort deltaL);
00674 ~AdaptConst3d002();
00675
00679 uint dim() const;
00680 uint dim();
00684 uint nelm() const;
00685 uint nelm();
00687 uint maxlevel();
00689 uint minlevel();
00693 concepts::Scan<concepts::ElementWithCell<F> >* scan() const;
00694 concepts::Scan<concepts::ElementWithCell<F> >* scan();
00696 short l(Constant3d001<F>& elm) {
00697 AdaptiveAdjust& adj(adj_[elm.support().key()]);
00698 return adj.l_;
00699 }
00706 void adjust(const concepts::Element<F>& elm, const AdaptiveAdjust& a);
00707 void adjust(const Constant3d001<F>& elm, const AdaptiveAdjust& a);
00717 void rebuild();
00725 std::ostream& info(std::ostream& os, uint mode = 0) const;
00726 };
00727
00728 template<class F>
00729 inline uint AdaptConst3d002<F>::dim() const {
00730 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00731 return dim_;
00732 }
00733
00734 template<class F>
00735 inline uint AdaptConst3d002<F>::dim() {
00736 if (rebuild_) rebuild();
00737 return dim_;
00738 }
00739
00740 template<class F>
00741 inline uint AdaptConst3d002<F>::nelm() const {
00742 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00743 return nelm_;
00744 }
00745
00746 template<class F>
00747 inline uint AdaptConst3d002<F>::nelm() {
00748 if (rebuild_) rebuild();
00749 return nelm_;
00750 }
00751
00752 template<class F>
00753 inline uint AdaptConst3d002<F>::maxlevel() {
00754 if (rebuild_) rebuild();
00755 return maxlvl_;
00756 }
00757
00758 template<class F>
00759 inline uint AdaptConst3d002<F>::minlevel() {
00760 if (rebuild_) rebuild();
00761 return minlvl_;
00762 }
00763
00764 template<class F>
00765 inline concepts::Scan<concepts::ElementWithCell<F> >*
00766 AdaptConst3d002<F>::scan() const {
00767 if (rebuild_) conceptsException(concepts::SpaceNotBuilt());
00768 return new concepts::PListScan<concepts::ElementWithCell<F> >(*elm_);
00769 }
00770
00771 template<class F>
00772 inline concepts::Scan<concepts::ElementWithCell<F> >*
00773 AdaptConst3d002<F>::scan() {
00774 if (rebuild_) rebuild();
00775 return new concepts::PListScan<concepts::ElementWithCell<F> >(*elm_);
00776 }
00777
00778 }
00779
00780 #endif // bemSpace_hh