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
102 {
103  b.get_header_rheolef (in);
104 }
105 template <class T>
106 void
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;
164  rheolef::put_header (out, *this);
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
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
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 
250 #ifdef _RHEOLEF_HAVE_MPI
252 #endif // _RHEOLEF_HAVE_MPI
253 #undef rheolef_instanciate
254 
255 }// namespace rheolef
rheolef::put_event
void put_event(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:182
rheolef::branch_basic::put_finalize
void put_finalize(odiststream &) const
Definition: branch.cc:235
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 format format paraview
Definition: iorheo-members.h:125
rheolef::branch_basic::~branch_basic
~branch_basic()
Definition: branch.cc:29
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef::get_event_vtk
void get_event_vtk(idiststream &ips, branch_basic< T, sequential > &b)
Definition: branch_seq_get_vtk.cc:51
rheolef::put_finalize_gnuplot
void put_finalize_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_gnuplot.cc:155
rheolef::branch_basic::put_finalize_rheolef
void put_finalize_rheolef(odiststream &) const
Definition: branch.cc:210
rheolef::branch_basic::size_type
base::size_type size_type
Definition: branch.h:88
rheolef::get_header_vtk
void get_header_vtk(idiststream &ips, branch_basic< T, sequential > &b)
Definition: branch_seq_get_vtk.cc:41
rheolef::catchmark
see the catchmark page for the full documentation
Definition: catchmark.h:67
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
rheolef::put_finalize
void put_finalize(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:215
rheolef::get_event
void get_event(idiststream &in, branch_basic< T, sequential > &b)
Definition: branch.cc:91
rheolef::sequential
Definition: distributed.h:28
rheolef::branch_basic
Definition: branch.h:83
rheolef::value
rheolef::std value
rheolef-config.version
version
Definition: rheolef-config.in:126
rheolef::put_finalize_paraview
void put_finalize_paraview(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_vtk_paraview.cc:97
rheolef::put_event_paraview
void put_event_paraview(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_vtk_paraview.cc:55
rheolef::rheolef_instanciate
rheolef_instanciate(Float, sequential) rheolef_instanciate(Float
rheolef::put_header_vtk
void put_header_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:40
rheolef::put_event_vtk
void put_event_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:72
vtk
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
Definition: iorheo-members.h:113
rheolef::put_header
void put_header(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:141
rheolef::put_header_gnuplot
void put_header_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_gnuplot.cc:41
rheolef::put_header_paraview
void put_header_paraview(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_vtk_paraview.cc:45
rheolef::distributed
Definition: distributed.h:88
rheolef::put_event_gnuplot
void put_event_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_gnuplot.cc:66
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 format format format gnuplot
Definition: iorheo-members.h:121
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
rheolef::branch_basic::get_event_rheolef
void get_event_rheolef(idiststream &)
Definition: branch.cc:56
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
Float
see the Float page for the full documentation
rheolef::branch_basic::put_event_rheolef
void put_event_rheolef(odiststream &) const
Definition: branch.cc:168
rheolef::branch_basic::put_header
void put_header(odiststream &) const
Definition: branch.cc:160
rheolef::branch_basic::get_header_rheolef
void get_header_rheolef(idiststream &)
Definition: branch.cc:39
rheolef::branch_basic::put_header_rheolef
void put_header_rheolef(odiststream &) const
Definition: branch.cc:124
rheolef::get_header
void get_header(idiststream &in, branch_basic< T, sequential > &b)
Definition: branch.cc:82
rheo
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color rheo
Definition: iorheo-members.h:65
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
rheolef::dis_scatch
bool dis_scatch(idiststream &ips, const communicator &comm, std::string ch)
distributed version of scatch(istream&,string)
Definition: diststream.cc:43
T
Expr1::float_type T
Definition: field_expr.h:261
rheolef::put_finalize_vtk
void put_finalize_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:87