Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

graphics/dataDX.hh
Go to the documentation of this file.
00001 /* graphics in OpenDX
00002  */
00003 
00004 #ifndef dataDX_hh
00005 #define dataDX_hh
00006 
00007 #if __ICC == 800
00008 #  include <slist>
00009 #  define __gnu_cxx std
00010 #else
00011 #  if __GNUC__ > 2
00012 #    include <ext/slist>
00013 #    if __GNUC__ == 3 && __GNUC_MINOR__ < 1
00014 #      define __gnu_cxx std
00015 #    endif
00016 #  else
00017 #    include <slist>
00018 #    define __gnu_cxx std
00019 #  endif
00020 #endif
00021 
00022 #include <fstream>
00023 #include <memory>
00024 #include "space/postProcess.hh"
00025 #include "space/element.hh"
00026 #include "space/formula.hh"
00027 #include "function/basis.hh"
00028 #include "spaceTraits.hh"
00029 
00030 namespace concepts {
00031   // forward declaration
00032   template<class F>
00033   class Vector;
00034 
00035   template<class F>
00036   class Formula;
00037 
00038   template<class F, class G>
00039   class ElementFormula;
00040 }
00041 
00042 namespace graphics {
00043 
00044   using concepts::Real;
00045 
00046   // forward declartions
00047   class VertexList;
00048 
00049   // ********************************************************** Space traits **
00050 
00056   template<typename T, typename traits = spaceTraits<T> >
00057   struct spcPosCon {
00058     static inline uint positionConnection() {
00059       return traits::positionConnection();
00060     }
00061     static inline uint boundary() {
00062       return traits::boundaryElements();
00063     }
00064   };
00065 
00079   template<typename T>
00080   bool spacePosCon(const T& spc) { return spcPosCon<T>::positionConnection(); }
00081 
00096   template<typename T>
00097   bool spaceBoundary(const T& spc) { return spcPosCon<T>::boundary(); }
00098 
00099   // **************************************************************** DataDX **
00100 
00131   template<class F>
00132   class DataDX {
00133   public:
00141     DataDX(concepts::Space<F>& spc, const std::string filename,
00142      bool pc = false, bool boundary = false, const uint dim = 2);
00144     DataDX(const DataDX<F>& dx);
00145     ~DataDX();
00146 
00148     DataDX<F>& operator=(const DataDX<F>& dx);
00149 
00154     void operator()(const concepts::Vector<Real>& solution,
00155                     const std::string& name);
00160     void operator()(const concepts::Formula<Real>& frm, const std::string& name);
00165     void operator()(const concepts::ElementFormula<F>& frm,
00166                     const std::string& name);
00167   private:
00169     concepts::Space<F>* spc_;
00170 
00172     std::string filename_;
00173 
00175     concepts::GlobalPostprocess<F> postProcess_;
00176 
00178     uint countp_;
00179 
00181     uint countq_;
00182 
00184     bool pc_;
00185 
00187     __gnu_cxx::slist<std::string> names_;
00188 
00190     std::auto_ptr<VertexList> vtxList_;
00191   };
00192 
00199   template<typename T>
00200   DataDX<Real> drawDataDX(T& spc, const std::string filename,
00201         const uint dim = 2) {
00202     return DataDX<Real>(spc, filename, spacePosCon(spc),
00203       spaceBoundary(spc), dim);
00204   }
00205 
00206   // ********************************************************** DataDXCounts **
00207 
00221   class DataDXCounts : public concepts::CellPostprocess<Real> {
00222 
00223   public:
00232     DataDXCounts(VertexList* vtxList = 0);
00233 
00235     void add(uint a) { counts_ += a; }
00236 
00238     uint counts() const;
00239 
00240     virtual void operator() (const concepts::Element<Real>& elm);
00241     virtual void operator() (const concepts::Cell&) {}
00242   private:
00244     uint counts_;
00245 
00247     VertexList* vtxList_;
00248   };
00249 
00250   // ***************************************************** DataDXCoordinates **
00251 
00264   class DataDXCoordinates : public concepts::CellPostprocess<Real> {
00265 
00266   public:
00277     DataDXCoordinates(std::ostream& os, const uint count, 
00278           VertexList* vtxList = 0, const uint dim = 2);
00279     virtual ~DataDXCoordinates();
00280 
00282     void add(uint a) { counts_ += a; }
00283 
00285     void inc() { cntCoords_++; }
00286 
00290     uint counts() const;
00291 
00292     virtual void operator() (const concepts::Element<Real>& elm);
00293     virtual void operator() (const concepts::Cell&) {}
00294 
00296     void write(const float x) const;
00297   private:
00299     std::ostream& os_;
00300 
00302     VertexList* vtxList_;
00303 
00305     const uint dim_;
00306 
00308     uint counts_;
00309 
00311     uint cntCoords_;
00312   };
00313 
00314   // ***************************************************** DataDXConnections **
00315 
00329   class DataDXConnections : public concepts::CellPostprocess<Real> {
00330 
00331   public:
00339     DataDXConnections(std::ostream& os, const uint count, 
00340           VertexList* vtxList = 0, const uint dim = 2);
00341     virtual ~DataDXConnections();
00342     virtual void operator() (const concepts::Element<Real>& elm);
00343     virtual void operator() (const concepts::Cell&) {}
00344 
00346     void add(uint a) { counts_ += a; }
00347 
00351     uint counts() const { return counts_; }
00352 
00354     void write(const int x) const;
00355   private:
00357     std::ostream& os_;
00358 
00360     VertexList* vtxList_;
00361 
00363     uint counts_;
00364 
00366     const uint dim_;
00367   };
00368 
00369   // ************************************************************ DataDXData **
00370 
00383   class DataDXData : public concepts::CellPostprocess<Real> {
00384 
00385   public:
00394     DataDXData(std::ostream& os, const concepts::Vector<Real>& solution, 
00395                const uint count, const std::string& name,
00396                VertexList* vtxList = 0);
00397 
00405     DataDXData(std::ostream& os, const concepts::Formula<Real>& frm,
00406                const uint count, const std::string& name,
00407                VertexList* vtxList = 0);
00408 
00416     DataDXData(std::ostream& os, const concepts::ElementFormula<Real>& frm,
00417                const uint count, const std::string& name,
00418                VertexList* vtxList = 0);
00419 
00420     virtual ~DataDXData();
00421     virtual void operator() (const concepts::Element<Real>& elm)
00422       throw(concepts::MissingFeature);
00423     virtual void operator() (const concepts::Cell&) {}
00424 
00425     const concepts::Formula<Real>* formula() const { return frm_.get(); }
00426     const concepts::Array<Real>& coeff() const { return coeff_; }
00427     const concepts::ElementFormula<Real>* elementFormula() const
00428     { return efrm_; }
00429 
00431     void write(const float x) const;
00432   private:
00434     std::ostream& os_;
00435 
00437     const concepts::Vector<Real>* solution_;
00438 
00440     std::auto_ptr<const concepts::Formula<Real> > frm_;
00441 
00443     const concepts::ElementFormula<Real>* efrm_;
00444 
00446     concepts::Array<Real> coeff_;
00447 
00449     concepts::Array<Real> shpfnc_;
00450 
00452     concepts::Array<Real> vertexSol_;
00453 
00455     uint vertexSolIndex_;
00456 
00458     std::string name_;
00459 
00461     uint pc_;
00462 
00464     VertexList* vtxList_;
00465 
00467     concepts::Array<Real> vtxData_;
00468   };
00469 
00470 } // namespace graphics
00471 
00472 #endif // dataDX_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)