Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
field_seq_put_gmsh_pos.cc
Go to the documentation of this file.
1
21//
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
36namespace rheolef {
37using namespace std;
38
39template <class T>
40odiststream&
41field_put_gmsh_pos (odiststream& ods, const field_basic<T,sequential>& uh, std::string name)
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 // ---------------------------
116 // ---------------------------
117 break;
118 }
119#endif // TODO
120 // ---------------------------
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
131 tensor_basic<T> value;
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}
171template <class T>
172odiststream&
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
T & dof(size_type idof)
Definition field.h:738
const geo_type & get_geo() const
Definition field.h:271
const space_type & get_space() const
Definition field.h:270
const std::string & valued() const
Definition field.h:274
std::size_t size_type
Definition field.h:225
generic mesh with rerefence counting
Definition geo.h:1089
see the geo_element page for the full documentation
size_type size() const
variant_type variant() const
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
#define error_macro(message)
Definition dis_macros.h:49
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 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)
STL namespace.