field_seq_put_gmsh_pos.cc
Go to the documentation of this file.
//
// gmsh pos output, for mesh adaptation
//
// author: Pierre.Saramito@imag.fr
//
// date: 12 may 1997 update: 23 oct 2011
//
#include "rheolef/field.h"
#include "rheolef/piola_util.h"
#include "rheolef/rheostream.h"
#include "rheolef/iorheo.h"
#include "rheolef/field_evaluate.h"
#include "rheolef/space_component.h"
#include "rheolef/field_expr.h"
namespace rheolef {
using namespace std;
template <class T>
odiststream&
field_put_gmsh_pos (odiststream& ods, const field_basic<T,sequential>& uh, std::string name)
{
typedef typename field_basic<T,sequential>::size_type size_type;
if (name == "") { name = uh.get_space().valued(); }
ostream& gmsh = ods.os();
gmsh << setprecision(numeric_limits<T>::digits10);
check_macro (uh.get_space().get_basis().name() == "P1",
"gmsh: unsupported " << uh.get_space().get_basis().name() << " approximation");
check_macro (uh.get_geo().order() == 1,
"gmsh: unsupported geo order > 1");
/*
type #list-of-coords #list-of-values
--------------------------------------------------------------------
Scalar point SP 3 1 * nb-time-steps
Vector point VP 3 3 * nb-time-steps
Tensor point TP 3 9 * nb-time-steps
Scalar line SL 6 2 * nb-time-steps
Vector line VL 6 6 * nb-time-steps
Tensor line TL 6 18 * nb-time-steps
Scalar triangle ST 9 3 * nb-time-steps
Vector triangle VT 9 9 * nb-time-steps
Tensor triangle TT 9 27 * nb-time-steps
Scalar quadrangle SQ 12 4 * nb-time-steps
Vector quadrangle VQ 12 12 * nb-time-steps
Tensor quadrangle TQ 12 36 * nb-time-steps
Scalar tetrahedron SS 12 4 * nb-time-steps
Vector tetrahedron VS 12 12 * nb-time-steps
Tensor tetrahedron TS 12 36 * nb-time-steps
Scalar hexahedron SH 24 8 * nb-time-steps
Vector hexahedron VH 24 24 * nb-time-steps
Tensor hexahedron TH 24 72 * nb-time-steps
Scalar prism SI 18 6 * nb-time-steps
Vector prism VI 18 18 * nb-time-steps
Tensor prism TI 18 54 * nb-time-steps
Scalar pyramid SY 15 5 * nb-time-steps
Vector pyramid VY 15 15 * nb-time-steps
Tensor pyramid TY 15 45 * nb-time-steps
*/
gmsh << "View \"" << name << "\" {" << endl;
static char gmsh_pos_type [reference_element::max_variant];
gmsh_pos_type [reference_element::p] = 'P';
gmsh_pos_type [reference_element::e] = 'L';
gmsh_pos_type [reference_element::t] = 'T';
gmsh_pos_type [reference_element::q] = 'Q';
gmsh_pos_type [reference_element::T] = 'S';
gmsh_pos_type [reference_element::H] = 'H';
gmsh_pos_type [reference_element::P] = 'I';
const geo_basic<T,sequential>& omega = uh.get_geo();
switch (uh.get_space().valued_tag()) {
// ---------------------------
case space_constant::scalar: {
// ---------------------------
for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
const geo_element& K = omega[ie];
gmsh << "S" << gmsh_pos_type[K.variant()] << "(";
for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
const point_basic<T>& x = omega.node(K[iloc]);
for (size_type i_comp = 0; i_comp < 3; i_comp++) {
gmsh << x[i_comp];
if (i_comp != 2) gmsh << ",";
}
if (iloc != nloc-1) gmsh << ",";
}
gmsh << "){";
for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
gmsh << uh.dof(K[iloc]);
if (iloc != nloc-1) gmsh << ",";
}
gmsh << "};" << endl;
}
break;
}
#ifdef TODO
// ---------------------------
case space_constant::vector: {
// ---------------------------
break;
}
#endif // TODO
// ---------------------------
case space_constant::tensor: {
// ---------------------------
field_component_const<T,sequential> uh_comp [3][3];
size_type d = uh.get_geo().dimension();
for (size_type i_comp = 0; i_comp < d; i_comp++) {
for (size_type j_comp = 0; j_comp < d; j_comp++) {
uh_comp[i_comp][j_comp].proxy_assign(uh(i_comp,j_comp));
}}
tensor_basic<T> value;
#define HAVE_ID_DEFAULT_TENSOR
#ifdef HAVE_ID_DEFAULT_TENSOR
// default (3,3) is 1 instead of 0
value (0,0) = value (1,1) = value (2,2) = 1;
#endif
for (size_type ie = 0, ne = omega.size(); ie < ne; ie++) {
const geo_element& K = omega[ie];
gmsh << "T" << gmsh_pos_type[K.variant()] << "(";
for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
const point_basic<T>& x = omega.node(K[iloc]);
for (size_type i_comp = 0; i_comp < 3; i_comp++) {
gmsh << x[i_comp];
if (i_comp != 2) gmsh << ",";
}
if (iloc != nloc-1) gmsh << ",";
}
gmsh << "){";
for (size_type iloc = 0, nloc = K.size(); iloc < nloc; iloc++) {
size_type inod = K[iloc];
const point_basic<T>& x = omega.node(inod);
for (size_type i_comp = 0; i_comp < d; i_comp++) {
for (size_type j_comp = 0; j_comp < d; j_comp++) {
value(i_comp,j_comp) = uh_comp [i_comp][j_comp].dof (inod);
}}
for (size_type i_comp = 0; i_comp < 3; i_comp++) {
for (size_type j_comp = 0; j_comp < 3; j_comp++) {
gmsh << value(i_comp,j_comp);
if (i_comp != 2 || j_comp != 2 || iloc != nloc-1) gmsh << ",";
}}
}
gmsh << "};" << endl;
}
break;
}
default: error_macro ("put_gmsh: do not known how to print " << uh.valued() << "-valued field");
}
gmsh << "};" << endl;
return ods;
}
template <class T>
odiststream&
field_put_gmsh_pos (odiststream& ods, const field_basic<T,sequential>& uh)
{
return field_put_gmsh_pos (ods, uh, "");
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
template odiststream& field_put_gmsh_pos<Float> (odiststream&, const field_basic<Float,sequential>&, std::string);
template odiststream& field_put_gmsh_pos<Float> (odiststream&, const field_basic<Float,sequential>&);
}// namespace rheolef
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::field_basic
Definition: field.h:235
rheolef::field_basic::get_space
const space_type & get_space() const
Definition: field.h:300
rheolef::field_basic::get_geo
const geo_type & get_geo() const
Definition: field.h:301
rheolef::field_basic::dof
T & dof(size_type idof)
Definition: field.h:658
rheolef::field_basic::valued
const std::string & valued() const
Definition: field.h:305
rheolef::field_basic::size_type
std::size_t size_type
Definition: field.h:239
rheolef::field_component_const
Definition: field_component.h:143
rheolef::field_component_const::dof
const T & dof(size_type idof) const
Definition: field_component.h:169
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
rheolef::geo_basic< T, sequential >
Definition: geo.h:1108
rheolef::geo_basic< T, sequential >::size
size_type size(size_type dim) const
Definition: geo.h:1209
rheolef::geo_basic< T, sequential >::node
const node_type & node(size_type inod) const
Definition: geo.h:1173
rheolef::geo_element
see the geo_element page for the full documentation
Definition: geo_element.h:102
rheolef::geo_element::size
size_type size() const
Definition: geo_element.h:168
rheolef::geo_element::variant
variant_type variant() const
Definition: geo_element.h:161
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::odiststream::os
std::ostream & os()
Definition: diststream.h:236
rheolef::point_basic
Definition: point.h:87
rheolef::reference_element::H
static const variant_type H
Definition: reference_element.h:81
rheolef::reference_element::q
static const variant_type q
Definition: reference_element.h:78
rheolef::reference_element::e
static const variant_type e
Definition: reference_element.h:76
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
rheolef::reference_element::p
static const variant_type p
Definition: reference_element.h:75
rheolef::reference_element::T
static const variant_type T
Definition: reference_element.h:79
rheolef::reference_element::P
static const variant_type P
Definition: reference_element.h:80
rheolef::reference_element::t
static const variant_type t
Definition: reference_element.h:77
rheolef::tensor_basic
Definition: tensor.h:90
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::value
rheolef::std value
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
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
mkgeo_ball.d
int d
Definition: mkgeo_ball.sh:154
mkgeo_contraction.name
string name
Definition: mkgeo_contraction.sh:133
rheolef::space_constant::tensor
@ tensor
Definition: space_constant.h:138
rheolef::space_constant::scalar
@ scalar
Definition: space_constant.h:136
rheolef::space_constant::vector
@ vector
Definition: space_constant.h:137
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
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)