branch_seq_get_vtk.cc
Go to the documentation of this file.
//
// branch: vtk input
//
// author: Pierre.Saramito@imag.fr
//
// 28 janv 2020
//
#include "rheolef/branch.h"
#include "rheolef/rheostream.h"
#include "rheolef/iorheo.h"
namespace rheolef {
// extern:
template <class T>
idiststream&
geo_get_vtk (idiststream& ips, geo_basic<T,sequential>& omega);
template <class T>
void
get_header_vtk (idiststream& ips, branch_basic<T,sequential>& b)
{
typedef typename geo_basic<T,sequential>::size_type size_type;
if (b._header_in_done) return;
b._header_in_done = true;
b._parameter_name = "t"; // unknown yet
b._n_value = std::numeric_limits<size_type>::max();
}
template <class T>
void
get_event_vtk (idiststream& ips, branch_basic<T,sequential>& b)
{
using namespace std;
typedef typename geo_basic<T,sequential>::size_type size_type;
// 1. get geo
geo_basic<T,sequential> omega;
geo_get_vtk (ips, omega);
check_macro (ips.good(), "bad input stream for vtk");
istream& is = ips.is();
string basename = iorheo::getbasename(is);
omega.set_name(basename);
// 2. get fields
string mark;
b.resize(0);
while (is) {
while (is >> ws >> mark) {
if (mark == "CELL_DATA" || mark == "POINT_DATA" || mark == "FIELD") break;
}
if (!is.good()) break; // end of file: close this event
size_type ndof = 0;
string name, dummy, approx, valued;
if (mark == "POINT_DATA" || mark == "CELL_DATA") {
is >> ndof;
while (is >> ws >> dummy) { if (dummy == "SCALARS") break; }
is >> name;
while (is >> ws >> dummy) { if (dummy == "LOOKUP_TABLE") break; }
is >> dummy; // the LOOKUP_TABLE name
// TODO: if mesh is Pk-order, then POINT_DATA are Pk also
// => manage omega.order > 1 in get_seq_get_vtk.cc and check it here
approx = (mark == "CELL_DATA") ? "P0" : "P1";
valued = "scalar";
space_basic<T,sequential> Xh (omega, approx, valued);
field_basic<T,sequential> uh (Xh);
for (size_type idof = 0; idof < ndof && is.good(); ++idof) { is >> uh.dof (idof); }
check_macro (is.good(), "bad input stream for vtk");
b.push_back (std::make_pair(name, uh));
} else if (mark == "FIELD") {
size_type n_field;
is >> dummy // something like "FieldData"
>> n_field;
for (size_type i_field = 0; i_field < n_field && is.good(); ++i_field) {
size_type n_comp, n_comp_dof;
is >> name;
if (name == "METADATA") {
// skit an optional trailing "METADATA INFORMATION 0"
is >> dummy >> dummy
>> name;
}
is >> n_comp >> n_comp_dof
>> dummy; // "float"
switch (n_comp) {
case 1: valued = "scalar"; break;
case 3: valued = "vector"; break;
case 9: valued = "tensor"; break;
default: error_macro ("branch: unexpected " << n_comp << "-component valued field");
}
ndof = n_comp*n_comp_dof;
// TODO: if mesh is Pk-order, then FIELD are Pk also
// => manage omega.order > 1 in get_seq_get_vtk.cc and check it here
approx = "P1";
space_basic<T,sequential> Xh (omega, approx, valued);
field_basic<T,sequential> uh (Xh);
for (size_type idof = 0; idof < ndof && is.good(); ++idof) { is >> uh.dof (idof); }
check_macro (is.good(), "bad input stream for vtk");
b.push_back (std::make_pair(name, uh));
}
} else {
error_macro ("branch: unexpected `" << mark << "' in vtk input."
<< " Expect POINT_DATA, or FIELD");
}
}
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
template void get_header_vtk<Float> (idiststream&, branch_basic<Float,sequential>&);
template void get_event_vtk<Float> (idiststream&, branch_basic<Float,sequential>&);
}// namespace rheolef
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::branch_basic
Definition: branch.h:83
rheolef::field_basic
Definition: field.h:235
rheolef::field_basic::dof
T & dof(size_type idof)
Definition: field.h:658
rheolef::geo_basic< T, sequential >
Definition: geo.h:1108
rheolef::geo_basic< T, sequential >::set_name
void set_name(std::string name)
rheolef::geo_basic
generic mesh with rerefence counting
Definition: geo.h:1089
rheolef::space_basic< T, sequential >
Definition: space.h:361
rheolef::std
Definition: vec_expr_v2.h:402
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::dummy
static iorheo::force_initialization dummy
Definition: iorheo.cc:147
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
mkgeo_ball.b
int b
Definition: mkgeo_ball.sh:152
mkgeo_contraction.name
string name
Definition: mkgeo_contraction.sh:133
mkgeo_couette.basename
string basename
Definition: mkgeo_couette.sh:73
rheolef::space_numbering::ndof
size_type ndof(const basis_basic< T > &b, const geo_size &gs, size_type map_dim)
Definition: space_numbering.cc:28
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::get_header_vtk< Float >
template void get_header_vtk< Float >(idiststream &, branch_basic< Float, sequential > &)
rheolef::get_event_vtk< Float >
template void get_event_vtk< Float >(idiststream &, branch_basic< Float, sequential > &)
rheolef::get_event_vtk
void get_event_vtk(idiststream &ips, branch_basic< T, sequential > &b)
Definition: branch_seq_get_vtk.cc:51
rheolef::geo_get_vtk
idiststream & geo_get_vtk(idiststream &ips, geo_basic< T, sequential > &omega)
Definition: geo_seq_get_vtk.cc:39
rheolef::get_header_vtk
void get_header_vtk(idiststream &ips, branch_basic< T, sequential > &b)
Definition: branch_seq_get_vtk.cc:41