Rheolef  7.1
an efficient C++ finite element environment
branch.cc
Go to the documentation of this file.
1 #include "rheolef/branch.h"
22 namespace rheolef {
23 using namespace std;
24 
25 // --------------------------------------------------------------------------
26 // cstor
27 // --------------------------------------------------------------------------
28 template <class T, class M>
30 {
31  if (_p_data_out) delete_macro (_p_data_out);
32  _p_data_out = 0;
33 }
34 // --------------------------------------------------------------------------
35 // input
36 // --------------------------------------------------------------------------
37 template <class T, class M>
38 void
40 {
41  if (_header_in_done) return;
42  _header_in_done = true;
43  check_macro (dis_scatch(in,"\nbranch"), "input stream does not contains a branch");
45  size_type sz;
46  int nval;
47  in >> version >> sz >> nval >> _parameter_name;
48  _n_value = ((nval == -1) ? numeric_limits<size_type>::max() : nval);
49  base::resize(sz);
50  for (size_type i = 0; i < sz; i++) {
51  in >> base::operator[](i).first;
52  }
53 }
54 template <class T, class M>
55 void
57 {
58  get_header_rheolef (in);
59  if (!in || !dis_scatch(in, "#"+parameter_name())) {
60  // no more events
61  return;
62  }
63  T value;
64  in >> value;
65  if (!in) {
66  // no more events...
67  return;
68  }
69  set_parameter(value);
70  for (typename branch_basic<T,M>::size_type i = 0; in && i < base::size(); i++) {
71  in >> catchmark (base::operator[](i).first) >> base::operator[](i).second;
72  }
73  // increment counter
74  if (_count_value == numeric_limits<typename branch_basic<T,M>::size_type>::max()) {
75  _count_value = 0;
76  } else {
77  _count_value++;
78  }
79 }
80 template <class T>
81 void
83 {
84  iorheo::flag_type format = iorheo::flags(in.is()) & iorheo::format_field;
85  if (format [iorheo::vtk]) { get_header_vtk (in,b); }
86  else if (format [iorheo::rheo]) { b.get_header_rheolef(in); }
87  else { error_macro ("unsupported input format="<<format); }
88 }
89 template <class T>
90 void
92 {
93  iorheo::flag_type format = iorheo::flags(in.is()) & iorheo::format_field;
94  if (format [iorheo::vtk]) { get_event_vtk (in,b); }
95  else if (format [iorheo::rheo]) { b.get_event_rheolef(in); }
96  else { error_macro ("unsupported input format="<<format); }
97 }
98 #ifdef _RHEOLEF_HAVE_MPI
99 template <class T>
100 void
101 get_header (idiststream& in, branch_basic<T,distributed>& b)
102 {
103  b.get_header_rheolef (in);
104 }
105 template <class T>
106 void
107 get_event (idiststream& in, branch_basic<T,distributed>& b)
108 {
109  b.get_event_rheolef (in);
110 }
111 #endif // _RHEOLEF_HAVE_MPI
112 template <class T, class M>
113 idiststream&
114 operator>> (idiststream& in, branch_basic<T,M>& b)
115 {
116  get_event (in,b);
117  return in;
118 }
119 // --------------------------------------------------------------------------
120 // output
121 // --------------------------------------------------------------------------
122 template <class T, class M>
123 void
125 {
126  int nval = -1;
127  if (_n_value != numeric_limits<size_type>::max()) nval = _n_value;
128  out << "#!branch" << endl
129  << endl
130  << "branch" << endl
131  << "1 " << base::size() << " " << nval << endl
132  << _parameter_name;
133  ;
134  for (size_type i = 0; i < base::size(); i++) {
135  out << " " << base::operator[](i).first;
136  }
137  out << endl;
138 }
139 template <class T>
140 void
142 {
143  iorheo::flag_type format = iorheo::flags(out.os()) & iorheo::format_field;
144  if (format [iorheo::gnuplot]) { put_header_gnuplot (out, b); }
145  else if (format [iorheo::paraview]) { put_header_paraview (out,b); }
146  else if (format [iorheo::vtk]) { put_header_vtk (out,b); }
147  else if (format [iorheo::rheo]) { b.put_header_rheolef(out); }
148  else { error_macro ("unsupported output/render format="<<format); }
149 }
150 #ifdef _RHEOLEF_HAVE_MPI
151 template <class T>
152 void
154 {
155  b.put_header_rheolef (out);
156 }
157 #endif // _RHEOLEF_HAVE_MPI
158 template <class T, class M>
159 void
161 {
162  if (_header_out_done) return;
163  _header_out_done = true;
165 }
166 template <class T, class M>
167 void
169 {
170  out << endl
171  << setprecision(numeric_limits<T>::digits10)
172  << "#" << _parameter_name << " " << _parameter_value << endl
173  << endl
174  ;
175  for (typename branch_basic<T,M>::size_type i = 0; i < base::size(); i++) {
176  out << catchmark (base::operator[](i).first) << base::operator[](i).second;
177  }
178  out.flush(); // when gziped output, make it available as soon as computed
179 }
180 template <class T>
181 void
183 {
184  b.put_header(out);
185  iorheo::flag_type format = iorheo::flags(out.os()) & iorheo::format_field;
186  // increment counter
187  if (format [iorheo::gnuplot]) { put_event_gnuplot (out,b); }
188  else if (format [iorheo::vtk]) { put_event_vtk (out,b); }
189  else if (format [iorheo::paraview]){ put_event_paraview (out,b); }
190  else { b.put_event_rheolef(out); }
191 }
192 #ifdef _RHEOLEF_HAVE_MPI
193 template <class T>
194 void
195 put_event (odiststream& out, const branch_basic<T,distributed>& b)
196 {
197  b.put_header(out);
198  b.put_event_rheolef (out);
199 }
200 #endif // _RHEOLEF_HAVE_MPI
201 template <class T, class M>
204 {
206  return out;
207 }
208 template <class T, class M>
209 void
211 {
212 }
213 template <class T>
214 void
216 {
217  if (b._finalize_out_done) return;
218  b._finalize_out_done = true;
219  iorheo::flag_type format = iorheo::flags(out.os()) & iorheo::format_field;
220 
221  if (format [iorheo::gnuplot]) { put_finalize_gnuplot (out,b); }
222  else if (format [iorheo::vtk]) { put_finalize_vtk (out,b); }
223  else if (format [iorheo::paraview]) { put_finalize_paraview (out,b); }
224  else { b.put_finalize_rheolef(out); }
225 }
226 #ifdef _RHEOLEF_HAVE_MPI
227 template <class T>
228 void
229 put_finalize (odiststream& out, const branch_basic<T,distributed>& b)
230 {
231 }
232 #endif // _RHEOLEF_HAVE_MPI
233 template <class T, class M>
234 void
236 {
237  rheolef::put_finalize (out, *this);
238 }
239 // ----------------------------------------------------------------------------
240 // instanciation in library
241 // ----------------------------------------------------------------------------
242 #define rheolef_instanciate(T,M) \
243  template class branch_basic<T,M>; \
244  template void get_header (idiststream&, branch_basic<T,M>&); \
245  template void get_event (idiststream&, branch_basic<T,M>&); \
246  template odiststream& operator<< (odiststream&, const branch_basic<T,M>&); \
247  template idiststream& operator>> (idiststream&, branch_basic<T,M>&);
248 
249 rheolef_instanciate(Float,sequential)
250 #ifdef _RHEOLEF_HAVE_MPI
251 rheolef_instanciate(Float,distributed)
252 #endif // _RHEOLEF_HAVE_MPI
253 #undef rheolef_instanciate
254 
255 }// namespace rheolef
see the Float page for the full documentation
void put_header_rheolef(odiststream &) const
Definition: branch.cc:124
void put_finalize_rheolef(odiststream &) const
Definition: branch.cc:210
void put_finalize(odiststream &) const
Definition: branch.cc:235
void get_header_rheolef(idiststream &)
Definition: branch.cc:39
base::size_type size_type
Definition: branch.h:88
void get_event_rheolef(idiststream &)
Definition: branch.cc:56
void put_event_rheolef(odiststream &) const
Definition: branch.cc:168
void put_header(odiststream &) const
Definition: branch.cc:160
see the catchmark page for the full documentation
Definition: catchmark.h:67
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::std value
Expr1::float_type T
Definition: field_expr.h:261
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format format format format paraview
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format format gnuplot
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format vtk
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color rheo
#define rheolef_instanciate(T, M)
Definition: branch.cc:242
This file is part of Rheolef.
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
void get_event(idiststream &in, branch_basic< T, sequential > &b)
Definition: branch.cc:91
void put_header_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
void put_event_paraview(odiststream &out, const branch_basic< T, sequential > &b)
void put_finalize(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:215
void get_header(idiststream &in, branch_basic< T, sequential > &b)
Definition: branch.cc:82
void put_finalize_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
void put_event(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:182
void put_header_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void put_header(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:141
void put_finalize_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void put_event_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void put_header_paraview(odiststream &out, const branch_basic< T, sequential > &b)
bool dis_scatch(idiststream &ips, const communicator &comm, std::string ch)
distributed version of scatch(istream&,string)
Definition: diststream.cc:43
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
void get_event_vtk(idiststream &ips, branch_basic< T, sequential > &b)
void put_event_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
void get_header_vtk(idiststream &ips, branch_basic< T, sequential > &b)
void put_finalize_paraview(odiststream &out, const branch_basic< T, sequential > &b)