branch.cc
Go to the documentation of this file.
#include "rheolef/branch.h"
namespace rheolef {
using namespace std;
// --------------------------------------------------------------------------
// cstor
// --------------------------------------------------------------------------
template <class T, class M>
branch_basic<T,M>::~branch_basic()
{
if (_p_data_out) delete_macro (_p_data_out);
_p_data_out = 0;
}
// --------------------------------------------------------------------------
// input
// --------------------------------------------------------------------------
template <class T, class M>
void
branch_basic<T,M>::get_header_rheolef (idiststream& in)
{
if (_header_in_done) return;
_header_in_done = true;
check_macro (dis_scatch(in,"\nbranch"), "input stream does not contains a branch");
size_type version;
size_type sz;
int nval;
in >> version >> sz >> nval >> _parameter_name;
_n_value = ((nval == -1) ? numeric_limits<size_type>::max() : nval);
base::resize(sz);
for (size_type i = 0; i < sz; i++) {
in >> base::operator[](i).first;
}
}
template <class T, class M>
void
branch_basic<T,M>::get_event_rheolef (idiststream& in)
{
get_header_rheolef (in);
if (!in || !dis_scatch(in, "#"+parameter_name())) {
// no more events
return;
}
T value;
in >> value;
if (!in) {
// no more events...
return;
}
set_parameter(value);
for (typename branch_basic<T,M>::size_type i = 0; in && i < base::size(); i++) {
in >> catchmark (base::operator[](i).first) >> base::operator[](i).second;
}
// increment counter
if (_count_value == numeric_limits<typename branch_basic<T,M>::size_type>::max()) {
_count_value = 0;
} else {
_count_value++;
}
}
template <class T>
void
get_header (idiststream& in, branch_basic<T,sequential>& b)
{
iorheo::flag_type format = iorheo::flags(in.is()) & iorheo::format_field;
if (format [iorheo::vtk]) { get_header_vtk (in,b); }
else if (format [iorheo::rheo]) { b.get_header_rheolef(in); }
else { error_macro ("unsupported input format="<<format); }
}
template <class T>
void
get_event (idiststream& in, branch_basic<T,sequential>& b)
{
iorheo::flag_type format = iorheo::flags(in.is()) & iorheo::format_field;
if (format [iorheo::vtk]) { get_event_vtk (in,b); }
else if (format [iorheo::rheo]) { b.get_event_rheolef(in); }
else { error_macro ("unsupported input format="<<format); }
}
#ifdef _RHEOLEF_HAVE_MPI
template <class T>
void
get_header (idiststream& in, branch_basic<T,distributed>& b)
{
b.get_header_rheolef (in);
}
template <class T>
void
get_event (idiststream& in, branch_basic<T,distributed>& b)
{
b.get_event_rheolef (in);
}
#endif // _RHEOLEF_HAVE_MPI
template <class T, class M>
idiststream&
operator>> (idiststream& in, branch_basic<T,M>& b)
{
get_event (in,b);
return in;
}
// --------------------------------------------------------------------------
// output
// --------------------------------------------------------------------------
template <class T, class M>
void
branch_basic<T,M>::put_header_rheolef (odiststream& out) const
{
int nval = -1;
if (_n_value != numeric_limits<size_type>::max()) nval = _n_value;
out << "#!branch" << endl
<< endl
<< "branch" << endl
<< "1 " << base::size() << " " << nval << endl
<< _parameter_name;
;
for (size_type i = 0; i < base::size(); i++) {
out << " " << base::operator[](i).first;
}
out << endl;
}
template <class T>
void
put_header (odiststream& out, const branch_basic<T,sequential>& b)
{
iorheo::flag_type format = iorheo::flags(out.os()) & iorheo::format_field;
if (format [iorheo::gnuplot]) { put_header_gnuplot (out, b); }
else if (format [iorheo::paraview]) { put_header_paraview (out,b); }
else if (format [iorheo::vtk]) { put_header_vtk (out,b); }
else if (format [iorheo::rheo]) { b.put_header_rheolef(out); }
else { error_macro ("unsupported output/render format="<<format); }
}
#ifdef _RHEOLEF_HAVE_MPI
template <class T>
void
put_header (odiststream& out, const branch_basic<T,distributed>& b)
{
b.put_header_rheolef (out);
}
#endif // _RHEOLEF_HAVE_MPI
template <class T, class M>
void
branch_basic<T,M>::put_header (odiststream& out) const
{
if (_header_out_done) return;
_header_out_done = true;
rheolef::put_header (out, *this);
}
template <class T, class M>
void
branch_basic<T,M>::put_event_rheolef (odiststream& out) const
{
out << endl
<< setprecision(numeric_limits<T>::digits10)
<< "#" << _parameter_name << " " << _parameter_value << endl
<< endl
;
for (typename branch_basic<T,M>::size_type i = 0; i < base::size(); i++) {
out << catchmark (base::operator[](i).first) << base::operator[](i).second;
}
out.flush(); // when gziped output, make it available as soon as computed
}
template <class T>
void
put_event (odiststream& out, const branch_basic<T,sequential>& b)
{
b.put_header(out);
iorheo::flag_type format = iorheo::flags(out.os()) & iorheo::format_field;
// increment counter
if (format [iorheo::gnuplot]) { put_event_gnuplot (out,b); }
else if (format [iorheo::vtk]) { put_event_vtk (out,b); }
else if (format [iorheo::paraview]){ put_event_paraview (out,b); }
else { b.put_event_rheolef(out); }
}
#ifdef _RHEOLEF_HAVE_MPI
template <class T>
void
put_event (odiststream& out, const branch_basic<T,distributed>& b)
{
b.put_header(out);
b.put_event_rheolef (out);
}
#endif // _RHEOLEF_HAVE_MPI
template <class T, class M>
odiststream&
operator<< (odiststream& out, const branch_basic<T,M>& b)
{
rheolef::put_event (out, b);
return out;
}
template <class T, class M>
void
branch_basic<T,M>::put_finalize_rheolef (odiststream& out) const
{
}
template <class T>
void
put_finalize (odiststream& out, const branch_basic<T,sequential>& b)
{
if (b._finalize_out_done) return;
b._finalize_out_done = true;
iorheo::flag_type format = iorheo::flags(out.os()) & iorheo::format_field;
if (format [iorheo::gnuplot]) { put_finalize_gnuplot (out,b); }
else if (format [iorheo::vtk]) { put_finalize_vtk (out,b); }
else if (format [iorheo::paraview]) { put_finalize_paraview (out,b); }
else { b.put_finalize_rheolef(out); }
}
#ifdef _RHEOLEF_HAVE_MPI
template <class T>
void
put_finalize (odiststream& out, const branch_basic<T,distributed>& b)
{
}
#endif // _RHEOLEF_HAVE_MPI
template <class T, class M>
void
branch_basic<T,M>::put_finalize (odiststream& out) const
{
rheolef::put_finalize (out, *this);
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define rheolef_instanciate(T,M) \
template class branch_basic<T,M>; \
template void get_header (idiststream&, branch_basic<T,M>&); \
template void get_event (idiststream&, branch_basic<T,M>&); \
template odiststream& operator<< (odiststream&, const branch_basic<T,M>&); \
template idiststream& operator>> (idiststream&, branch_basic<T,M>&);
rheolef_instanciate(Float,sequential)
#ifdef _RHEOLEF_HAVE_MPI
rheolef_instanciate(Float,distributed)
#endif // _RHEOLEF_HAVE_MPI
#undef rheolef_instanciate
}// namespace rheolef
Float
see the Float page for the full documentation
rheolef::branch_basic
Definition: branch.h:83
rheolef::branch_basic::put_header_rheolef
void put_header_rheolef(odiststream &) const
Definition: branch.cc:124
rheolef::branch_basic::put_finalize_rheolef
void put_finalize_rheolef(odiststream &) const
Definition: branch.cc:210
rheolef::branch_basic::~branch_basic
~branch_basic()
Definition: branch.cc:29
rheolef::branch_basic::put_finalize
void put_finalize(odiststream &) const
Definition: branch.cc:235
rheolef::branch_basic::get_header_rheolef
void get_header_rheolef(idiststream &)
Definition: branch.cc:39
rheolef::branch_basic::size_type
base::size_type size_type
Definition: branch.h:88
rheolef::branch_basic::get_event_rheolef
void get_event_rheolef(idiststream &)
Definition: branch.cc:56
rheolef::branch_basic::put_event_rheolef
void put_event_rheolef(odiststream &) const
Definition: branch.cc:168
rheolef::branch_basic::put_header
void put_header(odiststream &) const
Definition: branch.cc:160
rheolef::catchmark
see the catchmark page for the full documentation
Definition: catchmark.h:67
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::value
rheolef::std value
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
T
Expr1::float_type T
Definition: field_expr.h:261
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 format format paraview
Definition: iorheo-members.h:125
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 format format format gnuplot
Definition: iorheo-members.h:121
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
rheo
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color rheo
Definition: iorheo-members.h:65
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
rheolef-config.version
version
Definition: rheolef-config.in:126
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
rheolef::get_event
void get_event(idiststream &in, branch_basic< T, sequential > &b)
Definition: branch.cc:91
rheolef::put_header_gnuplot
void put_header_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_gnuplot.cc:41
rheolef::put_event_paraview
void put_event_paraview(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_vtk_paraview.cc:55
rheolef::rheolef_instanciate
rheolef_instanciate(Float, sequential) rheolef_instanciate(Float
rheolef::put_finalize
void put_finalize(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:215
rheolef::get_header
void get_header(idiststream &in, branch_basic< T, sequential > &b)
Definition: branch.cc:82
rheolef::put_finalize_gnuplot
void put_finalize_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_gnuplot.cc:155
rheolef::put_event
void put_event(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:182
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_header
void put_header(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch.cc:141
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::put_header_paraview
void put_header_paraview(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_vtk_paraview.cc:45
rheolef::dis_scatch
bool dis_scatch(idiststream &ips, const communicator &comm, std::string ch)
distributed version of scatch(istream&,string)
Definition: diststream.cc:43
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
rheolef::get_event_vtk
void get_event_vtk(idiststream &ips, branch_basic< T, sequential > &b)
Definition: branch_seq_get_vtk.cc:51
rheolef::put_event_gnuplot
void put_event_gnuplot(odiststream &ops, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_gnuplot.cc:66
rheolef::get_header_vtk
void get_header_vtk(idiststream &ips, branch_basic< T, sequential > &b)
Definition: branch_seq_get_vtk.cc:41
rheolef::put_finalize_paraview
void put_finalize_paraview(odiststream &out, const branch_basic< T, sequential > &b)
Definition: branch_seq_visu_vtk_paraview.cc:97
rheolef::distributed
Definition: distributed.h:88
rheolef::sequential
Definition: distributed.h:28