Rheolef  7.1
an efficient C++ finite element environment
branch_seq_put_vtk.cc
Go to the documentation of this file.
1 //
22 // vtk for paraview animations
23 //
24 // author: Pierre.Saramito@imag.fr
25 //
26 // date: 4 may 2001
27 //
28 #include "rheolef/branch.h"
29 #include "rheolef/iofem.h"
30 #include "rheolef/iorheo.h"
31 #include "rheolef/rheostream.h"
32 namespace rheolef {
33 using namespace std;
34 
35 // extern:
36 template <class T> odiststream& field_put_vtk (odiststream&, const field_basic<T,sequential>&, std::string, bool);
37 
38 template<class T>
39 void
41 {
42  ostream& os = out.os();
43  iorheo::setbranch_counter(os, 0);
44  b._count_value = 0;
45 }
46 // put data on a vtk stream
47 template<class T>
48 void
50 {
51  string basename = iorheo::getbasename(out_vtk.os());
52  out_vtk << setbasename(basename)
53  << setprecision(numeric_limits<T>::digits10);
54  string approx;
55  bool put_geo = true;
56  for (size_t i = 0; i < b.n_field(); i++) {
57  if (i == 0) {
58  const field_basic<T,sequential>& u0 = b[0].second;
59  approx = u0.get_approx();
60  }
61  const string& name = b[i].first;
62  const field_basic<T,sequential>& ui = b[i].second;
63  check_macro (ui.get_approx() == approx,
64  "field #"<<i<<" name '"<<name<<": approx `"<<ui.get_approx()<<"' incompatible with field #0 approx `"<<approx<<"'");
65  field_put_vtk (out_vtk, ui, name, put_geo);
66  put_geo = false;
67  }
68 }
69 // open the stream for a vtk file & put data on it
70 template<class T>
71 void
73 {
74  ostream& os = out.os();
75  string basename = iorheo::getbasename(os);
76  if (basename == "") basename = "output";
77  string data_file_name = basename + "-" + itos(b._count_value) + ".vtk";
78  ofstream vtk (data_file_name.c_str());
79  odiststream out_vtk (vtk);
80  bool verbose = iorheo::getverbose(clog);
81  verbose && clog << "! file `" << data_file_name << "' created" << endl;
82  put_event_vtk_stream (out_vtk, b);
83  vtk.close();
84 }
85 template<class T>
86 void
88 {
89 }
90 // ----------------------------------------------------------------------------
91 // instanciation in library
92 // ----------------------------------------------------------------------------
93 template void put_header_vtk (odiststream&, const branch_basic<Float,sequential>&);
94 template void put_event_vtk (odiststream&, const branch_basic<Float,sequential>&);
95 template void put_event_vtk_stream(odiststream&, const branch_basic<Float,sequential>&);
96 template void put_finalize_vtk (odiststream&, const branch_basic<Float,sequential>&);
97 
98 } // namespace rheolef
rheolef::put_event_vtk_stream
void put_event_vtk_stream(odiststream &out_vtk, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:49
rheolef::field_basic::get_approx
std::string get_approx() const
Definition: field.h:303
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef::branch_basic
Definition: branch.h:83
rheolef::odiststream::os
std::ostream & os()
Definition: diststream.h:236
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::field_basic
Definition: field_expr_utilities.h:38
mkgeo_couette.basename
basename
Definition: mkgeo_couette.sh:73
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
mkgeo_ball.b
b
Definition: mkgeo_ball.sh:152
mkgeo_ball.verbose
verbose
Definition: mkgeo_ball.sh:133
rheolef::itos
std::string itos(std::string::size_type i)
itos: see the rheostream page for the full documentation
rheolef::field_put_vtk
odiststream & field_put_vtk(odiststream &, const field_basic< T, sequential > &, std::string, bool)
Definition: field_seq_put_vtk.cc:154
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133
rheolef::put_finalize_vtk
void put_finalize_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:87