rheolef  7.0
field_seq_put_gmsh_pos.cc
Go to the documentation of this file.
1 #include "rheolef/field.h"
2 #include "rheolef/piola.h"
3 #include "rheolef/rheostream.h"
4 #include "rheolef/iorheo.h"
5 #include "rheolef/field_evaluate.h"
6 #include "rheolef/space_component.h"
7 #include "rheolef/field_expr_v2_linear.h"
8 
9 namespace rheolef {
10 using namespace std;
11 
12 template <class T>
13 odiststream&
14 field_put_gmsh_pos (odiststream& ods, const field_basic<T,sequential>& uh, std::string name)
15 {
17  if (name == "") { name = uh.get_space().valued(); }
18  ostream& gmsh = ods.os();
19  gmsh << setprecision(numeric_limits<T>::digits10);
20  check_macro (uh.get_space().get_numbering().name() == "P1",
21  "gmsh: unsupported " << uh.get_space().get_numbering().name() << " approximation");
22  check_macro (uh.get_geo().order() == 1,
23  "gmsh: unsupported geo order > 1");
24  /*
25  type #list-of-coords #list-of-values
26  --------------------------------------------------------------------
27  Scalar point SP 3 1 * nb-time-steps
28  Vector point VP 3 3 * nb-time-steps
29  Tensor point TP 3 9 * nb-time-steps
30  Scalar line SL 6 2 * nb-time-steps
31  Vector line VL 6 6 * nb-time-steps
32  Tensor line TL 6 18 * nb-time-steps
33  Scalar triangle ST 9 3 * nb-time-steps
34  Vector triangle VT 9 9 * nb-time-steps
35  Tensor triangle TT 9 27 * nb-time-steps
36  Scalar quadrangle SQ 12 4 * nb-time-steps
37  Vector quadrangle VQ 12 12 * nb-time-steps
38  Tensor quadrangle TQ 12 36 * nb-time-steps
39  Scalar tetrahedron SS 12 4 * nb-time-steps
40  Vector tetrahedron VS 12 12 * nb-time-steps
41  Tensor tetrahedron TS 12 36 * nb-time-steps
42  Scalar hexahedron SH 24 8 * nb-time-steps
43  Vector hexahedron VH 24 24 * nb-time-steps
44  Tensor hexahedron TH 24 72 * nb-time-steps
45  Scalar prism SI 18 6 * nb-time-steps
46  Vector prism VI 18 18 * nb-time-steps
47  Tensor prism TI 18 54 * nb-time-steps
48  Scalar pyramid SY 15 5 * nb-time-steps
49  Vector pyramid VY 15 15 * nb-time-steps
50  Tensor pyramid TY 15 45 * nb-time-steps
51  */
52  gmsh << "View \"" << name << "\" {" << endl;
53  static char gmsh_pos_type [reference_element::max_variant];
54  gmsh_pos_type [reference_element::p] = 'P';
55  gmsh_pos_type [reference_element::e] = 'L';
56  gmsh_pos_type [reference_element::t] = 'T';
57  gmsh_pos_type [reference_element::q] = 'Q';
58  gmsh_pos_type [reference_element::T] = 'S';
59  gmsh_pos_type [reference_element::H] = 'H';
60  gmsh_pos_type [reference_element::P] = 'I';
61  const geo_basic<T,sequential>& omega = uh.get_geo();
62  switch (uh.get_space().valued_tag()) {
64  for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
65  const geo_element& K = omega[ie];
66  gmsh << "S" << gmsh_pos_type[K.variant()] << "(";
67  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
68  const point_basic<T>& x = omega.node(K[iloc]);
69  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
70  gmsh << x[i_comp];
71  if (i_comp != 2) gmsh << ",";
72  }
73  if (iloc != nloc-1) gmsh << ",";
74  }
75  gmsh << "){";
76  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
77  gmsh << uh.dof(K[iloc]);
78  if (iloc != nloc-1) gmsh << ",";
79  }
80  gmsh << "};" << endl;
81  }
82  break;
83  }
84 #ifdef TODO
86  break;
87  }
88 #endif // TODO
91  size_type d = uh.get_geo().dimension();
92  for (size_type i_comp = 0; i_comp < d; i_comp++) {
93  for (size_type j_comp = 0; j_comp < d; j_comp++) {
94  uh_comp[i_comp][j_comp].proxy_assign(uh(i_comp,j_comp));
95  }}
97 #define HAVE_ID_DEFAULT_TENSOR
98 #ifdef HAVE_ID_DEFAULT_TENSOR
99  value (0,0) = value (1,1) = value (2,2) = 1;
100 #endif
101  for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
102  const geo_element& K = omega[ie];
103  gmsh << "T" << gmsh_pos_type[K.variant()] << "(";
104  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
105  const point_basic<T>& x = omega.node(K[iloc]);
106  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
107  gmsh << x[i_comp];
108  if (i_comp != 2) gmsh << ",";
109  }
110  if (iloc != nloc-1) gmsh << ",";
111  }
112  gmsh << "){";
113  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
114  size_type inod = K[iloc];
115  const point_basic<T>& x = omega.node(inod);
116  for (size_type i_comp = 0; i_comp < d; i_comp++) {
117  for (size_type j_comp = 0; j_comp < d; j_comp++) {
118  value(i_comp,j_comp) = uh_comp [i_comp][j_comp].dof (inod);
119  }}
120  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
121  for (size_type j_comp = 0; j_comp < 3; j_comp++) {
122  gmsh << value(i_comp,j_comp);
123  if (i_comp != 2 || j_comp != 2 || iloc != nloc-1) gmsh << ",";
124  }}
125  }
126  gmsh << "};" << endl;
127  }
128  break;
129  }
130  default: error_macro ("put_gmsh: do not known how to print " << uh.valued() << "-valued field");
131  }
132  gmsh << "};" << endl;
133  return ods;
134 }
135 template <class T>
138 {
139  return field_put_gmsh_pos (ods, uh, "");
140 }
142 template odiststream& field_put_gmsh_pos<Float> (odiststream&, const field_basic<Float,sequential>&);
143 
144 }// namespace rheolef
static const variant_type t
#define error_macro(message)
Definition: compiler.h:100
static const variant_type max_variant
static const variant_type q
std::size_t size_type
Definition: field.h:234
field - piecewise polynomial finite element field
verbose clean transpose logscale grid shrink ball stereo iso volume velocity elevation bezieradapt label color color format format format format format format gmsh
field_component_const< T, M > & proxy_assign(const field_component_const< T, M > &uh_comp)
template odiststream & field_put_gmsh_pos< Float >(odiststream &, const field_basic< Float, sequential > &, std::string)
idiststream, odiststream - distributed interface for large data streams
Definition: diststream.h:68
static const variant_type P
point - vertex of a mesh
Definition: point.h:22
static const variant_type p
STL namespace.
irheostream, orheostream - large data streams
Definition: compiler.h:7
static const variant_type T
T & dof(size_type idof)
Definition: field.h:553
const std::string & valued() const
Definition: field.h:288
static const variant_type e
const geo_type & get_geo() const
Definition: field.h:284
size_type size() const
#define check_macro(ok_condition, message)
Definition: compiler.h:104
size_t d
static const variant_type H
rheolef::std value
const T & dof(size_type idof) const
const space_type & get_space() const
Definition: field.h:283
odiststream & field_put_gmsh_pos(odiststream &, const field_basic< T, sequential > &)
geo_element - element of a mesh
variant_type variant() const
const node_type & node(size_type inod) const
Definition: geo.h:973
std::ostream & os()
Definition: diststream.h:166
size_type size(size_type dim) const
Definition: geo.h:1063