Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
branch_seq_get_vtk.cc
Go to the documentation of this file.
1
21//
22// branch: vtk input
23//
24// author: Pierre.Saramito@imag.fr
25//
26// 28 janv 2020
27//
28#include "rheolef/branch.h"
29#include "rheolef/rheostream.h"
30#include "rheolef/iorheo.h"
31
32namespace rheolef {
33
34// extern:
35template <class T>
36idiststream&
37geo_get_vtk (idiststream& ips, geo_basic<T,sequential>& omega);
38
39template <class T>
40void
42{
44 if (b._header_in_done) return;
45 b._header_in_done = true;
46 b._parameter_name = "t"; // unknown yet
47 b._n_value = std::numeric_limits<size_type>::max();
48}
49template <class T>
50void
52{
53 using namespace std;
55 // 1. get geo
57 geo_get_vtk (ips, omega);
58 check_macro (ips.good(), "bad input stream for vtk");
59 istream& is = ips.is();
60 string basename = iorheo::getbasename(is);
61 omega.set_name(basename);
62 // 2. get fields
63 string mark;
64 b.resize(0);
65 while (is) {
66 while (is >> ws >> mark) {
67 if (mark == "CELL_DATA" || mark == "POINT_DATA" || mark == "FIELD") break;
68 }
69 if (!is.good()) break; // end of file: close this event
70 size_type ndof = 0;
71 string name, dummy, approx, valued;
72 if (mark == "POINT_DATA" || mark == "CELL_DATA") {
73 is >> ndof;
74 while (is >> ws >> dummy) { if (dummy == "SCALARS") break; }
75 is >> name;
76 while (is >> ws >> dummy) { if (dummy == "LOOKUP_TABLE") break; }
77 is >> dummy; // the LOOKUP_TABLE name
78 // TODO: if mesh is Pk-order, then POINT_DATA are Pk also
79 // => manage omega.order > 1 in get_seq_get_vtk.cc and check it here
80 approx = (mark == "CELL_DATA") ? "P0" : "P1";
81 valued = "scalar";
82 space_basic<T,sequential> Xh (omega, approx, valued);
84 for (size_type idof = 0; idof < ndof && is.good(); ++idof) { is >> uh.dof (idof); }
85 check_macro (is.good(), "bad input stream for vtk");
86 b.push_back (std::make_pair(name, uh));
87 } else if (mark == "FIELD") {
88 size_type n_field;
89 is >> dummy // something like "FieldData"
90 >> n_field;
91 for (size_type i_field = 0; i_field < n_field && is.good(); ++i_field) {
92 size_type n_comp, n_comp_dof;
93 is >> name;
94 if (name == "METADATA") {
95 // skit an optional trailing "METADATA INFORMATION 0"
96 is >> dummy >> dummy
97 >> name;
98 }
99 is >> n_comp >> n_comp_dof
100 >> dummy; // "float"
101 switch (n_comp) {
102 case 1: valued = "scalar"; break;
103 case 3: valued = "vector"; break;
104 case 9: valued = "tensor"; break;
105 default: error_macro ("branch: unexpected " << n_comp << "-component valued field");
106 }
107 ndof = n_comp*n_comp_dof;
108 // TODO: if mesh is Pk-order, then FIELD are Pk also
109 // => manage omega.order > 1 in get_seq_get_vtk.cc and check it here
110 approx = "P1";
111 space_basic<T,sequential> Xh (omega, approx, valued);
113 for (size_type idof = 0; idof < ndof && is.good(); ++idof) { is >> uh.dof (idof); }
114 check_macro (is.good(), "bad input stream for vtk");
115 b.push_back (std::make_pair(name, uh));
116 }
117 } else {
118 error_macro ("branch: unexpected `" << mark << "' in vtk input."
119 << " Expect POINT_DATA, or FIELD");
120 }
121 }
122}
123// ----------------------------------------------------------------------------
124// instanciation in library
125// ----------------------------------------------------------------------------
128
129}// namespace rheolef
field::size_type size_type
Definition branch.cc:430
T & dof(size_type idof)
Definition field.h:738
generic mesh with rerefence counting
Definition geo.h:1089
idiststream: see the diststream page for the full documentation
Definition diststream.h:336
std::istream & is()
Definition diststream.h:400
the finite element space
Definition space.h:382
#define error_macro(message)
Definition dis_macros.h:49
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
This file is part of Rheolef.
idiststream & geo_get_vtk(idiststream &ips, geo_basic< T, sequential > &omega)
template void get_event_vtk< Float >(idiststream &, branch_basic< Float, sequential > &)
void get_event_vtk(idiststream &ips, branch_basic< T, sequential > &b)
template void get_header_vtk< Float >(idiststream &, branch_basic< Float, sequential > &)
void get_header_vtk(idiststream &ips, branch_basic< T, sequential > &b)
STL namespace.