branch_seq_put_vtk.cc
Go to the documentation of this file.
//
// vtk for paraview animations
//
// author: Pierre.Saramito@imag.fr
//
// date: 4 may 2001
//
#include "rheolef/branch.h"
#include "rheolef/iofem.h"
#include "rheolef/iorheo.h"
#include "rheolef/rheostream.h"
namespace rheolef {
using namespace std;
// extern:
template <class T> odiststream& field_put_vtk (odiststream&, const field_basic<T,sequential>&, std::string, bool);
template<class T>
void
put_header_vtk (odiststream& out, const branch_basic<T,sequential>& b)
{
ostream& os = out.os();
iorheo::setbranch_counter(os, 0);
b._count_value = 0;
}
// put data on a vtk stream
template<class T>
void
put_event_vtk_stream (odiststream& out_vtk, const branch_basic<T,sequential>& b)
{
string basename = iorheo::getbasename(out_vtk.os());
out_vtk << setbasename(basename)
<< setprecision(numeric_limits<T>::digits10);
string approx;
bool put_geo = true;
for (size_t i = 0; i < b.n_field(); i++) {
if (i == 0) {
const field_basic<T,sequential>& u0 = b[0].second;
approx = u0.get_approx();
}
const string& name = b[i].first;
const field_basic<T,sequential>& ui = b[i].second;
check_macro (ui.get_approx() == approx,
"field #"<<i<<" name '"<<name<<": approx `"<<ui.get_approx()<<"' incompatible with field #0 approx `"<<approx<<"'");
field_put_vtk (out_vtk, ui, name, put_geo);
put_geo = false;
}
}
// open the stream for a vtk file & put data on it
template<class T>
void
put_event_vtk (odiststream& out, const branch_basic<T,sequential>& b)
{
ostream& os = out.os();
string basename = iorheo::getbasename(os);
if (basename == "") basename = "output";
string data_file_name = basename + "-" + itos(b._count_value) + ".vtk";
ofstream vtk (data_file_name.c_str());
odiststream out_vtk (vtk);
bool verbose = iorheo::getverbose(clog);
verbose && clog << "! file `" << data_file_name << "' created" << endl;
put_event_vtk_stream (out_vtk, b);
vtk.close();
}
template<class T>
void
put_finalize_vtk (odiststream& out, const branch_basic<T,sequential>& b)
{
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
template void put_header_vtk (odiststream&, const branch_basic<Float,sequential>&);
template void put_event_vtk (odiststream&, const branch_basic<Float,sequential>&);
template void put_event_vtk_stream(odiststream&, const branch_basic<Float,sequential>&);
template void put_finalize_vtk (odiststream&, const branch_basic<Float,sequential>&);
} // namespace rheolef
rheolef::branch_basic
Definition: branch.h:83
rheolef::field_basic
Definition: field.h:235
rheolef::field_basic::get_approx
std::string get_approx() const
Definition: field.h:303
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::odiststream::os
std::ostream & os()
Definition: diststream.h:236
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
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
mkgeo_ball.verbose
verbose
Definition: mkgeo_ball.sh:133
mkgeo_contraction.name
string name
Definition: mkgeo_contraction.sh:133
mkgeo_couette.basename
string basename
Definition: mkgeo_couette.sh:73
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
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::put_header_vtk
void put_header_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:40
rheolef::put_finalize_vtk
void put_finalize_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:87
rheolef::put_event_vtk
void put_event_vtk(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_put_vtk.cc:72
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