1 #ifndef DUNE_GRAPE_DATA_DISPLAY_HH
2 #define DUNE_GRAPE_DATA_DISPLAY_HH
23 template<
class ctype,
int dim,
int dimworld,
int polOrd >
24 class GrapeLagrangePoints;
31 template<
class GV,
int dimR,
int polOrd >
36 static const int dimDomain = GridView::Grid::dimension;
39 typedef FieldVector< typename GridView::Grid::ctype, dimDomain >
DomainVector;
40 typedef FieldVector< typename GridView::Grid::ctype, dimRange >
RangeVector;
42 typedef typename GridView::template Codim< 0 >::Entity
Entity;
51 virtual std::string
name ()
const = 0;
60 template <
class EvalImpTraits>
61 struct EvalFunctionData
63 typedef typename EvalImpTraits :: GridType GridType;
64 typedef typename EvalImpTraits :: EvalImp EvalImp;
66 typedef typename GridType :: template Codim<0>
:: Entity EntityType;
67 enum { dim = GridType::dimension };
68 enum { dimworld = GridType::dimensionworld };
70 typedef typename GridType :: ctype ctype;
72 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
73 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
76 inline static void evalCoordNow (
const EntityType &en, DUNE_FDATA *fdata,
const double *coord,
double * val)
78 EvalImp::evalCoordNow(en,fdata,coord,val);
82 inline static void evalDofNow (
const EntityType &en,
int geomType, DUNE_FDATA *fdata ,
int localNum,
double * val)
84 EvalImp::evalDofNow(en,geomType,fdata,localNum,val);
88 inline static void evalCoord (DUNE_ELEM *he, DUNE_FDATA *df,
89 const double *coord,
double * val);
92 inline static void evalDof (DUNE_ELEM *he, DUNE_FDATA *df,
int localNum,
double * val);
95 inline static void getMinMaxValues(DUNE_FDATA *df,
double*
min,
double*
max );
98 template <
class Gr
idImp,
class DiscreteFunctionType>
99 struct EvalDiscreteFunctions;
101 template <
class Gr
idImp,
class DiscreteFunctionType>
102 struct EvalDiscreteFunctionsTraits
104 typedef GridImp GridType;
105 typedef EvalDiscreteFunctions <GridImp, DiscreteFunctionType > EvalImp;
108 template <
class Gr
idImp,
class DiscreteFunctionType>
109 struct EvalDiscreteFunctions
110 :
public EvalFunctionData< EvalDiscreteFunctionsTraits <GridImp, DiscreteFunctionType > >
112 typedef GridImp GridType;
113 typedef typename GridType :: template Codim<0>
:: Entity EntityType;
114 enum { dim = GridType::dimension };
115 enum { dimworld = GridType::dimensionworld };
117 typedef typename GridType :: ctype ctype;
119 typedef typename DiscreteFunctionType :: LocalFunctionType LocalFunctionType;
120 typedef typename DiscreteFunctionType :: DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
122 typedef typename DiscreteFunctionSpaceType :: RangeType RangeType;
123 typedef typename DiscreteFunctionSpaceType :: DomainType DomainType;
125 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
126 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
129 inline static void evalCoordNow (
const EntityType &en, DUNE_FDATA *fdata,
const double *coord,
double * val);
132 inline static void evalDofNow (
const EntityType &en,
int geomType, DUNE_FDATA *fdata ,
int localNum,
double * val);
135 inline static void evalScalar (
const EntityType &en,
int geomType,
136 DiscreteFunctionType & func, LocalFunctionType &lf,
137 const int * comp ,
int localNum,
double * val);
140 inline static void evalVector (
const EntityType &en,
int geomType,
141 DiscreteFunctionType & func, LocalFunctionType &lf,
142 const int * comp,
int vend,
int localNum,
double * val);
145 inline static void calcMinMax(DUNE_FDATA * df);
153 template<
class GV,
int dimR,
int polOrd >
154 struct EvalGrapeFunction;
156 template<
class GV,
int dimR,
int polOrd >
157 struct EvalGrapeFunctionTraits
159 typedef typename GV::Grid GridType;
160 typedef EvalGrapeFunction< GV, dimR, polOrd > EvalImp;
163 template<
class GV,
int dimR,
int polOrd >
164 struct EvalGrapeFunction
165 :
public EvalFunctionData< EvalGrapeFunctionTraits< GV, dimR, polOrd > >
173 static const int dimWorld = GridView::Grid::dimensionworld;
178 typedef typename GridView::template Codim< 0 >::Entity
Entity;
180 typedef typename GrapeInterface< dimDomain, dimWorld >::DUNE_ELEM DUNE_ELEM;
181 typedef typename GrapeInterface< dimDomain, dimWorld >::DUNE_FDATA DUNE_FDATA;
184 static void evalCoordNow (
const Entity &entity, DUNE_FDATA *fdata,
const double *coord,
double *val );
187 static void evalDofNow (
const Entity &entity,
int geomType, DUNE_FDATA *fdata,
int localNum,
double *val );
190 static void calcMinMax ( DUNE_FDATA *fdata );
198 template <
class Gr
idImp,
class VectorType,
class IndexSetImp >
199 struct EvalVectorData;
201 template <
class Gr
idImp,
class VectorType ,
class IndexSetImp >
202 struct EvalVectorDataTraits
204 typedef GridImp GridType;
205 typedef EvalVectorData <GridImp, VectorType, IndexSetImp > EvalImp;
208 template <
class Gr
idImp,
class VectorType,
class IndexSetImp >
209 struct EvalVectorData
210 :
public EvalFunctionData< EvalVectorDataTraits <GridImp, VectorType, IndexSetImp > >
212 typedef GridImp GridType;
213 typedef typename GridType :: template Codim<0>
:: Entity EntityType;
214 enum { dim = GridType::dimension };
215 enum { dimworld = GridType::dimensionworld };
217 typedef typename GridType :: ctype ctype;
219 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
220 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
223 inline static void evalCoordNow (
const EntityType &en, DUNE_FDATA *fdata,
const double *coord,
double * val);
226 inline static void evalDofNow (
const EntityType &en,
int geomType, DUNE_FDATA *fdata ,
int localNum,
double * val);
229 static void evalVectorLinear (
const EntityType &entity,
int geomType,
230 VectorType & func,
const IndexSetImp &indexSet,
231 const int *comp,
int vend,
int localNum,
double *val );
234 static void evalVectorConst (
const EntityType &entity,
int geomType,
235 VectorType & func,
const IndexSetImp &indexSet,
236 const int * comp,
int vend,
int localNum,
double * val);
239 inline static void calcMinMax(DUNE_FDATA * df);
246 template<
class Gr
idType>
253 enum { dim = GridType::dimension };
254 enum { dimworld = GridType::dimensionworld };
256 typedef typename GridType :: ctype ctype;
259 typedef typename GrapeInterface<dim,dimworld>::DUNE_ELEM DUNE_ELEM;
260 typedef typename GrapeInterface<dim,dimworld>::DUNE_FDATA DUNE_FDATA;
261 typedef typename GrapeInterface<dim,dimworld>::DUNE_DAT DUNE_DAT;
262 typedef typename GrapeInterface<dim,dimworld>::F_DATA F_DATA;
272 template <
class Gr
idPartType>
273 inline GrapeDataDisplay(
const GridPartType & gridPart,
const int myrank = -1);
287 template<
class VectorType,
class IndexSetType >
289 const VectorType &data,
290 const IndexSetType &indexSet,
292 const unsigned int dimRange,
293 bool continuous =
false );
297 template <
class DiscFuncType>
298 inline void dataDisplay(
const DiscFuncType &func,
bool vector =
false);
304 template <
class DiscFuncType>
305 inline void addData(
const DiscFuncType &func,
double time = 0.0,
bool vector =
false );
308 template <
class DiscFuncType>
309 inline void addData(
const DiscFuncType &func, std::string name ,
double time ,
bool vector =
false );
311 template<
class GV,
int dimR,
int polOrd >
316 template <
class DiscFuncType>
317 inline void addData(
const DiscFuncType &func,
const DATAINFO * ,
double time );
320 bool hasData () {
return (vecFdata_.size() > 0); }
323 std::vector < DUNE_FDATA * > & getFdataVec () {
return vecFdata_; }
334 template<
class VectorType,
class IndexSetType >
335 inline void addVector(
const std::string name,
336 const VectorType & data,
const IndexSetType & indexSet,
337 const double time ,
const int polOrd ,
338 const int dimRange,
bool continuous );
350 template<
class VectorType,
class IndexSetType >
351 inline void addVector(
const VectorType & data,
const IndexSetType & indexSet,
352 const DATAINFO * dinf,
double time ,
353 const int polOrd ,
const int dimRange,
bool continuous );
357 std::vector < DUNE_FDATA * > vecFdata_;
359 enum { polynomialOrder = 1 };
361 GrapeLagrangePoints<ctype,dim,dimworld,polynomialOrder> lagrangePoints_;
363 typedef typename GridType :: template Codim<0>
:: Entity EntityCodim0Type;
364 typedef void evalCoord_t(EntityCodim0Type &, DUNE_FDATA *,
const double *,
double * );
365 typedef void evalDof_t (EntityCodim0Type &,
int , DUNE_FDATA * ,
int ,
double * );
369 static DUNE_FDATA * createDuneFunc ();
371 static void deleteDuneFunc (DUNE_FDATA *);
375 template <
typename ctype,
int dim,
int dimworld,
int polOrd>
379 enum { maxPoints = 20 };
380 enum { numberOfTypes = (dim == 2) ? 2 : 6 };
382 std::vector < FieldMatrix<ctype,maxPoints,dim> > points_;
388 GrapeInterface_two_two::setupReferenceElements();
389 GrapeInterface_two_three::setupReferenceElements();
390 GrapeInterface_three_three::setupReferenceElements();
392 for(
int type=0; type<numberOfTypes; ++type)
394 FieldMatrix<ctype,maxPoints,dim> coords( ctype(0) );
395 const int nvx = numberOfVertices(type);
397 for(
int i=0; i<nvx; ++i)
399 const double * p = getCoordinate(type,i);
400 for(
int j=0; j<dimworld; ++j)
406 points_.push_back( coords );
412 const FieldVector<ctype,dim> &
413 getPoint (
const int geomType,
const int polyOrder ,
const int localNum )
const
415 assert( polOrd == polyOrder );
416 assert( geomType >= 0 );
417 assert( geomType < numberOfTypes );
418 return points_[geomType][localNum];
422 static int numberOfVertices(
const int type )
424 if(type < GrapeInterface_three_three::gr_tetrahedron)
425 return GrapeInterface_two_two::getElementDescription(type)->number_of_vertices;
427 return GrapeInterface_three_three::getElementDescription(type)->number_of_vertices;
430 static const double * getCoordinate(
const int type,
const int i )
432 if(type < GrapeInterface_three_three::gr_tetrahedron)
434 return GrapeInterface_two_two::getElementDescription(type)->coord[i];
437 return GrapeInterface_three_three::getElementDescription(type)->coord[i];