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

app-bholger/gfem/gfemSpace.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "gfemQuad.h"
00004 #include "space/space.hh"
00005 #include "geometry/mesh.hh"
00006 #include "hp2D/quad.hh"
00007 #include <vector>
00008 #include <map>
00009 #include <iostream>
00010 #include "limits"
00011 #include "gfemControl.h"
00012 
00013 namespace concepts {
00014 namespace gfem {
00015 
00033 struct GfemSpaceParams {
00034   GfemSpaceParams(Attribute attr_microOsc,  int p_macro = 1, int p_outer = 1, int p_edge = 1e6)
00035   {
00036     addGfemAttr(attr_microOsc, p_macro);
00037 
00038     p_outers[0] = p_outer;
00039     p_outers[1] = p_outer;
00040 
00041     p_edges[0] = std::min(p_outers[0], p_edge); 
00042     p_edges[1] = std::min(p_outers[1], p_edge); 
00043  }
00044 
00045   GfemSpaceParams(int p_outer = 1, int p_edge = 1e6)
00046   {
00047     p_outers[0] = p_outer;
00048     p_outers[1] = p_outer;
00049     p_edges[0] = std::min(p_outers[0], p_edge); 
00050     p_edges[1] = std::min(p_outers[1], p_edge); 
00051   }
00052 
00053   GfemSpaceParams(int po[2], int p_edge = 1e6)
00054   {
00055     p_outers[0] = po[0];
00056     p_outers[1] = po[1];
00057     p_edges[0] = std::min(p_outers[0], p_edge); 
00058     p_edges[1] = std::min(p_outers[1], p_edge); 
00059   }
00060 
00061   void addGfemAttr(Attribute gfemAttr, int p_macro) {
00062 #if 0
00063     printf("****** FIXME: hardcoded barrier geometry! ****\n");
00064     if(int(gfemAttr) == 8) {
00065       gfemParamMap[gfemAttr] = GfemCellParams(p_macro
00066           , GfemCellParams::SEL_ALL, GfemCellParams::SEL_POS);
00067     } else if(int(gfemAttr) == 9) {
00068       gfemParamMap[gfemAttr] = GfemCellParams(p_macro
00069           , GfemCellParams::SEL_ALL, GfemCellParams::SEL_PER);
00070     } else {
00071       gfemParamMap[gfemAttr] = GfemCellParams(p_macro);
00072     }
00073 #else
00074     gfemParamMap[gfemAttr] = GfemCellParams(p_macro);
00075 #endif
00076   }
00077 
00078   const GfemCellParams* getCellParams(Attribute gfemAttr)  const
00079   {
00080     GfemParamMap::const_iterator it = gfemParamMap.find(gfemAttr);
00081     if(it == gfemParamMap.end())
00082       return NULL;
00083     return &(it->second);
00084   }
00085 
00086   int p_outers[2];
00087   int p_edges[2];
00088 
00089   typedef std::map<Attribute, GfemCellParams> GfemParamMap;
00090   GfemParamMap gfemParamMap; 
00091 };
00092 
00093 
00094 class GfemSpace : public concepts::SpaceOnCells<Real> 
00095 {
00096 public:
00097   typedef hp2D::Quad<Real> hpQuad;
00098   typedef StlVectorScan<ElementWithCell<Real> > Scan;
00099   typedef StlVectorScan<GfemQuad > ScanGfem;
00100   typedef StlVectorScan<hpQuad > ScanOrdinary;
00101 
00102   const static bool NO_SCALE_RES = GfemControl<0>::NO_SCALE_RES;
00103   const static bool USE_SCALE_RES = GfemControl<0>::USE_SCALE_RES;
00104 
00105 
00115   GfemSpace(Mesh2& msh, const Unitcell& uc, const GfemSpaceParams& params,
00116       const concepts::BoundaryConditions& bc);
00117 
00118   virtual ~GfemSpace();
00119 
00120   void rebuild();
00121 
00123   virtual uint dim() const {
00124     return dim_; 
00125   }
00126 
00127   int getDim() {
00128     return dim();
00129   }
00130 
00131   int getDimGfem() const {
00132     return dimGfem;
00133   }
00134 
00135   int getDimOverl() const {
00136     return dimOverl;
00137   }
00138 
00139   int genVertDof(GfemControlVert ctrl);
00140 
00144   virtual uint nelm() const {
00145     return elems.size();    
00146   }
00147 
00148   void clear();
00149 
00150   int getNelm() const {
00151     return elems.size();
00152   }
00153 
00154   int getNelmGfem() const {
00155     return elemGfemSubs.size(); 
00156   }
00157 
00158   int getNelmOrdinary() const {
00159     return elemGfemSubs.size();  
00160   }
00161 
00163   virtual Scan* scan() const {
00164     return new Scan(elems, elems.begin());
00165   }
00166 
00167 
00168   ScanOrdinary* scanOrdinary() const {
00169     return new ScanOrdinary(elemOrdinarySubs, elemOrdinarySubs.begin());
00170   }
00171 
00172   ScanGfem* scanGfem() const {
00173     return new ScanGfem(elemGfemSubs, elemGfemSubs.begin());
00174   }
00175 
00176 
00177   void assignVertexDofs(const concepts::Quad& cell_t, const GfemOverlapCondition& overc,
00178         concepts::TColumn<Real>*& T1);
00179 
00180   void assignEdgeDofs(const concepts::Quad& cell_t, const GfemOverlapCondition& overc,
00181         concepts::TColumn<Real>*& T1);
00182 
00183   void assignInnerDofs(const concepts::Quad& cell_t, const GfemOverlapCondition& overc,
00184         concepts::TColumn<Real>*& T1);
00185 
00187   bool isVertexDof(const concepts::Connector2& cntr, uint i) const;
00188 
00193   bool isEdgeDof(const concepts::Connector2& cntr, uint i) const;
00194 
00199   bool isInnerDof(const concepts::Connector2& quad) const;
00200 
00201   void verbosePrint();
00202 
00206   void recomputeShapefunctions();
00207 
00208 protected:
00209   virtual std::ostream& info(std::ostream& os) const;
00210 
00214   int allocDofs(int numDofs);
00215 
00216 private:
00217 
00218   void processMesh(const Quad2d& quad);
00219   
00220   void processMicro(const Quad2d& quad);
00221 
00222   void processOverlap(const Quad2d& cell);
00223 
00224   void processBC(const Quad2d& quad);
00225 
00227   concepts::Mesh2& mesh;
00228 
00229   std::vector< ElementWithCell<Real>* > elems; 
00230   std::vector< GfemQuad* > elemGfemSubs; 
00231   std::vector< hpQuad* > elemOrdinarySubs; 
00233   typedef std::map< int, GfemControl<0> > ControlVert;
00234   typedef std::map< int, GfemControl<1> > ControlEdge;
00235   typedef std::map< int, GfemControl<2> > ControlCell;
00236   ControlVert controlVert;  
00237   ControlEdge controlEdge;  
00238   ControlCell controlCell;  
00239 
00240   int n_elem;
00241   int n_gfem;
00242   int n_ordinary;
00243   int dim_;
00244   int dimGfem;
00245   int dimOverl;
00246 
00247   GfemSpaceParams params;
00248   BoundaryConditions bc;
00249   const Unitcell& uc;
00250 
00251   //TODO: work here map of control informations
00252 };
00253 
00254 } // namespace
00255 } // namespace

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