meshagent.h

Go to the documentation of this file.
00001 #ifndef  __MeshAgent_h
00002 #define  __MeshAgent_h
00003 
00004 #include  "meshagentinterface.h"
00005 #include  "hierarchicalmesh.h"
00006 #include  "gascoignemultigridmesh.h"
00007 #include  "boundaryfunction.h"
00008 
00009 using namespace std;
00010 
00011 /*-----------------------------------------*/
00012 
00013 namespace Gascoigne
00014 {
00015     typedef std::map<int,int> IntMap;
00016 
00017 class MeshAgent : public virtual MeshAgentInterface
00018 {
00019 private:
00020 
00021   map<int,BoundaryFunction<2>* > _curved2d;
00022   map<int,BoundaryFunction<3>* > _curved3d;
00023   
00024   //Fuer die Zuordnung GM Nr auf altem Gitter zu GM Nr. auf neuem Gitter
00025   IntVector _cl2g, _celll2g;
00026   IntVector _fathers;//GM Nr zu HM nr.
00027   IntMap _cg2l, _cellg2l;
00028   map<int,set<int> > _co2n;
00029   bool _goc2nc;
00030   nvector<IntVector> _q4patch,_q4toq2;
00031 
00032 protected:
00033 
00034   int GetDimension() const {return HMP->dimension();}   
00035         
00036   HierarchicalMesh*         HMP;
00037   GascoigneMultiGridMesh*   GMG;
00038 
00039   virtual GascoigneMultiGridMesh* NewMultiGridMesh() {return new GascoigneMultiGridMesh;}
00040 
00041   virtual void ReInit();
00042   virtual void BuildQ4PatchList(const IntVector &patchl2g);
00043 
00044   GascoigneMesh*  GMesh(int l) { return GMG->GetGascoigneMesh(l);}
00045 
00046 public:
00047     
00048   MeshAgent();
00049   ~MeshAgent();
00050 
00051   void AddShape(int col, BoundaryFunction<2>* f) { _curved2d[col] = f;}
00052   void AddShape(int col, BoundaryFunction<3>* f) { _curved3d[col] = f;}
00053 
00054         map<int,BoundaryFunction<2>* >& GetShapes2d()       { return _curved2d; }
00055         map<int,BoundaryFunction<3>* >& GetShapes3d()       { return _curved3d; }
00056   const map<int,BoundaryFunction<2>* >& GetShapes2d() const { return _curved2d; }
00057   const map<int,BoundaryFunction<3>* >& GetShapes3d() const { return _curved3d; }
00058 
00059   void BasicInit(const ParamFile* pf);
00060   void BasicInit(const std::string& gridname, int dim, int patchdepth, int epatcher, bool goc2nc = false);
00061 
00062   const GascoigneMultiGridMesh& GetMultiGrid() const {return *GMG;}
00063   GascoigneMultiGridMesh& GetMultiGrid() {return *GMG;}
00064 
00065         HierarchicalMesh* GetHierarchicalMesh()       { return HMP;}
00066   const HierarchicalMesh* GetHierarchicalMesh() const { return HMP;}
00067 
00068   int nnodes() const {return GMG->GetGascoigneMesh(0)->nnodes();}
00069   int ncells() const {return GMG->GetGascoigneMesh(0)->ncells();}
00070   int nlevels() const {return GMG->nlevels();}
00071 
00072   const MeshInterface* GetMesh()      const { return GMG->GetGascoigneMesh(0);}
00073   const MeshInterface* GetMesh(int l) const { return GMG->GetGascoigneMesh(l);}
00074 
00075   void read_gup(const std::string& fname);
00076   void read_gip(const std::string& fname);
00077   void write_gup(const std::string& fname) const;
00078   void write_gip(const std::string& fname) const;
00079   void write_inp(const std::string& fname) const;
00080   void global_refine(int n);
00081   void global_patch_coarsen(int n);
00082   void random_patch_coarsen(double p, int n);
00083   void random_patch_refine(double p, int n);
00084   void refine_nodes(IntVector& refnodes, IntVector& coarsenodes);
00085   void refine_nodes(IntVector& refnodes);
00086   void refine_cells(IntVector& ref);
00087 
00088   const GascoigneMeshTransfer* GetTransfer(int l) const {return GMG->GetTransfer(l);}
00089 
00090   const std::set<int> Cello2n(int i)const;
00091   const int Cello2nFather(int i)const;
00092   void ClearCl2g() { _cl2g.clear(); }
00093   const bool Goc2nc() const{ return _goc2nc;}
00094 
00095   const IntVector& Celll2g() const { return _celll2g; }
00096   const IntMap& Cellg2l()    const { return _cellg2l; }
00097 };
00098 }
00099 
00100 #endif

Generated on Thu Sep 14 10:34:37 2006 for Gascoigne by  doxygen 1.4.7