Chi-Tech
cell.h
Go to the documentation of this file.
1#ifndef CHI_CELL_H
2#define CHI_CELL_H
3
4#include"../chi_mesh.h"
6#include <tuple>
7
8//Appending cell types to namespace
9namespace chi_mesh
10{
11enum class CellType
12{
13 GHOST = 0,
14 SLAB = 1,
15
16 TRIANGLE = 4,
17 QUADRILATERAL = 5,
18 POLYGON = 6,
19
20 TETRAHEDRON = 7,
21 HEXAHEDRON = 8,
22 WEDGE = 9,
23 PYRAMID = 10,
24 POLYHEDRON = 20,
25
26 POINT = 99
27};
28
29std::string CellTypeName(CellType type);
30
31//######################################################### Class def
32/** In this paradigm a face is an object which largely
33 * is considered to be planar (meaning all the vertices
34 * lay in the same plane).*/
36{
37public:
38 std::vector<uint64_t> vertex_ids_; /// A list of the vertices
39 Normal normal_; ///< The average/geometric normal
40 Vertex centroid_; ///< The face centroid
41 bool has_neighbor_=false; ///< Flag indicating whether face has a neighbor
42 uint64_t neighbor_id_=0; ///< If face has neighbor, contains the global_id.
43 ///< Otherwise contains boundary_id.
44
45public:
46 bool IsNeighborLocal(const chi_mesh::MeshContinuum& grid) const;
48 uint64_t GetNeighborLocalID(const chi_mesh::MeshContinuum& grid) const;
50
51public:
52 double ComputeFaceArea(const chi_mesh::MeshContinuum& grid) const;
53
56 size_t& address);
57 std::string ToString() const;
58
60
61};
62
63
64
65
66//######################################################### Class def
67/**Generic mesh cell object*/
68class Cell
69{
70private:
71 const CellType cell_type_; ///< Primary type, i.e. SLAB, POLYGON, POLYHEDRON
72 const CellType cell_sub_type_; ///< Sub-type i.e. SLAB, QUADRILATERAL, HEXAHEDRON
73
74public:
75 uint64_t global_id_ = 0;
76 uint64_t local_id_ = 0;
77 uint64_t partition_id_ = 0;
79 int material_id_ = -1;
80
81 std::vector<uint64_t> vertex_ids_;
82 std::vector<CellFace> faces_;
83
84public:
85 Cell(const Cell& other);
86 Cell(Cell&& other) noexcept;
87 explicit Cell(CellType in_cell_type,
88 CellType in_cell_sub_type) :
89 cell_type_(in_cell_type),
90 cell_sub_type_(in_cell_sub_type)
91 {}
92
93 Cell& operator=(const Cell& other);
94
95 virtual ~Cell() = default;
96
97public:
98 CellType Type() const {return cell_type_;}
100
103 size_t& address);
104 std::string ToString() const;
105
107};
108
109}
110
111#endif
int GetNeighborPartitionID(const chi_mesh::MeshContinuum &grid) const
Definition: cell.cc:99
Normal normal_
A list of the vertices.
Definition: cell.h:39
bool has_neighbor_
Flag indicating whether face has a neighbor.
Definition: cell.h:41
uint64_t neighbor_id_
Otherwise contains boundary_id.
Definition: cell.h:42
chi_data_types::ByteArray Serialize() const
Definition: cell.cc:225
std::vector< uint64_t > vertex_ids_
Definition: cell.h:38
void RecomputeCentroid(const chi_mesh::MeshContinuum &grid)
Definition: cell.cc:290
bool IsNeighborLocal(const chi_mesh::MeshContinuum &grid) const
Definition: cell.cc:86
double ComputeFaceArea(const chi_mesh::MeshContinuum &grid) const
Definition: cell.cc:183
Vertex centroid_
The face centroid.
Definition: cell.h:40
static CellFace DeSerialize(const chi_data_types::ByteArray &raw, size_t &address)
Definition: cell.cc:244
uint64_t GetNeighborLocalID(const chi_mesh::MeshContinuum &grid) const
Definition: cell.cc:112
int GetNeighborAssociatedFace(const chi_mesh::MeshContinuum &grid) const
Definition: cell.cc:128
std::string ToString() const
Definition: cell.cc:266
Cell(const Cell &other)
Definition: cell.cc:38
std::vector< CellFace > faces_
Definition: cell.h:82
static Cell DeSerialize(const chi_data_types::ByteArray &raw, size_t &address)
Definition: cell.cc:328
virtual ~Cell()=default
void RecomputeCentroidsAndNormals(const chi_mesh::MeshContinuum &grid)
Definition: cell.cc:397
Cell & operator=(const Cell &other)
Definition: cell.cc:69
Cell(CellType in_cell_type, CellType in_cell_sub_type)
Definition: cell.h:87
const CellType cell_type_
Primary type, i.e. SLAB, POLYGON, POLYHEDRON.
Definition: cell.h:71
CellType Type() const
Definition: cell.h:98
CellType SubType() const
Definition: cell.h:99
std::string ToString() const
Definition: cell.cc:364
const CellType cell_sub_type_
Sub-type i.e. SLAB, QUADRILATERAL, HEXAHEDRON.
Definition: cell.h:72
chi_data_types::ByteArray Serialize() const
Definition: cell.cc:301
uint64_t local_id_
Definition: cell.h:76
int material_id_
Definition: cell.h:79
uint64_t partition_id_
Definition: cell.h:77
uint64_t global_id_
Definition: cell.h:75
Vertex centroid_
Definition: cell.h:78
std::vector< uint64_t > vertex_ids_
Definition: cell.h:81
CellType
Definition: cell.h:12
std::string CellTypeName(CellType type)
Definition: cell.cc:12