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 }
84 operator<< (odiststream& ops, const geo_header& h)
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
field::size_type size_type
Definition: branch.cc:425
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
static const variant_type max_variant
static variant_type last_variant_by_dimension(size_type dim)
static variant_type first_variant_by_dimension(size_type dim)
size_t size_type
Definition: basis_get.cc:76
static const char * label_variant[]
Definition: geo_header.cc:26
rheolef::std value
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
coordinate_type coordinate_system(std::string sys_coord)
std::string coordinate_system_name(coordinate_type i)
This file is part of Rheolef.
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
bool need_upgrade() const
Definition: geo_header.cc:79
size_type map_dimension
Definition: geo_header.h:40
size_type dis_size_by_dimension[4]
Definition: geo_header.h:44