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"
52put_edge (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
54 typedef typename geo_basic<T,sequential>::size_type
size_type;
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;
68put_triangle (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
70 typedef typename geo_basic<T,sequential>::size_type
size_type;
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;
94put_quadrangle (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
96 typedef typename geo_basic<T,sequential>::size_type
size_type;
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;
117put_tetrahedron (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
119 typedef typename geo_basic<T,sequential>::size_type
size_type;
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;
169raw_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 <<
" "
184put_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)
186 typedef typename geo_basic<T,sequential>::size_type
size_type;
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;
224put_hexahedron (ostream&
vtk,
const geo_element& K,
const basis_basic<T>& my_numb,
const geo_basic<T,sequential>& omega)
226 typedef typename geo_basic<T,sequential>::size_type
size_type;
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;
257put (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;
302 for (
size_type inod = 0, nnod = my_node.size(); inod < nnod; inod++) {
303 vtk << my_node[inod] << endl;
308 size_type map_dim = omega.map_dimension();
310 std::array<size_type,reference_element::max_variant> size_by_variant;
311 size_by_variant.fill (0);
312 for (
size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
313 const geo_element& K = omega.get_geo_element (map_dim, ie);
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;
324 loc_ncell [variant] =
pow(my_order,
d);
325 loc_ndata [variant] = (n+1)*loc_ncell [variant];
326 ncell += loc_ncell[variant]*size_by_variant [variant];
327 ndata += loc_ndata[variant]*size_by_variant [variant];
333 string cell_numb_name =
"P"+std::to_string(my_numb.
degree())+opt_d;
335 vtk <<
"CELLS " << ncell <<
" " << ndata << endl;
336 for (
size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
337 const geo_element& K = omega.get_geo_element (map_dim, ie);
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;
352 for (
size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
353 const geo_element& K = omega.get_geo_element (map_dim, ie);
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;
364 for (
size_type inod = 0, nnod = my_node.size(); inod < nnod; inod++) {
384put_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()) {
436 subgeo_dim = omega.map_dimension();
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;
451 for (
size_type inod = 0, nnod = my_node.size(); inod < nnod; inod++) {
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++) {
461 const geo_element& K = omega.get_geo_element (subgeo_dim, ie);
462 size_by_variant [K.
variant()]++;
466 std::array<size_type,reference_element::max_variant> loc_ndata;
471 loc_ndata [variant] = n+1;
472 ncell += size_by_variant [variant];
473 ndata += loc_ndata[variant]*size_by_variant [variant];
479 string cell_numb_name =
"P"+std::to_string(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++) {
483 const geo_element& K = omega.get_geo_element (subgeo_dim, 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++) {
517 const geo_element& K = omega.get_geo_element (subgeo_dim, 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;
545 for (
size_type inod = 0, nnod = my_node.size(); inod < nnod; inod++) {
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) \
576template 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, \
#define _RHEOLEF_instanciation(T, M, A)
field::size_type size_type
see the Float page for the full documentation
bool is_discontinuous() const
see the disarray page for the full documentation
generic mesh with rerefence counting
see the geo_element page for the full documentation
reference_element::size_type size_type
variant_type variant() const
odiststream: see the diststream page for the full documentation
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static const variant_type H
size_type n_vertex() const
static const variant_type q
static const variant_type e
static variant_type last_variant_by_dimension(size_type dim)
size_type dimension() const
static variant_type first_variant_by_dimension(size_type dim)
static const variant_type p
static size_type n_node(variant_type variant, size_type order)
static const variant_type T
static const variant_type P
static const variant_type t
#define trace_macro(message)
#define error_macro(message)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
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
void dis_idof(const basis_basic< T > &b, const geo_size &gs, const geo_element &K, typename std::vector< size_type >::iterator dis_idof_tab)
This file is part of Rheolef.
odiststream & geo_put_vtk_high(odiststream &ops, const geo_basic< T, sequential > &omega, const basis_basic< T > &my_numb, const disarray< point_basic< T >, sequential > &my_node, bool append_data=true, size_t subgeo_dim=std::numeric_limits< size_t >::max())
odiststream & geo_put_vtk(odiststream &ops, const geo_basic< T, sequential > &omega, const basis_basic< T > &my_numb, const disarray< point_basic< T >, sequential > &my_node, bool append_data, size_t subgeo_dim)
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
void put(std::ostream &out, std::string name, const tiny_matrix< T > &a)
odiststream & geo_put_vtk_old(odiststream &ops, const geo_basic< T, sequential > &omega, const basis_basic< T > &my_numb, const disarray< point_basic< T >, sequential > &my_node, bool append_data)
#define VTK_BIQUADRATIC_QUADRATIC_WEDGE
#define VTK_LAGRANGE_QUADRILATERAL
#define VTK_QUADRATIC_EDGE
#define VTK_LAGRANGE_TETRAHEDRON
#define VTK_QUADRATIC_TRIANGLE
#define VTK_LAGRANGE_WEDGE
#define VTK_LAGRANGE_CURVE
#define VTK_QUADRATIC_TETRA
#define VTK_LAGRANGE_TRIANGLE
#define VTK_LAGRANGE_HEXAHEDRON
#define VTK_TRIQUADRATIC_HEXAHEDRON
#define VTK_BIQUADRATIC_QUAD