rheolef  6.5
geo_header.cc
Go to the documentation of this file.
1 #include "rheolef/geo_header.h"
2 
3 namespace rheolef {
4 
5 static
6 const char* label_variant [] = {
7  "nodes",
8  "edges",
9  "triangles",
10  "quadrangles",
11  "tetrahedra",
12  "prisms",
13  "hexahedra"
14 };
17 {
19  std::string label;
20  ips >> label;
21  check_macro (label == "header", "geo file format version 4: \"header\" keyword not found");
22  while (ips.good()) {
23  size_type value;
24  ips >> label;
25  if (label == "end") break;
26  if (label == "dimension") { ips >> h.dimension; }
27  else if (label == "order") { ips >> h.order; }
28  else if (label == "coordinate_system") {
29  std::string sys_coord_name;
30  ips >> sys_coord_name;
31  h.sys_coord = space_constant::coordinate_system (sys_coord_name);
32  }
33  else {
34  size_type variant = 0;
35  for (; variant < reference_element::max_variant; variant++) {
36  if (label == label_variant[variant]) break;
37  }
38  check_macro (variant < reference_element::max_variant, "unexpected header member: \""<<label<<"\"");
39  ips >> h.dis_size_by_variant [variant];
40  }
41  }
42  ips >> label;
43  check_macro (label == "header", "geo file format version 4: \"end header\" keyword not found");
44  for (size_type dim = 0; dim < 4; dim++) {
45  h.dis_size_by_dimension [dim] = 0;
46  for (size_type variant = reference_element::first_variant_by_dimension(dim);
47  variant < reference_element:: last_variant_by_dimension(dim); variant++) {
48  h.dis_size_by_dimension [dim] += h.dis_size_by_variant [variant];
49  }
50  }
51  for (h.map_dimension = h.dimension; h.map_dimension != 0; h.map_dimension--) {
52  if (h.dis_size_by_dimension [h.map_dimension] != 0) break;
53  }
54  return ips;
55 }
56 bool
58 {
59  return (map_dimension > 1) && (dis_size_by_dimension [map_dimension] > 0) && (dis_size_by_dimension[1] == 0);
60 }
63 {
64  using namespace std;
66  ops << "header" << endl
67  << " dimension " << h.dimension << endl;
69  ops << " coordinate_system " << space_constant::coordinate_system_name(h.sys_coord) << endl;
70  }
71  if (h.order != 1) {
72  ops << " order " << h.order << endl;
73  }
74  ops << " " << label_variant [0] << "\t" << h.dis_size_by_variant[0] << endl;
75  for (size_type dim = 3; dim > 0; dim--) {
77  variant < reference_element:: last_variant_by_dimension(dim); variant++) {
78  if (h.dis_size_by_variant[variant] != 0) {
79  ops << " " << label_variant [variant] << "\t" << h.dis_size_by_variant[variant] << endl;
80  }
81  }
82  }
83  ops << "end header" << endl;
84  return ops;
85 }
86 
87 } // namespace rheolef
88