30 #include "rheolef/geo.h"
31 #include "rheolef/space_numbering.h"
32 #include "rheolef/piola_util.h"
33 #include "rheolef/rheostream.h"
34 #include "rheolef/iorheo.h"
52 put_edge (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
55 typedef point_basic<size_type> ilat;
56 std::vector<size_type> inod;
59 for (
size_type i = 0; i < my_order; i++) {
62 vtk <<
"2\t" << inod[loc_inod0] <<
" " << inod[loc_inod1] << endl;
68 put_triangle (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
71 typedef point_basic<size_type> ilat;
72 std::vector<size_type> inod;
75 for (
size_type i = 0; i < my_order; i++) {
76 for (
size_type j = 0; i+j < my_order; j++) {
80 vtk <<
"3\t" << inod[loc_inod00] <<
" "
81 << inod[loc_inod10] <<
" "
82 << inod[loc_inod01] << endl;
83 if (i+j+1 >= my_order)
continue;
85 vtk <<
"3\t" << inod[loc_inod10] <<
" "
86 << inod[loc_inod11] <<
" "
87 << inod[loc_inod01] << endl;
94 put_quadrangle (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
97 typedef point_basic<size_type> ilat;
98 std::vector<size_type> inod;
101 for (
size_type i = 0; i < my_order; i++) {
102 for (
size_type j = 0; j < my_order; j++) {
107 vtk <<
"4\t" << inod[loc_inod00] <<
" "
108 << inod[loc_inod10] <<
" "
109 << inod[loc_inod11] <<
" "
110 << inod[loc_inod01] << endl;
117 put_tetrahedron (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
120 typedef point_basic<size_type> ilat;
121 std::vector<size_type> inod;
124 for (
size_type i = 0; i < my_order; i++) {
125 for (
size_type j = 0; i+j < my_order; j++) {
126 for (
size_type k = 0; i+j+k < my_order; k++) {
131 vtk <<
"4\t" << inod[loc_inod000] <<
" "
132 << inod[loc_inod100] <<
" "
133 << inod[loc_inod010] <<
" "
134 << inod[loc_inod001] << endl;
135 if (i+j+k+2 > my_order)
continue;
140 vtk <<
"4\t" << inod[loc_inod100] <<
" "
141 << inod[loc_inod101] <<
" "
142 << inod[loc_inod010] <<
" "
143 << inod[loc_inod001] << endl
144 <<
"4\t" << inod[loc_inod010] <<
" "
145 << inod[loc_inod011] <<
" "
146 << inod[loc_inod001] <<
" "
147 << inod[loc_inod101] << endl
148 <<
"4\t" << inod[loc_inod100] <<
" "
149 << inod[loc_inod101] <<
" "
150 << inod[loc_inod110] <<
" "
151 << inod[loc_inod010] << endl
152 <<
"4\t" << inod[loc_inod010] <<
" "
153 << inod[loc_inod110] <<
" "
154 << inod[loc_inod011] <<
" "
155 << inod[loc_inod101] << endl;
157 if (i+j+k+3 > my_order)
continue;
159 vtk <<
"4\t" << inod[loc_inod111] <<
" "
160 << inod[loc_inod101] <<
" "
161 << inod[loc_inod011] <<
" "
162 << inod[loc_inod110] << endl;
169 raw_put_prism (ostream&
vtk,
170 size_t i000,
size_t i100,
size_t i010,
171 size_t i001,
size_t i101,
size_t i011)
174 vtk <<
"6\t" << i000 <<
" "
184 put_prism (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega,
const disarray<point_basic<Float>,sequential>& my_node)
187 typedef point_basic<size_type> ilat;
188 std::vector<size_type> inod;
191 for (
size_type k = 0; k < my_order; k++) {
192 for (
size_type j = 0; j < my_order; j++) {
193 for (
size_type i = 0; i+j < my_order; i++) {
207 if (i+j+1 >= my_order)
continue;
224 put_hexahedron (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
227 typedef point_basic<size_type> ilat;
228 std::vector<size_type> inod;
231 for (
size_type i = 0; i < my_order; i++) {
232 for (
size_type j = 0; j < my_order; j++) {
233 for (
size_type k = 0; k < my_order; k++) {
242 vtk <<
"8\t" << inod[loc_inod000] <<
" "
243 << inod[loc_inod100] <<
" "
244 << inod[loc_inod110] <<
" "
245 << inod[loc_inod010] <<
" "
246 << inod[loc_inod001] <<
" "
247 << inod[loc_inod101] <<
" "
248 << inod[loc_inod111] <<
" "
249 << inod[loc_inod011] << endl;
257 put (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega,
const disarray<point_basic<Float>,sequential>& my_node)
259 switch (K.variant()) {
267 default:
error_macro (
"unsupported element variant `" << K.name() <<
"'");
288 ostream&
vtk = ops.
os();
289 check_macro (my_order >= omega.
order(),
"order="<<omega.
order()<<
" > field degree="<<my_order);
293 vtk << setprecision(numeric_limits<T>::digits10)
294 <<
"# vtk DataFile Version 1.0" << endl
295 <<
"Unstructured Grid" << endl
297 <<
"DATASET UNSTRUCTURED_GRID" << endl;
301 vtk <<
"POINTS " << my_node.size() <<
" float" << endl;
303 vtk << my_node[inod] << endl;
310 std::array<size_type,reference_element::max_variant> size_by_variant;
311 size_by_variant.fill (0);
314 size_by_variant [K.
variant()]++;
318 std::array<size_type,reference_element::max_variant> loc_ncell;
319 std::array<size_type,reference_element::max_variant> loc_ndata;
333 string cell_numb_name =
"P"+
itos(my_numb.
degree())+opt_d;
335 vtk <<
"CELLS " << ncell <<
" " << ndata << endl;
338 put (
vtk, K, cell_numb, omega, my_node);
343 std::array<size_type,reference_element::max_variant> cell_type;
351 vtk <<
"CELL_TYPES " << ncell << endl;
359 if (! append_data)
return ops;
360 std::string data_name =
"mesh";
361 vtk <<
"POINT_DATA " << my_node.size() << endl
362 <<
"SCALARS " << data_name <<
" float" << endl
363 <<
"LOOKUP_TABLE default" << endl;
384 put_high_nicely_ordered (
386 const basis_basic<T>& my_numb,
387 const geo_basic<T,sequential>& omega,
388 const geo_element& K)
391 std::vector<size_type> inod;
394 for (
size_type loc_inod = 0, loc_nnod = inod.size(); loc_inod < loc_nnod; loc_inod++) {
395 vtk <<
" " << inod[loc_inod];
404 const basis_basic<T>& my_numb,
405 const geo_basic<T,sequential>& omega,
406 const geo_element& K)
408 switch (K.variant()) {
416 default:
error_macro (
"unsupported element variant `" << K.name() <<
"'");
426 bool append_data =
true,
427 size_t subgeo_dim = std::numeric_limits<size_t>::max())
435 if (subgeo_dim == std::numeric_limits<size_type>::max()) {
438 ostream&
vtk = ops.
os();
442 vtk << setprecision(numeric_limits<T>::digits10)
443 <<
"# vtk DataFile Version 1.0" << endl
444 <<
"Unstructured Grid" << endl
446 <<
"DATASET UNSTRUCTURED_GRID" << endl;
450 vtk <<
"POINTS " << my_node.size() <<
" float" << endl;
452 vtk << my_node[inod] << endl;
458 std::array<size_type,reference_element::max_variant> size_by_variant;
459 size_by_variant.fill (0);
460 for (
size_type ie = 0, ne = omega.
size(subgeo_dim); ie < ne; ie++) {
462 size_by_variant [K.
variant()]++;
466 std::array<size_type,reference_element::max_variant> loc_ndata;
472 ncell += size_by_variant [
variant];
479 string cell_numb_name =
"P"+
itos(my_numb.
degree())+opt_d;
481 vtk <<
"CELLS " << ncell <<
" " << ndata << endl;
482 for (
size_type ie = 0, ne = omega.
size(subgeo_dim); ie < ne; ie++) {
484 put_high (
vtk, cell_numb, omega, K);
491 std::array<size_type,reference_element::max_variant> cell_type_one;
499 std::array<size_type,reference_element::max_variant> cell_type_two;
507 std::array<size_type,reference_element::max_variant> cell_type_high;
515 vtk <<
"CELL_TYPES " << ncell << endl;
516 for (
size_type ie = 0, ne = omega.
size(subgeo_dim); ie < ne; ie++) {
531 case 1:
vtk << cell_type_one [K.
variant()] << endl;
break;
532 case 2:
vtk << cell_type_two [K.
variant()] << endl;
break;
533 default:
vtk << cell_type_high [K.
variant()] << endl;
break;
540 if (! append_data)
return ops;
541 std::string data_name =
"mesh";
542 vtk <<
"POINT_DATA " << my_node.size() << endl
543 <<
"SCALARS " << data_name <<
" float" << endl
544 <<
"LOOKUP_TABLE default" << endl;
565 #if (_RHEOLEF_PARAVIEW_VERSION_MAJOR >= 5) && (_RHEOLEF_PARAVIEW_VERSION_MINOR >= 5)
567 return geo_put_vtk_high (ops, omega, my_numb, my_node, append_data, subgeo_dim);
575 #define _RHEOLEF_instanciation(T) \
576 template odiststream& geo_put_vtk ( \
578 const geo_basic<T,sequential>& omega, \
579 const basis_basic<T>& my_numb, \
580 const disarray<point_basic<T>,sequential>& my_node, \