Grid.hpp

00001 #ifndef __FIBER_GRID_HPP
00002 #define __FIBER_GRID_HPP "Created 27.02.2001 21:42:27 by werner"
00003 
00004 #include "GridAPI.h"
00005 #include <field/Field.hpp>
00006 #include <memcore/TypeInfo.hpp>
00007 #include <set>
00008 #include <list>
00009 
00010 #include "FieldID.hpp"
00011 #include "FiberSpace.hpp"
00012 #include "Transformation.hpp"
00013 #include "Representation.hpp"
00014 #include "Chart.hpp"
00015 #include "Skeleton.hpp"
00016 #include "SkeletonID.hpp"
00017 
00018 namespace Fiber
00019 {
00020         using MemCore::WeakPtr;
00021         using MemCore::NullPtr;
00022         using std::set;
00023         using std::list;
00024 
00031 class   GRID_API Timestep : public Interface<Timestep>
00032 {
00033 public: 
00034         long    timestep;
00035 };
00036 
00050 class   GRID_API Grid : public ReferenceBase<Grid>, public Intercube, public Attributes
00051 {
00052         WeakPtr<GridContainer>  myContainer;
00053         RefPtr<Atlas>           myAtlas;
00054 
00055         typedef map<SkeletonID, RefPtr<Skeleton> > Skeletons_t;
00056         Skeletons_t *Skeletons; 
00057 
00059         Grid(const Grid&);
00060 
00062         void operator=(const Grid&);
00063 
00064 public:
00065         typedef std::pair<SkeletonID, RefPtr<Skeleton> > SkeletonInfo;
00066 
00073         Grid (const WeakPtr<GridContainer>&GC, const RefPtr<GlobalCharts>&GAtlas);
00074 
00076         ~Grid(); 
00077 
00079         RefPtr<Skeleton> findVertices() const; 
00080 
00082         SkeletonInfo    getVerticesInfo() const;
00083 
00085         SkeletonInfo    getEdgeInfo() const; 
00086 
00088         SkeletonInfo    getFaceInfo() const; 
00089 
00097         int     getMemoryUsage(memsize_t&UsedMemory, memsize_t&WantedMemory) const;
00098 
00111         double NumberOfHoles() const;
00112 
00113 
00115         const RefPtr<Atlas>&MyAtlas() const
00116         {
00117                 return myAtlas;
00118         } 
00119 
00121         RefPtr<Chart> findChart(const RefPtr<ChartID>&id) const
00122         {
00123                 return (*myAtlas)(id);
00124         } 
00125 
00127         RefPtr<Chart> findChart(const type_info&ChartType) const; 
00128 
00130         RefPtr<Chart> findChart(const type_info&ChartType, const string&name) const;
00131 
00133         RefPtr<Chart> makeChart(const type_info&ChartType);
00134 
00136         RefPtr<Chart> makeChart(const type_info&ChartType, const string&name); 
00137 
00139         RefPtr<Chart> makeCartesianChart(); 
00141         RefPtr<Chart> findCartesianChart() const;
00142 
00145         RefPtr<Representation> getCartesianRepresentation(const Skeleton&Skel) const; 
00146 
00149         RefPtr<Representation> getTimePolar2DRepresentation(const Skeleton&Skel) const;
00150         
00153         RefPtr<Representation> getCartesianRepresentation() const
00154         {
00155         RefPtr<Skeleton> S = findVertices();
00156                 if (!S)
00157                         return NullPtr(); 
00158 
00159                 return  getCartesianRepresentation(*S);
00160         } 
00161 
00162         RefPtr<Representation> getTimePolar2DRepresentation() const
00163         {
00164         RefPtr<Skeleton> S = findVertices();
00165                 if (!S)
00166                 {
00167                         puts("Grid::getTimePolar2DRepresentation(): no Vertex Skeleton found!");fflush(stdout);
00168                         return NullPtr(); 
00169                 }
00170                 return  getTimePolar2DRepresentation(*S);
00171         }
00172 
00177         Skeleton& makeVertices(int dims); 
00178 
00183         Representation&makeCartesianRepresentation(int Dims); 
00184 
00191         Representation&operator[](int Dims)
00192         {
00193                 return makeCartesianRepresentation(Dims);
00194         }
00195 
00201         RefPtr<Field> operator()(const string&fieldname) const;
00202 
00209         RefPtr<Field>&operator[](const string&fieldname);
00210 
00215         RefPtr<Field> CartesianPositions() const; 
00216 
00217         RefPtr<Field> TimePolar2DPositions() const;
00218 
00224         RefPtr<Field> getCartesianPositions() const
00225         {
00226                 return CartesianPositions();
00227         }
00228 
00229 
00230         Skeleton        &operator[](const SkeletonID&Sid);
00231         RefPtr<Skeleton> operator()(const SkeletonID&Sid) const;
00232 
00233 
00234         RefPtr<Representation> CellsAsVertices(int dims) const; 
00235 
00236         int     MinLevel(int IndexDepth=0) const;
00237         int     MaxLevel(int IndexDepth=0) const;
00238 
00239         RefPtr<Skeleton> findRefinementLevel(int Level, int IndexDepth) const; 
00240 
00244         typedef SkeletonIterator Iterator; 
00245 
00249         int iterate(SkeletonIterator&) const;
00250 
00252         int nSkeletons() const;
00253 
00254 #if 0
00255 
00260         RefPtr<Chart> getGlobalChart(const type_info&t, const string&id) const;
00261 
00267         RefPtr<Chart> getGlobalChart(const vector<char*>&component_names,
00268                                      const type_info&element_type,
00269                                      const string&id) const;
00270 
00271 #endif
00272 
00273 /*      /// Search for a certain chart by name
00274         RefPtr<Chart> findChart(const string&id) const
00275         {
00276                 return (*myGridAtlas)(id);
00277         }
00278 */
00279 
00280 
00284         void    Speak(int indent=0, int maxindent=-1) const;
00285 };
00286 
00287 } /* namespace Fiber */ 
00288 
00289 #endif /* __FIBER_GRID_HPP */