Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
geo_header.cc
Go to the documentation of this file.
1
21#include "rheolef/geo_header.h"
22
23namespace rheolef {
24
25static
26const char* label_variant [] = {
27 "nodes",
28 "edges",
29 "triangles",
30 "quadrangles",
31 "tetrahedra",
32 "prisms",
33 "hexahedra"
34};
35idiststream&
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()) {
43 size_type value;
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;
55 for (; variant < reference_element::max_variant; variant++) {
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;
68 variant < reference_element:: last_variant_by_dimension(dim); variant++) {
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}
78bool
84operator<< (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--) {
99 variant < reference_element:: last_variant_by_dimension(dim); variant++) {
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:430
idiststream: see the diststream page for the full documentation
Definition diststream.h:336
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
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)
static const char * label_variant[]
Definition geo_header.cc:26
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::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition catchmark.h:99
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition catchmark.h:88
STL namespace.
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