Rheolef  7.2
an efficient C++ finite element environment
field_seq_put_gmsh_pos.cc
Go to the documentation of this file.
1 //
22 // gmsh pos output, for mesh adaptation
23 //
24 // author: Pierre.Saramito@imag.fr
25 //
26 // date: 12 may 1997 update: 23 oct 2011
27 //
28 #include "rheolef/field.h"
29 #include "rheolef/piola_util.h"
30 #include "rheolef/rheostream.h"
31 #include "rheolef/iorheo.h"
32 #include "rheolef/field_evaluate.h"
33 #include "rheolef/space_component.h"
34 #include "rheolef/field_expr.h"
35 
36 namespace rheolef {
37 using namespace std;
38 
39 template <class T>
40 odiststream&
42 {
44  if (name == "") { name = uh.get_space().valued(); }
45  ostream& gmsh = ods.os();
46  gmsh << setprecision(numeric_limits<T>::digits10);
47  check_macro (uh.get_space().get_basis().name() == "P1",
48  "gmsh: unsupported " << uh.get_space().get_basis().name() << " approximation");
49  check_macro (uh.get_geo().order() == 1,
50  "gmsh: unsupported geo order > 1");
51  /*
52  type #list-of-coords #list-of-values
53  --------------------------------------------------------------------
54  Scalar point SP 3 1 * nb-time-steps
55  Vector point VP 3 3 * nb-time-steps
56  Tensor point TP 3 9 * nb-time-steps
57  Scalar line SL 6 2 * nb-time-steps
58  Vector line VL 6 6 * nb-time-steps
59  Tensor line TL 6 18 * nb-time-steps
60  Scalar triangle ST 9 3 * nb-time-steps
61  Vector triangle VT 9 9 * nb-time-steps
62  Tensor triangle TT 9 27 * nb-time-steps
63  Scalar quadrangle SQ 12 4 * nb-time-steps
64  Vector quadrangle VQ 12 12 * nb-time-steps
65  Tensor quadrangle TQ 12 36 * nb-time-steps
66  Scalar tetrahedron SS 12 4 * nb-time-steps
67  Vector tetrahedron VS 12 12 * nb-time-steps
68  Tensor tetrahedron TS 12 36 * nb-time-steps
69  Scalar hexahedron SH 24 8 * nb-time-steps
70  Vector hexahedron VH 24 24 * nb-time-steps
71  Tensor hexahedron TH 24 72 * nb-time-steps
72  Scalar prism SI 18 6 * nb-time-steps
73  Vector prism VI 18 18 * nb-time-steps
74  Tensor prism TI 18 54 * nb-time-steps
75  Scalar pyramid SY 15 5 * nb-time-steps
76  Vector pyramid VY 15 15 * nb-time-steps
77  Tensor pyramid TY 15 45 * nb-time-steps
78  */
79  gmsh << "View \"" << name << "\" {" << endl;
80  static char gmsh_pos_type [reference_element::max_variant];
81  gmsh_pos_type [reference_element::p] = 'P';
82  gmsh_pos_type [reference_element::e] = 'L';
83  gmsh_pos_type [reference_element::t] = 'T';
84  gmsh_pos_type [reference_element::q] = 'Q';
85  gmsh_pos_type [reference_element::T] = 'S';
86  gmsh_pos_type [reference_element::H] = 'H';
87  gmsh_pos_type [reference_element::P] = 'I';
88  const geo_basic<T,sequential>& omega = uh.get_geo();
89  switch (uh.get_space().valued_tag()) {
90  // ---------------------------
92  // ---------------------------
93  for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
94  const geo_element& K = omega[ie];
95  gmsh << "S" << gmsh_pos_type[K.variant()] << "(";
96  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
97  const point_basic<T>& x = omega.node(K[iloc]);
98  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
99  gmsh << x[i_comp];
100  if (i_comp != 2) gmsh << ",";
101  }
102  if (iloc != nloc-1) gmsh << ",";
103  }
104  gmsh << "){";
105  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
106  gmsh << uh.dof(K[iloc]);
107  if (iloc != nloc-1) gmsh << ",";
108  }
109  gmsh << "};" << endl;
110  }
111  break;
112  }
113 #ifdef TODO
114  // ---------------------------
115  case space_constant::vector: {
116  // ---------------------------
117  break;
118  }
119 #endif // TODO
120  // ---------------------------
121  case space_constant::tensor: {
122  // ---------------------------
123  size_type d = uh.get_geo().dimension();
124 #ifdef TO_CLEAN
126  for (size_type i_comp = 0; i_comp < d; i_comp++) {
127  for (size_type j_comp = 0; j_comp < d; j_comp++) {
128  uh_comp[i_comp][j_comp].proxy_assign(uh(i_comp,j_comp));
129  }}
130 #endif // TO_CLEAN
132 #define HAVE_ID_DEFAULT_TENSOR
133 #ifdef HAVE_ID_DEFAULT_TENSOR
134  // default (3,3) is 1 instead of 0
135  value (0,0) = value (1,1) = value (2,2) = 1;
136 #endif
137  for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
138  const geo_element& K = omega[ie];
139  gmsh << "T" << gmsh_pos_type[K.variant()] << "(";
140  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
141  const point_basic<T>& x = omega.node(K[iloc]);
142  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
143  gmsh << x[i_comp];
144  if (i_comp != 2) gmsh << ",";
145  }
146  if (iloc != nloc-1) gmsh << ",";
147  }
148  gmsh << "){";
149  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
150  size_type inod = K[iloc];
151  const point_basic<T>& x = omega.node(inod);
152  for (size_type i_comp = 0; i_comp < d; i_comp++) {
153  for (size_type j_comp = 0; j_comp < d; j_comp++) {
154  value(i_comp,j_comp) = uh (i_comp,j_comp).dof (inod);
155  }}
156  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
157  for (size_type j_comp = 0; j_comp < 3; j_comp++) {
158  gmsh << value(i_comp,j_comp);
159  if (i_comp != 2 || j_comp != 2 || iloc != nloc-1) gmsh << ",";
160  }}
161  }
162  gmsh << "};" << endl;
163  }
164  break;
165  }
166  default: error_macro ("put_gmsh: do not known how to print " << uh.valued() << "-valued field");
167  }
168  gmsh << "};" << endl;
169  return ods;
170 }
171 template <class T>
172 odiststream&
174 {
175  return field_put_gmsh_pos (ods, uh, "");
176 }
177 // ----------------------------------------------------------------------------
178 // instanciation in library
179 // ----------------------------------------------------------------------------
182 
183 }// namespace rheolef
field::size_type size_type
Definition: branch.cc:430
const space_type & get_space() const
Definition: field.h:270
const geo_type & get_geo() const
Definition: field.h:271
T & dof(size_type idof)
Definition: field.h:738
const std::string & valued() const
Definition: field.h:274
std::size_t size_type
Definition: field.h:225
size_type size(size_type dim) const
Definition: geo.h:1209
const node_type & node(size_type inod) const
Definition: geo.h:1173
see the geo_element page for the full documentation
Definition: geo_element.h:102
size_type size() const
Definition: geo_element.h:168
variant_type variant() const
Definition: geo_element.h:161
odiststream: see the diststream page for the full documentation
Definition: diststream.h:137
std::ostream & os()
Definition: diststream.h:247
static const variant_type H
static const variant_type q
static const variant_type e
static const variant_type max_variant
static const variant_type p
static const variant_type T
static const variant_type P
static const variant_type t
size_t size_type
Definition: basis_get.cc:76
rheolef::std value
#define error_macro(message)
Definition: dis_macros.h:49
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format gmsh
This file is part of Rheolef.
odiststream & field_put_gmsh_pos(odiststream &, const field_basic< T, sequential > &)
template odiststream & field_put_gmsh_pos< Float >(odiststream &, const field_basic< Float, sequential > &, std::string)