15 std::vector<chi_mesh::Vector3> node_locations,
16 std::vector<std::vector<int>> face_node_mappings,
20 num_nodes_(num_nodes),
21 node_locations_(std::move(node_locations)),
22 face_node_mappings_(std::move(face_node_mappings))
59 catch (
const std::out_of_range& oor)
61 throw std::out_of_range(
62 "chi_math::CellMapping::MapFaceNode: "
63 "Either face_index or face_node_index is out of range");
70 std::vector<double>& areas)
79 volume = (v1 - v0).Norm();
88 size_t num_faces = cell.
faces_.size();
89 areas.reserve(num_faces);
91 for (
size_t f = 0; f < num_faces; ++f)
93 const uint64_t v0i = cell.
faces_[f].vertex_ids_[0];
94 const uint64_t v1i = cell.
faces_[f].vertex_ids_[1];
99 areas.push_back((v1 - v0).Norm());
105 ((sidev01.
x) * (sidev02.
y) - (sidev02.
x) * (sidev01.
y));
107 volume += sidedetJ / 2.0;
117 size_t num_faces = cell.
faces_.size();
118 areas.assign(num_faces, 0.0);
119 for (
size_t f = 0; f < num_faces; f++)
121 const auto& face = cell.
faces_[f];
122 const size_t num_edges = face.vertex_ids_.size();
123 for (
size_t e = 0; e < num_edges; ++e)
125 size_t ep1 = (e < (num_edges - 1)) ? e + 1 : 0;
126 uint64_t v0i = face.vertex_ids_[e];
127 uint64_t v1i = face.vertex_ids_[ep1];
129 const auto& v0 = grid.
vertices[v0i];
130 const auto& v1 = cell.
faces_[f].centroid_;
131 const auto& v2 = grid.
vertices[v1i];
132 const auto& v3 = vcc;
134 const auto sidev01 = v1 - v0;
135 const auto sidev02 = v2 - v0;
136 const auto sidev03 = v3 - v0;
144 areas[f] += (sidev01.Cross(sidev02)).Norm() / 2.0;
145 volume += J.
Det() / 6.0;
151 throw std::logic_error(
"chi_math::CellMapping::ComputeCellVolume: "
152 "Unsupported cell type.");
double CellVolume() const
const std::vector< std::vector< int > > & GetFaceNodeMappings() const
int MapFaceNode(size_t face_index, size_t face_node_index) const
const chi_mesh::MeshContinuum & ReferenceGrid() const
CellMapping(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell, size_t num_nodes, std::vector< chi_mesh::Vector3 > node_locations, std::vector< std::vector< int > > face_node_mappings, const VandAFunction &volume_area_function)
const std::vector< std::vector< int > > face_node_mappings_
static void ComputeCellVolumeAndAreas(const chi_mesh::MeshContinuum &grid, const chi_mesh::Cell &cell, double &volume, std::vector< double > &areas)
std::function< void(const chi_mesh::MeshContinuum &, const chi_mesh::Cell &, double &, std::vector< double > &)> VandAFunction
const std::vector< chi_mesh::Vector3 > node_locations_
double FaceArea(size_t face_index) const
const chi_mesh::MeshContinuum & ref_grid_
std::vector< double > areas_
size_t NumFaceNodes(size_t face_index) const
const chi_mesh::Cell & ReferenceCell() const
const std::vector< chi_mesh::Vector3 > & GetNodeLocations() const
const chi_mesh::Cell & cell_
std::vector< CellFace > faces_
std::vector< uint64_t > vertex_ids_
void SetColJVec(int j, Vector3 vec)