Rheolef  7.1
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  // ---------------------------
124  size_type d = uh.get_geo().dimension();
125  for (size_type i_comp = 0; i_comp < d; i_comp++) {
126  for (size_type j_comp = 0; j_comp < d; j_comp++) {
127  uh_comp[i_comp][j_comp].proxy_assign(uh(i_comp,j_comp));
128  }}
130 #define HAVE_ID_DEFAULT_TENSOR
131 #ifdef HAVE_ID_DEFAULT_TENSOR
132  // default (3,3) is 1 instead of 0
133  value (0,0) = value (1,1) = value (2,2) = 1;
134 #endif
135  for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
136  const geo_element& K = omega[ie];
137  gmsh << "T" << gmsh_pos_type[K.variant()] << "(";
138  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
139  const point_basic<T>& x = omega.node(K[iloc]);
140  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
141  gmsh << x[i_comp];
142  if (i_comp != 2) gmsh << ",";
143  }
144  if (iloc != nloc-1) gmsh << ",";
145  }
146  gmsh << "){";
147  for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
148  size_type inod = K[iloc];
149  const point_basic<T>& x = omega.node(inod);
150  for (size_type i_comp = 0; i_comp < d; i_comp++) {
151  for (size_type j_comp = 0; j_comp < d; j_comp++) {
152  value(i_comp,j_comp) = uh_comp [i_comp][j_comp].dof (inod);
153  }}
154  for (size_type i_comp = 0; i_comp < 3; i_comp++) {
155  for (size_type j_comp = 0; j_comp < 3; j_comp++) {
156  gmsh << value(i_comp,j_comp);
157  if (i_comp != 2 || j_comp != 2 || iloc != nloc-1) gmsh << ",";
158  }}
159  }
160  gmsh << "};" << endl;
161  }
162  break;
163  }
164  default: error_macro ("put_gmsh: do not known how to print " << uh.valued() << "-valued field");
165  }
166  gmsh << "};" << endl;
167  return ods;
168 }
169 template <class T>
170 odiststream&
172 {
173  return field_put_gmsh_pos (ods, uh, "");
174 }
175 // ----------------------------------------------------------------------------
176 // instanciation in library
177 // ----------------------------------------------------------------------------
180 
181 }// namespace rheolef
field::size_type size_type
Definition: branch.cc:425
const space_type & get_space() const
Definition: field.h:300
const geo_type & get_geo() const
Definition: field.h:301
T & dof(size_type idof)
Definition: field.h:658
const std::string & valued() const
Definition: field.h:305
std::size_t size_type
Definition: field.h:239
const T & dof(size_type idof) const
field_component_const< T, M > & proxy_assign(const field_component_const< T, M > &uh_comp)
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:126
std::ostream & os()
Definition: diststream.h:236
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)