PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
mshWriter.h
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 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_MSHWRITER_H
12#define RW_MSHWRITER_H
13
14#include "util/matrix.h" // definition of SymMatrix3
15#include "util/point.h" // definition of Point
16#include <cstdint> // uint8_t type
17#include <cstring> // string and size_t type
18#include <fstream>
19#include <vector>
20
21namespace rw {
22
23namespace writer {
24
29class MshWriter {
30
31public:
40 explicit MshWriter(const std::string &filename, const std::string &compress_type = "");
41
52 void appendNodes(const std::vector<util::Point> *nodes,
53 const std::vector<util::Point> *u = nullptr);
54
63 void appendMesh(const std::vector<util::Point> *nodes,
64 const size_t &element_type,
65 const std::vector<size_t> *en_con,
66 const std::vector<util::Point> *u = nullptr);
67
80 void appendPointData(const std::string &name,
81 const std::vector<uint8_t> *data);
82
88 void appendPointData(const std::string &name,
89 const std::vector<size_t> *data);
90
96 void appendPointData(const std::string &name, const std::vector<int> *data);
97
103 void appendPointData(const std::string &name, const std::vector<float> *data);
104
110 void appendPointData(const std::string &name,
111 const std::vector<double> *data);
112
118 void appendPointData(const std::string &name,
119 const std::vector<util::Point> *data);
120
127 void appendPointData(const std::string &name,
128 const std::vector<util::SymMatrix3> *data);
129
142 void appendCellData(const std::string &name, const std::vector<float> *data);
143
149 void appendCellData(const std::string &name,
150 const std::vector<util::SymMatrix3> *data);
151
164 void appendFieldData(const std::string &name, const double &data);
165
171 void appendFieldData(const std::string &name, const float &data);
172
177 void addTimeStep(const double &timestep);
178
184 void close();
185
186private:
200 void writeMshDataHeader(const std::string &name, int field_type,
201 size_t num_data, bool is_node_data = true);
202
204 std::string d_filename;
205
207 std::string d_compressType;
208
210 FILE *d_file;
211};
212
213} // namespace writer
214
215} // namespace rw
216
217#endif // RW_MSHWRITER_H
A .msh writer for simple point data and complex fem mesh data.
Definition mshWriter.h:29
std::string d_compressType
compression_type Specify the compressor (if any)
Definition mshWriter.h:207
void addTimeStep(const double &timestep)
Writes the time step to the file.
void appendMesh(const std::vector< util::Point > *nodes, const size_t &element_type, const std::vector< size_t > *en_con, const std::vector< util::Point > *u=nullptr)
Writes the mesh data to file.
Definition mshWriter.cpp:94
void writeMshDataHeader(const std::string &name, int field_type, size_t num_data, bool is_node_data=true)
utility function
Definition mshWriter.cpp:28
FILE * d_file
msh file
Definition mshWriter.h:210
void appendFieldData(const std::string &name, const double &data)
Writes the scalar field data to the file.
void close()
Closes the file and store it to the hard disk.
void appendNodes(const std::vector< util::Point > *nodes, const std::vector< util::Point > *u=nullptr)
Writes the nodes to the file.
Definition mshWriter.cpp:60
void appendPointData(const std::string &name, const std::vector< uint8_t > *data)
Writes the scalar point data to the file.
void appendCellData(const std::string &name, const std::vector< float > *data)
Writes the float data associated to cells to the file.
std::string d_filename
filename
Definition mshWriter.h:204
Definition contact.h:20
Collection of methods and database related to reading and writing.