12 #include <unordered_map> 20 namespace unstructured_impl {
26 file_.open(filename, std::ifstream::in);
30 std::getline(file_, line);
31 std::istringstream iss(line);
34 iss >> num_vertices_ >> num_cells_;
37 vertex_start_ = file_.tellg();
39 for(
size_t i(0); i < num_vertices_; ++i) {
40 std::getline(file_, line);
43 cell_start_ = file_.tellg();
51 file_.seekg(cell_start_);
52 for(
size_t l(0); l < num_cells_; ++l) {
53 std::getline(file_, line);
54 std::istringstream iss(line);
55 ids_.push_back(std::vector<size_t>(
56 std::istream_iterator<size_t>(iss), std::istream_iterator<size_t>()));
65 flog_assert(dimension == 0 || dimension == 2,
"invalid dimension");
66 return dimension == 0 ? num_vertices_ : num_cells_;
73 const std::vector<std::vector<size_t>> &
entities(
size_t from_dim,
74 size_t to_dim)
const override {
75 flog_assert(from_dim == 2,
"invalid dimension " << from_dim);
76 flog_assert(to_dim == 0,
"invalid dimension " << to_dim);
85 entities(
size_t from_dim,
size_t to_dim,
size_t entity_id)
const override {
86 flog_assert(from_dim == 2,
"invalid dimension " << from_dim);
87 flog_assert(to_dim == 0,
"invalid dimension " << to_dim);
90 std::vector<size_t> ids;
91 size_t v0, v1, v2, v3;
94 file_.seekg(cell_start_);
97 for(
size_t l(0); l < entity_id; ++l) {
98 std::getline(file_, line);
102 std::getline(file_, line);
103 std::istringstream iss(line);
106 iss >> v0 >> v1 >> v2 >> v3;
116 point_t vertex(
size_t vertex_id)
const {
121 file_.seekg(vertex_start_);
124 for(
size_t l(0); l < vertex_id; ++l) {
125 std::getline(file_, line);
129 std::getline(file_, line);
130 std::istringstream iss(line);
139 mutable std::ifstream file_;
140 std::vector<std::vector<size_t>> ids_;
142 size_t num_vertices_;
145 mutable std::iostream::pos_type vertex_start_;
146 mutable std::iostream::pos_type cell_start_;
const std::vector< std::vector< size_t > > & entities(size_t from_dim, size_t to_dim) const override
Definition: simple_definition.hh:73
Definition: definition.hh:35
#define flog_assert(test, message)
Definition: flog.hh:411
#define flog_fatal(message)
Definition: flog.hh:358
Definition: dimensioned_array.hh:58
Definition: simple_definition.hh:22
std::vector< size_t > entities(size_t from_dim, size_t to_dim, size_t entity_id) const override
Definition: simple_definition.hh:85
size_t num_entities(size_t dimension) const override
Definition: simple_definition.hh:64
Definition: control.hh:31
static constexpr size_t dimension()
Definition: definition.hh:51