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 // ----------------------------------------------------------------------------
178 template odiststream& field_put_gmsh_pos<Float> (odiststream&, const field_basic<Float,sequential>&, std::string);
179 template odiststream& field_put_gmsh_pos<Float> (odiststream&, const field_basic<Float,sequential>&);
180 
181 }// namespace rheolef
rheolef::reference_element::e
static const variant_type e
Definition: reference_element.h:76
rheolef::reference_element::H
static const variant_type H
Definition: reference_element.h:81
rheolef::field_basic::get_space
const space_type & get_space() const
Definition: field.h:300
rheolef::point_basic
Definition: point.h:87
rheolef::value
rheolef::std value
rheolef::field_component_const
Definition: field.h:207
rheolef::reference_element::T
static const variant_type T
Definition: reference_element.h:79
rheolef::tensor_basic
Definition: tensor.h:90
rheolef::geo_element::size
size_type size() const
Definition: geo_element.h:168
rheolef::geo_element
see the geo_element page for the full documentation
Definition: geo_element.h:102
rheolef::odiststream::os
std::ostream & os()
Definition: diststream.h:236
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::geo_element::variant
variant_type variant() const
Definition: geo_element.h:161
rheolef::field_basic::get_geo
const geo_type & get_geo() const
Definition: field.h:301
rheolef::space_constant::tensor
Definition: space_constant.h:138
rheolef::space_constant::scalar
Definition: space_constant.h:136
rheolef::geo_basic< T, sequential >
Definition: geo.h:1108
gmsh
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
Definition: iorheo-members.h:83
rheolef::geo_basic< T, sequential >::node
const node_type & node(size_type inod) const
Definition: geo.h:1173
rheolef::field_basic
Definition: field_expr_utilities.h:38
rheolef::field_basic::dof
T & dof(size_type idof)
Definition: field.h:658
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::field_component_const::proxy_assign
field_component_const< T, M > & proxy_assign(const field_component_const< T, M > &uh_comp)
Definition: field_component.h:280
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
rheolef::field_component_const::dof
const T & dof(size_type idof) const
Definition: field_component.h:169
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::geo_basic< T, sequential >::size
size_type size(size_type dim) const
Definition: geo.h:1209
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
rheolef::field_basic::valued
const std::string & valued() const
Definition: field.h:305
rheolef::reference_element::p
static const variant_type p
Definition: reference_element.h:75
rheolef::reference_element::q
static const variant_type q
Definition: reference_element.h:78
rheolef::reference_element::P
static const variant_type P
Definition: reference_element.h:80
rheolef::space_constant::vector
Definition: space_constant.h:137
rheolef::reference_element::t
static const variant_type t
Definition: reference_element.h:77
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::field_put_gmsh_pos
odiststream & field_put_gmsh_pos(odiststream &, const field_basic< T, sequential > &)
Definition: field_seq_put_gmsh_pos.cc:171
rheolef::field_put_gmsh_pos< Float >
template odiststream & field_put_gmsh_pos< Float >(odiststream &, const field_basic< Float, sequential > &, std::string)
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133
rheolef::field_basic::size_type
std::size_t size_type
Definition: field.h:239