dataDX.hh

Go to the documentation of this file.
1 
6 #ifndef dataDX_hh
7 #define dataDX_hh
8 #include <forward_list>
9 #include <fstream>
10 #include <memory>
11 #include "space/postProcess.hh"
12 #include "space/element.hh"
13 #include "space/formula.hh"
14 #include "function/basis.hh"
15 #include "spaceTraits.hh"
16 
17 namespace concepts {
18  // forward declaration
19  template<class F>
20  class Vector;
21 
22  template<class F>
23  class Formula;
24 
25  template<class F, class G>
26  class ElementFormula;
27 }
28 
29 namespace graphics {
30 
31  using concepts::Real;
32 
33  // forward declartions
34  class VertexList;
35 
36  // ********************************************************** Space traits **
37 
43  template<typename T, typename traits = spaceTraits<T> >
44  struct spcPosCon {
45  static inline uint positionConnection() {
46  return traits::positionConnection();
47  }
48  static inline uint boundary() {
49  return traits::boundaryElements();
50  }
51  };
52 
66  template<typename T>
67  bool spacePosCon(const T& spc) { return spcPosCon<T>::positionConnection(); }
68 
83  template<typename T>
84  bool spaceBoundary(const T& spc) { return spcPosCon<T>::boundary(); }
85 
86  // **************************************************************** DataDX **
87 
118  template<class F>
119  class DataDX {
120  public:
128  DataDX(concepts::Space<F>& spc, const std::string filename,
129  bool pc = false, bool boundary = false, const uint dim = 2);
131  DataDX(const DataDX<F>& dx);
133 
136 
141  void operator()(const concepts::Vector<Real>& solution,
142  const std::string& name);
147  void operator()(const concepts::Formula<Real>& frm, const std::string& name);
153  const std::string& name);
154  private:
157 
159  std::string filename_;
160 
163 
165  uint countp_;
166 
168  uint countq_;
169 
171  bool pc_;
172 
174  std::forward_list<std::string> names_;
175 
177  std::unique_ptr<VertexList> vtxList_;
178  };
179 
186  template<typename T>
187  DataDX<Real> drawDataDX(T& spc, const std::string filename,
188  const uint dim = 2) {
189  return DataDX<Real>(spc, filename, spacePosCon(spc),
190  spaceBoundary(spc), dim);
191  }
192 
193  // ********************************************************** DataDXCounts **
194 
209 
210  public:
219  DataDXCounts(VertexList* vtxList = 0);
220 
222  void add(uint a) { counts_ += a; }
223 
225  uint counts() const;
226 
227  virtual void operator() (const concepts::Element<Real>& elm);
228  virtual void operator() (const concepts::Cell&) {}
229  private:
231  uint counts_;
232 
235  };
236 
237  // ***************************************************** DataDXCoordinates **
238 
252 
253  public:
264  DataDXCoordinates(std::ostream& os, const uint count,
265  VertexList* vtxList = 0, const uint dim = 2);
267 
269  void add(uint a) { counts_ += a; }
270 
272  void inc() { cntCoords_++; }
273 
277  uint counts() const;
278 
279  virtual void operator() (const concepts::Element<Real>& elm);
280  virtual void operator() (const concepts::Cell&) {}
281 
283  void write(const float x) const;
284  private:
286  std::ostream& os_;
287 
290 
292  const uint dim_;
293 
295  uint counts_;
296 
299  };
300 
301  // ***************************************************** DataDXConnections **
302 
317 
318  public:
326  DataDXConnections(std::ostream& os, const uint count,
327  VertexList* vtxList = 0, const uint dim = 2);
329  virtual void operator() (const concepts::Element<Real>& elm);
330  virtual void operator() (const concepts::Cell&) {}
331 
333  void add(uint a) { counts_ += a; }
334 
338  uint counts() const { return counts_; }
339 
341  void write(const int x) const;
342  private:
344  std::ostream& os_;
345 
347  uint counts_;
348 
350  const uint dim_;
351  };
352 
353  // ************************************************************ DataDXData **
354 
367  class DataDXData : public concepts::CellPostprocess<Real> {
368 
369  public:
378  DataDXData(std::ostream& os, const concepts::Vector<Real>& solution,
379  const uint count, const std::string& name,
380  VertexList* vtxList = 0);
381 
389  DataDXData(std::ostream& os, const concepts::Formula<Real>& frm,
390  const uint count, const std::string& name,
391  VertexList* vtxList = 0);
392 
400  DataDXData(std::ostream& os, const concepts::ElementFormula<Real>& frm,
401  const uint count, const std::string& name,
402  VertexList* vtxList = 0);
403 
404  virtual ~DataDXData();
405  virtual void operator() (const concepts::Element<Real>& elm)
407  virtual void operator() (const concepts::Cell&) {}
408 
409  const concepts::Formula<Real>* formula() const { return frm_.get(); }
410  const concepts::Array<Real>& coeff() const { return coeff_; }
412  { return efrm_; }
413 
415  void write(const float x) const;
416  private:
418  std::ostream& os_;
419 
422 
424  std::unique_ptr<const concepts::Formula<Real> > frm_;
425 
428 
431 
434 
437 
439  std::string name_;
440 
442  uint pc_;
443 
446 
449  };
450 
451 } // namespace graphics
452 
453 #endif // dataDX_hh
const concepts::ElementFormula< Real > * efrm_
Formula to plot (given elementwise)
Definition: dataDX.hh:427
Draws a picture of data in DX format and stores the result in a file.
Definition: dataDX.hh:119
std::ostream & os_
Output stream.
Definition: dataDX.hh:418
void operator()(const concepts::ElementFormula< F > &frm, const std::string &name)
Application operator.
std::string filename_
Filename.
Definition: dataDX.hh:159
bool pc_
Data correspond to positions (false) or connections (true)
Definition: dataDX.hh:171
Graphics in OpenDX - point counter.
Definition: dataDX.hh:208
virtual void operator()(const concepts::Element< Real > &elm)
std::ostream & os_
Output stream.
Definition: dataDX.hh:286
virtual void operator()(const concepts::Element< Real > &elm)
DataDX< F > & operator=(const DataDX< F > &dx)
Assignement operator.
const uint dim_
Dimension.
Definition: dataDX.hh:350
void inc()
Increments cntCoords_ by 1.
Definition: dataDX.hh:272
Abstract class for a space.
const concepts::Array< Real > & coeff() const
Definition: dataDX.hh:410
uint counts_
Counts the number of non-corner points in former elements.
Definition: dataDX.hh:347
static uint positionConnection()
Definition: dataDX.hh:45
bool spacePosCon(const T &spc)
Trampoline function for the class spcPosCon.
Definition: dataDX.hh:67
concepts::Array< Real > vertexSol_
Solution in the vertices in the list of vertices.
Definition: dataDX.hh:436
uint countp_
Number of points in the file.
Definition: dataDX.hh:165
const concepts::ElementFormula< Real > * elementFormula() const
Definition: dataDX.hh:411
Global Postprocessing.
Definition: postProcess.hh:70
Graphics in OpenDX - data.
Definition: dataDX.hh:367
A cell in a mesh consist of topological information (neighbours, connectivity, orientation) and geome...
Definition: cell.hh:39
void write(const float x) const
Writes a float in binary format to the output stream.
DataDXCounts(VertexList *vtxList=0)
Constructor.
DataDX< Real > drawDataDX(T &spc, const std::string filename, const uint dim=2)
Trampoline function to create a DataDX.
Definition: dataDX.hh:187
concepts::Space< F > * spc_
The space.
Definition: dataDX.hh:156
void add(uint a)
Increments the counter for the quads or cubes by a.
Definition: dataDX.hh:333
void write(const float x) const
Writes a float in binary format to the output stream.
void add(uint a)
Increments the counter for the points by a.
Definition: dataDX.hh:222
std::forward_list< std::string > names_
Names of the data fields.
Definition: dataDX.hh:174
Graphics in OpenDX - connections.
Definition: dataDX.hh:316
VertexList * vtxList_
List of the vertices.
Definition: dataDX.hh:234
void write(const int x) const
Writes integer in binary format to the output stream.
concepts::GlobalPostprocess< F > postProcess_
Post processor.
Definition: dataDX.hh:162
VertexList * vtxList_
List of vertices.
Definition: dataDX.hh:445
concepts::Array< Real > coeff_
Elementwise coefficients of the shape functions.
Definition: dataDX.hh:430
void add(uint a)
Increments the counter for the quads or cubes by a.
Definition: dataDX.hh:269
uint counts() const
Returns the number of quads or cubes which have to be built with connections.
void operator()(const concepts::Formula< Real > &frm, const std::string &name)
Application operator.
DataDXData(std::ostream &os, const concepts::Vector< Real > &solution, const uint count, const std::string &name, VertexList *vtxList=0)
Constructor.
DataDX(const DataDX< F > &dx)
Copy constructor.
bool spaceBoundary(const T &spc)
Trampoline function for the class spcPosCon.
Definition: dataDX.hh:84
concepts::Array< Real > shpfnc_
Values of the shape functions.
Definition: dataDX.hh:433
Graphics.
Definition: basis.hh:33
DataDXData(std::ostream &os, const concepts::ElementFormula< Real > &frm, const uint count, const std::string &name, VertexList *vtxList=0)
Constructor.
VertexList * vtxList_
List of the vertices.
Definition: dataDX.hh:289
std::unique_ptr< const concepts::Formula< Real > > frm_
Formula to plot.
Definition: dataDX.hh:424
std::ostream & os_
Output stream.
Definition: dataDX.hh:344
uint cntCoords_
Number of coordinates written so far, only for internal use.
Definition: dataDX.hh:298
std::string name_
Name of this data component.
Definition: dataDX.hh:439
uint countq_
Number of quad in the file.
Definition: dataDX.hh:168
uint pc_
Data correspond to positions (0) or connections (1)
Definition: dataDX.hh:442
virtual void operator()(const concepts::Element< Real > &elm)
DataDX(concepts::Space< F > &spc, const std::string filename, bool pc=false, bool boundary=false, const uint dim=2)
Constructor.
Class containing a list of vertices.
Definition: vertexList.hh:97
Determines the traits class belonging to a space by a default template parameter.
Definition: dataDX.hh:44
static uint boundary()
Definition: dataDX.hh:48
Graphics in OpenDX - coordinates.
Definition: dataDX.hh:251
uint counts() const
Returns the number of points.
const uint dim_
Dimension of the coordinates to be saved.
Definition: dataDX.hh:292
DataDXData(std::ostream &os, const concepts::Formula< Real > &frm, const uint count, const std::string &name, VertexList *vtxList=0)
Constructor.
concepts::Array< Real > vtxData_
Data vector of data belonging to the vertex list.
Definition: dataDX.hh:448
Exception class to express a missing feature.
Definition: exceptions.hh:206
uint counts() const
Returns the number of quads or cubes which have to be built with connections.
Definition: dataDX.hh:338
DataDXConnections(std::ostream &os, const uint count, VertexList *vtxList=0, const uint dim=2)
Constructor.
void operator()(const concepts::Vector< Real > &solution, const std::string &name)
Application operator.
std::unique_ptr< VertexList > vtxList_
List of vertices.
Definition: dataDX.hh:177
virtual void operator()(const concepts::Element< Real > &elm)
uint counts_
Counter for the number of points.
Definition: dataDX.hh:231
const concepts::Formula< Real > * formula() const
Definition: dataDX.hh:409
const concepts::Vector< Real > * solution_
Vector of the variable to plot.
Definition: dataDX.hh:421
Abstract class for per cell postprocessing.
Definition: postProcess.hh:38
DataDXCoordinates(std::ostream &os, const uint count, VertexList *vtxList=0, const uint dim=2)
Constructor.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
uint counts_
Number of quads or cubes which have to be built with connections.
Definition: dataDX.hh:295
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich