dune-fem 2.12-git
Loading...
Searching...
No Matches
readiotupledata.cc
Go to the documentation of this file.
1//**************************************************************
2// (C) written and directecd by Robert Kloefkorn
3//**************************************************************
4#ifndef DATADISP_READIOTUPLE_CC
5#define DATADISP_READIOTUPLE_CC
6
7// needed in readiotparams.cc
8#define USE_GRAPE_DISPLAY
9
10//- system includes
11#include <stack>
12
13//- include grape io stuff
17
19typedef Dune::GridSelector::GridType GR_GridType;
20
22typedef GrapeDataDisplay<GR_GridType> GrapeDispType;
23
26
29
30template <class T>
31inline void deleteObjects(std::stack<T *> & stack);
32
34{
35 std::cerr << msg << std::endl;
36 std::cerr.flush();
37 exit(EXIT_FAILURE);
38}
39
40inline GrapeDispType * readTupleData(const char * path, const char * filename,
41 double & time , int n,
42 int timestep, int myRank, int mySize,
43 INFO* info)
44{
45 // check whether we use a fixed mesh
46 const bool fixedMesh = (info->fix_mesh == 1) ? true : false;
47
48 // the grid is new if not a fixed mesh or the stack is empty
49 const bool newGrid = ( ! fixedMesh || gridStack.empty() );
50
51 // init grid
52 GR_GridType * grid = ( ! newGrid ) ? gridStack.top() : 0;
53
54 assert(filename);
55 std::string fn (filename);
56 DATAINFO * dinf = info[n].datinf;
57
58 Fem::IOTuple<GR_DiscFuncType>::ReturnType* tup =
59 Fem::IOTuple<GR_DiscFuncType>::input(grid,time,myRank,mySize,path,fn);
60 std::cout << "Finished reading grid" << std::endl;
61
62 // push all new grids to grid stack
63 if( newGrid ) gridStack.push(grid);
64
65 GrapeDispType * disp = new GrapeDispType ( *grid, myRank );
66 dispStack.push(disp);
67
68 // discrete functions of non-valid data are removed
69 Fem::IOTuple<GR_DiscFuncType>::addToDisplayOrRemove(*disp,dinf,time,*tup);
70
71 //Element<0> :: get( *tup );
72 // *(Element<0> :: get( *tup ))
73 // do some post processing
74 postProcessing(*disp,*grid,time,timestep, *tup);
75 return disp;
76}
77
78// setup the hole data tree for grape
79inline INFO * readData(INFO * info , const char * path, int i_start, int i_end,
80 int i_delta, int n, double timestep, int numProcs)
81{
82 double t_start = 1e308;
83 double t_end = -t_start, t_act = 0.0;
84 typedef CombinedGrapeDisplay < GrapeDispType > CombinedDisplayType;
85
86 CombinedGrapeDisplay < GrapeDispType > * comdisp = new CombinedDisplayType ();
87
88 int ntime, n_step = 0;
89
90 for (ntime = i_start; ntime <= i_end; ntime += i_delta)
91 {
92 printf("timestep = %d | last timestep = %d | stepsize = %d\n", ntime, i_end, i_delta);
93 {
94 int anzProcs = numProcs;
95
96 for(int proc=0; proc<anzProcs; ++proc)
97 {
98 assert(path || numProcs <= 1);
99 GrapeDispType *newdisp = 0;
100
101 int anz = n; // (n > 0) ? n : 1;
102 for(int i=0; i<anz; ++i)
103 {
104 // use standard procedure to create path name
105 std::string newpath =
106 Fem::IOInterface::createRecoverPath(path,proc,info[i].name,ntime);
107
108 newdisp = readTupleData(newpath.c_str(), info[i].name,
109 t_act , i , ntime, proc, anzProcs, info);
110
111 if( comdisp )
112 {
113 assert(newdisp != 0);
114 assert( comdisp );
115 comdisp->addDisplay( *newdisp );
116 }
117 }
118 assert(newdisp);
119 newdisp->addMyMeshToTimeScene(info[0].tsc,t_act,proc);
120 }
121
122 if( comdisp )
123 {
124 // this is the combine object, which is put to the last time scene
125 comdisp->addMyMeshToGlobalTimeScene(t_act,0);
126 }
127 }
128 printf("actual time: %f (timestep size: %e)\n\n",t_act,timestep);
129
130
131 if (ntime == i_start) t_start = t_end = t_act;
132 t_start = std::min(t_start, t_act);
133 t_end = std::max(t_end, t_act);
134
135 if (timestep > 0) t_act += timestep*i_delta;
136 n_step++;
137 }
138 return info;
139}
140
141template <class T>
142inline void deleteObjects(std::stack<T *> & stack)
143{
144 while(! stack.empty() )
145 {
146 T * obj = stack.top();
147 stack.pop();
148 delete obj;
149 }
150 return;
151}
152
153inline void deleteAllObjects()
154{
157 return ;
158}
159#endif
const char * name()
void postProcessing(const GrapeDispType &disp, const GR_GridType &grid, const double time, const IOTupleType &data)
Definition programtemplate.cc:25
void dataDispErrorExit(std::string msg)
Definition readiotupledata.cc:33
Dune::GridSelector::GridType GR_GridType
type of used grid
Definition readiotupledata.cc:19
static std::stack< GrapeDispType * > dispStack
Definition readiotupledata.cc:28
void deleteAllObjects()
Definition readiotupledata.cc:153
static std::stack< GR_GridType * > gridStack
Definition readiotupledata.cc:27
void deleteObjects(std::stack< T * > &stack)
Definition readiotupledata.cc:142
INFO * readData(INFO *info, const char *path, int i_start, int i_end, int i_delta, int n, double timestep, int numProcs)
Definition readiotupledata.cc:79
GrapeDispType * readTupleData(const char *path, const char *filename, double &time, int n, int timestep, int myRank, int mySize, INFO *info)
Definition readiotupledata.cc:40
GrapeDataDisplay< GR_GridType > GrapeDispType
type of GrapeDisplay
Definition readiotupledata.cc:22
GR_InputType GR_DiscFuncType
type of discrete function tuple
Definition readiotupledata.cc:25
InTupleType GR_InputType
Definition converttemplate.cc:20
std::string path
Definition readioparams.cc:156
Definition grcommon.hh:19
Definition grcommon.hh:31
int fix_mesh
Definition grcommon.hh:32
const char * name
Definition grcommon.hh:33
DATAINFO * datinf
Definition grcommon.hh:34
T c_str(T... args)
T empty(T... args)
T endl(T... args)
T max(T... args)
T min(T... args)
T pop(T... args)
T top(T... args)