Go to the documentation of this file.00001
00002
00003
00004 #ifndef graphDataGnuplot_hh
00005 #define graphDataGnuplot_hh
00006
00007 #include <string>
00008 #include <fstream>
00009 #include <memory>
00010 #include "basics/typedefs.hh"
00011 #include "basics/vectorsMatricesForward.hh"
00012 #include "basics/exceptions.hh"
00013 #include "space/postProcess.hh"
00014 #include "space/formula.hh"
00015 #include "space/function.hh"
00016 #include "function/vector.hh"
00017
00018
00019 namespace concepts {
00020
00021 template<class F>
00022 class Formula;
00023
00024 template<class F, class G>
00025 class ElementFormula;
00026 }
00027
00028 namespace graphics {
00029 using concepts::Real;
00030
00031
00032
00036 template<typename F>
00037 class DataGnuplotCell : public concepts::CellPostprocess<F> {
00038 public:
00045 DataGnuplotCell(std::ofstream* ofs,
00046 const concepts::Vector<Real>& solution,
00047 const concepts::ElementFunction<Real>* fun = 0);
00052 DataGnuplotCell(std::ofstream* ofs, const concepts::Formula<Real>& frm,
00053 const concepts::ElementFunction<Real>* fun = 0);
00058 DataGnuplotCell(std::ofstream* ofs,
00059 const concepts::ElementFormula<F>& frm,
00060 const concepts::ElementFunction<Real>* fun = 0);
00061 virtual ~DataGnuplotCell();
00062 virtual void operator() (const concepts::Element<F>& elm)
00063 throw(concepts::MissingFeature);
00064 virtual void operator() (const concepts::Cell& cell)
00065 throw(concepts::MissingFeature);
00067 std::ofstream* write() { return ofs_; }
00069 const concepts::Array<Real>& coeff() const { return coeff_; }
00071 const concepts::Formula<Real>* formula() const { return frm_.get(); }
00073 const concepts::ElementFormula<F>* elementFormula() const {
00074 return frmElm_;
00075 }
00077 const concepts::ElementFunction<F>* elementFunction() const {
00078 return fun_;
00079 }
00080 private:
00082 std::ofstream* ofs_;
00084 concepts::Array<Real> coeff_;
00086 const concepts::Vector<Real>* solution_;
00088 std::auto_ptr<const concepts::Formula<Real> > frm_;
00090 const concepts::ElementFormula<F>* frmElm_;
00092 const concepts::ElementFunction<F>* fun_;
00093 };
00094
00095
00096
00106 template<typename T, typename S>
00107 void drawDataGnuplot(T& msh_spc, std::string filename, const S& sol,
00108 const concepts::ElementFunction<Real>* fun = 0) {
00109 std::ofstream ofs(filename.c_str());
00110 concepts::GlobalPostprocess<Real> postProcess(msh_spc);
00111 DataGnuplotCell<Real> gnu(&ofs, sol, fun);
00112 postProcess(gnu);
00113 }
00114
00115 }
00116
00117 #endif // graphDataGnuplot_hh