00001 #ifndef DUNE_GRAPE_DATA_DISPLAY_HH
00002 #define DUNE_GRAPE_DATA_DISPLAY_HH
00003
00004
00005 #include <vector>
00006
00007
00008 #include "grapegriddisplay.hh"
00009
00016 namespace Dune
00017 {
00018
00019 template <typename ctype, int dim, int dimworld, int polOrd>
00020 class GrapeLagrangePoints;
00021
00022 template <class EvalImpTraits>
00023 struct EvalFunctionData
00024 {
00025 typedef typename EvalImpTraits :: GridType GridType;
00026 typedef typename EvalImpTraits :: EvalImp EvalImp;
00027
00028 typedef typename GridType :: template Codim<0> :: Entity EntityType;
00029 enum { dim = GridType::dimension };
00030 enum { dimworld = GridType::dimensionworld };
00031
00032 typedef typename GridType :: ctype ctype;
00033
00034 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
00035 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
00036
00037
00038 inline static void evalCoordNow (EntityType &en, DUNE_FDATA *fdata, const double *coord, double * val)
00039 {
00040 EvalImp::evalCoordNow(en,fdata,coord,val);
00041 }
00042
00043
00044 inline static void evalDofNow (EntityType &en, int geomType, DUNE_FDATA *fdata , int localNum, double * val)
00045 {
00046 EvalImp::evalDofNow(en,geomType,fdata,localNum,val);
00047 }
00048
00049
00050 inline static void evalCoord (DUNE_ELEM *he, DUNE_FDATA *df,
00051 const double *coord, double * val);
00052
00053
00054 inline static void evalDof (DUNE_ELEM *he, DUNE_FDATA *df, int localNum, double * val);
00055
00056
00057 inline static void getMinMaxValues(DUNE_FDATA *df, double* min, double* max );
00058 };
00059
00060 template <class GridImp, class DiscreteFunctionType>
00061 struct EvalDiscreteFunctions;
00062
00063 template <class GridImp, class DiscreteFunctionType>
00064 struct EvalDiscreteFunctionsTraits
00065 {
00066 typedef GridImp GridType;
00067 typedef EvalDiscreteFunctions <GridImp, DiscreteFunctionType > EvalImp;
00068 };
00069
00070 template <class GridImp, class DiscreteFunctionType>
00071 struct EvalDiscreteFunctions
00072 : public EvalFunctionData< EvalDiscreteFunctionsTraits <GridImp, DiscreteFunctionType > >
00073 {
00074 typedef GridImp GridType;
00075 typedef typename GridType :: template Codim<0> :: Entity EntityType;
00076 enum { dim = GridType::dimension };
00077 enum { dimworld = GridType::dimensionworld };
00078
00079 typedef typename GridType :: ctype ctype;
00080
00081 typedef typename DiscreteFunctionType :: LocalFunctionType LocalFunctionType;
00082 typedef typename DiscreteFunctionType :: DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
00083
00084 typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
00085 typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
00086
00087 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
00088 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
00089
00090
00091 inline static void evalCoordNow (EntityType &en, DUNE_FDATA *fdata, const double *coord, double * val);
00092
00093
00094 inline static void evalDofNow (EntityType &en, int geomType, DUNE_FDATA *fdata , int localNum, double * val);
00095
00096
00097 inline static void evalScalar (EntityType &en, int geomType,
00098 DiscreteFunctionType & func, LocalFunctionType &lf,
00099 const int * comp , int localNum, double * val);
00100
00101
00102 inline static void evalVector (EntityType &en, int geomType,
00103 DiscreteFunctionType & func, LocalFunctionType &lf,
00104 const int * comp, int vend, int localNum, double * val);
00105
00106
00107 inline static void calcMinMax(DUNE_FDATA * df);
00108 };
00109
00110 template <class GridImp, class VectorType, class IndexSetImp >
00111 struct EvalVectorData;
00112
00113 template <class GridImp, class VectorType , class IndexSetImp >
00114 struct EvalVectorDataTraits
00115 {
00116 typedef GridImp GridType;
00117 typedef EvalVectorData <GridImp, VectorType, IndexSetImp > EvalImp;
00118 };
00119
00120 template <class GridImp, class VectorType, class IndexSetImp >
00121 struct EvalVectorData
00122 : public EvalFunctionData< EvalVectorDataTraits <GridImp, VectorType, IndexSetImp > >
00123 {
00124 typedef GridImp GridType;
00125 typedef typename GridType :: template Codim<0> :: Entity EntityType;
00126 enum { dim = GridType::dimension };
00127 enum { dimworld = GridType::dimensionworld };
00128
00129 typedef typename GridType :: ctype ctype;
00130
00131 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
00132 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
00133
00134
00135 inline static void evalCoordNow (EntityType &en, DUNE_FDATA *fdata, const double *coord, double * val);
00136
00137
00138 inline static void evalDofNow (EntityType &en, int geomType, DUNE_FDATA *fdata , int localNum, double * val);
00139
00140
00141 inline static void evalVectorLinear (EntityType &en, int geomType,
00142 VectorType & func, const IndexSetImp & set,
00143 const int * comp, int vend, int localNum, double * val);
00144
00145
00146 inline static void evalVectorConst (EntityType &en, int geomType,
00147 VectorType & func, const IndexSetImp & set,
00148 const int * comp, int vend, int localNum, double * val);
00149
00150
00151 inline static void calcMinMax(DUNE_FDATA * df);
00152 };
00153
00154
00158 template<class GridType>
00159 class GrapeDataDisplay : public GrapeGridDisplay < GridType >
00160 {
00161 typedef GrapeDataDisplay < GridType > MyDisplayType;
00162
00163 typedef GrapeGridDisplay < GridType > BaseType;
00164
00165 enum { dim = GridType::dimension };
00166 enum { dimworld = GridType::dimensionworld };
00167
00168 typedef typename GridType :: ctype ctype;
00169
00170 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
00171 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
00172 typedef typename GrapeInterface<dim,dimworld>::DUNE_DAT DUNE_DAT;
00173 typedef typename GrapeInterface<dim,dimworld>::F_DATA F_DATA;
00174
00175 public:
00176 typedef GridType MyGridType;
00177
00179 inline GrapeDataDisplay(const GridType &grid, const int myrank = -1);
00180
00182 template <class GridPartType>
00183 inline GrapeDataDisplay(const GridPartType & gridPart, const int myrank = -1);
00184
00186 inline ~GrapeDataDisplay();
00187
00197 template< class VectorType, class IndexSetType >
00198 inline void displayVector ( const std::string name,
00199 const VectorType &data,
00200 const IndexSetType &indexSet,
00201 const int polOrd,
00202 const unsigned int dimRange,
00203 bool continuous = false );
00204
00207 template <class DiscFuncType>
00208 inline void dataDisplay(const DiscFuncType &func, bool vector = false);
00209
00211 inline void display();
00212
00214 template <class DiscFuncType>
00215 inline void addData(const DiscFuncType &func, double time = 0.0, bool vector = false );
00216
00218 template <class DiscFuncType>
00219 inline void addData(const DiscFuncType &func, const DATAINFO * , double time );
00220
00222 template <class DiscFuncType>
00223 inline void addData(const DiscFuncType &func, std::string name , double time , bool vector = false );
00224
00225
00226 bool hasData () { return (vecFdata_.size() > 0); }
00227
00228
00229 std::vector < DUNE_FDATA * > & getFdataVec () { return vecFdata_; }
00230
00231 private:
00241 template<class VectorType, class IndexSetType >
00242 inline void addVector(const std::string name,
00243 const VectorType & data, const IndexSetType & indexSet,
00244 const double time , const int polOrd ,
00245 const int dimRange, bool continuous );
00246
00256 template<class VectorType, class IndexSetType >
00257 inline void addVector(const VectorType & data, const IndexSetType & indexSet,
00258 const DATAINFO * dinf, double time ,
00259 const int polOrd , const int dimRange, bool continuous );
00260
00262 std::vector < DUNE_FDATA * > vecFdata_;
00263
00264 enum { polynomialOrder = 1 };
00265
00266 GrapeLagrangePoints<ctype,dim,dimworld,polynomialOrder> lagrangePoints_;
00267
00268 typedef typename GridType :: template Codim<0> :: Entity EntityCodim0Type;
00269 typedef void evalCoord_t(EntityCodim0Type &, DUNE_FDATA *, const double *, double * );
00270 typedef void evalDof_t (EntityCodim0Type &,int , DUNE_FDATA * , int , double * );
00271
00272 public:
00273
00274 static DUNE_FDATA * createDuneFunc ();
00275
00276 static void deleteDuneFunc (DUNE_FDATA *);
00277 };
00278
00279 template <typename ctype, int dim, int dimworld, int polOrd>
00280 class GrapeLagrangePoints
00281 {
00282 enum { maxPoints = 20 };
00283 enum { numberOfTypes = (dim == 2) ? 2 : 6 };
00284
00285 std::vector < FieldMatrix<ctype,maxPoints,dim> > points_;
00286 public:
00288 GrapeLagrangePoints ()
00289 {
00290 for(int type=0; type<numberOfTypes; type++)
00291 {
00292 FieldMatrix<ctype,maxPoints,dim> coords(0.0);
00293 int nvx = numberOfVertices(type);
00294
00295 for(int i=0; i<nvx; i++)
00296 {
00297 const double * p = getCoordinate(type,i);
00298 for(int j=0; j<dimworld; j++)
00299 {
00300 assert( p );
00301 coords[i][j] = p[j];
00302 }
00303 }
00304 points_.push_back( coords );
00305 }
00306 }
00307
00310 const FieldVector<ctype,dim> &
00311 getPoint (int geomType, int polyOrder , int localNum ) const
00312 {
00313 assert( polOrd == polyOrder );
00314 assert( geomType >= 0 );
00315 assert( geomType < numberOfTypes );
00316 return points_[geomType][localNum];
00317 }
00318
00319 private:
00320 int numberOfVertices( int type )
00321 {
00322 if(type < 2)
00323 return GrapeInterface_two_two::getElementDescription(type)->number_of_vertices;
00324 else
00325 return GrapeInterface_three_three::getElementDescription(type)->number_of_vertices;
00326 }
00327
00328 const double * getCoordinate( int type, int i )
00329 {
00330 if(type < 2)
00331 return GrapeInterface_two_two::getElementDescription(type)->coord[i];
00332 else
00333 return GrapeInterface_three_three::getElementDescription(type)->coord[i];
00334 }
00335 };
00336
00337 }
00338
00339 #include "grape/grapedatadisplay.cc"
00340 #endif