Chi-Tech
pwl_polygon_00_constrdestr.cc
Go to the documentation of this file.
2
5
7{
8
9// ###################################################################
10/** Constructor.*/
12 const chi_mesh::Cell& poly_cell,
13 const chi_mesh::MeshContinuum& ref_grid,
14 const chi_math::QuadratureTriangle& volume_quadrature,
15 const chi_math::QuadratureLine& surface_quadrature)
17 poly_cell,
18 poly_cell.vertex_ids_.size(), // num_nodes
19 MakeFaceNodeMapping(poly_cell)),
20 volume_quadrature_(volume_quadrature),
21 surface_quadrature_(surface_quadrature)
22{
23 num_of_subtris_ = static_cast<int>(poly_cell.faces_.size());
24 beta_ = 1.0 / num_of_subtris_;
25
26 //=========================================== Get raw vertices
27 vc_ = poly_cell.centroid_;
28
29 //=========================================== Calculate legs and determinants
30 for (int side = 0; side < num_of_subtris_; side++)
31 {
32 const chi_mesh::CellFace& face = poly_cell.faces_[side];
33
34 const auto& v0 = ref_grid_.vertices[face.vertex_ids_[0]];
35 const auto& v1 = ref_grid_.vertices[face.vertex_ids_[1]];
37
38 chi_mesh::Vector3 sidev01 = v1 - v0;
39 chi_mesh::Vector3 sidev02 = v2 - v0;
40
41 double sidedetJ = ((sidev01.x) * (sidev02.y) - (sidev02.x) * (sidev01.y));
42
43 FEside_data2d triangle_data;
44 triangle_data.detJ = sidedetJ;
45 triangle_data.detJ_surf = sidev01.Norm();
46
47 triangle_data.v_index[0] = face.vertex_ids_[0];
48 triangle_data.v_index[1] = face.vertex_ids_[1];
49
50 triangle_data.v0 = v0;
51
52 // Set Jacobian
53 triangle_data.J.SetIJ(0, 0, sidev01.x);
54 triangle_data.J.SetIJ(1, 0, sidev01.y);
55 triangle_data.J.SetIJ(0, 1, sidev02.x);
56 triangle_data.J.SetIJ(1, 1, sidev02.y);
57 triangle_data.J.SetIJ(2, 2, 0.0);
58
59 // Set Jacobian inverse
60 triangle_data.Jinv.SetIJ(0, 0, sidev02.y / sidedetJ);
61 triangle_data.Jinv.SetIJ(1, 0, -sidev01.y / sidedetJ);
62 triangle_data.Jinv.SetIJ(0, 1, -sidev02.x / sidedetJ);
63 triangle_data.Jinv.SetIJ(1, 1, sidev01.x / sidedetJ);
64 triangle_data.Jinv.SetIJ(2, 2, 0.0);
65
66 // Set Jacobian-Transpose inverse
67 triangle_data.JTinv.SetIJ(0, 0, sidev02.y / sidedetJ);
68 triangle_data.JTinv.SetIJ(1, 0, -sidev02.x / sidedetJ);
69 triangle_data.JTinv.SetIJ(0, 1, -sidev01.y / sidedetJ);
70 triangle_data.JTinv.SetIJ(1, 1, sidev01.x / sidedetJ);
71 triangle_data.JTinv.SetIJ(2, 2, 0.0);
72
73 // Set face normal
74 triangle_data.normal = face.normal_;
75
76 sides_.push_back(triangle_data);
77 }
78
79 //=========================================== Compute node to side mapping
80 for (int v = 0; v < poly_cell.vertex_ids_.size(); v++)
81 {
82 const uint64_t vindex = poly_cell.vertex_ids_[v];
83 std::vector<int> side_mapping(num_of_subtris_);
84 for (int side = 0; side < num_of_subtris_; side++)
85 {
86 side_mapping[side] = -1;
87
88 const chi_mesh::CellFace& face = poly_cell.faces_[side];
89 if (face.vertex_ids_[0] == vindex) { side_mapping[side] = 0; }
90 if (face.vertex_ids_[1] == vindex) { side_mapping[side] = 1; }
91 }
92 node_to_side_map_.push_back(side_mapping);
93 }
94}
95
96} // namespace chi_math::cell_mapping
const chi_mesh::MeshContinuum & ref_grid_
Definition: CellMapping.h:117
PieceWiseLinearPolygonMapping(const chi_mesh::Cell &poly_cell, const chi_mesh::MeshContinuum &ref_grid, const QuadratureTriangle &volume_quadrature, const QuadratureLine &surface_quadrature)
Normal normal_
A list of the vertices.
Definition: cell.h:39
std::vector< uint64_t > vertex_ids_
Definition: cell.h:38
std::vector< CellFace > faces_
Definition: cell.h:82
Vertex centroid_
Definition: cell.h:78
std::vector< uint64_t > vertex_ids_
Definition: cell.h:81
void SetIJ(int i, int j, double value)
double x
Element-0.
double y
Element-1.
double Norm() const