dataGnuplot.hh

Go to the documentation of this file.
1 
6 #ifndef graphDataGnuplot_hh
7 #define graphDataGnuplot_hh
8 
9 #include <string>
10 #include <fstream>
11 #include <memory>
12 #include "basics/typedefs.hh"
14 #include "basics/exceptions.hh"
15 #include "space/postProcess.hh"
16 #include "space/formula.hh"
17 #include "space/function.hh"
18 #include "function/vector.hh"
19 
20 
21 namespace concepts {
22  // forward declaration
23  template<class F>
24  class Formula;
25 
26  template<class F, class G>
27  class ElementFormula;
28 }
29 
30 namespace graphics {
31  using concepts::Real;
32 
33  // ******************************************************* DataGnuplotCell **
34 
38  template<typename F>
40  public:
47  DataGnuplotCell(std::ofstream* ofs,
48  const concepts::Vector<Real>& solution,
49  const concepts::ElementFunction<Real>* fun = 0);
54  DataGnuplotCell(std::ofstream* ofs, const concepts::Formula<Real>& frm,
55  const concepts::ElementFunction<Real>* fun = 0);
60  DataGnuplotCell(std::ofstream* ofs,
61  const concepts::ElementFormula<F>& frm,
62  const concepts::ElementFunction<Real>* fun = 0);
63  virtual ~DataGnuplotCell();
64  virtual void operator() (const concepts::Element<F>& elm)
66  virtual void operator() (const concepts::Cell& cell)
69  std::ofstream* write() { return ofs_; }
71  const concepts::Array<Real>& coeff() const { return coeff_; }
73  const concepts::Formula<Real>* formula() const { return frm_.get(); }
76  return frmElm_;
77  }
80  return fun_;
81  }
82  private:
84  std::ofstream* ofs_;
90  std::unique_ptr<const concepts::Formula<Real> > frm_;
95  };
96 
97  // *********************************************************** DataGnuplot **
98 
108  template<typename T, typename S>
109  void drawDataGnuplot(T& msh_spc, std::string filename, const S& sol,
110  const concepts::ElementFunction<Real>* fun = 0) {
111  std::ofstream ofs(filename.c_str());
112  concepts::GlobalPostprocess<Real> postProcess(msh_spc);
113  DataGnuplotCell<Real> gnu(&ofs, sol, fun);
114  postProcess(gnu);
115  }
116 
117 } // namespace graphics
118 
119 #endif // graphDataGnuplot_hh
DataGnuplotCell(std::ofstream *ofs, const concepts::Vector< Real > &solution, const concepts::ElementFunction< Real > *fun=0)
Constructor.
An abstract class for an element of a space.
Definition: exceptions.hh:15
const concepts::Array< Real > & coeff() const
Returns the coefficients of the elements shape functions.
Definition: dataGnuplot.hh:71
An abstract class for a function in a FE space.
std::unique_ptr< const concepts::Formula< Real > > frm_
Formula.
Definition: dataGnuplot.hh:90
A cell in a mesh consist of topological information (neighbours, connectivity, orientation) and geome...
Definition: cell.hh:39
DataGnuplotCell(std::ofstream *ofs, const concepts::Formula< Real > &frm, const concepts::ElementFunction< Real > *fun=0)
Constructor.
std::ofstream * write()
Returns the stream to write the data to.
Definition: dataGnuplot.hh:69
const concepts::Vector< Real > * solution_
Vector of the variable to plot.
Definition: dataGnuplot.hh:88
DataGnuplotCell(std::ofstream *ofs, const concepts::ElementFormula< F > &frm, const concepts::ElementFunction< Real > *fun=0)
Constructor.
Writes the data which describe the elements to the given streams.
Definition: dataGnuplot.hh:39
const concepts::ElementFunction< F > * fun_
Function of the solution.
Definition: dataGnuplot.hh:94
void drawDataGnuplot(T &msh_spc, std::string filename, const S &sol, const concepts::ElementFunction< Real > *fun=0)
Creates a data file for viewing the data with Gnuplot using DataGnuplotCell.
Definition: dataGnuplot.hh:109
const concepts::ElementFunction< F > * elementFunction() const
Returns the function of the solution.
Definition: dataGnuplot.hh:79
Graphics.
Definition: basis.hh:33
concepts::Array< Real > coeff_
Elementwise coefficients of the shape functions.
Definition: dataGnuplot.hh:86
const concepts::ElementFormula< F > * frmElm_
Formula (given elementwise)
Definition: dataGnuplot.hh:92
const concepts::Formula< Real > * formula() const
Returns the formula to plot.
Definition: dataGnuplot.hh:73
Exception class to express a missing feature.
Definition: exceptions.hh:206
const concepts::ElementFormula< F > * elementFormula() const
Returns the formula to plot (given elementwise)
Definition: dataGnuplot.hh:75
virtual void operator()(const concepts::Element< F > &elm)
Application operator.
Abstract class for per cell postprocessing.
Definition: postProcess.hh:38
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
std::ofstream * ofs_
Stream to write the data to.
Definition: dataGnuplot.hh:84
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