Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

app-kersten/ThinSheet/thinSheetGeom.hh
Go to the documentation of this file.
00001 
00006 #ifndef thinsheetgeom_hh
00007 #define thinsheetgeom_hh
00008 
00009 #include "geometry.hh"
00010 #include "toolbox/array.hh"
00011 #include "boost/shared_ptr.hpp"
00012 
00013 namespace concepts {
00014 
00015   // ********************************************************** ThinMeshes2d **
00016 
00020   class ThinMeshes2d : public CellToCellMapping<2,2> {
00021   public:
00022     ThinMeshes2d(const Real d);
00023 
00025     virtual void thickness(const Real d) = 0;
00026     Mesh2* limitMesh() const { return limitMesh_.get(); }
00027     Mesh2* thinMesh()  const { return thinMesh_ .get(); }
00028     
00033     void addMesh(Mesh2* msh, bool holding = false);
00034 
00040     void connectOppositeEdges(const Edge2d* edge1, const Edge2d* edge2,
00041                               const Attribute attrib = Attribute(),
00042                               const Quad2dSubdivision* strategy = 0);
00043 
00044     virtual const Sequence<Edge2d*>& outerBoundary() const = 0;
00045     virtual const Sequence<Edge2d*>& innerBoundary() const = 0;
00046 
00051     void connectOuterMesh(const Sequence<Edge2d*>& innerBoundary,
00052                           Mesh2* msh = 0,
00053                           const Attribute attrib = Attribute());
00054     void connectInnerMesh(const Sequence<Edge2d*>& outerBoundary,
00055                           Mesh2* msh = 0,
00056                           const Attribute attrib = Attribute());
00057 
00058     // rebuilds the child -> parent mapping
00059     virtual void rebuild() = 0;
00060 
00061     void holdMe(const Mesh* msh) {
00062       if (msh) holdMeshes_.push_back(boost::shared_ptr<const Mesh>(msh));
00063     }
00064     void holdMe(const Connector* cntr) {
00065       if (cntr) holdCntr_.push_back(boost::shared_ptr<const Connector>(cntr));
00066     }
00067   protected:
00068     virtual std::ostream& info(std::ostream& os) const;
00069 
00070     // thickness of the sheet
00071     Real d_;
00072 
00073     // mesh of the asymptotic expansion
00074     std::auto_ptr<MutableMesh2> limitMesh_;
00075     // mesh with particular thickness
00076     std::auto_ptr<MutableMesh2> thinMesh_;
00077     // connecting meshes to the inner and outer
00078     std::auto_ptr<MutableMesh2> cMeshInn_, cMeshOut_;
00079 
00081     Sequence<boost::shared_ptr<const Mesh> > holdMeshes_;
00083     Sequence<boost::shared_ptr<const Connector> > holdCntr_;
00084   };
00085 
00086   // *************************************************** ThinEllipseMeshes2d **
00087 
00088   class ThinEllipseMeshes2d : public ThinMeshes2d {
00089   public:
00101     ThinEllipseMeshes2d(const Real a, const Real k, const uint n,
00102                         const Real D, const Real d = 0.0);
00103     virtual ~ThinEllipseMeshes2d();
00104 
00105     void thickness(const Real d);
00106 
00107     PointInCell<2> operator()(const PointInCell<2> P) const;
00108 
00109     inline const Sequence<Edge2d*>& outerBoundary() const {
00110       return outerMesh_->cells();
00111     }
00112     inline const Sequence<Edge2d*>& innerBoundary() const  {
00113       return innerMesh_->cells();
00114     }
00115 
00116     // rebuilds the child -> parent mapping
00117     virtual void rebuild() {
00118       conceptsAssert(thinRelat_.get(), Assertion());
00119       thinRelat_->rebuildCells();
00120     }
00121   protected:
00122     virtual std::ostream& info(std::ostream& os) const;
00123   private:
00124     // Sizes describing the ellipse
00125     const Real a_, k_, D_;
00126     // Number of sections
00127     const uint n_;
00128 
00129     // Edge parametrisation for the midline
00130     Sequence<MappingEdge2d*> inner_, midline_, outer_;
00131 
00132     EdgeMesh *innerMesh_, *outerMesh_, *midMesh_;
00133 
00134     // Interior and exterior boundary of the sheet.
00135     // Changed thickness will change this.
00136     std::auto_ptr<EdgeMesh> innerSheet_, outerSheet_;
00137 
00138     // Relation information between levels of the meshes
00139     std::auto_ptr<concepts::RelativeCells> limitRelat_, thinRelat_;
00140     
00141     Sequence<const concepts::Connector*> limitCntr_;
00142 
00143     std::map<const concepts::Connector*,
00144              std::pair<uint, const concepts::Connector*> > rmap_;
00145   };
00146 
00147   // *************************************************** ThinStraightMeshes2d **
00148 
00149   class ThinStraightMeshes2d : public ThinMeshes2d {
00150   public:
00161     ThinStraightMeshes2d(const Real L, const uint n,
00162                          const Real D, const Real d = 0.0);
00163     virtual ~ThinStraightMeshes2d();
00164 
00165     void thickness(const Real d);
00166 
00167     PointInCell<2> operator()(const PointInCell<2> P) const;
00168 
00169     inline const Sequence<Edge2d*>& outerBoundary() const {
00170       return outerMesh_->cells();
00171     }
00172     inline const Sequence<Edge2d*>& innerBoundary() const  {
00173       return innerMesh_->cells();
00174     }
00175 
00176     // rebuilds the child -> parent mapping
00177     virtual void rebuild() {
00178       conceptsAssert(thinRelat_.get(), Assertion());
00179       thinRelat_->rebuildCells();
00180     }
00181   protected:
00182     virtual std::ostream& info(std::ostream& os) const;
00183   private:
00184     // Sizes describing the sheet
00185     const Real L_, D_;
00186     // Number of sections
00187     const uint n_;
00188 
00189     // Edge parametrisation for the midline
00190     Sequence<MappingEdge2d*> inner_, midline_, outer_;
00191 
00192     EdgeMesh *innerMesh_, *outerMesh_, *midMesh_;
00193 
00194     // Interior and exterior boundary of the sheet.
00195     // Changed thickness will change this.
00196     std::auto_ptr<EdgeMesh> innerSheet_, outerSheet_;
00197 
00198     // Relation information between levels of the meshes
00199     std::auto_ptr<concepts::RelativeCells> limitRelat_, thinRelat_;
00200     
00201     Sequence<const concepts::Connector*> limitCntr_;
00202 
00203     std::map<const concepts::Connector*,
00204              std::pair<uint, const concepts::Connector*> > rmap_;
00205   };
00206 
00207   // ***************************************** generateThinMeshes2dFromInput **
00208 
00246   std::pair<ThinMeshes2d*,  PiecewiseFormulaBase<Real>*>
00247   generateThinMeshes2dFromInput(const InOutParameters input,
00248                                 bool verbose = false);
00249 
00250   // ********************************************************* ThinSheetCell **
00251 
00256   template<int dim>
00257   class ThinSheetCell {
00258   public:
00263     virtual const Real d(const Array<Real>& xi) const = 0;
00265     virtual const bool constThickness() const = 0;
00266   };
00267 
00272   template<>
00273   class ThinSheetCell<2> {
00274   public:
00279     virtual const Real d(const Real& xi) const = 0;
00281     virtual const bool constThickness() const = 0;
00282   };
00283 
00284   // ******************************************************* ThinSheetQuad2d **
00285 
00294   class ThinSheetQuad2d : public Quad2d, public ThinSheetCell<2> {
00295   public:
00302     ThinSheetQuad2d(Quad& cntr, const MappingEdge2d& midline, const Real d);
00303     virtual ~ThinSheetQuad2d();
00304 
00310 //     virtual ThinSheetQuad2d* child(uint i);
00311 //     /** Returns a child. If no children exist, none are created and 0 is
00312 //  returned.
00313 //  @param i Index of the child to be returned.
00314 //     */
00315 //     virtual const ThinSheetQuad2d* child(uint i) const;
00316 
00317     virtual const Real d(const Real& xi) const { return d_; }
00318     virtual const bool constThickness() const { return true; }
00319     const Real curvature(const Real xi, uint n = 0) const;
00320     const MappingEdge2d* midline() const;
00321 //     const Real midlineJacobian(const Real xi) const;
00322 
00327     const ThinSheetQuad2d* neighbour(uint i) const;
00328     void neighbour(uint i, const ThinSheetQuad2d* neigbour);
00330     const ThinSheetQuad2d* father() const { return father_; }
00336     const MappingEdge2d* edge(uint i) const;
00337   protected:
00338     virtual std::ostream& info(std::ostream& os) const;
00339   private:
00341     const Real d_;
00343     const MappingEdge2d* midline_;
00347     const MappingEdge2d* edges_[2];
00348 
00349 //     /// Pointer to the element map
00350 //     std::auto_ptr<MappingQuad2d> map_;
00351 
00353     const ThinSheetQuad2d* neighbour_[2];
00355     const ThinSheetQuad2d* father_;
00356 
00357 //     /** Pointer to the first child. 
00358 //  The children are stored in a linked list.
00359 //     */
00360 //     ThinSheetQuad2d* chld_;
00361 
00362 //     /// Level of the element
00363 //     uint l_;
00364 
00365 //     /// Index of the element (ie. left or right child)
00366 //     uint i_;
00367 
00374     ThinSheetQuad2d(Quad& cntr,
00375         const ThinSheetQuad2d& father,
00376         const Index& idx);
00377 
00379     virtual Quad2d* createChild_(Quad& cntr, const Index& idx) const;
00380   };
00381 
00382   // ************************************************************* ThinSheet **
00383 
00388   class ThinSheet : public Mesh2 {
00389   public:
00395     ThinSheet(const Real d) : d_(d) {}
00396     inline const Real d() const { return d_; }
00397   protected:
00398     virtual std::ostream& info(std::ostream& os) const {
00399       return os << "ThinSheet(d = " << d_ << ")";
00400     }
00401   private:
00403     const Real d_;
00404   };
00405 
00406   // ****************************************************** ThinSheetParabel **
00407 
00421   class ThinSheetParabel : public ThinSheet {
00422   public:
00428     ThinSheetParabel(const Real d, const Real p, const Real R = 1.0);
00429     virtual ~ThinSheetParabel();
00430 
00431     inline uint ncell() const { return ncell_; }
00432     inline Scan2* scan() { return new S(&cell_); }
00433   protected:
00434     virtual std::ostream& info(std::ostream& os) const;
00435   private:
00437     class S : public Scan<Cell2> {
00438       uint idx_;
00439       Array<Quad2d*>* cell_;
00440     public:
00441       inline S(Array<Quad2d*>* cell) : idx_(0), cell_(cell) {}
00442       inline S(const S &scan) : idx_(scan.idx_),
00443         cell_(scan.cell_) {}
00444 
00445       inline bool eos() const { return idx_ == cell_->size(); }
00446       inline Cell2& operator++(int) { return *(*cell_)[idx_++]; }
00447 
00448       inline Scan2* clone() const { return new S(*this); }
00449     };
00450 
00452     uint ncell_;
00453 
00455     Array<Vertex*> vtx_;
00456     Array<Edge*> edg_;
00457     Array<Quad*> quad_;
00458 
00460     Array<Quad2d*> cell_;
00461   };
00462 
00463   // ****************************************************** ThinSheetEllipse **
00464 
00478   class ThinSheetEllipse : public ThinSheet {
00479   public:
00486     ThinSheetEllipse(const Real d, const Real a, const Real k,
00487          const Real R = 1.0);
00488     virtual ~ThinSheetEllipse();
00489 
00490     inline uint ncell() const { return ncell_; }
00491     inline Scan2* scan() { return new S(&cell_); }
00492 
00494     inline const Quad2d* cell(uint i) const { return cell_[i]; }
00495 
00496     virtual std::ostream& info(std::ostream& os) const;
00497   private:
00499     class S : public Scan<Cell2> {
00500       uint idx_;
00501       Array<Quad2d*>* cell_;
00502     public:
00503       inline S(Array<Quad2d*>* cell) : idx_(0), cell_(cell) {}
00504       inline S(const S &scan) : idx_(scan.idx_),
00505         cell_(scan.cell_) {}
00506 
00507       inline bool eos() const { return idx_ == cell_->size(); }
00508       inline Cell2& operator++(int) { return *(*cell_)[idx_++]; }
00509 
00510       inline Scan2* clone() const { return new S(*this); }
00511     };
00512 
00514     uint ncell_;
00515 
00517     Array<Vertex*> vtx_;
00518     Array<Edge*> edg_;
00519     Array<Quad*> quad_;
00520 
00522     Array<Quad2d*> cell_;
00523 
00526     const Real2d point_(const Real a, const Real b) const;
00527   };
00528 
00529   // ***************************************************** ThinSheetEllipse2 **
00530 
00548   class ThinSheetEllipse2 : public ThinSheet {
00549   public:
00557     ThinSheetEllipse2(const Real d, const Real a, const Real k,
00558                       const Real D, const Real R = 1.0);
00559     virtual ~ThinSheetEllipse2();
00560 
00561     inline uint ncell() const { return ncell_; }
00562     inline Scan2* scan() { return new S(&cell_); }
00563 
00565     inline const Quad2d* cell(uint i) const { return cell_[i]; }
00566 
00567     virtual std::ostream& info(std::ostream& os) const;
00568   private:
00570     class S : public Scan<Cell2> {
00571       uint idx_;
00572       Array<Quad2d*>* cell_;
00573     public:
00574       inline S(Array<Quad2d*>* cell) : idx_(0), cell_(cell) {}
00575       inline S(const S &scan) : idx_(scan.idx_),
00576         cell_(scan.cell_) {}
00577 
00578       inline bool eos() const { return idx_ == cell_->size(); }
00579       inline Cell2& operator++(int) { return *(*cell_)[idx_++]; }
00580 
00581       inline Scan2* clone() const { return new S(*this); }
00582     };
00583 
00585     uint ncell_;
00586 
00588     Array<Vertex*> vtx_;
00589     Array<Edge*> edg_;
00590     Array<Quad*> quad_;
00591 
00593     Array<Quad2d*> cell_;
00594 
00597     const Real2d point_(const Real a, const Real b) const;
00598   };
00599 
00600 } // namespace concepts
00601 
00602 #endif // thinsheetgeom_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)