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

hp2D/spacePreBuilder.hh
Go to the documentation of this file.
00001 /* space pre builder classes for 2D spaces
00002 */
00003 
00004 #ifndef hpSpacePreBuilder2D_hh
00005 #define hpSpacePreBuilder2D_hh
00006 
00007 #include <set>
00008 #include <queue>
00009 #include "basics/outputOperator.hh"
00010 #include "geometry/cell2D.hh"
00011 #include "space/spacePreBuilder.hh"
00012 #include "space/space.hh"
00013 #include "space/hpMethod.hh"          // for AdaptiveControlP
00014 #include "toolbox/stiffArray.hh"
00015 #include "toolbox/multiArray.hh"
00016 #include "toolbox/hashMap.hh"
00017 #include "toolbox/sequence.hh"
00018 #include "toolbox/set.hh"
00019 #include "hp2D/edgeMinMax.hh"
00020 
00021 // If flag is set to 1, edgelist_ and vertexlist_ collect keys, not
00022 // local indices. That is easier to debug, but lightly slower.
00023 #define KeyLists 1
00024 
00025 namespace hp2D {
00026 
00027   // *********************************************************** NotValidDof **
00028 
00033   //   class NotValidDof : public concepts::ExceptionBase {};
00034 
00035   // ******************************************************* SpacePreBuilder **
00036 
00037   class SpacePreBuilder : public concepts::SpacePreBuilder {
00038   public:
00040     SpacePreBuilder(concepts::Mesh2& msh) : msh_(msh) {}
00042     virtual ~SpacePreBuilder() {}
00043 
00045     virtual concepts::Mesh2& mesh() const { return msh_; }
00049     virtual bool vtxDof(const concepts::Connector2& cntr, uint i) const = 0;
00054     virtual ushort edgeDof(const concepts::Connector2& cntr, uint i) const = 0;
00059     virtual const ushort* innerDof(const concepts::Connector2& cntr) const = 0;
00067     virtual const ushort* pMax(const concepts::Connector2& cntr,
00068                                ushort* p = 0) const = 0;
00073     virtual ushort edgeP(const concepts::Connector2& cntr, uint i) const = 0;
00074   protected:
00076     concepts::Mesh2& msh_;
00077   };
00078   
00079   typedef concepts::Adaptivity<concepts::Connector,
00080                                concepts::AdaptiveAdjustP<2> > Adaptivity;
00081 
00082   // *********************************************************** DegreeDim **
00083 
00092   template<typename F>
00093   struct DegreeDim {};
00094 
00095   template<>
00096   struct DegreeDim<concepts::Quad>         { static const ushort dim = 2; };
00097 
00098   template<>
00099   struct DegreeDim<concepts::InfiniteQuad> { static const ushort dim = 2; };
00100 
00101   template<>
00102   struct DegreeDim<concepts::Triangle>     { static const ushort dim = 1; };
00103   
00104 
00105   // **************************************************************** hpFull **
00106 
00157   class hpFull : public SpacePreBuilder, public Adaptivity {
00158   public:
00160     hpFull(concepts::Mesh2& msh, uint l = 0, uint p = 1, bool build = false);
00165     hpFull(const hpFull& preBuild);
00167     virtual ~hpFull() {}
00168 
00169     void setPolyEdgeRule(const PolyEdgeRule& rule);
00170 
00174     virtual void adjust(const concepts::Connector& cell,
00175                         const concepts::AdaptiveAdjustP<2>& a);
00180     void adjust(const uint nrCell, const concepts::AdaptiveAdjustP<2>& a);
00185     void adjust(const concepts::AdaptiveAdjustP<2>& a);
00186 
00193     uint available() const { return rebuild_ ? 0 : build_; }
00197     virtual void rebuildMesh();
00201     virtual void rebuildDof();
00205     virtual bool vtxDof(const concepts::Connector2& cntr, uint i) const;
00210     virtual ushort edgeDof(const concepts::Connector2& cntr, uint i) const;
00216     virtual const ushort* innerDof(const concepts::Connector2& cntr) const;
00226     virtual const ushort* pMax(const concepts::Connector2& cntr,
00227                                ushort* p = 0) const;
00232     virtual ushort edgeP(const concepts::Connector2& cntr, uint i) const;
00241     const concepts::IndexRange& index(uint dim,
00242                                       const concepts::Connector2& cntr,
00243                                       uint i = 0, uint spcNo = 0) const;
00256     virtual concepts::IndexRange&
00257       setIndex(uint& firstIdx, uint noIdx, uint dim,
00258          const concepts::Connector& cntr, uint i = 0,
00259          uint spcNo = 0) throw(concepts::NotValidDof);
00260 
00267     virtual concepts::Set<concepts::IndexRange> indices
00268       (uint dim, const concepts::Connector& cntr, uint spcNo = 0) const
00269       throw(concepts::MissingFeature);
00270 
00274     void clearAllIndices(uint spcNo = 0);
00275 
00277     uint ncells() { return cells_.size(); }
00278 
00280     bool isHangEdge(const concepts::Connector1& cntr) const;
00284     void storeMatlab(const std::string name);
00285 
00287     concepts::Set<concepts::Cell2*> cells() const { return cells_; }
00289     std::set<concepts::Cell2*> allCells() const { return allCells_; }
00290   protected:
00291     virtual std::ostream& info(std::ostream& os) const;
00292   private:
00296     bool rebuild_;
00298     uint build_;
00300     std::auto_ptr<const PolyEdgeRule> polyEdgeRule_;
00301 
00303     concepts::HashMap<concepts::AdaptiveAdjustP<2> > adj_;
00304 
00305     // mapping from space number to an index range
00306     typedef std::map<uint, concepts::IndexRange> IndexType;
00307     // index range per space number for all 'member of space' vertices dof
00308     typedef concepts::AdaptiveControl<IndexType> CtrlType_0;
00309     // index range per space number for all 'member of space' edge dof
00310     typedef concepts::AdaptiveControlP<1, IndexType> CtrlType_1;
00311     // index range per space number for all inner dof
00312     typedef concepts::AdaptiveControlP<2, IndexType> CtrlType_2;
00313 
00315     concepts::HashMap<CtrlType_0> ctrl0_;
00317     concepts::HashMap<CtrlType_1> ctrl1_;
00319     concepts::HashMap<CtrlType_2> ctrl2_;
00320 
00322     concepts::HashMap<ushort> polyDep_;
00324     concepts::HashMap<ushort> polyHang_;
00328     mutable concepts::HashMap<concepts::StiffArray<2,ushort> > pmax_;
00333     mutable concepts::HashMap<concepts::StiffArray<2,ushort> > pminInner_;
00334 
00336     concepts::Set<concepts::Cell2*> cells_;
00338     std::set<concepts::Cell2*> allCells_;
00342     concepts::HashMap<std::set<uint> > vertexList_;
00346     concepts::HashMap<std::set<uint> > edgeList_;
00348     concepts::Set<uint> hangEdges_;
00349 
00351     bool isMember_(const concepts::Connector2& cntr) const;
00353     bool isMember_(const concepts::Connector1& cntr) const;
00354 
00358     const ushort* pMinInner_(const concepts::Quad& quad);
00359 
00363     void refine_(concepts::Quad2d& cell, concepts::Level<2> L, short* P,
00364                  concepts::HashMap<CtrlType_2>::iterator& i2);
00365     void refine_(concepts::InfiniteQuad2d& cell, concepts::Level<2> L,
00366                  short* P, concepts::HashMap<CtrlType_2>::iterator& i2);
00370     void refine_(concepts::Cell2& cell, ushort* P,
00371                  concepts::HashMap<CtrlType_2>::iterator& i2);
00372 
00377     void memberEdges_(const concepts::Connector2& cntr,
00378                       std::set<const concepts::Connector1*>& edges);
00379 
00384     ushort takeOutchildrenEdges_
00385     (const concepts::Connector1& edge, const concepts::Connector1& cntr1,
00386      std::set<const concepts::Connector1*>& edges,
00387      std::set<const concepts::Connector0*>& vertices);
00388 
00390     template<class F>
00391     bool getEdgeSupport_(F cntr);
00392 
00396     template<class F>
00397     bool getPretendedVertexSupport_
00398     (F cntr,
00399      concepts::HashMap<std::queue<concepts::StiffArray<2, uint> > >& nonLocal);
00400 
00402     void getRootCells_
00403     (const concepts::Connector2& cntr, const std::set<uint>& vertices,
00404      std::map<uint, std::vector<const concepts::Connector2*> >& rootCells);
00405 
00410     void getNonLocalVertexSupport_
00411     (concepts::HashMap<std::queue<concepts::StiffArray<2, uint> > >& nonLocal,
00412      const std::map<uint, std::vector<const concepts::Connector2*> >&
00413      rootCells);
00414 
00425     void getEdgeMappings_
00426     (uint key, const std::vector<const concepts::Connector2*>& root,
00427      concepts::MultiArray<2, const concepts::Connector2*>& edgesToCell, 
00428      std::map<uint,
00429        concepts::Sequence<const concepts::Connector2*> >& edgeToCell,
00430      std::map<uint, uint>& fatherEdges, std::map<uint, uint>& mosEdges) const;
00431 
00432     void dependentEdges_(const concepts::Quad& quad);
00433     void polyDependentEdges_(const concepts::Quad& quad,
00434            const concepts::Edge& edge,
00435            const concepts::Edge& oppEdge, const uint p);
00436 
00437     ushort* pMax_(const concepts::Quad& cntr) const;
00438     ushort* pMax_(const concepts::InfiniteQuad& cntr) const;
00439 
00440     void setPmax_(const concepts::Connector2& cntr, ushort* Pmax);
00441 
00445     void polyHangingEdges_(const concepts::Connector1& edge, const uint& p);
00446 
00452     template<class F>
00453     void findControl_(F*& ctrl, const concepts::Connector2& cntr, uint i);
00454 
00462           IndexType& findIndex_(uint dim, const concepts::Connector2& cntr, 
00463                                 uint i);
00464     const IndexType& findIndex_(uint dim, const concepts::Connector2& cntr,
00465                                 uint i) const;
00466   };
00467 
00468 } // namespace hp2D
00469 
00470 #endif // hpSpacePreBuilder2D_hh

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