Rheolef  7.2
an efficient C++ finite element environment
branch.cc
Go to the documentation of this file.
1
21#include "rheolef/branch.h"
22namespace rheolef {
23using namespace std;
24
25// --------------------------------------------------------------------------
26// cstor
27// --------------------------------------------------------------------------
28template <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// --------------------------------------------------------------------------
37template <class T, class M>
38void
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}
54template <class T, class M>
55void
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}
80template <class T>
81void
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}
89template <class T>
90void
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
99template <class T>
100void
102{
103 b.get_header_rheolef (in);
104}
105template <class T>
106void
108{
109 b.get_event_rheolef (in);
110}
111#endif // _RHEOLEF_HAVE_MPI
112template <class T, class M>
113idiststream&
115{
116 get_event (in,b);
117 return in;
118}
119// --------------------------------------------------------------------------
120// output
121// --------------------------------------------------------------------------
122template <class T, class M>
123void
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}
139template <class T>
140void
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
151template <class T>
152void
154{
155 b.put_header_rheolef (out);
156}
157#endif // _RHEOLEF_HAVE_MPI
158template <class T, class M>
159void
161{
162 if (_header_out_done) return;
163 _header_out_done = true;
166template <class T, class M>
167void
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}
180template <class T>
181void
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
193template <class T>
194void
196{
197 b.put_header(out);
198 b.put_event_rheolef (out);
199}
200#endif // _RHEOLEF_HAVE_MPI
201template <class T, class M>
204{
206 return out;
207}
208template <class T, class M>
209void
211{
212}
213template <class T>
214void
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
227template <class T>
228void
230{
231}
232#endif // _RHEOLEF_HAVE_MPI
233template <class T, class M>
234void
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
see the Float page for the full documentation
base::size_type size_type
Definition: branch.h:88
see the catchmark page for the full documentation
Definition: catchmark.h:67
idiststream: see the diststream page for the full documentation
Definition: diststream.h:336
std::istream & is()
Definition: diststream.h:400
std::bitset< last > flag_type
Definition: iorheo.h:440
odiststream: see the diststream page for the full documentation
Definition: diststream.h:137
#define error_macro(message)
Definition: dis_macros.h:49
Expr1::float_type T
Definition: field_expr.h:230
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
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.
void put_header_paraview(odiststream &out, const branch_basic< T, sequential > &b)
void put_header_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void put_event(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:182
idiststream & operator>>(idiststream &in, branch_basic< T, M > &b)
Definition: branch.cc:114
void put_header(odiststream &out, const branch_basic< T, distributed > &b)
Definition: branch.cc:153
void put_finalize(odiststream &out, const branch_basic< T, distributed > &b)
Definition: branch.cc:229
void put_finalize_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, distributed > &b)
Definition: branch.cc:101
void put_event_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
void put_finalize_vtk(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:44
void put_header_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
void put_event(odiststream &out, const branch_basic< T, distributed > &b)
Definition: branch.cc:195
void get_event_vtk(idiststream &ips, branch_basic< T, sequential > &b)
void put_event_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void get_event(idiststream &in, branch_basic< T, distributed > &b)
Definition: branch.cc:107
void put_event_paraview(odiststream &out, const branch_basic< T, sequential > &b)
void put_finalize_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
void put_header(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:141
void get_header_vtk(idiststream &ips, branch_basic< T, sequential > &b)
STL namespace.
ostream & operator<<(ostream &os, const tiny_element &K)
Definition: tiny_element.cc:27