Class documentation of Concepts

Loading...
Searching...
No Matches
outputTecplot.hh
Go to the documentation of this file.
1
6#ifndef OutputTecplot_hh
7#define OutputTecplot_hh
8
9#include <iostream>
10#include <complex>
11#include <vector>
12#include "outputOperator.hh"
13#include "vectorsMatrices.hh"
14#include "toolbox/array.hh"
15
16namespace concepts {
17
18 // ********************************************************* OutputTecplot **
19
25 template<typename F>
26 class OutputTecplot : public virtual OutputOperator {
27 public:
28 OutputTecplot(const F& val) : val_(val) {}
33 void header(std::ostream& os, std::string name, uint cnt = 0);
34 protected:
36 std::ostream& info(std::ostream& os) const {
37 return os << val_;
38 }
39 private:
40 const F& val_;
41 };
42
43 template<typename F>
44 void OutputTecplot<F>::header(std::ostream& os, std::string name, uint cnt) {
45 os << name << cnt;
46 }
47
48 // *************************************** OutputTecplot<std::complex<F> > **
49
50 template<typename F>
51 class OutputTecplot<std::complex<F> > : public virtual OutputOperator {
52 public:
53 OutputTecplot(const std::complex<F>& val) : val_(val) {}
58 void header(std::ostream& os, std::string name, uint cnt = 0);
59 protected:
61 std::ostream& info(std::ostream& os) const {
62 return os << OutputTecplot<F>(std::real(val_)) << " "
63 << OutputTecplot<F>(std::imag(val_));
64 }
65 private:
66 const std::complex<F>& val_;
67 };
68
69 template<typename F>
71 (std::ostream& os, std::string name, uint cnt) {
72 os << name << cnt << "r, " << name << cnt << "i";
73 }
74
75 // ********************************************** OutputTecplot<Array<F> > **
76
77 template<typename F>
78 class OutputTecplot<Array<F> > : public virtual OutputOperator {
79 public:
80 OutputTecplot(const Array<F>& val) : val_(val) {}
85 void header(std::ostream& os, std::string name, uint cnt = 0);
86 protected:
88 std::ostream& info(std::ostream& os) const {
89 for(uint i = 0; i < val_.size(); ++i)
90 os << OutputTecplot<F>(val_[i]) << " ";
91 return os;
92 }
93 private:
94 const Array<F>& val_;
95 };
96
97 template<typename F>
99 (std::ostream& os, std::string name, uint cnt) {
100 OutputTecplot<F> o(val_[0]);
101 for(uint i = 0; i < val_.size(); ) {
102 o.header(os, name, cnt+i);
103 if (++i < val_.size()) os << ", ";
104 }
105 }
106
107 // ****************************************** OutputTecplot<Point<F,dim> > **
108
110 template<typename F, int dim>
111 class OutputTecplot<Point<F,dim> > : public virtual OutputOperator {
112 public:
113 OutputTecplot(const Point<F,dim>& val) : val_(val) {}
118 void header(std::ostream& os, std::string name, uint cnt = 0);
119 protected:
121 std::ostream& info(std::ostream& os) const {
122 for(uint i = 0; i < dim; ++i)
123 os << OutputTecplot<F>(val_[i]) << " ";
124 return os;
125 }
126 private:
127 const Point<F,dim>& val_;
128 };
129
130 template<typename F, int dim>
132 (std::ostream& os, std::string name, uint cnt) {
133 if (dim == 1)
134 os << name << cnt;
135 else {
136 OutputTecplot<F> o(val_[0]);
137 for(uint i = 0; i < dim; ) {
138 o.header(os, name, cnt+i);
139 if (++i < dim) os << ", ";
140 }
141 }
142 }
143
144} // namespace concepts
145
146#endif // OutputTecplot_hh
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void header(std::ostream &os, std::string name, uint cnt=0)
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320