PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
mshReader.h
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2024 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#ifndef RW_MSHREADER_H
12#define RW_MSHREADER_H
13
14#include "util/point.h" // definition of Point
15#include <fstream>
16#include <string>
17#include <vector>
18
19namespace rw {
20
21namespace reader {
22
28class MshReader {
29
30public:
35 explicit MshReader(const std::string &filename);
36
49 void readMesh(size_t dim, std::vector<util::Point> *nodes,
50 size_t &element_type, size_t &num_elems,
51 std::vector<size_t> *enc, std::vector<std::vector<size_t>> *nec,
52 std::vector<double> *volumes, bool is_fd = false);
53
59 void readNodes(std::vector<util::Point> *nodes);
60
69 void readCells(size_t dim, size_t &element_type,
70 size_t &num_elems, std::vector<size_t> *enc,
71 std::vector<std::vector<size_t>> *nec);
72
79 bool readPointData(const std::string &name, std::vector<util::Point> *data);
80
87 bool readPointData(const std::string &name, std::vector<double> *data);
88
90 void close();
91
92private:
94 std::string d_filename;
95
97 std::ifstream d_file;
98};
99
100} // namespace reader
101
102} // namespace rw
103
104#endif // RW_MSHREADER_H
A class to read Gmsh (msh) mesh files.
Definition mshReader.h:28
std::string d_filename
filename
Definition mshReader.h:94
void readMesh(size_t dim, std::vector< util::Point > *nodes, size_t &element_type, size_t &num_elems, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec, std::vector< double > *volumes, bool is_fd=false)
Reads mesh data into node file and element file.
Definition mshReader.cpp:22
void readCells(size_t dim, size_t &element_type, size_t &num_elems, std::vector< size_t > *enc, std::vector< std::vector< size_t > > *nec)
Reads cell data, i.e. element-node connectivity and node-element connectivity.
bool readPointData(const std::string &name, std::vector< util::Point > *data)
reads point data from .vtu file
void close()
Close the file.
void readNodes(std::vector< util::Point > *nodes)
Reads nodal position.
std::ifstream d_file
vtk/vtu file
Definition mshReader.h:97
Collection of methods and database related to reading and writing.