25 using boost::property_tree::ptree;
29 MeshState::MeshState()
40 size_t MeshState::GetNumNodes()
const
45 void MeshState::SetNumNodes(
size_t n)
52 m_nodes_attr.SetNum(n);
55 int MeshState::GetNodeID(
size_t node_idx)
const
57 return m_nodes_id.at(node_idx);
60 double MeshState::GetNodeX(
size_t node_idx)
const
62 return m_nodes_x.at(node_idx);
65 double MeshState::GetNodeY(
size_t node_idx)
const
67 return m_nodes_y.at(node_idx);
70 void MeshState::SetNodeID(
size_t node_idx,
int value)
72 m_nodes_id.at(node_idx) = value;
75 void MeshState::SetNodeX(
size_t node_idx,
double value)
77 m_nodes_x.at(node_idx) = value;
80 void MeshState::SetNodeY(
size_t node_idx,
double value)
82 m_nodes_y.at(node_idx) = value;
85 vector<int> MeshState::GetNodesID()
const
90 vector<double> MeshState::GetNodesX()
const
95 vector<double> MeshState::GetNodesY()
const
100 void MeshState::SetNodesID(vector<int> values)
102 if (values.size() != m_num_nodes) {
103 throw runtime_error(
"MeshState::SetNodesID(): Number of IDs doesn't match number of nodes.");
109 void MeshState::SetNodesX(vector<double> values)
111 if (values.size() != m_num_nodes) {
112 throw runtime_error(
"MeshState::SetNodesX(): Number of X coords doesn't match number of nodes.");
118 void MeshState::SetNodesY(vector<double> values)
120 if (values.size() != m_num_nodes) {
121 throw runtime_error(
"MeshState::SetNodesY(): Number of Y coords doesn't match number of nodes.");
131 size_t MeshState::GetNumCells()
const
136 void MeshState::SetNumCells(
size_t n)
140 m_cells_id.resize(n);
141 m_cells_nodes.resize(n);
142 m_cells_walls.resize(n);
143 m_cells_attr.SetNum(n);
146 int MeshState::GetCellID(
size_t cell_idx)
const
148 return m_cells_id.at(cell_idx);
151 size_t MeshState::GetCellNumNodes(
size_t cell_idx)
const
153 return m_cells_nodes.at(cell_idx).size();
156 vector<int> MeshState::GetCellNodes(
size_t cell_idx)
const
158 return m_cells_nodes.at(cell_idx);
161 size_t MeshState::GetCellNumWalls(
size_t cell_idx)
const
163 return m_cells_walls.at(cell_idx).size();
166 vector<int> MeshState::GetCellWalls(
size_t cell_idx)
const
168 return m_cells_walls.at(cell_idx);
171 void MeshState::SetCellID(
size_t cell_idx,
int value)
173 m_cells_id.at(cell_idx) = value;
176 void MeshState::SetCellNodes(
size_t cell_idx, vector<int> node_ids)
178 m_cells_nodes.at(cell_idx) = node_ids;
181 void MeshState::SetCellWalls(
size_t cell_idx, vector<int> wall_ids)
183 m_cells_walls.at(cell_idx) = wall_ids;
186 vector<int> MeshState::GetCellsID()
const
191 vector<size_t> MeshState::GetCellsNumNodes()
const
193 vector<size_t> cells_num_nodes(m_num_cells);
195 for (vector<int> cell_nodes : m_cells_nodes) {
196 cells_num_nodes[cell_idx++] = cell_nodes.size();
198 return cells_num_nodes;
201 vector<size_t> MeshState::GetCellsNumWalls()
const
203 vector<size_t> cells_num_walls(m_num_cells);
205 for (vector<int> cell_walls : m_cells_walls) {
206 cells_num_walls[cell_idx++] = cell_walls.size();
208 return cells_num_walls;
211 void MeshState::SetCellsID(vector<int> values)
213 if (values.size() != m_num_cells) {
214 throw runtime_error(
"MeshState::SetCellsID(): Number of IDs doesn't match number of cells.");
220 vector<int> MeshState::GetBoundaryPolygonNodes()
const
222 return m_boundary_polygon_nodes;
225 vector<int> MeshState::GetBoundaryPolygonWalls()
const
227 return m_boundary_polygon_walls;
230 void MeshState::SetBoundaryPolygonNodes(vector<int> node_ids)
232 m_boundary_polygon_nodes = node_ids;
235 void MeshState::SetBoundaryPolygonWalls(vector<int> wall_ids)
237 m_boundary_polygon_walls = wall_ids;
244 size_t MeshState::GetNumWalls()
const
249 void MeshState::SetNumWalls(
size_t n)
253 m_walls_id.resize(n);
254 m_walls_cells.resize(n);
255 m_walls_nodes.resize(n);
256 m_walls_attr.SetNum(n);
259 int MeshState::GetWallID(
size_t wall_idx)
const
261 return m_walls_id.at(wall_idx);
264 pair<int, int> MeshState::GetWallNodes(
size_t wall_idx)
const
266 return m_walls_nodes.at(wall_idx);
269 pair<int, int> MeshState::GetWallCells(
size_t wall_idx)
const
271 return m_walls_cells.at(wall_idx);
274 void MeshState::SetWallID(
size_t wall_idx,
int value)
276 m_walls_id.at(wall_idx) = value;
279 void MeshState::SetWallNodes(
size_t wall_idx, pair<int, int> nodes_ids)
281 m_walls_nodes.at(wall_idx) = nodes_ids;
284 void MeshState::SetWallCells(
size_t wall_idx, pair<int, int> cells_ids)
286 m_walls_cells.at(wall_idx) = cells_ids;
289 vector<int> MeshState::GetWallsID()
const
294 void MeshState::SetWallsID(vector<int> values)
296 if (values.size() != m_num_walls) {
297 throw runtime_error(
"setWallsID(): Number of IDs doesn't match number of walls.");
303 void MeshState::PrintToStream(ostream& out)
const
305 out <<
"MeshState:" << endl;
308 out <<
"Nodes:" << endl;
309 out << setw(6) <<
"ID" << setw(16) <<
"X" << setw(16) <<
"Y";
310 for (
string name : NodeAttributeContainer().GetNames<int>()) {
311 out << setw(20) << (name +
" [i]");
313 for (
string name : NodeAttributeContainer().GetNames<
double>()) {
314 out << setw(20) << (name +
" [d]");
316 for (
string name : NodeAttributeContainer().GetNames<
string>()) {
317 out << setw(20) << (name +
" [s]");
320 for (
size_t idx = 0; idx < NodeAttributeContainer().GetNum(); ++idx) {
321 out << setw(6) << m_nodes_id[idx];
322 out << setw(16) << m_nodes_x[idx];
323 out << setw(16) << m_nodes_y[idx];
324 for (
string name : NodeAttributeContainer().GetNames<int>()) {
325 out << setw(20) << NodeAttributeContainer().Get<
int>(idx, name);
327 for (
string name : NodeAttributeContainer().GetNames<
double>()) {
328 out << setw(20) << NodeAttributeContainer().Get<
double>(idx, name);
330 for (
string name : NodeAttributeContainer().GetNames<
string>()) {
331 out << setw(20) << NodeAttributeContainer().Get<
string>(idx, name);
337 out <<
"Cells:" << endl;
338 out << setw(6) <<
"ID";
339 for (
string name : CellAttributeContainer().GetNames<int>()) {
340 out << setw(20) << (name +
" [i]");
342 for (
string name : CellAttributeContainer().GetNames<
double>()) {
343 out << setw(20) << (name +
" [d]");
345 for (
string name : CellAttributeContainer().GetNames<
string>()) {
346 out << setw(20) << (name +
" [s]");
348 out << setw(8) <<
"Nodes / Walls" << endl;
349 for (
size_t idx = 0; idx < CellAttributeContainer().GetNum(); ++idx) {
350 out << setw(6) << m_cells_id[idx];
351 for (
string name : CellAttributeContainer().GetNames<int>()) {
352 out << setw(20) << CellAttributeContainer().Get<
int>(idx, name);
354 for (
string name : CellAttributeContainer().GetNames<
double>()) {
355 out << setw(20) << CellAttributeContainer().Get<
double>(idx, name);
357 for (
string name : CellAttributeContainer().GetNames<
string>()) {
358 out << setw(20) << CellAttributeContainer().Get<
string>(idx, name);
361 for (
const int node_id : m_cells_nodes[idx]) {
362 out << node_id <<
" ";
365 for (
const int wall_id : m_cells_walls[idx]) {
366 out << wall_id <<
" ";
372 out <<
"Boundary polygon : Nodes / Walls" << endl;
374 for (
const int node_id : m_boundary_polygon_nodes) {
375 out << node_id <<
" ";
378 for (
const int wall_id : m_boundary_polygon_walls) {
379 out << wall_id <<
" ";
384 out <<
"Walls:" << endl;
385 out << setw(6) <<
"ID" <<
386 setw(8) <<
"cell_1" << setw(8) <<
"cell_2"
387 << setw(8) <<
"node_1" << setw(8) <<
"node_2";
388 for (
string name : WallAttributeContainer().GetNames<int>()) {
389 out << setw(20) << (name +
" [i]");
391 for (
string name : WallAttributeContainer().GetNames<
double>()) {
392 out << setw(20) << (name +
" [d]");
394 for (
string name : WallAttributeContainer().GetNames<
string>()) {
395 out << setw(20) << (name +
" [s]");
398 for (
size_t idx = 0; idx < WallAttributeContainer().GetNum(); ++idx) {
399 out << setw(6) << m_walls_id[idx];
400 out << setw(8) << m_walls_cells[idx].first;
401 out << setw(8) << m_walls_cells[idx].second;
402 out << setw(8) << m_walls_nodes[idx].first;
403 out << setw(8) << m_walls_nodes[idx].second;
404 for (
string name : WallAttributeContainer().GetNames<int>()) {
405 out << setw(20) << WallAttributeContainer().Get<
int>(idx, name);
407 for (
string name : WallAttributeContainer().GetNames<
double>()) {
408 out << setw(20) << WallAttributeContainer().Get<
double>(idx, name);
410 for (
string name : WallAttributeContainer().GetNames<
string>()) {
411 out << setw(20) << WallAttributeContainer().Get<
string>(idx, name);
Namespace for the core simulator.