Chi-Tech
unpartmesh_05_pushproxycell.cc
Go to the documentation of this file.
2
3//###################################################################
4/**Makes a cell from proxy information and pushes the cell to the mesh.*/
6 PushProxyCell(const std::string& type_str,
7 const std::string& sub_type_str,
8 int cell_num_faces, int cell_material_id,
9 const std::vector<std::vector<uint64_t>> &proxy_faces)
10{
11 const std::string fname = __FUNCTION__;
13 if (type_str == "SLAB" ) type = CellType::SLAB;
14 else if (type_str == "POLYGON" ) type = CellType::POLYGON;
15 else if (type_str == "POLYHEDRON") type = CellType::POLYHEDRON;
16 else
17 throw std::logic_error(fname + ": Unsupported cell primary type.");
18
19 chi_mesh::CellType sub_type;
20 if (sub_type_str == "SLAB" ) sub_type = CellType::SLAB;
21 else if (sub_type_str == "POLYGON" ) sub_type = CellType::POLYGON;
22 else if (sub_type_str == "TRIANGLE" ) sub_type = CellType::TRIANGLE;
23 else if (sub_type_str == "QUADRILATERAL") sub_type = CellType::QUADRILATERAL;
24 else if (sub_type_str == "POLYHEDRON" ) sub_type = CellType::POLYHEDRON;
25 else if (sub_type_str == "TETRAHEDRON" ) sub_type = CellType::TETRAHEDRON;
26 else if (sub_type_str == "HEXAHEDRON" ) sub_type = CellType::HEXAHEDRON;
27 else
28 throw std::logic_error(fname + ": Unsupported cell secondary type.");
29
30 auto cell = new LightWeightCell(type, sub_type);
31
32 cell->material_id = cell_material_id;
33
34 //Filter cell-vertex-ids from faces
35 std::set<uint64_t> cell_vertex_id_set;
36 for (auto& proxy_face : proxy_faces)
37 for (uint64_t fvid : proxy_face)
38 cell_vertex_id_set.insert(fvid);
39
40 //Assign cell-vertex-ids
41 cell->vertex_ids.reserve(cell_vertex_id_set.size());
42 for (uint64_t cvid : cell_vertex_id_set)
43 cell->vertex_ids.push_back(cvid);
44
45 //Assign faces from proxy faces
46 cell->faces.reserve(cell_num_faces);
47 for (auto& proxy_face : proxy_faces)
48 cell->faces.emplace_back(proxy_face);
49
50 raw_cells_.push_back(cell);
51
53 if (type == CellType::SLAB ) dimension = DIMENSION_1;
54 if (type == CellType::POLYGON ) dimension = DIMENSION_2;
55 if (type == CellType::POLYHEDRON) dimension = DIMENSION_3;
56
57 attributes_ = dimension | UNSTRUCTURED;
58}
std::vector< LightWeightCell * > raw_cells_
void PushProxyCell(const std::string &type_str, const std::string &sub_type_str, int cell_num_faces, int cell_material_id, const std::vector< std::vector< uint64_t > > &proxy_faces)
CellType
Definition: cell.h:12
MeshAttributes
Definition: chi_mesh.h:70
@ UNSTRUCTURED
Definition: chi_mesh.h:77
@ DIMENSION_1
Definition: chi_mesh.h:72
@ DIMENSION_2
Definition: chi_mesh.h:73
@ DIMENSION_3
Definition: chi_mesh.h:74