Chi-Tech
volmesher_extruder_createlocal_nodes.cc
Go to the documentation of this file.
2
4
5#include "chi_runtime.h"
6#include "chi_log.h"
7
8#include "chi_mpi.h"
9
10
11//###################################################################
12/** Creates nodes that are owned locally from the 2D template grid.*/
16{
17 //================================================== For each layer
18 std::set<uint64_t> vertex_ids_with_local_scope;
19 for (size_t iz=0; iz<(vertex_layers_.size() - 1); iz++)
20 {
21 for (const auto& template_cell : template_grid.local_cells)
22 {
23 // Check template cell type
24 if (template_cell.Type() != chi_mesh::CellType::POLYGON)
25 throw std::logic_error("Extruder::CreateLocalNodes: "
26 "Template cell error. Not of base type POLYGON");
27
28 bool has_local_scope = HasLocalScope(template_cell, template_grid, iz);
29
30 if (has_local_scope)
31 {
32 auto& vertex_set = vertex_ids_with_local_scope;
33 for (auto tc_vid : template_cell.vertex_ids_)
34 vertex_set.insert(tc_vid + iz * node_z_index_incr_);
35
36 for (auto tc_vid : template_cell.vertex_ids_)
37 vertex_set.insert(tc_vid + (iz + 1) * node_z_index_incr_);
38 }
39 }//for template cell
40 }//for layer
41
42 //============================================= Now add all nodes
43 // that are local or neighboring
44 uint64_t vid = 0;
45 for (auto layer_z_level : vertex_layers_)
46 {
47 for (auto& id_vertex : template_grid.vertices)
48 {
49 const auto& vertex = id_vertex.second;
50 auto local_scope = vertex_ids_with_local_scope.find(vid);
51
52 if (local_scope != vertex_ids_with_local_scope.end())
53 grid.vertices.Insert(vid, Vector3(vertex.x, vertex.y, layer_z_level));
54
55 ++vid;
56 }//for vertex
57 }//for layer
58
59 grid.SetGlobalVertexCount(vid);
60}
LocalCellHandler local_cells
void SetGlobalVertexCount(const uint64_t count)
void Insert(const uint64_t global_id, const chi_mesh::Vector3 &vec)
void CreateLocalNodes(chi_mesh::MeshContinuum &template_grid, chi_mesh::MeshContinuum &grid)
bool HasLocalScope(const chi_mesh::Cell &template_cell, const chi_mesh::MeshContinuum &template_continuum, size_t z_level)
std::vector< double > vertex_layers_
VectorN< 3 > Vector3