Rheolef  7.1
an efficient C++ finite element environment
geo_header.cc
Go to the documentation of this file.
1 #include "rheolef/geo_header.h"
22 
23 namespace rheolef {
24 
25 static
26 const char* label_variant [] = {
27  "nodes",
28  "edges",
29  "triangles",
30  "quadrangles",
31  "tetrahedra",
32  "prisms",
33  "hexahedra"
34 };
35 idiststream&
36 operator>> (idiststream& ips, geo_header& h)
37 {
39  std::string label;
40  ips >> label;
41  check_macro (label == "header", "geo file format version 4: \"header\" keyword not found");
42  while (ips.good()) {
44  ips >> label;
45  if (label == "end") break;
46  if (label == "dimension") { ips >> h.dimension; }
47  else if (label == "order") { ips >> h.order; }
48  else if (label == "coordinate_system") {
49  std::string sys_coord_name;
50  ips >> sys_coord_name;
51  h.sys_coord = space_constant::coordinate_system (sys_coord_name);
52  }
53  else {
54  size_type variant = 0;
56  if (label == label_variant[variant]) break;
57  }
58  check_macro (variant < reference_element::max_variant, "unexpected header member: \""<<label<<"\"");
59  ips >> h.dis_size_by_variant [variant];
60  }
61  }
62  ips >> label;
63  check_macro (label == "header", "geo file format version 4: \"end header\" keyword not found");
64  // build also size_by_dimension (useful)
65  for (size_type dim = 0; dim < 4; dim++) {
66  h.dis_size_by_dimension [dim] = 0;
69  h.dis_size_by_dimension [dim] += h.dis_size_by_variant [variant];
70  }
71  }
72  // compute also map_dimension = max dimension with non-empty geo_element set
73  for (h.map_dimension = h.dimension; h.map_dimension != 0; h.map_dimension--) {
74  if (h.dis_size_by_dimension [h.map_dimension] != 0) break;
75  }
76  return ips;
77 }
78 bool
80 {
81  return (map_dimension > 1) && (dis_size_by_dimension [map_dimension] > 0) && (dis_size_by_dimension[1] == 0);
82 }
85 {
86  using namespace std;
88  ops << "header" << endl
89  << " dimension " << h.dimension << endl;
90  if (h.sys_coord != space_constant::cartesian) {
91  ops << " coordinate_system " << space_constant::coordinate_system_name(h.sys_coord) << endl;
92  }
93  if (h.order != 1) {
94  ops << " order " << h.order << endl;
95  }
96  ops << " " << label_variant [0] << "\t" << h.dis_size_by_variant[0] << endl;
97  for (size_type dim = 3; dim > 0; dim--) {
100  if (h.dis_size_by_variant[variant] != 0) {
101  ops << " " << label_variant [variant] << "\t" << h.dis_size_by_variant[variant] << endl;
102  }
103  }
104  }
105  ops << "end header" << endl;
106  return ops;
107 }
108 
109 } // namespace rheolef
rheolef::reference_element::last_variant_by_dimension
static variant_type last_variant_by_dimension(size_type dim)
Definition: reference_element.h:150
rheolef::space_constant::coordinate_system_name
std::string coordinate_system_name(coordinate_type i)
Definition: space_constant.cc:69
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
mkgeo_contraction.h
h
Definition: mkgeo_contraction.sh:179
rheolef::space_constant::cartesian
Definition: space_constant.h:122
rheolef::value
rheolef::std value
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::reference_element::first_variant_by_dimension
static variant_type first_variant_by_dimension(size_type dim)
Definition: reference_element.h:148
mkgeo_ball.variant
variant
Definition: mkgeo_ball.sh:149
rheolef::label_variant
static const char * label_variant[]
Definition: geo_header.cc:26
rheolef::geo_header::map_dimension
size_type map_dimension
Definition: geo_header.h:40
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
rheolef::geo_header::size_type
size_t size_type
Definition: geo_header.h:33
rheolef::geo_header::dis_size_by_dimension
size_type dis_size_by_dimension[4]
Definition: geo_header.h:44
rheolef::geo_header::need_upgrade
bool need_upgrade() const
Definition: geo_header.cc:79
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
mkgeo_ball.dim
dim
Definition: mkgeo_ball.sh:307
rheolef::space_constant::coordinate_system
coordinate_type coordinate_system(std::string sys_coord)
Definition: space_constant.cc:75
rheolef::std
Definition: vec_expr_v2.h:391
rheolef::geo_header
Definition: geo_header.h:32