Rheolef  7.2
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 approx0;
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  basis b0 = u0.get_space().get_basis();
60  approx0 = (! b0.is_hierarchical()) ? b0.name() : b0[0].name();
61  }
62  const string& name = b[i].first;
63  const field_basic<T,sequential>& ui = b[i].second;
64 
65  basis bi = ui.get_space().get_basis();
66  string approx = (! bi.is_hierarchical()) ? bi.name() : bi[0].name();
67  if (approx != approx0) {
68  warning_macro("field #"<<i<<" name '"<<name<<": approx `"<<approx<<"' incompatible with field #0 approx `"<<approx0<<"'");
69  error_macro ("HINT: use the \"branch -proj\" option");
70  }
71  field_put_vtk (out_vtk, ui, name, put_geo);
72  put_geo = false;
73  }
74 }
75 // open the stream for a vtk file & put data on it
76 template<class T>
77 void
79 {
80  ostream& os = out.os();
81  string basename = iorheo::getbasename(os);
82  if (basename == "") basename = "output";
83  string data_file_name = basename + "-" + std::to_string(b._count_value) + ".vtk";
84  ofstream vtk (data_file_name.c_str());
85  odiststream out_vtk (vtk);
86  bool verbose = iorheo::getverbose(clog);
87  verbose && clog << "! file `" << data_file_name << "' created" << endl;
88  put_event_vtk_stream (out_vtk, b);
89  vtk.close();
90 }
91 template<class T>
92 void
94 {
95 }
96 // ----------------------------------------------------------------------------
97 // instanciation in library
98 // ----------------------------------------------------------------------------
103 
104 } // namespace rheolef
see the basis page for the full documentation
const space_type & get_space() const
Definition: field.h:270
odiststream: see the diststream page for the full documentation
Definition: diststream.h:137
std::ostream & os()
Definition: diststream.h:247
#define error_macro(message)
Definition: dis_macros.h:49
#define warning_macro(message)
Definition: dis_macros.h:53
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)
odiststream & field_put_vtk(odiststream &, const field_basic< T, sequential > &, std::string, bool)