Go to the documentation of this file.00001
00002
00003
00004 #ifndef graphicsbasis_hh
00005 #define graphicsbasis_hh
00006
00007 #include <fstream>
00008 #include "basics/debug.hh"
00009 #include "basics/exceptions.hh"
00010 #include "basics/outputOperator.hh"
00011 #include "basics/typedefs.hh"
00012 #include "toolbox/array.hh"
00013 #include "toolbox/elementGraphics.hh"
00014 #include "toolbox/sequence.hh"
00015 #include "geometry/cell2D.hh"
00016
00017
00018 #include "space/function.hh"
00019 #include "space/postProcess.hh"
00020 #include "space/space.hh"
00021
00022 #define MatlabMeshWriteFormula_D 0
00023
00024 namespace concepts {
00025 template<class F>
00026 class Vector;
00027
00028 template<class F, class G>
00029 class ElementFormula;
00030
00031 template<class F>
00032 class PiecewiseFormulaBase;
00033 }
00034
00035 namespace graphics {
00036
00037 using concepts::Real;
00038
00039
00040
00045 template<class F>
00046 struct Size {
00047 const uint n() = 0;
00048 };
00049
00050 template<>
00051 struct Size<Real> {
00052 static const uint n() { return 1; }
00053 };
00054
00055 template<>
00056 struct Size<concepts::Cmplx> {
00057 static const uint n() { return 1; }
00058 };
00059
00060 template<class F, int dim>
00061 struct Size<concepts::Point<F, dim> > {
00062 static const uint n() { return Size<F>::n() * dim; }
00063 };
00064
00065 template<class F, int dim>
00066 struct Size<concepts::Mapping<F, dim> > {
00067 static const uint n() { return Size<F>::n() * dim * dim; }
00068 };
00069
00070
00071
00076 class OutputBase : public concepts::OutputOperator {
00077 public:
00080 OutputBase(const std::string filename, const bool append = false);
00081 virtual ~OutputBase() { ofs_.reset(0); }
00082 protected:
00083 virtual std::ostream& info(std::ostream& os) const;
00085 std::auto_ptr<std::ofstream> ofs_;
00086 };
00087
00088
00089
00096 template<class F = Real>
00097 class BaseOutputCell : public concepts::CellPostprocess<F> {
00098 public:
00099 BaseOutputCell(std::map<std::string, std::ostream*>& os, const uint dim,
00100 const concepts::ElementGraphicsBase::graphicsType type)
00101 : type_(type), dim_(dim), os_(os) {}
00102 virtual void operator()(const concepts::Element<F>& elm) = 0;
00103 virtual void operator()(const concepts::Cell& cell) = 0;
00105 std::map<std::string, std::ostream*>& write() { return os_; }
00107 uint streams() const { return os_.size(); }
00109
00110 std::vector<uint>& count() { return cnt_; }
00112
00114 uint dim() const { return dim_; }
00116 virtual uint n() const = 0;
00117 protected:
00118 virtual std::ostream& info(std::ostream& os) const;
00120 const enum concepts::ElementGraphicsBase::graphicsType type_;
00122 concepts::Sequence<uint> cnt_;
00124
00126 const uint dim_;
00128 std::map<std::string, std::ostream*>& os_;
00129 };
00130
00131
00132
00141 template<class F, class G = typename concepts::Realtype<F>::type>
00142 class BaseDataCell : public BaseOutputCell<G> {
00143 public:
00150 BaseDataCell(std::map<std::string, std::ostream*>& os,
00151 const uint dim,
00152 const concepts::ElementGraphicsBase::graphicsType type,
00153 const concepts::Vector<F>& sol,
00154 const concepts::ElementFunction<F,G>* fun = 0);
00157 virtual void operator()(const concepts::Element<G>& elm);
00159 virtual void operator()(const concepts::Cell& cell)
00160 throw(concepts::MissingFeature);
00162 const concepts::Array<F>& coeff() const { return coeff_; }
00164 const concepts::ElementFunction<F,G>*& elementFunction()
00165 { return fun_; }
00166 const concepts::Vector<F>& sol() const { return sol_; }
00167 virtual uint n() const;
00168 protected:
00169 virtual std::ostream& info(std::ostream& os) const;
00170 private:
00172 concepts::Array<F> coeff_;
00174 const concepts::Vector<F>& sol_;
00176 const concepts::ElementFunction<F,G>* fun_;
00177 };
00178
00179
00180
00187 template<class F, class G = typename concepts::Realtype<F>::type>
00188 class BaseElementFormulaCell : public BaseOutputCell<G> {
00189 public:
00196 BaseElementFormulaCell
00197 (std::map<std::string, std::ostream*>& os, const uint dim,
00198 const concepts::ElementGraphicsBase::graphicsType type,
00199 const concepts::ElementFormula<F,G>& fun);
00202 virtual void operator()(const concepts::Element<G>& elm);
00204 virtual void operator()(const concepts::Cell& cell)
00205 throw(concepts::MissingFeature);
00207 const concepts::ElementFormula<F,G>& elementFormula()
00208 { return fun_; }
00209 virtual uint n() const { return Size<F>::n(); }
00210 protected:
00211 virtual std::ostream& info(std::ostream& os) const;
00213 const concepts::ElementFormula<F,G>& fun_;
00214 };
00215
00216
00217
00224 template<class F, class G = typename concepts::Realtype<F>::type>
00225 class BaseFormulaCell : public BaseOutputCell<G> {
00226 public:
00234 BaseFormulaCell(std::map<std::string, std::ostream*>& os,
00235 const uint dim,
00236 const concepts::ElementGraphicsBase::graphicsType type,
00237 const concepts::PiecewiseFormulaBase<F>& frm,
00238 const uint points = 5);
00241 virtual void operator()(const concepts::Element<G>& elm);
00243 virtual void operator()(const concepts::Cell& cell)
00244 throw(concepts::MissingFeature);
00246 const concepts::PiecewiseFormulaBase<F>* formula() const { return &frm_; }
00247 virtual uint n() const { return Size<F>::n(); }
00248 protected:
00249 virtual std::ostream& info(std::ostream& os) const;
00250 private:
00252 const concepts::PiecewiseFormulaBase<F>& frm_;
00254 const concepts::Array<uint> Points_;
00255 };
00256
00257
00258
00265 class BaseMeshCell : public BaseOutputCell<Real> {
00266 public:
00273 BaseMeshCell(std::map<std::string, std::ostream*>& os, const uint dim,
00274 const concepts::ElementGraphicsBase::graphicsType type,
00275 const uint points = 5);
00278 virtual void operator()(const concepts::Element<Real>& elm);
00281 virtual void operator()(const concepts::Cell& cell)
00282 throw(concepts::MissingFeature);
00284 virtual uint n() const { return 0; }
00285 protected:
00286 virtual std::ostream& info(std::ostream& os) const;
00287 private:
00289 const concepts::Array<uint> Points_;
00290 };
00291
00292 }
00293
00294 #endif // graphicsbasis_hh