dataMatlab.hh

Go to the documentation of this file.
1 
6 #ifndef graphDataMatlab_hh
7 #define graphDataMatlab_hh
8 
9 #include <string>
10 #include <fstream>
11 #include <sstream>
12 #include <memory>
13 #include <vector>
14 #include "basics/typedefs.hh"
16 #include "basics/exceptions.hh"
18 #include "toolbox/dynArray.hh"
19 #include "function/vector.hh"
20 #include "geometry/formula.hh"
21 #include "space/postProcess.hh"
22 #include "space/function.hh"
23 #include "basis.hh"
24 
25 // debugging
26 #include "basics/debug.hh"
27 
28 #define Matlab2Constr_D 0
29 
30 namespace concepts {
31  template<class F>
32  class Vector;
33 }
34 
35 namespace graphics {
36 
37  using concepts::Real;
38  using concepts::Real2d;
39 
40  // ******************************************************** DataMatlabCell **
41 
46  public:
56  DataMatlabCell(std::ofstream* ofsmsh, std::ofstream* ofs1,
57  std::ofstream* ofs2, std::ofstream* ofs3,
58  uint dim, Real scl);
59 
65  DataMatlabCell(std::ofstream* ofs, uint dim, Real scl);
66 
69  virtual void operator()(const concepts::Element<Real>& elm)
72  virtual void operator()(const concepts::Cell& cell)
74 
76  void write(std::ofstream** ofsmsh, std::ofstream** ofs1,
77  std::ofstream** ofs2, std::ofstream** ofs3);
79  void setVec(const concepts::Vector<Real>* sol);
81  const concepts::Array<Real>& coeff() const {return coeff_;}
83  const concepts::Vector<Real>* solution() const {return sol_;}
84  Real offset() const {return offset_;}
85  Real range() const {return range_;}
87  uint& count() {return cnt_;}
88  uint dim() const {return dim_;}
89  Real scale() const {return scl_;}
91  private:
93  uint dim_;
97  std::ofstream *ofsmsh_, *ofs1_, *ofs2_, *ofs3_;
103  uint cnt_;
106 
108  std::unique_ptr<concepts::DynArray<uint> > map_;
109  };
110 
111  // ************************************************************ DataMatlab **
112 
131  class DataMatlab {
132  public:
139  DataMatlab(concepts::Space<Real>& spc, const std::string filename,
140  uint dim = 2, Real scl = 1.0);
142 
147 
148  private:
150  void createStreams_(std::string filename);
153 
155  uint dim_;
157  uint cnt_;
159  std::unique_ptr<std::ofstream> ofsmsh_;
161  std::unique_ptr<std::ofstream> ofs1_, ofs2_, ofs3_;
162 
165  std::unique_ptr<DataMatlabCell> mtlb_;
166  };
167 
168 } // namespace graphics
169 
170 #endif // graphDataMatlab_hh
void operator()(const concepts::Vector< Real > &sol)
Application operator.
DataMatlabCell(std::ofstream *ofs, uint dim, Real scl)
Constructor.
uint dim_
Spatial dimension of the space.
Definition: dataMatlab.hh:93
Real offset_
Offset and range for color.
Definition: dataMatlab.hh:95
const concepts::Array< Real > & coeff() const
Returns the coefficients of the elements shape functions.
Definition: dataMatlab.hh:81
concepts::GlobalPostprocess< Real > postProcess_
Post processor.
Definition: dataMatlab.hh:164
Point< Real, 2 > Real2d
A cell in a mesh consist of topological information (neighbours, connectivity, orientation) and geome...
Definition: cell.hh:39
DataMatlab(concepts::Space< Real > &spc, const std::string filename, uint dim=2, Real scl=1.0)
Constructor.
virtual void operator()(const concepts::Cell &cell)
not operational
std::unique_ptr< std::ofstream > ofsmsh_
Stream for connections.
Definition: dataMatlab.hh:159
std::ofstream * ofs1_
Definition: dataMatlab.hh:97
concepts::Array< Real > coeff_
Elementwise coefficients of the shape functions.
Definition: dataMatlab.hh:99
uint cnt_
Number of vectors written to the files.
Definition: dataMatlab.hh:157
void closeStreams_()
Closes the streams.
Writes the data which describe the elements to the given streams.
Definition: dataMatlab.hh:45
const concepts::Vector< Real > * sol_
Vector of the variable to plot.
Definition: dataMatlab.hh:101
Graphics.
Definition: basis.hh:33
void setVec(const concepts::Vector< Real > *sol)
Sets the vector of the variable to plot.
Draws a picture of data in Matlab format and stores the result in files.
Definition: dataMatlab.hh:131
virtual void operator()(const concepts::Element< Real > &elm)
Output of the mesh and vector data of the element.
std::ofstream * ofs3_
Definition: dataMatlab.hh:97
Real scl_
Data scaling factor.
Definition: dataMatlab.hh:105
uint & count()
Number of points written to the files, used for mesh representation.
Definition: dataMatlab.hh:87
std::unique_ptr< std::ofstream > ofs2_
Definition: dataMatlab.hh:161
std::ofstream * ofsmsh_
Streams to write the data to.
Definition: dataMatlab.hh:97
std::unique_ptr< std::ofstream > ofs3_
Definition: dataMatlab.hh:161
const concepts::Vector< Real > * solution() const
Returns pointer to vector to plot.
Definition: dataMatlab.hh:83
void write(std::ofstream **ofsmsh, std::ofstream **ofs1, std::ofstream **ofs2, std::ofstream **ofs3)
Returns the streams to write the data to.
Exception class to express a missing feature.
Definition: exceptions.hh:206
std::unique_ptr< std::ofstream > ofs1_
Streams for coordinates.
Definition: dataMatlab.hh:161
std::ofstream * ofs2_
Definition: dataMatlab.hh:97
std::unique_ptr< concepts::DynArray< uint > > map_
Map for vertices of the elements.
Definition: dataMatlab.hh:108
void createStreams_(std::string filename)
Create the streams.
concepts::DynArray< uint > & map()
Definition: dataMatlab.hh:90
DataMatlabCell(std::ofstream *ofsmsh, std::ofstream *ofs1, std::ofstream *ofs2, std::ofstream *ofs3, uint dim, Real scl)
Constructor.
Abstract class for per cell postprocessing.
Definition: postProcess.hh:38
std::unique_ptr< DataMatlabCell > mtlb_
Definition: dataMatlab.hh:165
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
uint dim_
Spatial dimension of the space.
Definition: dataMatlab.hh:155
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich