rheolef  7.0
field_seq_put_gmsh.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 geo_put_gmsh (odiststream& ods, const geo_basic<T,sequential>&);
15 
16 template <class T>
17 odiststream&
18 field_put_gmsh (odiststream& ods, const field_basic<T,sequential>& uh, std::string name)
19 {
21  geo_put_gmsh (ods, uh.get_geo());
22  if (name == "") { name = uh.get_space().valued(); }
23  ostream& gmsh = ods.os();
24  gmsh << setprecision(numeric_limits<T>::digits10);
25  size_type n_gmsh_comp = 1;
26  switch (uh.get_space().valued_tag()) {
27  case space_constant::scalar: n_gmsh_comp = 1; break;
28  case space_constant::vector: n_gmsh_comp = 3; break;
29  case space_constant::tensor: n_gmsh_comp = 9; break;
30  default: error_macro ("put_gmsh: do not known how to print " << uh.valued() << "-valued field");
31  }
32  if (uh.get_space().degree() != uh.get_geo().order()) {
33  warning_macro ("gmsh: unsupported field degree != geo order");
34  }
35  gmsh << "$NodeData" << endl
36  << "1" << endl
37  << "\"" << name << "\"" << endl
38  << "1" << endl
39  << "0.0" << endl
40  << "3" << endl
41  << "0" << endl
42  << n_gmsh_comp << endl
43  << uh.get_geo().n_node() << endl;
44  switch (uh.get_space().valued_tag()) {
46  for (size_type idof = 0, ndof = uh.ndof(); idof < ndof; idof++) {
47  gmsh << idof+1 << " " << uh.dof(idof) << endl;
48  }
49  break;
50  }
52  size_type n_comp = uh.size();
53  std::vector<field_component_const<T,sequential> > uh_comp (n_comp);
54  for (size_type i_comp = 0; i_comp < n_comp; i_comp++) {
55  uh_comp[i_comp].proxy_assign (uh[i_comp]);
56  }
57  std::vector<T> u_dof (n_comp);
58  for (size_type idof = 0, ndof = uh_comp[0].ndof(); idof < ndof; idof++) {
59  gmsh << idof+1;
60  for (size_type i_comp = 0; i_comp < n_comp; i_comp++) {
61  gmsh << " " << uh_comp[i_comp].dof (idof);
62  }
63  for (size_type i_comp = n_comp; i_comp < 3; i_comp++) {
64  gmsh << " 0";
65  }
66  gmsh << endl;
67  }
68  break;
69  }
71  size_type d = uh.get_geo().dimension();
72  switch (d) {
73  case 1: {
74  field_basic<T,sequential> t00 = uh(0,0);
75  for (size_type idof = 0, ndof = t00.ndof(); idof < ndof; idof++) {
76  gmsh << t00.dof(idof) << " 0 0 "
77  << "0 0 0 "
78  << "0 0 0" << endl;
79  }
80  break;
81  }
82  case 2: {
83  field_basic<T,sequential> t00 = uh(0,0);
84  field_basic<T,sequential> t01 = uh(0,1);
85  field_basic<T,sequential> t11 = uh(1,1);
86  for (size_type idof = 0, ndof = t00.ndof(); idof < ndof; idof++) {
87  gmsh << t00.dof(idof) << " " << t01.dof(idof) << " 0 "
88  << t01.dof(idof) << " " << t11.dof(idof) << " 0 "
89  << "0 0 0" << endl;
90  }
91  break;
92  }
93  case 3: {
94  field_basic<T,sequential> t00 = uh(0,0);
95  field_basic<T,sequential> t01 = uh(0,1);
96  field_basic<T,sequential> t11 = uh(1,1);
97  field_basic<T,sequential> t02 = uh(0,2);
98  field_basic<T,sequential> t12 = uh(1,2);
99  field_basic<T,sequential> t22 = uh(2,2);
100  for (size_type idof = 0, ndof = t00.ndof(); idof < ndof; idof++) {
101  gmsh << t00.dof(idof) << " " << t01.dof(idof) << " " << t02.dof(idof) << " "
102  << t01.dof(idof) << " " << t11.dof(idof) << " " << t12.dof(idof) << " "
103  << t02.dof(idof) << " " << t12.dof(idof) << " " << t22.dof(idof) << endl;
104  }
105  }
106  default: break;
107  }
108  break;
109  }
110  default: error_macro ("put_gmsh: do not known how to print " << uh.valued() << "-valued field");
111  }
112  gmsh << "$EndNodeData" << endl;
113  return ods;
114 }
115 template <class T>
118 {
119  return field_put_gmsh (ods, uh, "");
120 }
122 template odiststream& field_put_gmsh<Float> (odiststream&, const field_basic<Float,sequential>&);
123 
124 }// namespace rheolef
size_type ndof() const
Definition: field.h:318
#define error_macro(message)
Definition: compiler.h:100
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
idiststream, odiststream - distributed interface for large data streams
Definition: diststream.h:68
size_type size() const
Definition: field.h:309
STL namespace.
odiststream & field_put_gmsh(odiststream &, const field_basic< T, sequential > &)
irheostream, orheostream - large data streams
Definition: compiler.h:7
T & dof(size_type idof)
Definition: field.h:553
const std::string & valued() const
Definition: field.h:288
const geo_type & get_geo() const
Definition: field.h:284
#define warning_macro(message)
Definition: compiler.h:102
odiststream & geo_put_gmsh(odiststream &ods, const geo_basic< T, sequential > &)
size_t d
template odiststream & field_put_gmsh< Float >(odiststream &, const field_basic< Float, sequential > &, std::string)
const space_type & get_space() const
Definition: field.h:283
std::ostream & os()
Definition: diststream.h:166