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 // ----------------------------------------------------------------------------
97 
98 } // namespace rheolef
std::string get_approx() const
Definition: field.h:303
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
std::ostream & os()
Definition: diststream.h:236
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
This file is part of Rheolef.
void put_event_vtk_stream(odiststream &out_vtk, const branch_basic< T, sequential > &b)
void put_header_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void put_finalize_vtk(odiststream &out, const branch_basic< T, sequential > &b)
void put_event_vtk(odiststream &out, const branch_basic< T, sequential > &b)
std::string itos(std::string::size_type i)
itos: see the rheostream page for the full documentation
odiststream & field_put_vtk(odiststream &, const field_basic< T, sequential > &, std::string, bool)