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

hp2D/space.hh
Go to the documentation of this file.
00001 /* space class for 2D hp FEM
00002  */
00003 
00004 #ifndef hpSpace2D_hh
00005 #define hpSpace2D_hh
00006 
00007 #include <memory>
00008 #include <cstring>
00009 #include <set>
00010 #include "basics/exceptions.hh"
00011 #include "basics/typedefs.hh"
00012 #include "toolbox/scannerConnectors.hh"
00013 #include "toolbox/hashMap.hh"
00014 #include "geometry/continuityData.hh"
00015 #include "geometry/cell2D.hh"
00016 #include "geometry/mesh.hh"
00017 #include "geometry/boundaryConditions.hh"
00018 #include "space/space.hh"
00019 #include "space/hpMethod.hh"
00020 #include "element.hh"
00021 
00022 namespace concepts {
00023 
00024   // forward declarations
00025   template<class F>
00026   class SMatrixBase;
00027 
00028   class SMatrix1D;
00029 
00030 //   // ****************************************************************** Scan **
00031 
00032 //   template<>
00033 //   class Scan<hp2D::Element<Real> > :
00034 //     public concepts::Scan<concepts::Element<Real> > 
00035 //   {
00036 //   public:  
00037 //     hp2D::Element<Real>& operator++(int) = 0;
00038 //   };
00039 
00040 } // namespace concepts
00041 
00042 namespace hp2D {
00043   using concepts::Real;
00044 
00045   // forward declarations
00046   template<class F>
00047   class Quad;
00048 
00049   class BuildDofsBase;
00050 
00051   // ****************************************************** IndexNotExisting **
00052 
00057   class NotConnectedIndex : public concepts::ExceptionBase {};
00058 
00059   // ***************************************************************** Space **
00060 
00083   class Space :
00084     public concepts::SpaceOnCells<Real>,
00085     public concepts::AdaptiveSpace<Real, concepts::AdaptiveAdjustP<2> > 
00086   {
00087   public:
00088     friend class BuildDofsBase;
00089 
00090     typedef concepts::Scan<hp2D::Element<Real> > Scan;
00091 
00102     Space(concepts::Mesh2& msh, uint l, uint p,
00103           concepts::BoundaryConditions* bc = 0);
00107     Space(const Space& spc);
00108     virtual ~Space();
00109 
00110     inline virtual uint dim() const;
00111     inline virtual uint nelm() const;
00112     inline virtual Scan* scan() const;
00117     inline Scan* constScan() const;
00118 
00119     inline uint dim();
00120     inline uint nelm();
00121     inline Scan* scan();
00122 
00123     virtual void adjust(const concepts::Element<Real>& elm,
00124                         const concepts::AdaptiveAdjustP<2>& a);
00125 
00143     Space rebuild();
00144 
00155     void buildVertexDofs(const BuildDofsBase& b);
00156 
00164     void buildEdgeDofs(const BuildDofsBase& b);
00165 
00173     void buildInnerDofs(const BuildDofsBase& b);
00175 
00177     uint connectedIdx(const concepts::Attribute& a) const;
00178 
00182     void recomputeShapefunctions();
00183   protected:
00184     virtual std::ostream& info(std::ostream& os) const;
00185   private:
00187     concepts::Mesh2& msh_;
00189     concepts::BoundaryConditions* bc_;
00190 
00195     bool rebuild_;
00196 
00198     uint dim_;
00199 
00201     uint nelm_;
00202 
00204     concepts::Joiner<Element<Real>*, 1>* elm_;
00205 
00207     __gnu_cxx::hash_map<uint, concepts::AdaptiveControl<> > ctrl0_;
00209     std::auto_ptr<__gnu_cxx::hash_map< uint, concepts::AdaptiveControlP<1> > > ctrl1_;
00211     __gnu_cxx::hash_map<uint, concepts::AdaptiveControlP<2> > ctrl2_;
00212 
00214     __gnu_cxx::hash_map<uint, concepts::AdaptiveControl<> > ctrlc0_;
00215 
00217     __gnu_cxx::hash_map<uint, const concepts::Attribute*> vtxConnect_;
00218 
00220     std::map<uint, concepts::CellData> cellList_;
00222     std::map<uint, concepts::EdgeData> edgeList_;
00224     std::map<uint, concepts::VertexData> vertexList_;
00225 
00226     /* Linked list of ghost cells, created for handling subdivision
00227        in 4 quadrilaterials
00228        */
00229     //     concepts::Joiner<concepts::Quad*, 1>* ghostCells_;
00230 
00232     __gnu_cxx::hash_map<uint, concepts::AdaptiveAdjustP<2> > adj_;
00233 
00235     std::auto_ptr<concepts::SMatrix1D> S1left_, S1right_;
00239     std::auto_ptr<concepts::SMatrixBase<Real> > Smatrices2H_[2];
00243     std::auto_ptr<concepts::SMatrixBase<Real> > Smatrices2V_[2];
00247     std::auto_ptr<concepts::SMatrixBase<Real> > Smatrices4_[4];
00248 
00252     std::auto_ptr<BuildDofsBase> buildVertexDofs_;
00256     std::auto_ptr<BuildDofsBase> buildEdgeDofs_;
00260     std::auto_ptr<BuildDofsBase> buildInnerDofs_;
00261 
00262   private:
00283     void meshAndPoly_(concepts::Quad2d& cell, concepts::Level<2>& L, int* P);
00284 
00289     void enforceBC_(const concepts::Connector2& cell);
00290 
00292     void createCellList_(const concepts::Connector& cntr,
00293         const concepts::CellData* father);
00295     void createVtxEdgList_(const concepts::Connector2& cell);
00296 
00311     void enrichElm_(const concepts::Quad2d& cell, int* p);
00312 
00322     void minimumRule_(const concepts::Connector2& cntr,
00323         const concepts::Connector1& edge);
00324 
00338     void buildElements_(concepts::Quad2d& cell, ushort* Pmax,
00339         concepts::TColumn<Real>* T0 = 0);
00340 
00341     void buildEmptyElements_(concepts::Quad2d& cell);
00342 
00347     void computePmax_(const concepts::Connector2& cntr,
00348         ushort Pmax[2]) const;
00349 
00356     void recomputeSmatrices_(const Quad<Real>& elm);
00357 
00358     void deactivate_(const concepts::Edge& edg);
00359     void deactivate_(const concepts::Vertex& vtx);
00360 
00374     bool activeCell_(concepts::Cell& cell);
00378     void status_();
00379     void matlabstatus_();
00380 
00381 
00387     Space(const Space& spc, uint i);
00388   };
00389 
00390   uint Space::dim() const {
00391     if (rebuild_) throw conceptsException(concepts::SpaceNotBuilt());
00392     return dim_; 
00393   }
00394 
00395   uint Space::nelm() const {
00396     if (rebuild_) throw conceptsException(concepts::SpaceNotBuilt());
00397     return nelm_; 
00398   }
00399 
00400   Space::Scan* Space::scan() const {
00401     if (rebuild_) throw conceptsException(concepts::SpaceNotBuilt());
00402     return new concepts::PListScan<Element<Real> >(*elm_);
00403   }
00404 
00405   Space::Scan* Space::constScan() const {
00406     return new concepts::PListScan<Element<Real> >(*elm_);
00407   }
00408 
00409   uint Space::dim() {
00410     if (rebuild_) rebuild();
00411     return dim_; 
00412   }
00413 
00414   uint Space::nelm() {
00415     if (rebuild_) rebuild();
00416     return nelm_; 
00417   }
00418 
00419   Space::Scan* Space::scan() {
00420     if (rebuild_) rebuild();
00421     return new concepts::PListScan<Element<Real> >(*elm_);
00422   }
00423 
00424 } // namespace hp2D
00425 
00426 #include "buildDofsBase.hh"
00427 
00428 #endif // hpSpace2D_h

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