geo_header.cc
Go to the documentation of this file.
#include "rheolef/geo_header.h"
namespace rheolef {
static
const char* label_variant [] = {
"nodes",
"edges",
"triangles",
"quadrangles",
"tetrahedra",
"prisms",
"hexahedra"
};
idiststream&
operator>> (idiststream& ips, geo_header& h)
{
typedef geo_header::size_type size_type;
std::string label;
ips >> label;
check_macro (label == "header", "geo file format version 4: \"header\" keyword not found");
while (ips.good()) {
size_type value;
ips >> label;
if (label == "end") break;
if (label == "dimension") { ips >> h.dimension; }
else if (label == "order") { ips >> h.order; }
else if (label == "coordinate_system") {
std::string sys_coord_name;
ips >> sys_coord_name;
h.sys_coord = space_constant::coordinate_system (sys_coord_name);
}
else {
size_type variant = 0;
for (; variant < reference_element::max_variant; variant++) {
if (label == label_variant[variant]) break;
}
check_macro (variant < reference_element::max_variant, "unexpected header member: \""<<label<<"\"");
ips >> h.dis_size_by_variant [variant];
}
}
ips >> label;
check_macro (label == "header", "geo file format version 4: \"end header\" keyword not found");
// build also size_by_dimension (useful)
for (size_type dim = 0; dim < 4; dim++) {
h.dis_size_by_dimension [dim] = 0;
for (size_type variant = reference_element::first_variant_by_dimension(dim);
variant < reference_element:: last_variant_by_dimension(dim); variant++) {
h.dis_size_by_dimension [dim] += h.dis_size_by_variant [variant];
}
}
// compute also map_dimension = max dimension with non-empty geo_element set
for (h.map_dimension = h.dimension; h.map_dimension != 0; h.map_dimension--) {
if (h.dis_size_by_dimension [h.map_dimension] != 0) break;
}
return ips;
}
bool
geo_header::need_upgrade () const
{
return (map_dimension > 1) && (dis_size_by_dimension [map_dimension] > 0) && (dis_size_by_dimension[1] == 0);
}
odiststream&
operator<< (odiststream& ops, const geo_header& h)
{
using namespace std;
typedef geo_header::size_type size_type;
ops << "header" << endl
<< " dimension " << h.dimension << endl;
if (h.sys_coord != space_constant::cartesian) {
ops << " coordinate_system " << space_constant::coordinate_system_name(h.sys_coord) << endl;
}
if (h.order != 1) {
ops << " order " << h.order << endl;
}
ops << " " << label_variant [0] << "\t" << h.dis_size_by_variant[0] << endl;
for (size_type dim = 3; dim > 0; dim--) {
for (size_type variant = reference_element::first_variant_by_dimension(dim);
variant < reference_element:: last_variant_by_dimension(dim); variant++) {
if (h.dis_size_by_variant[variant] != 0) {
ops << " " << label_variant [variant] << "\t" << h.dis_size_by_variant[variant] << endl;
}
}
}
ops << "end header" << endl;
return ops;
}
} // 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
@ 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