diff --git a/framework/field_functions/field_function.h b/framework/field_functions/field_function.h index d67305f6d6..7aefe8f56e 100644 --- a/framework/field_functions/field_function.h +++ b/framework/field_functions/field_function.h @@ -5,7 +5,6 @@ #include "framework/parameters/input_parameters.h" #include "framework/math/unknown_manager/unknown_manager.h" -#include "framework/mesh/mesh.h" namespace opensn { diff --git a/framework/field_functions/field_function_grid_based.cc b/framework/field_functions/field_function_grid_based.cc index 6df30cf2b4..4ba689f6b5 100644 --- a/framework/field_functions/field_function_grid_based.cc +++ b/framework/field_functions/field_function_grid_based.cc @@ -5,7 +5,6 @@ #include "framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.h" #include "framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_discontinuous.h" #include "framework/math/spatial_discretization/spatial_discretization.h" -#include "framework/mesh/mesh.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" #include "framework/mesh/mesh_continuum/grid_vtk_utils.h" #include "framework/object_factory.h" diff --git a/framework/field_functions/field_function_grid_based.h b/framework/field_functions/field_function_grid_based.h index 4fb1d0b2ff..7d3fe2e1ce 100644 --- a/framework/field_functions/field_function_grid_based.h +++ b/framework/field_functions/field_function_grid_based.h @@ -5,7 +5,6 @@ #include "framework/field_functions/field_function.h" #include "framework/data_types/parallel_vector/ghosted_parallel_stl_vector.h" -#include "framework/mesh/mesh.h" #include #include #include diff --git a/framework/field_functions/interpolation/ffinter_line.cc b/framework/field_functions/interpolation/ffinter_line.cc index 9f0c615226..2a10ff1a73 100644 --- a/framework/field_functions/interpolation/ffinter_line.cc +++ b/framework/field_functions/interpolation/ffinter_line.cc @@ -6,7 +6,7 @@ #include "framework/data_types/vector_ghost_communicator/vector_ghost_communicator.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" #include "framework/field_functions/field_function_grid_based.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/logging/log.h" #include "framework/runtime.h" #include diff --git a/framework/field_functions/interpolation/ffinter_point.cc b/framework/field_functions/interpolation/ffinter_point.cc index e1446e6cb6..f5d4d118d4 100644 --- a/framework/field_functions/interpolation/ffinter_point.cc +++ b/framework/field_functions/interpolation/ffinter_point.cc @@ -81,7 +81,7 @@ FieldFunctionInterpolationPoint::Execute() const auto field_data = ref_ff.GetGhostedFieldVector(); - const auto& cell = grid->cells[owning_cell_gid_]; + const auto& cell = grid->GetGlobalCell(owning_cell_gid_); const auto& cell_mapping = sdm.GetCellMapping(cell); const size_t num_nodes = cell_mapping.GetNumNodes(); diff --git a/framework/graphs/kba_graph_partitioner.cc b/framework/graphs/kba_graph_partitioner.cc index 7df47aa51b..54ddb63b36 100644 --- a/framework/graphs/kba_graph_partitioner.cc +++ b/framework/graphs/kba_graph_partitioner.cc @@ -3,7 +3,6 @@ #include "framework/graphs/kba_graph_partitioner.h" #include "framework/utils/utils.h" -#include "framework/mesh/mesh.h" #include "framework/runtime.h" #include "framework/logging/log.h" #include diff --git a/framework/math/geometry.h b/framework/math/geometry.h index c7c4cd7b35..4401ced8ab 100644 --- a/framework/math/geometry.h +++ b/framework/math/geometry.h @@ -3,7 +3,6 @@ #pragma once -#include "framework/mesh/mesh.h" #include namespace opensn @@ -20,6 +19,14 @@ enum class GeometryType THREED_CARTESIAN = 6, }; +enum CoordinateSystemType : int +{ + UNDEFINED = 0, + CARTESIAN = 1, + CYLINDRICAL = 2, + SPHERICAL = 3, +}; + constexpr std::string_view ToString(GeometryType type) noexcept { diff --git a/framework/math/quadratures/spatial/spatial_quadrature.h b/framework/math/quadratures/spatial/spatial_quadrature.h index a74e6d4ac8..3feba8afc8 100644 --- a/framework/math/quadratures/spatial/spatial_quadrature.h +++ b/framework/math/quadratures/spatial/spatial_quadrature.h @@ -4,7 +4,6 @@ #pragma once #include "framework/math/quadratures/quadrature_order.h" -#include "framework/mesh/mesh.h" #include "framework/parameters/input_parameters.h" #include diff --git a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.cc b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.cc index 7b7cd32945..b8d12af375 100644 --- a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.cc +++ b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.cc @@ -59,7 +59,7 @@ PieceWiseLinearBaseMapping::GetVertexLocations(const std::shared_ptrvertices[vid]); + verts.push_back(grid->GlobalVertex(vid)); return verts; } diff --git a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.h b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.h index 2e8324f8b8..eddcea9e95 100644 --- a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.h +++ b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.h @@ -3,7 +3,6 @@ #pragma once -#include "framework/mesh/mesh.h" #include "framework/math/spatial_discretization/cell_mappings/cell_mapping.h" #include diff --git a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polygon_mapping.cc b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polygon_mapping.cc index 174a26ccf9..e96d42c600 100644 --- a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polygon_mapping.cc +++ b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polygon_mapping.cc @@ -29,8 +29,8 @@ PieceWiseLinearPolygonMapping::PieceWiseLinearPolygonMapping( { const CellFace& face = poly_cell.faces[side]; - const auto& v0 = grid_->vertices[face.vertex_ids[0]]; - const auto& v1 = grid_->vertices[face.vertex_ids[1]]; + const auto& v0 = grid_->GlobalVertex(face.vertex_ids[0]); + const auto& v1 = grid_->GlobalVertex(face.vertex_ids[1]); Vector3 v2 = vc_; Vector3 sidev01 = v1 - v0; @@ -187,7 +187,7 @@ PieceWiseLinearPolygonMapping::ShapeValue(size_t i, const Vector3& xyz) const { for (std::size_t s = 0; s < num_of_subtris_; ++s) { - const auto& p0 = grid_->vertices[sides_[s].v_index[0]]; + const auto& p0 = grid_->GlobalVertex(sides_[s].v_index[0]); Vector3 xyz_ref = xyz - p0; Vector3 xi_eta_zeta = sides_[s].Jinv * xyz_ref; @@ -225,7 +225,7 @@ PieceWiseLinearPolygonMapping::ShapeValues(const Vector3& xyz, Vector& s shape_values.Resize(num_nodes_, 0.0); for (std::size_t s = 0; s < num_of_subtris_; ++s) { - const auto& p0 = grid_->vertices[sides_[s].v_index[0]]; + const auto& p0 = grid_->GlobalVertex(sides_[s].v_index[0]); Vector3 xi_eta_zeta = sides_[s].Jinv * (xyz - p0); double xi = xi_eta_zeta.x; @@ -265,7 +265,7 @@ PieceWiseLinearPolygonMapping::GradShapeValue(size_t i, const Vector3& xyz) cons for (std::size_t e = 0; e < num_of_subtris_; ++e) { - const auto& p0 = grid_->vertices[sides_[e].v_index[0]]; + const auto& p0 = grid_->GlobalVertex(sides_[e].v_index[0]); Vector3 xyz_ref = xyz - p0; Vector3 xi_eta_zeta = sides_[e].Jinv * xyz_ref; diff --git a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polyhedron_mapping.cc b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polyhedron_mapping.cc index 3becc53538..f1dd0435d8 100644 --- a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polyhedron_mapping.cc +++ b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_polyhedron_mapping.cc @@ -53,9 +53,9 @@ PieceWiseLinearPolyhedronMapping::PieceWiseLinearPolyhedronMapping( side_data.v_index[0] = v0index; side_data.v_index[1] = v1index; - const auto& v0 = grid_->vertices[v0index]; + const auto& v0 = grid_->GlobalVertex(v0index); const auto& v1 = vfc; - const auto& v2 = grid_->vertices[v1index]; + const auto& v2 = grid_->GlobalVertex(v1index); const auto& v3 = vcc; side_data.v0 = v0; @@ -412,7 +412,7 @@ PieceWiseLinearPolyhedronMapping::ShapeValue(size_t i, const Vector3& xyz) const for (size_t s = 0; s < face_data_[f].sides.size(); ++s) { // Map xyz to xi_eta_zeta - const auto& p0 = grid_->vertices[face_data_[f].sides[s].v_index[0]]; + const auto& p0 = grid_->GlobalVertex(face_data_[f].sides[s].v_index[0]); Vector3 xyz_ref = xyz - p0; Vector3 xi_eta_zeta = face_data_[f].sides[s].Jinv * xyz_ref; @@ -461,7 +461,7 @@ PieceWiseLinearPolyhedronMapping::ShapeValues(const Vector3& xyz, { const auto& side_fe_info = face_data_[f].sides[s]; // Map xyz to xi_eta_zeta - const auto& p0 = grid_->vertices[side_fe_info.v_index[0]]; + const auto& p0 = grid_->GlobalVertex(side_fe_info.v_index[0]); Vector3 xi_eta_zeta = side_fe_info.Jinv * (xyz - p0); double xi = xi_eta_zeta.x; @@ -507,7 +507,7 @@ PieceWiseLinearPolyhedronMapping::GradShapeValue(size_t i, const Vector3& xyz) c for (size_t s = 0; s < face_data_[f].sides.size(); ++s) { // Map xyz to xi_eta_zeta - const auto& p0 = grid_->vertices[face_data_[f].sides[s].v_index[0]]; + const auto& p0 = grid_->GlobalVertex(face_data_[f].sides[s].v_index[0]); Vector3 xyz_ref = xyz - p0; Vector3 xi_eta_zeta = face_data_[f].sides[s].Jinv * xyz_ref; diff --git a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.cc b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.cc index b486aa9c38..d0f75c84c7 100644 --- a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.cc +++ b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.cc @@ -17,8 +17,8 @@ PieceWiseLinearSlabMapping::PieceWiseLinearSlabMapping( v1i_(slab_cell.vertex_ids[1]), volume_quadrature_(volume_quadrature) { - v0_ = grid_->vertices[v0i_]; - const auto& v1 = grid_->vertices[v1i_]; + v0_ = grid_->GlobalVertex(v0i_); + const auto& v1 = grid_->GlobalVertex(v1i_); Vector3 v01 = v1 - v0_; h_ = v01.Norm(); @@ -64,8 +64,8 @@ PieceWiseLinearSlabMapping::SlabGradShape(uint32_t index) const double PieceWiseLinearSlabMapping::ShapeValue(size_t i, const Vector3& xyz) const { - const auto& p0 = grid_->vertices[v0i_]; - const auto& p1 = grid_->vertices[v1i_]; + const auto& p0 = grid_->GlobalVertex(v0i_); + const auto& p1 = grid_->GlobalVertex(v1i_); Vector3 xyz_ref = xyz - p0; Vector3 v01 = p1 - p0; @@ -87,8 +87,8 @@ void PieceWiseLinearSlabMapping::ShapeValues(const Vector3& xyz, Vector& shape_values) const { shape_values.Resize(num_nodes_, 0.0); - const auto& p0 = grid_->vertices[v0i_]; - const auto& p1 = grid_->vertices[v1i_]; + const auto& p0 = grid_->GlobalVertex(v0i_); + const auto& p1 = grid_->GlobalVertex(v1i_); Vector3 xyz_ref = xyz - p0; Vector3 v01 = p1 - p0; @@ -243,7 +243,7 @@ PieceWiseLinearSlabMapping::MakeSurfaceFiniteElementData(size_t face_index) cons for (size_t qp = 0; qp < num_srf_qpoints; ++qp) { F_JxW.push_back(JxW); - const auto face_xyz = (f == 0) ? grid_->vertices[v0i_] : grid_->vertices[v1i_]; + const auto face_xyz = (f == 0) ? grid_->GlobalVertex(v0i_) : grid_->GlobalVertex(v1i_); F_qpoints_xyz.push_back(face_xyz); } diff --git a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.h b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.h index a8c73f0141..e4c98f79ce 100644 --- a/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.h +++ b/framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_slab_mapping.h @@ -5,7 +5,7 @@ #include "framework/math/spatial_discretization/cell_mappings/finite_element/piecewise_linear/piecewise_linear_base_mapping.h" #include "framework/math/quadratures/spatial/line_quadrature.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include namespace opensn diff --git a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_base.cc b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_base.cc index 06a31c12e7..cd726c24ab 100644 --- a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_base.cc +++ b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_base.cc @@ -67,10 +67,10 @@ PieceWiseLinearBase::CreateCellMappings() for (const auto& cell : grid_->local_cells) cell_mappings_.push_back(MakeCellMapping(cell)); - const auto ghost_ids = grid_->cells.GetGhostGlobalIDs(); + const auto ghost_ids = grid_->GetGhostGlobalIDs(); for (uint64_t ghost_id : ghost_ids) { - auto ghost_mapping = MakeCellMapping(grid_->cells[ghost_id]); + auto ghost_mapping = MakeCellMapping(grid_->GetGlobalCell(ghost_id)); nb_cell_mappings_.insert(std::make_pair(ghost_id, std::move(ghost_mapping))); } } diff --git a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc index 7153289168..50fdc44879 100644 --- a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc +++ b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.cc @@ -49,10 +49,10 @@ PieceWiseLinearContinuous::OrderNodes() // Now we add the partitions associated with the // ghost cells. - const auto ghost_cell_ids = grid_->cells.GetGhostGlobalIDs(); + const auto ghost_cell_ids = grid_->GetGhostGlobalIDs(); for (const uint64_t ghost_id : ghost_cell_ids) { - const auto& ghost_cell = grid_->cells[ghost_id]; + const auto& ghost_cell = grid_->GetGlobalCell(ghost_id); for (const uint64_t vid : ghost_cell.vertex_ids) ls_node_ids_psubs[vid].insert(ghost_cell.partition_id); } // for ghost_id diff --git a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_discontinuous.cc b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_discontinuous.cc index e8c7f24610..ae2009f389 100644 --- a/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_discontinuous.cc +++ b/framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_discontinuous.cc @@ -71,9 +71,9 @@ PieceWiseLinearDiscontinuous::OrderNodes() // Collect ghost cell ids needing block addresses std::map> ghost_cell_ids_consolidated; - for (uint64_t global_id : grid_->cells.GetGhostGlobalIDs()) + for (uint64_t global_id : grid_->GetGhostGlobalIDs()) { - const auto& cell = grid_->cells[global_id]; + const auto& cell = grid_->GetGlobalCell(global_id); const int locI = cell.partition_id; std::vector& locI_cell_id_list = ghost_cell_ids_consolidated[locI]; @@ -93,7 +93,7 @@ PieceWiseLinearDiscontinuous::OrderNodes() for (uint64_t cell_global_id : cell_id_list) { - const auto& cell = grid_->cells[cell_global_id]; + const auto& cell = grid_->GetGlobalCell(cell_global_id); const auto cell_block_address = local_block_address_ + cell_local_block_address_[cell.local_id]; @@ -156,7 +156,7 @@ PieceWiseLinearDiscontinuous::BuildSparsityPattern(std::vector& nodal_n { if (face.has_neighbor and face.IsNeighborLocal(grid_.get())) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const auto& adj_cell_mapping = GetCellMapping(adj_cell); for (size_t i = 0; i < num_nodes; ++i) @@ -180,7 +180,7 @@ PieceWiseLinearDiscontinuous::BuildSparsityPattern(std::vector& nodal_n { if (face.has_neighbor and (not face.IsNeighborLocal(grid_.get()))) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const auto& adj_cell_mapping = GetCellMapping(adj_cell); for (int i = 0; i < cell_mapping.GetNumNodes(); ++i) diff --git a/framework/math/spatial_discretization/finite_element/unit_cell_matrices.h b/framework/math/spatial_discretization/finite_element/unit_cell_matrices.h index 8b03884fe8..75b189d665 100644 --- a/framework/math/spatial_discretization/finite_element/unit_cell_matrices.h +++ b/framework/math/spatial_discretization/finite_element/unit_cell_matrices.h @@ -6,9 +6,8 @@ #include "framework/data_types/dense_matrix.h" #include "framework/data_types/vector3.h" #include "framework/math/geometry.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/math/spatial_discretization/spatial_discretization.h" -#include "framework/mesh/mesh.h" namespace opensn { diff --git a/framework/math/spatial_discretization/spatial_discretization.cc b/framework/math/spatial_discretization/spatial_discretization.cc index 53467d2547..54ae5c0571 100644 --- a/framework/math/spatial_discretization/spatial_discretization.cc +++ b/framework/math/spatial_discretization/spatial_discretization.cc @@ -119,7 +119,7 @@ SpatialDiscretization::MakeInternalFaceNodeMappings(const double tolerance) cons std::vector face_adj_mapping(num_face_nodes, -1); if (face.has_neighbor) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const auto& adj_cell_mapping = this->GetCellMapping(adj_cell); const auto& adj_node_locations = adj_cell_mapping.GetNodeLocations(); const size_t adj_num_nodes = adj_cell_mapping.GetNumNodes(); diff --git a/framework/math/spatial_discretization/spatial_discretization.h b/framework/math/spatial_discretization/spatial_discretization.h index b97a343068..e52de896a8 100644 --- a/framework/math/spatial_discretization/spatial_discretization.h +++ b/framework/math/spatial_discretization/spatial_discretization.h @@ -7,8 +7,7 @@ #include "framework/math/quadratures/spatial/spatial_quadrature.h" #include "framework/math/unknown_manager/unknown_manager.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" -#include "framework/mesh/cell/cell.h" -#include "framework/mesh/mesh.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/math/math.h" #include #include diff --git a/framework/math/spatial_weight_function.cc b/framework/math/spatial_weight_function.cc index 1ca853b8f6..fb71d6eaf7 100644 --- a/framework/math/spatial_weight_function.cc +++ b/framework/math/spatial_weight_function.cc @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MIT #include "framework/math/spatial_weight_function.h" -#include "framework/mesh/mesh.h" #include namespace opensn diff --git a/framework/math/spatial_weight_function.h b/framework/math/spatial_weight_function.h index 659ba7a070..95aed292a0 100644 --- a/framework/math/spatial_weight_function.h +++ b/framework/math/spatial_weight_function.h @@ -4,7 +4,7 @@ #pragma once #include "framework/data_types/vector3.h" -#include "framework/mesh/mesh.h" +#include "framework/mesh/mesh_continuum/mesh_continuum.h" namespace opensn { diff --git a/framework/mesh/io/vtk_io.cc b/framework/mesh/io/vtk_io.cc index f66c2f90d0..653885815c 100644 --- a/framework/mesh/io/vtk_io.cc +++ b/framework/mesh/io/vtk_io.cc @@ -887,7 +887,7 @@ MeshIO::ToOBJ(const std::shared_ptr& grid, const char* file_name, auto node_g_index = node; node_mapping[node_g_index] = node_counter; - Vector3 cur_v = grid->vertices[node_g_index]; + Vector3 cur_v = grid->GlobalVertex(node_g_index); // clang-format off of << "v " @@ -983,7 +983,7 @@ MeshIO::ToExodusII(const std::shared_ptr& grid, for (size_t v = 0; v < num_verts; ++v) { vertex_map[v] = v; - const auto& vertex = grid->vertices[v]; + const auto& vertex = grid->GlobalVertex(v); points->InsertNextPoint(vertex.x, vertex.y, vertex.z); // Exodus node- and cell indices are 1-based therefore we add a 1 here. @@ -1095,7 +1095,7 @@ MeshIO::ToExodusII(const std::shared_ptr& grid, // Load vertices for (uint64_t vid : vid_set) { - const auto& vertex = grid->vertices[vid]; + const auto& vertex = grid->GlobalVertex(vid); points->InsertNextPoint(vertex.x, vertex.y, vertex.z); // Exodus node- and cell indices are 1-based therefore we add a 1 here. @@ -1151,7 +1151,7 @@ MeshIO::ToExodusII(const std::shared_ptr& grid, // Load vertices for (uint64_t vid : vid_set) { - const auto& vertex = grid->vertices[vid]; + const auto& vertex = grid->GlobalVertex(vid); points->InsertNextPoint(vertex.x, vertex.y, vertex.z); } diff --git a/framework/mesh/logical_volume/boolean_logical_volume.cc b/framework/mesh/logical_volume/boolean_logical_volume.cc index 7057c3d1fc..fc587acc1d 100644 --- a/framework/mesh/logical_volume/boolean_logical_volume.cc +++ b/framework/mesh/logical_volume/boolean_logical_volume.cc @@ -2,7 +2,6 @@ // SPDX-License-Identifier: MIT #include "framework/mesh/logical_volume/boolean_logical_volume.h" -#include "framework/mesh/mesh.h" #include "framework/object_factory.h" namespace opensn diff --git a/framework/mesh/logical_volume/surface_mesh_logical_volume.cc b/framework/mesh/logical_volume/surface_mesh_logical_volume.cc index 19e031d513..7304ca3816 100644 --- a/framework/mesh/logical_volume/surface_mesh_logical_volume.cc +++ b/framework/mesh/logical_volume/surface_mesh_logical_volume.cc @@ -2,8 +2,6 @@ // SPDX-License-Identifier: MIT #include "framework/mesh/logical_volume/surface_mesh_logical_volume.h" -#include "framework/mesh/mesh.h" -#include "framework/mesh/mesh_face.h" #include "framework/mesh/surface_mesh/surface_mesh.h" #include "framework/mesh/raytrace/raytracer.h" #include "framework/object_factory.h" diff --git a/framework/mesh/mesh.h b/framework/mesh/mesh.h deleted file mode 100644 index 2812321426..0000000000 --- a/framework/mesh/mesh.h +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-FileCopyrightText: 2024 The OpenSn Authors -// SPDX-License-Identifier: MIT - -#pragma once - -#include -#include - -namespace opensn -{ - -enum CoordinateSystemType : int -{ - UNDEFINED = 0, - CARTESIAN = 1, - CYLINDRICAL = 2, - SPHERICAL = 3, -}; - -constexpr std::string_view -ToString(CoordinateSystemType type) noexcept -{ - switch (type) - { - case CoordinateSystemType::UNDEFINED: - return "UNDEFINED"; - case CoordinateSystemType::CARTESIAN: - return "CARTESIAN"; - case CoordinateSystemType::CYLINDRICAL: - return "CYLINDRICAL"; - case CoordinateSystemType::SPHERICAL: - return "SPHERICAL"; - default: - return "UNKNOWN"; - } -} - -enum MeshType : int -{ - ORTHOGONAL, - UNSTRUCTURED -}; - -constexpr std::string_view -ToString(MeshType type) noexcept -{ - switch (type) - { - case ORTHOGONAL: - return "UNDEFINED"; - case UNSTRUCTURED: - return "CARTESIAN"; - default: - return "UNKNOWN"; - } -} - -enum BoundaryID : int -{ - XMIN = 0, - XMAX = 1, - YMIN = 2, - YMAX = 3, - ZMIN = 4, - ZMAX = 5 -}; - -struct OrthoMeshAttributes -{ - size_t Nx = 0; - size_t Ny = 0; - size_t Nz = 0; -}; - -} // namespace opensn diff --git a/framework/mesh/cell/cell.cc b/framework/mesh/mesh_continuum/cell.cc similarity index 93% rename from framework/mesh/cell/cell.cc rename to framework/mesh/mesh_continuum/cell.cc index c079cd41ba..e83afbe7eb 100644 --- a/framework/mesh/cell/cell.cc +++ b/framework/mesh/mesh_continuum/cell.cc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT #include "framework/mesh/mesh_continuum/mesh_continuum.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/data_types/matrix3x3.h" #include "framework/data_types/byte_array.h" #include "framework/logging/log.h" @@ -64,7 +64,7 @@ CellFace::IsNeighborLocal(const MeshContinuum* grid) const if (grid->GetNumPartitions() == 1) return true; - const auto& adj_cell = grid->cells[neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(neighbor_id); return (adj_cell.partition_id == opensn::mpi_comm.rank()); } @@ -77,7 +77,7 @@ CellFace::GetNeighborPartitionID(const MeshContinuum* grid) const if (grid->GetNumPartitions() == 1) return 0; - const auto& adj_cell = grid->cells[neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(neighbor_id); return adj_cell.partition_id; } @@ -90,7 +90,7 @@ CellFace::GetNeighborLocalID(const MeshContinuum* grid) const if (grid->GetNumPartitions() == 1) return neighbor_id; // cause global_ids=local_ids - const auto& adj_cell = grid->cells[neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(neighbor_id); if (adj_cell.partition_id != opensn::mpi_comm.rank()) throw std::logic_error("Cell local ID requested from a non-local cell."); @@ -112,7 +112,7 @@ CellFace::GetNeighborAdjacentFaceIndex(const MeshContinuum* grid) const throw std::logic_error(outstr.str()); } - const auto& adj_cell = grid->cells[cur_face.neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(cur_face.neighbor_id); int adj_face_idx = -1; std::set cfvids(cur_face.vertex_ids.begin(), @@ -158,7 +158,7 @@ CellFace::ComputeGeometricInfo(const MeshContinuum* grid, const Cell& cell) // Compute the centroid centroid = Vector3(0.0, 0.0, 0.0); for (const auto& vid : vertex_ids) - centroid += grid->vertices[vid]; + centroid += grid->GlobalVertex(vid); centroid /= static_cast(vertex_ids.size()); // Compute areas and normals @@ -187,8 +187,8 @@ CellFace::ComputeGeometricInfo(const MeshContinuum* grid, const Cell& cell) { // A polygon face is just a line. Normals and areas are // computed using the vertices. - const auto& v0 = grid->vertices[vertex_ids[0]]; - const auto& v1 = grid->vertices[vertex_ids[1]]; + const auto& v0 = grid->GlobalVertex(vertex_ids[0]); + const auto& v1 = grid->GlobalVertex(vertex_ids[1]); // The outward pointing normal is orthogonal to the vector // pointing from the first vertex to the second. This is @@ -218,8 +218,8 @@ CellFace::ComputeGeometricInfo(const MeshContinuum* grid, const Cell& cell) { const auto vid0 = vertex_ids[v]; const auto vid1 = v < num_verts - 1 ? vertex_ids[v + 1] : vertex_ids[0]; - const auto& v0 = grid->vertices[vid0]; - const auto& v1 = grid->vertices[vid1]; + const auto& v0 = grid->GlobalVertex(vid0); + const auto& v1 = grid->GlobalVertex(vid1); const auto subnormal = (v0 - centroid).Cross(v1 - centroid); @@ -336,7 +336,7 @@ Cell::ComputeGeometricInfo(const MeshContinuum* grid) // Compute cell centroid centroid = Vector3(0.0, 0.0, 0.0); for (const auto& vid : vertex_ids) - centroid += grid->vertices[vid]; + centroid += grid->GlobalVertex(vid); centroid /= static_cast(vertex_ids.size()); // Compute face geometric data @@ -350,8 +350,8 @@ Cell::ComputeGeometricInfo(const MeshContinuum* grid) // The volume of a slab is the distance between the two vertices. case CellType::SLAB: { - const auto& v0 = grid->vertices[vertex_ids[0]]; - const auto& v1 = grid->vertices[vertex_ids[1]]; + const auto& v0 = grid->GlobalVertex(vertex_ids[0]); + const auto& v1 = grid->GlobalVertex(vertex_ids[1]); volume = (v1 - v0).Norm(); break; } @@ -362,8 +362,8 @@ Cell::ComputeGeometricInfo(const MeshContinuum* grid) { for (const auto& face : faces) { - const auto& v0 = grid->vertices[face.vertex_ids[0]]; - const auto& v1 = grid->vertices[face.vertex_ids[1]]; + const auto& v0 = grid->GlobalVertex(face.vertex_ids[0]); + const auto& v1 = grid->GlobalVertex(face.vertex_ids[1]); const auto e0 = v1 - v0; const auto e1 = centroid - v0; @@ -382,8 +382,8 @@ Cell::ComputeGeometricInfo(const MeshContinuum* grid) for (unsigned int v = 0; v < num_verts; ++v) { const auto vid1 = v < num_verts - 1 ? v + 1 : 0; - const auto& v0 = grid->vertices[face.vertex_ids[v]]; - const auto& v1 = grid->vertices[face.vertex_ids[vid1]]; + const auto& v0 = grid->GlobalVertex(face.vertex_ids[v]); + const auto& v1 = grid->GlobalVertex(face.vertex_ids[vid1]); Matrix3x3 J; J.SetColJVec(0, face.centroid - v0); diff --git a/framework/mesh/cell/cell.h b/framework/mesh/mesh_continuum/cell.h similarity index 100% rename from framework/mesh/cell/cell.h rename to framework/mesh/mesh_continuum/cell.h diff --git a/framework/mesh/mesh_continuum/grid_vtk_utils.cc b/framework/mesh/mesh_continuum/grid_vtk_utils.cc index 2d8691246c..8e0d8fccf2 100644 --- a/framework/mesh/mesh_continuum/grid_vtk_utils.cc +++ b/framework/mesh/mesh_continuum/grid_vtk_utils.cc @@ -32,9 +32,9 @@ UploadCellGeometryDiscontinuous(const std::shared_ptr grid, { uint64_t vgi = cell.vertex_ids[v]; std::vector d_node(3); - d_node[0] = grid->vertices[vgi].x; - d_node[1] = grid->vertices[vgi].y; - d_node[2] = grid->vertices[vgi].z; + d_node[0] = grid->GlobalVertex(vgi).x; + d_node[1] = grid->GlobalVertex(vgi).y; + d_node[2] = grid->GlobalVertex(vgi).z; points->InsertPoint(node_counter, d_node.data()); cell_vids[v] = node_counter++; @@ -559,7 +559,7 @@ PrepareVtkUnstructuredGrid(const std::shared_ptr grid, bool disco { for (uint64_t vid : cell.vertex_ids) { - const auto& vertex = grid->vertices[vid]; + const auto& vertex = grid->GlobalVertex(vid); points->InsertNextPoint(vertex.x, vertex.y, vertex.z); vertex_map[vid] = node_count; ++node_count; diff --git a/framework/mesh/mesh_continuum/mesh_continuum.cc b/framework/mesh/mesh_continuum/mesh_continuum.cc index b47e6eac33..69a1e60b4a 100644 --- a/framework/mesh/mesh_continuum/mesh_continuum.cc +++ b/framework/mesh/mesh_continuum/mesh_continuum.cc @@ -3,11 +3,10 @@ #include "framework/mesh/mesh_continuum/mesh_continuum.h" #include "framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.h" -#include "framework/mesh/mesh.h" #include "framework/mesh/mesh_continuum/grid_face_histogram.h" #include "framework/mesh/mesh_continuum/grid_vtk_utils.h" #include "framework/mesh/logical_volume/logical_volume.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/data_types/ndarray.h" #include "framework/mpi/mpi_comm_set.h" #include "framework/utils/timer.h" @@ -22,10 +21,6 @@ namespace opensn MeshContinuum::MeshContinuum() : local_cells(LocalCellHandler::Create(local_cells_)), - cells(local_cells_, - ghost_cells_, - global_cell_id_to_local_id_map_, - global_cell_id_to_nonlocal_id_map_), dim_(0), mesh_type_(UNSTRUCTURED), coord_sys_(CoordinateSystemType::UNDEFINED), @@ -135,8 +130,8 @@ MeshContinuum::ComputeGeometricInfo() for (auto& cell : local_cells) cell.ComputeGeometricInfo(this); - for (const auto& ghost_id : cells.GetGhostGlobalIDs()) - cells[ghost_id].ComputeGeometricInfo(this); + for (const auto& ghost_id : GetGhostGlobalIDs()) + GetGlobalCell(ghost_id).ComputeGeometricInfo(this); } void @@ -146,7 +141,7 @@ MeshContinuum::ClearCellReferences() ghost_cells_.clear(); global_cell_id_to_local_id_map_.clear(); global_cell_id_to_nonlocal_id_map_.clear(); - vertices.Clear(); + global_vertex_id_map_.clear(); } uint64_t @@ -166,6 +161,13 @@ MeshContinuum::MakeBoundaryID(const std::string& boundary_name) const return max_id + 1; } +void +MeshContinuum::SetBoundaryName(std::uint64_t id, const std::string& name) +{ + boundary_id_map_[id] = name; + boundary_name_map_[name] = id; +} + void MeshContinuum::SetOrthogonalBoundaries() { @@ -194,8 +196,7 @@ MeshContinuum::SetOrthogonalBoundaries() for (auto& name : boundary_names) { uint64_t bndry_id = MakeBoundaryID(name); - GetBoundaryIDMap()[bndry_id] = name; - GetBoundaryNameMap()[name] = bndry_id; + SetBoundaryName(bndry_id, name); } const Vector3 ihat(1.0, 0.0, 0.0); @@ -233,6 +234,76 @@ MeshContinuum::SetOrthogonalBoundaries() log.Log() << program_timer.GetTimeString() << " Done setting orthogonal boundaries."; } +void +MeshContinuum::AddGlobalCell(std::shared_ptr new_cell) +{ + if (new_cell->partition_id == opensn::mpi_comm.rank()) + { + new_cell->local_id = local_cells_.size(); + local_cells_.push_back(std::move(new_cell)); + global_cell_id_to_local_id_map_[local_cells_.back()->global_id] = local_cells_.size() - 1; + } + else + { + ghost_cells_.push_back(std::move(new_cell)); + global_cell_id_to_nonlocal_id_map_[ghost_cells_.back()->global_id] = ghost_cells_.size() - 1; + } +} + +Cell& +MeshContinuum::GetGlobalCell(uint64_t cell_global_index) +{ + auto local_it = global_cell_id_to_local_id_map_.find(cell_global_index); + if (local_it != global_cell_id_to_local_id_map_.end()) + return *local_cells_[local_it->second]; + + auto ghost_it = global_cell_id_to_nonlocal_id_map_.find(cell_global_index); + if (ghost_it != global_cell_id_to_nonlocal_id_map_.end()) + return *ghost_cells_[ghost_it->second]; + + throw std::out_of_range("Cell with global ID " + std::to_string(cell_global_index) + + " not found."); +} + +const Cell& +MeshContinuum::GetGlobalCell(uint64_t cell_global_index) const +{ + auto local_it = global_cell_id_to_local_id_map_.find(cell_global_index); + if (local_it != global_cell_id_to_local_id_map_.end()) + return *local_cells_[local_it->second]; + + auto ghost_it = global_cell_id_to_nonlocal_id_map_.find(cell_global_index); + if (ghost_it != global_cell_id_to_nonlocal_id_map_.end()) + return *ghost_cells_[ghost_it->second]; + + throw std::out_of_range("Cell with global ID " + std::to_string(cell_global_index) + + " not found."); +} + +std::vector +MeshContinuum::GetGhostGlobalIDs() const +{ + std::vector ids; + ids.reserve(GhostCellCount()); + + for (const auto& cell : ghost_cells_) + ids.push_back(cell->global_id); + + return ids; +} + +uint64_t +MeshContinuum::GetGhostLocalID(uint64_t cell_global_index) const +{ + auto foreign_location = global_cell_id_to_nonlocal_id_map_.find(cell_global_index); + + if (foreign_location != global_cell_id_to_nonlocal_id_map_.end()) + return foreign_location->second; + + throw std::out_of_range("Cell with global ID " + std::to_string(cell_global_index) + + " not found."); +} + std::shared_ptr MeshContinuum::MakeGridFaceHistogram(double master_tolerance, double slave_tolerance) const { @@ -326,7 +397,7 @@ MeshContinuum::FindAssociatedVertices(const CellFace& cur_face, "MeshContinuum::FindAssociatedVertices. Index " "points to a boundary"); - const auto& adj_cell = cells[cur_face.neighbor_id]; + const auto& adj_cell = GetGlobalCell(cur_face.neighbor_id); dof_mapping.reserve(cur_face.vertex_ids.size()); @@ -365,7 +436,7 @@ MeshContinuum::FindAssociatedCellVertices(const CellFace& cur_face, "MeshContinuum::FindAssociatedVertices. Index " "points to a boundary"); - const auto& adj_cell = cells[cur_face.neighbor_id]; + const auto& adj_cell = GetGlobalCell(cur_face.neighbor_id); dof_mapping.reserve(cur_face.vertex_ids.size()); @@ -418,8 +489,8 @@ MeshContinuum::CheckPointInsideCell(const Cell& cell, const Vector3& point) cons // edge will return a zero value, and a point outside the cell will return a positive value. if (cell.GetType() == CellType::SLAB) { - const auto& v0 = grid_ref.vertices[cell.vertex_ids[0]]; - const auto& v1 = grid_ref.vertices[cell.vertex_ids[1]]; + const auto& v0 = grid_ref.GlobalVertex(cell.vertex_ids[0]); + const auto& v1 = grid_ref.GlobalVertex(cell.vertex_ids[1]); return (v0.z - point.z) * (v1.z - point.z) <= 0.0; } @@ -496,13 +567,13 @@ MeshContinuum::CheckPointInsideCellFace(const Cell& cell, // 1D, face is a point; simple equality check (could we just check z here?) if (face.vertex_ids.size() == 1) - return vertices[face.vertex_ids[0]].AbsoluteEquals(point, tol); + return GlobalVertex(face.vertex_ids[0]).AbsoluteEquals(point, tol); // 2D, face is a line; equal if len(ap) + len(bp) == len(ap) where a=v0, b=v1 if (face.vertex_ids.size() == 2) { - const auto& a = vertices[face.vertex_ids[0]]; - const auto& b = vertices[face.vertex_ids[1]]; + const auto& a = GlobalVertex(face.vertex_ids[0]); + const auto& b = GlobalVertex(face.vertex_ids[1]); const auto ap = (a - point).Norm(); const auto bp = (b - point).Norm(); const auto ab = (a - b).Norm(); @@ -519,7 +590,7 @@ MeshContinuum::CheckPointInsideCellFace(const Cell& cell, const auto InsideEdge = [this, &point, &face](const auto vi1, const auto vi2) { const auto edge_centroid = - (vertices[face.vertex_ids[vi1]] + vertices[face.vertex_ids[vi2]]) / 2.0; + (GlobalVertex(face.vertex_ids[vi1]) + GlobalVertex(face.vertex_ids[vi2])) / 2.0; const auto normal = (edge_centroid - face.centroid).Normalized(); return (point - edge_centroid).Dot(normal) <= 0.0; }; @@ -559,12 +630,12 @@ MeshContinuum::MakeCellOrthoSizes() const std::vector cell_ortho_sizes(local_cells.size()); for (const auto& cell : local_cells) { - Vector3 vmin = vertices[cell.vertex_ids.front()]; + Vector3 vmin = GlobalVertex(cell.vertex_ids.front()); Vector3 vmax = vmin; for (const auto vid : cell.vertex_ids) { - const auto& vertex = vertices[vid]; + const auto& vertex = GlobalVertex(vid); vmin.x = std::min(vertex.x, vmin.x); vmin.y = std::min(vertex.y, vmin.y); vmin.z = std::min(vertex.z, vmin.z); @@ -602,7 +673,7 @@ MeshContinuum::GetLocalBoundingBox() const { for (const uint64_t vid : cell.vertex_ids) { - const auto& vertex = vertices[vid]; + const auto& vertex = GlobalVertex(vid); if (not initialized) { xyz_min = vertex; @@ -622,9 +693,9 @@ MeshContinuum::SetUniformBlockID(const unsigned int blk_id) for (auto& cell : local_cells) cell.block_id = blk_id; - const auto& ghost_ids = cells.GetGhostGlobalIDs(); + const auto& ghost_ids = GetGhostGlobalIDs(); for (uint64_t ghost_id : ghost_ids) - cells[ghost_id].block_id = blk_id; + GetGlobalCell(ghost_id).block_id = blk_id; mpi_comm.barrier(); log.Log() << program_timer.GetTimeString() << " Done setting block id " << blk_id @@ -646,10 +717,10 @@ MeshContinuum::SetBlockIDFromLogicalVolume(const LogicalVolume& log_vol, } } - const auto& ghost_ids = cells.GetGhostGlobalIDs(); + const auto& ghost_ids = GetGhostGlobalIDs(); for (uint64_t ghost_id : ghost_ids) { - auto& cell = cells[ghost_id]; + auto& cell = GetGlobalCell(ghost_id); if (log_vol.Inside(cell.centroid) and sense) cell.block_id = blk_id; } @@ -675,8 +746,7 @@ MeshContinuum::SetUniformBoundaryID(const std::string& boundary_name) face.neighbor_id = bndry_id; } } - GetBoundaryIDMap()[bndry_id] = boundary_name; - GetBoundaryNameMap()[boundary_name] = bndry_id; + SetBoundaryName(bndry_id, boundary_name); } void @@ -685,8 +755,6 @@ MeshContinuum::SetBoundaryIDFromLogicalVolume(const LogicalVolume& log_vol, const bool sense) { // Check if name already has id - auto& grid_bndry_id_map = GetBoundaryIDMap(); - auto& grid_bndry_name_map = GetBoundaryNameMap(); uint64_t bndry_id = MakeBoundaryID(boundary_name); // Loop over cells @@ -708,10 +776,9 @@ MeshContinuum::SetBoundaryIDFromLogicalVolume(const LogicalVolume& log_vol, int global_num_faces_modified = 0; mpi_comm.all_reduce(num_faces_modified, global_num_faces_modified, mpi::op::sum()); - if (global_num_faces_modified > 0 and grid_bndry_id_map.count(bndry_id) == 0) + if (global_num_faces_modified > 0 and boundary_id_map_.count(bndry_id) == 0) { - grid_bndry_id_map[bndry_id] = boundary_name; - grid_bndry_name_map[boundary_name] = bndry_id; + SetBoundaryName(bndry_id, boundary_name); } } @@ -723,7 +790,7 @@ MeshContinuum::ComputeCentroidFromListOfNodes(const std::vector& list) Vector3 centroid; for (auto node_id : list) - centroid = centroid + vertices[node_id]; + centroid = centroid + GlobalVertex(node_id); return centroid / double(list.size()); } @@ -737,9 +804,9 @@ MeshContinuum::GetTetrahedralFaceVertices(const Cell& cell, const auto num_sides = face.vertex_ids.size(); assert(side < num_sides); const size_t sp1 = (side < (num_sides - 1)) ? side + 1 : 0; - const auto& v0 = vertices[face.vertex_ids[side]]; + const auto& v0 = GlobalVertex(face.vertex_ids[side]); const auto& v1 = face.centroid; - const auto& v2 = vertices[face.vertex_ids[sp1]]; + const auto& v2 = GlobalVertex(face.vertex_ids[sp1]); const auto& v3 = cell.centroid; return {{{{v0, v1, v2}}, {{v0, v2, v3}}, {{v1, v3, v2}}, {{v0, v3, v1}}}}; } diff --git a/framework/mesh/mesh_continuum/mesh_continuum.h b/framework/mesh/mesh_continuum/mesh_continuum.h index da7fb863bf..1eecd99780 100644 --- a/framework/mesh/mesh_continuum/mesh_continuum.h +++ b/framework/mesh/mesh_continuum/mesh_continuum.h @@ -4,13 +4,12 @@ #pragma once #include "framework/data_types/ndarray.h" -#include "framework/mesh/mesh.h" #include "framework/mesh/mesh_continuum/mesh_continuum_local_cell_handler.h" -#include "framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.h" -#include "framework/mesh/mesh_continuum/mesh_continuum_vertex_handler.h" #include "framework/math/geometry.h" #include #include +#include +#include namespace opensn { @@ -19,9 +18,66 @@ class GridFaceHistogram; class MeshGenerator; class LogicalVolume; +constexpr std::string_view +ToString(CoordinateSystemType type) noexcept +{ + switch (type) + { + case CoordinateSystemType::UNDEFINED: + return "UNDEFINED"; + case CoordinateSystemType::CARTESIAN: + return "CARTESIAN"; + case CoordinateSystemType::CYLINDRICAL: + return "CYLINDRICAL"; + case CoordinateSystemType::SPHERICAL: + return "SPHERICAL"; + default: + return "UNKNOWN"; + } +} + +enum MeshType : int +{ + ORTHOGONAL, + UNSTRUCTURED +}; + +constexpr std::string_view +ToString(MeshType type) noexcept +{ + switch (type) + { + case ORTHOGONAL: + return "UNDEFINED"; + case UNSTRUCTURED: + return "CARTESIAN"; + default: + return "UNKNOWN"; + } +} + +enum BoundaryID : int +{ + XMIN = 0, + XMAX = 1, + YMIN = 2, + YMAX = 3, + ZMIN = 4, + ZMAX = 5 +}; + +struct OrthoMeshAttributes +{ + size_t Nx = 0; + size_t Ny = 0; + size_t Nz = 0; +}; + /// Encapsulates all the necessary information required to fully define a computational domain. class MeshContinuum { + using GlobalVertexIDMap = std::map; + public: MeshContinuum(); @@ -45,6 +101,22 @@ class MeshContinuum void SetGlobalVertexCount(const uint64_t count) { global_vertex_count_ = count; } uint64_t GetGlobalVertexCount() const { return global_vertex_count_; } + + /// Get vertex using global vertex ID + Vector3& GlobalVertex(const uint64_t global_id) { return global_vertex_id_map_.at(global_id); } + + /// Get vertex using global vertex ID + const Vector3& GlobalVertex(const uint64_t global_id) const + { + return global_vertex_id_map_.at(global_id); + } + + /// Add global vertex providing global ID and location in 3D space + void AddGlobalVertex(const uint64_t global_id, const Vector3& pos) + { + global_vertex_id_map_.insert(std::make_pair(global_id, pos)); + } + int GetNumPartitions() const { return num_partitions_; } size_t GetGlobalNumberOfCells() const; @@ -69,9 +141,45 @@ class MeshContinuum */ uint64_t MakeBoundaryID(const std::string& boundary_name) const; + /** + * Associate boundary name with a boundary ID + * + * \param id Boundary ID + * \param name Boundary name to associate with ``id`` + */ + void SetBoundaryName(std::uint64_t id, const std::string& name); + /// Defines the standard x/y/z min/max boundaries. void SetOrthogonalBoundaries(); + /// Returns the the total number of ghost cells + size_t GhostCellCount() const { return global_cell_id_to_nonlocal_id_map_.size(); } + + /** + * Adds a new cell to the appropriate category (local or ghost). + * @param new_cell The cell to add. + */ + void AddGlobalCell(std::shared_ptr new_cell); + + /// Returns a reference to a cell given its global cell index. + Cell& GetGlobalCell(uint64_t cell_global_index); + + /// Returns a const reference to a cell given its global cell index. + const Cell& GetGlobalCell(uint64_t cell_global_index) const; + + /** + * Returns the cell global ids of all ghost cells. These are cells that neighbors to this + * partition's cells but are on a different partition. + */ + std::vector GetGhostGlobalIDs() const; + + /** + * Returns the local storage address of a ghost cell. If the ghost is not truly a ghost then -1 is + * returned, but is wasteful and therefore the user of this function should implement code to + * prevent it. + */ + uint64_t GetGhostLocalID(uint64_t cell_global_index) const; + /** * Populates a face histogram. * @@ -160,9 +268,7 @@ class MeshContinuum /// Compute volume per block IDs std::map ComputeVolumePerBlockID() const; - VertexHandler vertices; LocalCellHandler local_cells; - GlobalCellHandler cells; private: /// Spatial dimension @@ -176,12 +282,15 @@ class MeshContinuum int num_partitions_; uint64_t global_vertex_count_; + /// + GlobalVertexIDMap global_vertex_id_map_; /// Locally owned cells std::vector> local_cells_; /// Locally stored ghost cells std::vector> ghost_cells_; std::map global_cell_id_to_local_id_map_; + /// Global to ghost ID map std::map global_cell_id_to_nonlocal_id_map_; public: diff --git a/framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.cc b/framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.cc deleted file mode 100644 index 3fdcae26fb..0000000000 --- a/framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.cc +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-FileCopyrightText: 2024 The OpenSn Authors -// SPDX-License-Identifier: MIT - -#include "framework/mesh/mesh_continuum/mesh_continuum.h" -#include "framework/runtime.h" -#include "framework/logging/log.h" - -namespace opensn -{ - -void -GlobalCellHandler::PushBack(std::shared_ptr new_cell) -{ - if (new_cell->partition_id == opensn::mpi_comm.rank()) - { - new_cell->local_id = local_cells_ref_.size(); - local_cells_ref_.push_back(std::move(new_cell)); - global_to_local_map_[local_cells_ref_.back()->global_id] = local_cells_ref_.size() - 1; - } - else - { - ghost_cells_ref_.push_back(std::move(new_cell)); - global_to_ghost_map_[ghost_cells_ref_.back()->global_id] = ghost_cells_ref_.size() - 1; - } -} - -Cell& -GlobalCellHandler::operator[](uint64_t cell_global_index) -{ - auto local_it = global_to_local_map_.find(cell_global_index); - if (local_it != global_to_local_map_.end()) - return *local_cells_ref_[local_it->second]; - - auto ghost_it = global_to_ghost_map_.find(cell_global_index); - if (ghost_it != global_to_ghost_map_.end()) - return *ghost_cells_ref_[ghost_it->second]; - - throw std::out_of_range("Cell with global ID " + std::to_string(cell_global_index) + - " not found."); -} - -const Cell& -GlobalCellHandler::operator[](uint64_t cell_global_index) const -{ - auto local_it = global_to_local_map_.find(cell_global_index); - if (local_it != global_to_local_map_.end()) - return *local_cells_ref_[local_it->second]; - - auto ghost_it = global_to_ghost_map_.find(cell_global_index); - if (ghost_it != global_to_ghost_map_.end()) - return *ghost_cells_ref_[ghost_it->second]; - - throw std::out_of_range("Cell with global ID " + std::to_string(cell_global_index) + - " not found."); -} - -std::vector -GlobalCellHandler::GetGhostGlobalIDs() const -{ - std::vector ids; - ids.reserve(GhostCellCount()); - - for (auto& cell : ghost_cells_ref_) - ids.push_back(cell->global_id); - - return ids; -} - -uint64_t -GlobalCellHandler::GetGhostLocalID(uint64_t cell_global_index) const -{ - auto foreign_location = global_to_ghost_map_.find(cell_global_index); - - if (foreign_location != global_to_ghost_map_.end()) - return foreign_location->second; - - throw std::out_of_range("Cell with global ID " + std::to_string(cell_global_index) + - " not found."); -} - -} // namespace opensn diff --git a/framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.h b/framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.h deleted file mode 100644 index 8305728b45..0000000000 --- a/framework/mesh/mesh_continuum/mesh_continuum_global_cell_handler.h +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: 2024 The OpenSn Authors -// SPDX-License-Identifier: MIT - -#pragma once - -#include "framework/mesh/cell/cell.h" -#include - -namespace opensn -{ - -/// Handles all global index queries. -class GlobalCellHandler -{ - friend class MeshContinuum; - -public: - /** - * Adds a new cell to the appropriate category (local or ghost). - * @param new_cell The cell to add. - */ - void PushBack(std::shared_ptr new_cell); - - /// Returns a reference to a cell given its global cell index. - Cell& operator[](uint64_t cell_global_index); - - /// Returns a const reference to a cell given its global cell index. - const Cell& operator[](uint64_t cell_global_index) const; - - /// Returns the the total number of ghost cells - size_t GhostCellCount() const { return global_to_ghost_map_.size(); } - - /** - * Returns the cell global ids of all ghost cells. These are cells that neighbors to this - * partition's cells but are on a different partition. - */ - std::vector GetGhostGlobalIDs() const; - - /** - * Returns the local storage address of a ghost cell. If the ghost is not truly a ghost then -1 is - * returned, but is wasteful and therefore the user of this function should implement code to - * prevent it. - */ - uint64_t GetGhostLocalID(uint64_t cell_global_index) const; - -private: - explicit GlobalCellHandler(std::vector>& native_cells, - std::vector>& foreign_cells, - std::map& global_to_local_map, - std::map& global_to_ghost_map) - : local_cells_ref_(native_cells), - ghost_cells_ref_(foreign_cells), - global_to_local_map_(global_to_local_map), - global_to_ghost_map_(global_to_ghost_map) - { - } - - std::vector>& local_cells_ref_; - std::vector>& ghost_cells_ref_; - - /// Global to local ID map - std::map& global_to_local_map_; - /// Global to ghost ID map - std::map& global_to_ghost_map_; -}; - -} // namespace opensn diff --git a/framework/mesh/mesh_continuum/mesh_continuum_local_cell_handler.h b/framework/mesh/mesh_continuum/mesh_continuum_local_cell_handler.h index ad9eb28a2d..631922b58a 100644 --- a/framework/mesh/mesh_continuum/mesh_continuum_local_cell_handler.h +++ b/framework/mesh/mesh_continuum/mesh_continuum_local_cell_handler.h @@ -3,7 +3,7 @@ #pragma once -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include namespace opensn diff --git a/framework/mesh/mesh_continuum/mesh_continuum_vertex_handler.h b/framework/mesh/mesh_continuum/mesh_continuum_vertex_handler.h deleted file mode 100644 index d2c59d4e97..0000000000 --- a/framework/mesh/mesh_continuum/mesh_continuum_vertex_handler.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: 2024 The OpenSn Authors -// SPDX-License-Identifier: MIT - -#pragma once - -#include "framework/data_types/vector3.h" -#include - -namespace opensn -{ - -/// Manages a vertex map with custom calls. -class VertexHandler -{ - using GlobalIDMap = std::map; - -public: - // Iterators - GlobalIDMap::iterator begin() { return m_global_id_vertex_map_.begin(); } - GlobalIDMap::iterator end() { return m_global_id_vertex_map_.end(); } - - GlobalIDMap::const_iterator begin() const { return m_global_id_vertex_map_.begin(); } - GlobalIDMap::const_iterator end() const { return m_global_id_vertex_map_.end(); } - - // Accessors - Vector3& operator[](const uint64_t global_id) { return m_global_id_vertex_map_.at(global_id); } - - const Vector3& operator[](const uint64_t global_id) const - { - return m_global_id_vertex_map_.at(global_id); - } - - // Utilities - void Insert(const uint64_t global_id, const Vector3& vec) - { - m_global_id_vertex_map_.insert(std::make_pair(global_id, vec)); - } - - size_t GetNumLocallyStored() const { return m_global_id_vertex_map_.size(); } - - void Clear() { m_global_id_vertex_map_.clear(); } - -private: - std::map m_global_id_vertex_map_; -}; - -} // namespace opensn diff --git a/framework/mesh/mesh_edge_loops.h b/framework/mesh/mesh_edge_loops.h deleted file mode 100644 index d3ad893e6f..0000000000 --- a/framework/mesh/mesh_edge_loops.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: 2024 The OpenSn Authors -// SPDX-License-Identifier: MIT - -#pragma once - -#include "framework/data_types/vector3.h" -#include - -namespace opensn -{ - -/// Structure containing edge properties -struct Edge -{ - /// Indices of the vertices - std::array v_index{-1, -1}; - /// Indices of faces adjoining it - std::array f_index{-1, -1, -1, -1}; - /// Vector vertices - std::array vertices{}; -}; - -} // namespace opensn diff --git a/framework/mesh/mesh_face.h b/framework/mesh/mesh_face.h deleted file mode 100644 index ba487a340b..0000000000 --- a/framework/mesh/mesh_face.h +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-FileCopyrightText: 2024 The OpenSn Authors -// SPDX-License-Identifier: MIT - -#pragma once - -#include "framework/data_types/vector3.h" -#include - -namespace opensn -{ - -/// Data structure for a triangular face. -struct Face -{ - /// vertex indices - std::array v_index{-1, -1, -1}; - /// normal indices - std::array n_index{-1, -1, -1}; - /// vertex texture indices - std::array vt_index{-1, -1, -1}; - /// edge indices - std::array, 3> e_index{{{-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}}}; - - Vector3 geometric_normal; - Vector3 assigned_normal; - Vector3 face_centroid; - - bool invalidated{false}; -}; - -/** - * Data structure for a polygon face. - * - * edges - * An array of 4 integers. - * [0] = Vertex index of edge start. - * [1] = Vertex index of edge end. - * [2] = Index of the face adjoining this edge (not the current face). - * -1 if not connected to anything,-1*boundary_index if connected - * to a boundary. - * [3] = Edge number of adjoining face. -1 if not connected - * to anything. 0 if a boundary. - * - * face_indices - * [0] = Index of the adjoining cell. -1 if not connected to anything. - * -1*boundary_index if connected to a boundary. - * [1] = Face number of adjoining cell. -1 if not connected - * to anything. 0 if a boundary. - * [2] = Partition ID of adjacent cell. - */ -struct PolyFace -{ - std::vector v_indices; - std::vector> edges; - std::array face_indices{{-1, -1, -1}}; - - Vector3 geometric_normal; - Vector3 face_centroid; - - bool invalidated{false}; -}; - -} // namespace opensn diff --git a/framework/mesh/mesh_generator/distributed_mesh_generator.cc b/framework/mesh/mesh_generator/distributed_mesh_generator.cc index 6ba42dbaeb..aabd91b898 100644 --- a/framework/mesh/mesh_generator/distributed_mesh_generator.cc +++ b/framework/mesh/mesh_generator/distributed_mesh_generator.cc @@ -280,19 +280,18 @@ std::shared_ptr DistributedMeshGenerator::SetupLocalMesh(DistributedMeshData& mesh_info) { auto grid_ptr = MeshContinuum::New(); - grid_ptr->GetBoundaryIDMap() = mesh_info.boundary_id_map; for (auto& [id, name] : mesh_info.boundary_id_map) - grid_ptr->GetBoundaryNameMap()[name] = id; + grid_ptr->SetBoundaryName(id, name); auto& vertices = mesh_info.vertices; for (const auto& [vid, vertex] : vertices) - grid_ptr->vertices.Insert(vid, vertex); + grid_ptr->AddGlobalVertex(vid, vertex); auto& cells = mesh_info.cells; for (const auto& [pidgid, raw_cell] : cells) { const auto& [cell_pid, cell_global_id] = pidgid; - grid_ptr->cells.PushBack(SetupCell(raw_cell, cell_global_id, cell_pid)); + grid_ptr->AddGlobalCell(SetupCell(raw_cell, cell_global_id, cell_pid)); } grid_ptr->SetDimension(mesh_info.dimension); diff --git a/framework/mesh/mesh_generator/mesh_generator.cc b/framework/mesh/mesh_generator/mesh_generator.cc index 5b1798c139..cf2cb14871 100644 --- a/framework/mesh/mesh_generator/mesh_generator.cc +++ b/framework/mesh/mesh_generator/mesh_generator.cc @@ -8,7 +8,7 @@ #include "framework/object_factory.h" #include "framework/runtime.h" #include "framework/logging/log.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include namespace opensn @@ -146,9 +146,9 @@ MeshGenerator::SetupMesh(const std::shared_ptr& input_umesh, auto cell = SetupCell(*raw_cell, cell_global_id, cell_pids[cell_global_id]); for (const auto vid : cell->vertex_ids) - grid_ptr->vertices.Insert(vid, input_umesh->GetVertices()[vid]); + grid_ptr->AddGlobalVertex(vid, input_umesh->GetVertices()[vid]); - grid_ptr->cells.PushBack(std::move(cell)); + grid_ptr->AddGlobalCell(std::move(cell)); } ++cell_global_id; } // for raw_cell @@ -269,7 +269,7 @@ MeshGenerator::ComputeAndPrintStats(const std::shared_ptr& grid) mpi_comm.all_reduce(num_local_cells, min_num_local_cells, mpi::op::min()); const size_t avg_num_local_cells = num_global_cells / mpi_comm.size(); - const size_t num_local_ghosts = grid->cells.GhostCellCount(); + const size_t num_local_ghosts = grid->GhostCellCount(); const double local_ghost_to_local_cell_ratio = double(num_local_ghosts) / double(num_local_cells); double average_ghost_ratio = 0.0; diff --git a/framework/mesh/mesh_generator/split_file_mesh_generator.cc b/framework/mesh/mesh_generator/split_file_mesh_generator.cc index fc9a75bfe1..001089153e 100644 --- a/framework/mesh/mesh_generator/split_file_mesh_generator.cc +++ b/framework/mesh/mesh_generator/split_file_mesh_generator.cc @@ -365,21 +365,20 @@ std::shared_ptr SplitFileMeshGenerator::SetupLocalMesh(SplitMeshInfo& mesh_info) { auto grid_ptr = MeshContinuum::New(); - grid_ptr->GetBoundaryIDMap() = mesh_info.boundary_id_map; for (auto& [id, name] : mesh_info.boundary_id_map) - grid_ptr->GetBoundaryNameMap()[name] = id; + grid_ptr->SetBoundaryName(id, name); auto& cells = mesh_info.cells; auto& vertices = mesh_info.vertices; for (const auto& [vid, vertex] : vertices) - grid_ptr->vertices.Insert(vid, vertex); + grid_ptr->AddGlobalVertex(vid, vertex); for (const auto& [pidgid, raw_cell] : cells) { const auto& [cell_pid, cell_global_id] = pidgid; auto cell = SetupCell(raw_cell, cell_global_id, cell_pid); - grid_ptr->cells.PushBack(std::move(cell)); + grid_ptr->AddGlobalCell(std::move(cell)); } grid_ptr->SetDimension(mesh_info.dimension); diff --git a/framework/mesh/mesh_mapping/mesh_mapping.cc b/framework/mesh/mesh_mapping/mesh_mapping.cc index 6bfa48a709..88e34b4dff 100644 --- a/framework/mesh/mesh_mapping/mesh_mapping.cc +++ b/framework/mesh/mesh_mapping/mesh_mapping.cc @@ -4,7 +4,7 @@ #include "framework/mesh/mesh_mapping/mesh_mapping.h" #include "framework/runtime.h" #include "framework/logging/log.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" #include "framework/math/spatial_discretization/finite_element/piecewise_linear/piecewise_linear_continuous.h" #include diff --git a/framework/mesh/raytrace/raytracer.cc b/framework/mesh/raytrace/raytracer.cc index e055a85a7b..0d11c934f3 100644 --- a/framework/mesh/raytrace/raytracer.cc +++ b/framework/mesh/raytrace/raytracer.cc @@ -3,7 +3,7 @@ #include "framework/mesh/raytrace/raytracer.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/logging/log.h" #include #include @@ -73,20 +73,20 @@ RayTracer::TraceRay(const Cell& cell, Vector3& pos_i, Vector3& omega_i, int func const auto& grid = Grid(); for (auto vi : cell.vertex_ids) - outstr << grid->vertices[vi].PrintStr() << "\n"; + outstr << grid->GlobalVertex(vi).PrintStr() << "\n"; for (const auto& face : cell.faces) { outstr << "Face with centroid: " << face.centroid.PrintStr() << " "; outstr << "n=" << face.normal.PrintStr() << "\n"; for (auto vi : face.vertex_ids) - outstr << grid->vertices[vi].PrintStr() << "\n"; + outstr << grid->GlobalVertex(vi).PrintStr() << "\n"; } outstr << "o Cell\n"; for (const auto& vid : cell.vertex_ids) { - auto& v = grid->vertices[vid]; + auto& v = grid->GlobalVertex(vid); outstr << "v " << v.x << " " << v.y << " " << v.z << "\n"; } @@ -138,7 +138,7 @@ RayTracer::TraceIncidentRay(const Cell& cell, const Vector3& pos_i, const Vector continue /*the loop*/; } - const auto& p0 = grid->vertices[face.vertex_ids[0]]; + const auto& p0 = grid->GlobalVertex(face.vertex_ids[0]); const auto& n = face.normal; const auto ppos_i = p0 - pos_i; @@ -152,7 +152,7 @@ RayTracer::TraceIncidentRay(const Cell& cell, const Vector3& pos_i, const Vector } // SLAB else if (cell_type == CellType::POLYGON) { - const auto& p1 = grid->vertices[face.vertex_ids[1]]; + const auto& p1 = grid->GlobalVertex(face.vertex_ids[1]); intersects_cell = CheckLineIntersectStrip(p0, p1, n, pos_i, pos_ext, I); } // POLYGON else if (cell_type == CellType::POLYHEDRON) @@ -164,8 +164,8 @@ RayTracer::TraceIncidentRay(const Cell& cell, const Vector3& pos_i, const Vector uint64_t v0i = vids[s]; uint64_t v1i = (s < (num_sides - 1)) ? vids[s + 1] : vids[0]; - const auto& v0 = grid->vertices[v0i]; - const auto& v1 = grid->vertices[v1i]; + const auto& v0 = grid->GlobalVertex(v0i); + const auto& v1 = grid->GlobalVertex(v1i); const auto& v2 = face.centroid; const auto v01 = v1 - v0; @@ -223,7 +223,7 @@ RayTracer::TraceSlab(const Cell& cell, for (int f = 0; f < num_faces; ++f) { auto fpi = cell.vertex_ids[f]; // face point index - Vector3 face_point = grid->vertices[fpi]; + Vector3 face_point = grid->GlobalVertex(fpi); bool intersects = CheckPlaneLineIntersect( cell.faces[f].normal, face_point, pos_i, pos_f_line, intersection_point, &weights); @@ -275,8 +275,8 @@ RayTracer::TracePolygon(const Cell& cell, auto fpi = cell.faces[f].vertex_ids[0]; // face point index 0 auto fpf = cell.faces[f].vertex_ids[1]; // face point index 1 - const Vector3& face_point_i = grid->vertices[fpi]; - const Vector3& face_point_f = grid->vertices[fpf]; + const Vector3& face_point_i = grid->GlobalVertex(fpi); + const Vector3& face_point_f = grid->GlobalVertex(fpf); bool intersects = CheckLineIntersectStrip( face_point_i, face_point_f, cell.faces[f].normal, pos_i, pos_f_line, ip); @@ -345,8 +345,8 @@ RayTracer::TracePolyhedron(const Cell& cell, auto v1_index = (s < (num_sides - 1)) ? // if not last vertex face.vertex_ids[s + 1] : face.vertex_ids[0]; // else - const auto& v0 = grid->vertices[v0_index]; - const auto& v1 = grid->vertices[v1_index]; + const auto& v0 = grid->GlobalVertex(v0_index); + const auto& v1 = grid->GlobalVertex(v1_index); const auto& v2 = cell.faces[f].centroid; auto v01 = v1 - v0; @@ -613,7 +613,7 @@ PopulateRaySegmentLengths(const std::shared_ptr grid, { for (const auto& face : cell.faces) // edges { - const auto& v0 = grid->vertices[face.vertex_ids[0]]; + const auto& v0 = grid->GlobalVertex(face.vertex_ids[0]); const auto& vc = cell.centroid; auto n0 = (vc - v0).Cross(khat).Normalized(); @@ -642,7 +642,7 @@ PopulateRaySegmentLengths(const std::shared_ptr grid, // Face center to vertex segments for (auto vi : face.vertex_ids) { - auto& vert = grid->vertices[vi]; + auto& vert = grid->GlobalVertex(vi); Vector3 intersection_point; @@ -666,8 +666,8 @@ PopulateRaySegmentLengths(const std::shared_ptr grid, auto vid_1 = (v < (face.vertex_ids.size() - 1)) ? face.vertex_ids[v + 1] : face.vertex_ids[0]; - auto& v0 = grid->vertices[vid_0]; - auto& v1 = grid->vertices[vid_1]; + auto& v0 = grid->GlobalVertex(vid_0); + auto& v1 = grid->GlobalVertex(vid_1); const auto& v2 = vcc; Vector3 intersection_point; diff --git a/framework/mesh/raytrace/raytracer.h b/framework/mesh/raytrace/raytracer.h index 2d4fccbe3c..a38636654f 100644 --- a/framework/mesh/raytrace/raytracer.h +++ b/framework/mesh/raytrace/raytracer.h @@ -3,8 +3,7 @@ #pragma once -#include "framework/mesh/mesh.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/data_types/vector3.h" namespace opensn diff --git a/framework/mesh/surface_mesh/surface_mesh.cc b/framework/mesh/surface_mesh/surface_mesh.cc index 6f75fc2701..fccd468e7a 100644 --- a/framework/mesh/surface_mesh/surface_mesh.cc +++ b/framework/mesh/surface_mesh/surface_mesh.cc @@ -2,8 +2,6 @@ // SPDX-License-Identifier: MIT #include "framework/mesh/surface_mesh/surface_mesh.h" -#include "framework/mesh/mesh_face.h" -#include "framework/mesh/mesh_edge_loops.h" #include "framework/runtime.h" #include "framework/logging/log.h" #include "framework/utils/timer.h" @@ -46,7 +44,7 @@ SurfaceMesh::~SurfaceMesh() std::ostream& operator<<(std::ostream& os, SurfaceMesh& obj) { - std::vector::const_iterator curface; + std::vector::const_iterator curface; for (curface = obj.GetTriangles().begin(); curface != obj.GetTriangles().end(); ++curface) { long index = std::distance(obj.GetTriangles().begin(), curface); diff --git a/framework/mesh/surface_mesh/surface_mesh.h b/framework/mesh/surface_mesh/surface_mesh.h index a317612f77..f9ad20c01a 100644 --- a/framework/mesh/surface_mesh/surface_mesh.h +++ b/framework/mesh/surface_mesh/surface_mesh.h @@ -10,10 +10,6 @@ namespace opensn { -struct Face; -struct PolyFace; -struct Edge; - /** * Generic surface mesh class. * This class facilitates many functions within the mesh environment including logically determining @@ -22,6 +18,69 @@ struct Edge; class SurfaceMesh { public: + /// Structure containing edge properties + struct Edge + { + /// Indices of the vertices + std::array v_index{-1, -1}; + /// Indices of faces adjoining it + std::array f_index{-1, -1, -1, -1}; + /// Vector vertices + std::array vertices{}; + }; + + /// Data structure for a triangular face. + struct Face + { + /// vertex indices + std::array v_index{-1, -1, -1}; + /// normal indices + std::array n_index{-1, -1, -1}; + /// vertex texture indices + std::array vt_index{-1, -1, -1}; + /// edge indices + std::array, 3> e_index{ + {{-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}}}; + + Vector3 geometric_normal; + Vector3 assigned_normal; + Vector3 face_centroid; + + bool invalidated{false}; + }; + + /** + * Data structure for a polygon face. + * + * edges + * An array of 4 integers. + * [0] = Vertex index of edge start. + * [1] = Vertex index of edge end. + * [2] = Index of the face adjoining this edge (not the current face). + * -1 if not connected to anything,-1*boundary_index if connected + * to a boundary. + * [3] = Edge number of adjoining face. -1 if not connected + * to anything. 0 if a boundary. + * + * face_indices + * [0] = Index of the adjoining cell. -1 if not connected to anything. + * -1*boundary_index if connected to a boundary. + * [1] = Face number of adjoining cell. -1 if not connected + * to anything. 0 if a boundary. + * [2] = Partition ID of adjacent cell. + */ + struct PolyFace + { + std::vector v_indices; + std::vector> edges; + std::array face_indices{{-1, -1, -1}}; + + Vector3 geometric_normal; + Vector3 face_centroid; + + bool invalidated{false}; + }; + explicit SurfaceMesh(const InputParameters& params); const std::vector& GetVertices() const { return vertices_; } diff --git a/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc b/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc index 99fe00be9e..204e02735e 100644 --- a/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc +++ b/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.cc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: MIT #include "framework/mesh/unpartitioned_mesh/unpartitioned_mesh.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/runtime.h" #include "framework/logging/log.h" #include "framework/utils/timer.h" diff --git a/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.h b/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.h index 61dbfe126a..a4d8a56b03 100644 --- a/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.h +++ b/framework/mesh/unpartitioned_mesh/unpartitioned_mesh.h @@ -3,8 +3,8 @@ #pragma once -#include "framework/mesh/cell/cell.h" -#include "framework/mesh/mesh.h" +#include "framework/mesh/mesh_continuum/cell.h" +#include "framework/mesh/mesh_continuum/mesh_continuum.h" #include #include #include diff --git a/framework/mpi/mpi_comm_set.h b/framework/mpi/mpi_comm_set.h index 239a5777d7..0610673627 100644 --- a/framework/mpi/mpi_comm_set.h +++ b/framework/mpi/mpi_comm_set.h @@ -3,7 +3,6 @@ #pragma once -#include "framework/mesh/mesh.h" #include "framework/runtime.h" #include "mpicpp-lite/mpicpp-lite.h" diff --git a/modules/diffusion/diffusion_mip_solver.cc b/modules/diffusion/diffusion_mip_solver.cc index bcf86e3ee1..cf4fabb8e8 100644 --- a/modules/diffusion/diffusion_mip_solver.cc +++ b/modules/diffusion/diffusion_mip_solver.cc @@ -128,7 +128,7 @@ DiffusionMIPSolver::AssembleAand_b_wQpoints(const std::vector& q_vector) if (face.has_neighbor) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const auto& adj_cell_mapping = sdm_.GetCellMapping(adj_cell); const auto ac_nodes = adj_cell_mapping.GetNodeLocations(); const size_t acf = MeshContinuum::MapCellFace(cell, adj_cell, f); @@ -659,7 +659,7 @@ DiffusionMIPSolver::AssembleAand_b(const std::vector& q_vector) if (face.has_neighbor) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const auto& adj_cell_mapping = sdm_.GetCellMapping(adj_cell); const auto ac_nodes = adj_cell_mapping.GetNodeLocations(); const size_t acf = MeshContinuum::MapCellFace(cell, adj_cell, f); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc index 100444c9ef..023edcbfc9 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_acceleration.cc @@ -1157,7 +1157,7 @@ CMFDAcceleration::BuildFaceCurrentCache() if (grid.IsCellLocal(neighbor_id)) continue; - const auto& neighbor_cell = grid.cells[neighbor_id]; + const auto& neighbor_cell = grid.GetGlobalCell(neighbor_id); auto& requests = pid_request_sets[neighbor_cell.partition_id]; for (unsigned int cg = 0; cg < num_coarse_groups_; ++cg) requests.emplace(neighbor_id, fine_face.cell_id, cg); @@ -1195,7 +1195,7 @@ CMFDAcceleration::BuildFaceCurrentCache() const auto owner_cell_gid = requests[r]; const auto neighbor_cell_gid = requests[r + 1]; const auto cg = static_cast(requests[r + 2]); - const auto& owner_cell = grid.cells[owner_cell_gid]; + const auto& owner_cell = grid.GetGlobalCell(owner_cell_gid); OpenSnInvalidArgumentIf(owner_cell.partition_id != opensn::mpi_comm.rank(), "CMFD face-current request references a nonlocal owner cell."); @@ -1420,7 +1420,7 @@ CMFDAcceleration::ComputePartialOutwardCurrents(const CMFDCoarseCell& coarse_cel double neighbor_partial_current = 0.0; for (const auto& fine_face : coarse_face.fine_faces) { - const auto& fine_cell = grid.cells[fine_face.cell_id]; + const auto& fine_cell = grid.GetGlobalCell(fine_face.cell_id); double owner_outflow = 0.0; for (unsigned int g = FineGroupBegin(coarse_group); g < FineGroupEnd(coarse_group); ++g) owner_outflow += @@ -1435,7 +1435,7 @@ CMFDAcceleration::ComputePartialOutwardCurrents(const CMFDCoarseCell& coarse_cel if (grid.IsCellLocal(*neighbor_id)) { - const auto& neighbor_cell = grid.cells[*neighbor_id]; + const auto& neighbor_cell = grid.GetGlobalCell(*neighbor_id); bool found_face = false; for (std::size_t nf = 0; nf < neighbor_cell.faces.size(); ++nf) { diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_coarse_mesh.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_coarse_mesh.cc index 4284c5f158..1db3e9de65 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_coarse_mesh.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_coarse_mesh.cc @@ -3,7 +3,7 @@ #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_coarse_mesh.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/mpi/mpi_utils.h" #include "framework/runtime.h" #include "framework/utils/error.h" @@ -51,7 +51,7 @@ BuildGhostFineToCoarseMap(const MeshContinuum& grid, const CMFDCoarseMesh& coars for (const auto& face : cell.faces) if (face.has_neighbor and not grid.IsCellLocal(face.neighbor_id)) { - const auto& neighbor_cell = grid.cells[face.neighbor_id]; + const auto& neighbor_cell = grid.GetGlobalCell(face.neighbor_id); pid_request_sets[neighbor_cell.partition_id].insert(face.neighbor_id); } @@ -99,7 +99,7 @@ BuildRemoteCoarseCellMetadataMap(const MeshContinuum& grid, std::map> pid_request_sets; for (const auto& [fine_cell_id, coarse_cell_id] : ghost_fine_to_coarse) { - const auto& fine_cell = grid.cells[fine_cell_id]; + const auto& fine_cell = grid.GetGlobalCell(fine_cell_id); pid_request_sets[fine_cell.partition_id].insert(coarse_cell_id); } @@ -171,7 +171,7 @@ CMFDCoarseMesh::BuildExteriorFaces(const MeshContinuum& grid) for (const auto fine_cell_id : coarse_cell.fine_cell_ids) { - const auto& fine_cell = grid.cells[fine_cell_id]; + const auto& fine_cell = grid.GetGlobalCell(fine_cell_id); for (std::size_t f = 0; f < fine_cell.faces.size(); ++f) { const auto& fine_face = fine_cell.faces[f]; @@ -255,12 +255,14 @@ CMFDCoarseMesh::BuildIdentity(const MeshContinuum& grid) coarse_face.has_neighbor = fine_face.has_neighbor; coarse_face.neighbor_id = fine_face.neighbor_id; coarse_face.neighbor_partition_id = fine_face.has_neighbor - ? grid.cells[fine_face.neighbor_id].partition_id + ? grid.GetGlobalCell(fine_face.neighbor_id).partition_id : fine_cell.partition_id; - coarse_face.neighbor_block_id = - fine_face.has_neighbor ? grid.cells[fine_face.neighbor_id].block_id : fine_cell.block_id; - coarse_face.neighbor_centroid = - fine_face.has_neighbor ? grid.cells[fine_face.neighbor_id].centroid : fine_cell.centroid; + coarse_face.neighbor_block_id = fine_face.has_neighbor + ? grid.GetGlobalCell(fine_face.neighbor_id).block_id + : fine_cell.block_id; + coarse_face.neighbor_centroid = fine_face.has_neighbor + ? grid.GetGlobalCell(fine_face.neighbor_id).centroid + : fine_cell.centroid; coarse_face.normal = fine_face.normal; coarse_face.centroid = fine_face.centroid; coarse_face.area = fine_face.area; @@ -311,7 +313,7 @@ CMFDCoarseMesh::BuildLocalAggregation(const MeshContinuum& grid, { const auto fine_cell_id = queue.front(); queue.pop_front(); - const auto& fine_cell = grid.cells[fine_cell_id]; + const auto& fine_cell = grid.GetGlobalCell(fine_cell_id); coarse_cell.fine_cell_ids.push_back(fine_cell.global_id); coarse_cell.volume += fine_cell.volume; @@ -322,7 +324,7 @@ CMFDCoarseMesh::BuildLocalAggregation(const MeshContinuum& grid, if (not face.has_neighbor or not grid.IsCellLocal(face.neighbor_id)) continue; - const auto& neighbor = grid.cells[face.neighbor_id]; + const auto& neighbor = grid.GetGlobalCell(face.neighbor_id); if (neighbor.block_id != seed_cell.block_id or assigned.count(neighbor.global_id) > 0 or coarse_cell.fine_cell_ids.size() + queue.size() >= target_fine_cells_per_coarse_cell) continue; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_vector_tools.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_vector_tools.cc index 41b9e8597f..94fc740ae9 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_vector_tools.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/cmfd_vector_tools.cc @@ -75,7 +75,7 @@ CMFDRestrictScalarFlux(const DiscreteOrdinatesProblem& do_problem, for (const uint64_t fine_cell_id : coarse_cell.fine_cell_ids) { - const auto& fine_cell = do_problem.GetGrid()->cells[fine_cell_id]; + const auto& fine_cell = do_problem.GetGrid()->GetGlobalCell(fine_cell_id); OpenSnInvalidArgumentIf(fine_cell.partition_id != opensn::mpi_comm.rank(), "CMFD restriction currently requires local fine cells."); @@ -133,7 +133,7 @@ CMFDProlongateScalarFluxRatio(const DiscreteOrdinatesProblem& do_problem, for (const uint64_t fine_cell_id : coarse_cell.fine_cell_ids) { - const auto& fine_cell = do_problem.GetGrid()->cells[fine_cell_id]; + const auto& fine_cell = do_problem.GetGrid()->GetGlobalCell(fine_cell_id); OpenSnInvalidArgumentIf(fine_cell.partition_id != opensn::mpi_comm.rank(), "CMFD prolongation currently requires local fine cells."); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/discrete_ordinates_keigen_acceleration.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/discrete_ordinates_keigen_acceleration.cc index ec24493a71..3bcb34a222 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/discrete_ordinates_keigen_acceleration.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/discrete_ordinates_keigen_acceleration.cc @@ -84,9 +84,9 @@ DiscreteOrdinatesKEigenAcceleration::MakePWLDGhostIndices(const SpatialDiscretiz { std::set ghost_ids; const auto& grid = *pwld.GetGrid(); - for (const uint64_t ghost_id : grid.cells.GetGhostGlobalIDs()) + for (const uint64_t ghost_id : grid.GetGhostGlobalIDs()) { - const auto& cell = grid.cells[ghost_id]; + const auto& cell = grid.GetGlobalCell(ghost_id); const auto& cell_mapping = pwld.GetCellMapping(cell); for (int i = 0; i < cell_mapping.GetNumNodes(); ++i) for (int u = 0; u < uk_man.GetNumberOfUnknowns(); ++u) @@ -181,11 +181,11 @@ DiscreteOrdinatesKEigenAcceleration::NodallyAveragedPWLDVector(const std::vector } // for local cell // Ghost cells - const auto ghost_cell_ids = grid->cells.GetGhostGlobalIDs(); + const auto ghost_cell_ids = grid->GetGhostGlobalIDs(); const auto& vid_set = partition_bndry_vertex_id_set; for (const auto global_id : ghost_cell_ids) { - const auto& cell = grid->cells[global_id]; + const auto& cell = grid->GetGlobalCell(global_id); const auto& cell_mapping = pwld_sdm.GetCellMapping(cell); const size_t num_nodes = cell_mapping.GetNumNodes(); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/smm_acceleration.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/smm_acceleration.cc index 229ace723c..b3ce763dd6 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/smm_acceleration.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/acceleration/smm_acceleration.cc @@ -623,7 +623,7 @@ SMMAcceleration::ComputeSourceCorrection() const // Interior face terms if (face.has_neighbor) { - const auto& nbr_cell = grid->cells[face.neighbor_id]; + const auto& nbr_cell = grid->GetGlobalCell(face.neighbor_id); const auto& nbr_cell_mapping = pwld.GetCellMapping(nbr_cell); const auto& nbr_nodes = nbr_cell_mapping.GetNodeLocations(); diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/io/angular_flux_io.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/io/angular_flux_io.cc index 40ec76624d..fa8ec9414e 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/io/angular_flux_io.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/io/angular_flux_io.cc @@ -157,7 +157,7 @@ DiscreteOrdinatesProblemIO::ReadAngularFluxes( for (uint64_t c = 0; c < file_num_local_cells; ++c) { const uint64_t cell_global_id = file_cell_ids[c]; - const auto& cell = grid->cells[cell_global_id]; + const auto& cell = grid->GetGlobalCell(cell_global_id); if (not grid->IsCellLocal(cell_global_id)) continue; @@ -229,7 +229,7 @@ DiscreteOrdinatesProblemIO::ReadAngularFluxes( for (uint64_t c = 0; c < file_num_local_cells; ++c) { const auto cell_global_id = file_cell_ids[c]; - const auto& cell = grid->cells[cell_global_id]; + const auto& cell = grid->GetGlobalCell(cell_global_id); for (uint64_t i = 0; i < discretization.GetCellNumNodes(cell); ++i) for (uint64_t n = 0; n < num_gs_dirs; ++n) for (unsigned int g = 0; g < num_gs_groups; ++g) diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h index c2f2e83aab..44d2adda0f 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_aggregation/angle_aggregation.h @@ -9,7 +9,6 @@ #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/sweep.h" #include "framework/math/quadratures/angular/angular_quadrature.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" -#include "framework/mesh/mesh.h" #include #include #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/angle_set.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/angle_set.h index aee9869012..02338c6110 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/angle_set.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/angle_set.h @@ -7,7 +7,6 @@ #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/sweep_boundary.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/communicators/async_comm.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds.h" -#include "framework/mesh/mesh.h" #include "framework/logging/log.h" #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc index a65b9fdba5..c8485c937c 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.cc @@ -4,7 +4,7 @@ #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/angle_set/angle_set.h" #include "modules/linear_boltzmann_solvers/lbs_problem/groupset/lbs_groupset.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" namespace opensn { diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.h index 8dcfd33018..be87d6e806 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/isotropic_boundary.h @@ -4,7 +4,6 @@ #pragma once #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/sweep_boundary.h" -#include "framework/mesh/mesh.h" #include "framework/math/math.h" #include #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.h index 1647133ca3..786acf41c0 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/reflecting_boundary.h @@ -4,7 +4,8 @@ #pragma once #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/sweep_boundary.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" +#include "framework/mesh/mesh_continuum/mesh_continuum.h" #include #include namespace opensn diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/vacuum_boundary.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/vacuum_boundary.h index 2ab7961081..ac22a1c0ea 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/vacuum_boundary.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/vacuum_boundary.h @@ -4,7 +4,6 @@ #pragma once #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/boundary/sweep_boundary.h" -#include "framework/mesh/mesh.h" #include "framework/math/math.h" #include #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aah_fluds_common_data.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aah_fluds_common_data.cc index 139fdee5ae..47db072a88 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aah_fluds_common_data.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aah_fluds_common_data.cc @@ -336,7 +336,7 @@ AAH_FLUDSCommonData::LocalIncidentMapping(const Cell& cell, dof_mapping.second = cell_nodal_mapping[f].face_node_mapping_; // Find associated face counter for slot lookup - const auto& adj_cell = grid->cells[face.neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(face.neighbor_id); const auto adj_so_index = local_so_cell_mapping[adj_cell.local_id]; const auto& face_oris = spds.GetCellFaceOrientations()[adj_cell.local_id]; int adj_f_counter = -1; diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h index dd73ce383a..1eb4baa3ed 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/aahd_structs.h @@ -4,7 +4,7 @@ #pragma once #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds_structs.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds_common_data.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds_common_data.cc index 1417cbb778..25b34d1aef 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds_common_data.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds_common_data.cc @@ -3,7 +3,7 @@ #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbc_fluds_common_data.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" #include "framework/mpi/mpi_utils.h" #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_fluds.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_fluds.h index 3580710cf5..340889d350 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_fluds.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_fluds.h @@ -6,7 +6,7 @@ #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_structs.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/cbcd_fluds_common_data.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/fluds/fluds.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "caribou/main.hpp" #include #include diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc index 1a1a22ac4d..468c26b6bd 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/aah.cc @@ -150,7 +150,7 @@ AAH_SPDS::ComputeLocalLocationEdgeWeights() const const double mu = omega_.Dot(face.normal); if (mu > tolerance) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const int to_loc = adj_cell.partition_id; row[to_loc] += mu * mu * face.area; } diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/cbc.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/cbc.cc index 2b744217e5..da7126e36f 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/cbc.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/cbc.cc @@ -90,7 +90,7 @@ CBC_SPDS::CBC_SPDS(const Vector3& omega, else if (orientation == OUTGOING) { if (face.has_neighbor and grid->IsCellLocal(face.neighbor_id)) - successors.push_back(grid->cells[face.neighbor_id].local_id); + successors.push_back(grid->GetGlobalCell(face.neighbor_id).local_id); } } diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc index 138143c110..cc36dff71f 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/spds/spds.cc @@ -433,7 +433,7 @@ SPDS::PopulateCellRelationships( } // if face owned else if (finfo.has_neighbor and not finfo.neighbor_local) { - const auto& adj_cell = grid_->cells[face.neighbor_id]; + const auto& adj_cell = grid_->GetGlobalCell(face.neighbor_id); const auto adj_face_idx = finfo.neighbor_adj_face; const auto& adj_face = adj_cell.faces[adj_face_idx]; @@ -526,7 +526,7 @@ SPDS::PrintGhostedGraph() const std::cout << " " << face.neighbor_id << " [shape=\"circle\", style=filled fillcolor=red " "fontcolor=white] //proc=" - << grid_->cells[face.neighbor_id].partition_id << "\n"; + << grid_->GetGlobalCell(face.neighbor_id).partition_id << "\n"; } } @@ -546,10 +546,10 @@ SPDS::PrintGhostedGraph() const } } std::cout << "\n"; - const auto ghost_ids = grid_->cells.GetGhostGlobalIDs(); + const auto ghost_ids = grid_->GetGhostGlobalIDs(); for (const uint64_t global_id : ghost_ids) { - const auto& cell = grid_->cells[global_id]; + const auto& cell = grid_->GetGlobalCell(global_id); for (const auto& face : cell.faces) { if (face.has_neighbor and (cell.global_id > face.neighbor_id) and diff --git a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h index 073eb1e5d5..f79c720247 100644 --- a/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h +++ b/modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep_chunks/cbc_sweep_kernels.h @@ -5,7 +5,7 @@ #include "framework/data_types/dense_matrix.h" #include "framework/data_types/vector.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/math/spatial_discretization/spatial_discretization.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/discrete_ordinates_problem.h" #include "modules/linear_boltzmann_solvers/discrete_ordinates_problem/sweep/communicators/cbc_async_comm.h" diff --git a/modules/linear_boltzmann_solvers/lbs_problem/io/flux_moments_io.cc b/modules/linear_boltzmann_solvers/lbs_problem/io/flux_moments_io.cc index b54dc6976d..9f37e99817 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/io/flux_moments_io.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/io/flux_moments_io.cc @@ -155,7 +155,7 @@ LBSSolverIO::ReadFluxMoments(LBSProblem& lbs_problem, for (uint64_t c = 0; c < file_num_local_cells; ++c) { const uint64_t cell_global_id = file_cell_ids[c]; - const auto& cell = grid->cells[cell_global_id]; + const auto& cell = grid->GetGlobalCell(cell_global_id); if (not grid->IsCellLocal(cell_global_id)) continue; @@ -201,7 +201,7 @@ LBSSolverIO::ReadFluxMoments(LBSProblem& lbs_problem, for (uint64_t c = 0; c < file_num_local_cells; ++c) { const uint64_t cell_global_id = file_cell_ids[c]; - const auto& cell = grid->cells[cell_global_id]; + const auto& cell = grid->GetGlobalCell(cell_global_id); for (uint64_t i = 0; i < discretization.GetCellNumNodes(cell); ++i) for (unsigned int m = 0; m < num_moments; ++m) for (unsigned int g = 0; g < num_groups; ++g) diff --git a/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc b/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc index 3e1db93612..63f8547c8e 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.cc @@ -925,10 +925,10 @@ LBSProblem::InitializeMaterials() (block_id_to_xs_map_.find(cell.block_id) == block_id_to_xs_map_.end())) ++invalid_mat_cell_count; } - const auto& ghost_cell_ids = grid_->cells.GetGhostGlobalIDs(); + const auto& ghost_cell_ids = grid_->GetGhostGlobalIDs(); for (uint64_t cell_id : ghost_cell_ids) { - const auto& cell = grid_->cells[cell_id]; + const auto& cell = grid_->GetGlobalCell(cell_id); unique_block_ids.insert(cell.block_id); if (cell.block_id == std::numeric_limits::max() or (block_id_to_xs_map_.find(cell.block_id) == block_id_to_xs_map_.end())) @@ -1040,10 +1040,10 @@ LBSProblem::ComputeUnitIntegrals() unit_cell_matrices_[cell.local_id] = ComputeUnitCellIntegrals(sdm, cell, grid_->GetCoordinateSystem()); - const auto ghost_ids = grid_->cells.GetGhostGlobalIDs(); + const auto ghost_ids = grid_->GetGhostGlobalIDs(); for (auto ghost_id : ghost_ids) unit_ghost_cell_matrices_[ghost_id] = - ComputeUnitCellIntegrals(sdm, grid_->cells[ghost_id], grid_->GetCoordinateSystem()); + ComputeUnitCellIntegrals(sdm, grid_->GetGlobalCell(ghost_id), grid_->GetCoordinateSystem()); // Assessing global unit cell matrix storage std::array num_local_ucms = {unit_cell_matrices_.size(), @@ -1130,7 +1130,7 @@ LBSProblem::InitializeParrays() const int neighbor_partition = face.GetNeighborPartitionID(grid_.get()); face_local_flags[f] = (neighbor_partition == opensn::mpi_comm.rank()); face_locality[f] = neighbor_partition; - neighbor_cell_ptrs[f] = &grid_->cells[face.neighbor_id]; + neighbor_cell_ptrs[f] = &grid_->GetGlobalCell(face.neighbor_id); } ++f; diff --git a/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.cc b/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.cc index e237b5904a..6973c6ba61 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.cc @@ -116,10 +116,10 @@ PointSource::Initialize(const LBSProblem& lbs_problem) // If the point source lies on a partition boundary, ghost cells must be // added to the total volume. - auto ghost_global_ids = grid->cells.GetGhostGlobalIDs(); + auto ghost_global_ids = grid->GetGhostGlobalIDs(); for (uint64_t global_id : ghost_global_ids) { - const auto& nbr_cell = grid->cells[global_id]; + const auto& nbr_cell = grid->GetGlobalCell(global_id); if (grid->CheckPointInsideCell(nbr_cell, location_)) { const auto& fe_values = ghost_unit_cell_matrices.at(nbr_cell.global_id); diff --git a/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.h b/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.h index 7e21995450..4a649a50bd 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.h +++ b/modules/linear_boltzmann_solvers/lbs_problem/point_source/point_source.h @@ -3,7 +3,6 @@ #pragma once -#include "framework/mesh/mesh.h" #include "framework/math/math.h" #include "framework/parameters/input_parameters.h" #include diff --git a/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc b/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc index fd8fdd9395..b0090a140f 100644 --- a/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc +++ b/modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.cc @@ -4,7 +4,7 @@ #include "modules/linear_boltzmann_solvers/lbs_problem/volumetric_source/volumetric_source.h" #include "modules/linear_boltzmann_solvers/lbs_problem/lbs_problem.h" #include "framework/math/functions/function.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/mesh/mesh_continuum/mesh_continuum.h" #include "framework/mesh/logical_volume/logical_volume.h" #include "framework/logging/log.h" diff --git a/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc b/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc index da7590ba57..c405c4ebf4 100644 --- a/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc +++ b/modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.cc @@ -420,7 +420,7 @@ ResponseEvaluator::EvaluateResponse(const std::string& buffer) const for (size_t fi = 0; fi < num_face_nodes; ++fi) { const auto i = cell_mapping.MapFaceNode(f, fi); - const auto& node = grid->vertices[cell.vertex_ids[i]]; + const auto& node = grid->GlobalVertex(cell.vertex_ids[i]); const auto& intF_shapeI = fe_values.intS_shapeI[f](i); const auto psi_bndry = EvaluateBoundaryCondition(bndry_id, node, groupset); diff --git a/python/lib/mesh.cc b/python/lib/mesh.cc index df594e2a1e..78eab5e1ef 100644 --- a/python/lib/mesh.cc +++ b/python/lib/mesh.cc @@ -166,10 +166,10 @@ WrapMesh(py::module& mesh) } } // change ghost cells - std::vector ghost_ids = self.cells.GetGhostGlobalIDs(); + std::vector ghost_ids = self.GetGhostGlobalIDs(); for (std::uint64_t ghost_id : ghost_ids) { - Cell& cell = self.cells[ghost_id]; + Cell& cell = self.GetGlobalCell(ghost_id); auto new_block_id = func(cell.centroid, cell.block_id); if (cell.block_id != new_block_id) { diff --git a/test/unit/framework/data_types/data_types_test.cc b/test/unit/framework/data_types/data_types_test.cc index 70e0cb5147..73459e6229 100644 --- a/test/unit/framework/data_types/data_types_test.cc +++ b/test/unit/framework/data_types/data_types_test.cc @@ -4,7 +4,7 @@ #include "gtest/gtest.h" #include "framework/data_types/byte_array.h" #include "framework/data_types/ndarray.h" -#include "framework/mesh/cell/cell.h" +#include "framework/mesh/mesh_continuum/cell.h" #include "framework/mpi/mpi_utils.h" #include "framework/logging/log.h" #include "framework/runtime.h" diff --git a/test/unit/framework/mesh/mesh_continuum_test.cc b/test/unit/framework/mesh/mesh_continuum_test.cc index 4eda004047..1a73e3616a 100644 --- a/test/unit/framework/mesh/mesh_continuum_test.cc +++ b/test/unit/framework/mesh/mesh_continuum_test.cc @@ -26,7 +26,7 @@ TestPointInsideCell(const std::shared_ptr grid) const auto has_vertex = std::find(other_cell.vertex_ids.begin(), other_cell.vertex_ids.end(), vi) != other_cell.vertex_ids.end(); - const auto within = grid->CheckPointInsideCell(other_cell, grid->vertices[vi]); + const auto within = grid->CheckPointInsideCell(other_cell, grid->GlobalVertex(vi)); EXPECT_EQ(has_vertex, within); } @@ -50,8 +50,8 @@ TestPointInsideCell(const std::shared_ptr grid) for (size_t side = 0; side < face.vertex_ids.size(); ++side) { const size_t sp1 = (side < (face.vertex_ids.size() - 1)) ? side + 1 : 0; - const auto& v0 = grid->vertices[face.vertex_ids[side]]; - const auto& v1 = grid->vertices[face.vertex_ids[sp1]]; + const auto& v0 = grid->GlobalVertex(face.vertex_ids[side]); + const auto& v1 = grid->GlobalVertex(face.vertex_ids[sp1]); const auto c = (v0 + v1) / 2.0; EXPECT_TRUE(grid->CheckPointInsideCell(cell, c)); } @@ -65,9 +65,9 @@ TestPointInsideCell(const std::shared_ptr grid) for (size_t side = 0; side < face.vertex_ids.size(); ++side) { const size_t sp1 = (side < (face.vertex_ids.size() - 1)) ? side + 1 : 0; - const auto& v0 = grid->vertices[face.vertex_ids[side]]; + const auto& v0 = grid->GlobalVertex(face.vertex_ids[side]); const auto& v1 = face.centroid; - const auto& v2 = grid->vertices[face.vertex_ids[sp1]]; + const auto& v2 = grid->GlobalVertex(face.vertex_ids[sp1]); const auto& v3 = cell.centroid; const auto c = (v0 + v1 + v2 + v3) / 4.0; for (const auto& other_cell : grid->local_cells) @@ -127,7 +127,7 @@ TestPointInsideCellFace(const std::shared_ptr grid) const auto& face = cell.faces[face_i]; const auto has_vertex = std::find(face.vertex_ids.begin(), face.vertex_ids.end(), vi) != face.vertex_ids.end(); - const auto within = grid->CheckPointInsideCellFace(cell, face_i, grid->vertices[vi]); + const auto within = grid->CheckPointInsideCellFace(cell, face_i, grid->GlobalVertex(vi)); EXPECT_EQ(has_vertex, within); } @@ -163,7 +163,7 @@ TestPointInsideCellFace(const std::shared_ptr grid) const auto vi1 = face.vertex_ids[i]; const auto vi2 = (i == face.vertex_ids.size() - 1) ? face.vertex_ids[0] : face.vertex_ids[i + 1]; - const auto edge_centroid = (grid->vertices[vi1] + grid->vertices[vi2]) / 2; + const auto edge_centroid = (grid->GlobalVertex(vi1) + grid->GlobalVertex(vi2)) / 2; for (const auto& other_cell : grid->local_cells) for (std::size_t other_face_i = 0; other_face_i < other_cell.faces.size(); ++other_face_i) diff --git a/test/unit/framework/mesh/surface_mesh_test.cc b/test/unit/framework/mesh/surface_mesh_test.cc index ac6c1c5fd1..5303cc0a4c 100644 --- a/test/unit/framework/mesh/surface_mesh_test.cc +++ b/test/unit/framework/mesh/surface_mesh_test.cc @@ -1,5 +1,4 @@ #include "framework/mesh/surface_mesh/surface_mesh.h" -#include "framework/mesh/mesh_face.h" #include #include diff --git a/test/unit/framework/spatial_discretization/sdm_test_02_discontinuous.cc b/test/unit/framework/spatial_discretization/sdm_test_02_discontinuous.cc index 565b7161ec..d1f711300a 100644 --- a/test/unit/framework/spatial_discretization/sdm_test_02_discontinuous.cc +++ b/test/unit/framework/spatial_discretization/sdm_test_02_discontinuous.cc @@ -128,7 +128,7 @@ math_SDM_Test02_Discontinuous(std::shared_ptr grid, if (face.has_neighbor) { - const auto& adj_cell = grid->cells[face.neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(face.neighbor_id); const auto& adj_cell_mapping = sdm.GetCellMapping(adj_cell); const auto ac_nodes = adj_cell_mapping.GetNodeLocations(); const size_t acf = MeshContinuum::MapCellFace(cell, adj_cell, f); diff --git a/test/unit/framework/tutorials/tutorial_91a_pwld.cc b/test/unit/framework/tutorials/tutorial_91a_pwld.cc index 2521c8a8c6..098987a0d8 100644 --- a/test/unit/framework/tutorials/tutorial_91a_pwld.cc +++ b/test/unit/framework/tutorials/tutorial_91a_pwld.cc @@ -202,7 +202,7 @@ SimTest91_PWLD(std::shared_ptr grid) const MultiGroupXS& cell_xs) { const auto cell_global_id = ijk_mapping.MapNDtoLin(ijk[1], ijk[0], ijk[2]); - const auto& cell = grid->cells[cell_global_id]; + const auto& cell = grid->GetGlobalCell(cell_global_id); const auto cell_local_id = cell.local_id; const auto& cell_mapping = sdm.GetCellMapping(cell); const size_t num_nodes = cell_mapping.GetNumNodes(); @@ -242,7 +242,7 @@ SimTest91_PWLD(std::shared_ptr grid) const double* upwind_psi = zero_vector.data(); if (face.has_neighbor) { - const auto& adj_cell = grid->cells[face.neighbor_id]; + const auto& adj_cell = grid->GetGlobalCell(face.neighbor_id); const int aj = cell_adj_mapping[cell.local_id][f][fj]; const auto ajmap = sdm.MapDOFLocal(adj_cell, aj, psi_uk_man, d, 0); upwind_psi = &psi_old[ajmap]; diff --git a/test/unit/framework/tutorials/tutorial_93_raytracing.cc b/test/unit/framework/tutorials/tutorial_93_raytracing.cc index 394a5d3748..00724c6222 100644 --- a/test/unit/framework/tutorials/tutorial_93_raytracing.cc +++ b/test/unit/framework/tutorials/tutorial_93_raytracing.cc @@ -181,14 +181,14 @@ SimTest93_RayTracing(std::shared_ptr grid) auto GetCellApproximateSize = [&grid](const Cell& cell) { - const auto& v0 = grid->vertices[cell.vertex_ids[0]]; + const auto& v0 = grid->GlobalVertex(cell.vertex_ids[0]); double xmin = v0.x, xmax = v0.x; double ymin = v0.y, ymax = v0.y; double zmin = v0.z, zmax = v0.z; for (uint64_t vid : cell.vertex_ids) { - const auto& v = grid->vertices[vid]; + const auto& v = grid->GlobalVertex(vid); xmin = std::min(xmin, v.x); xmax = std::max(xmax, v.x); @@ -223,7 +223,7 @@ SimTest93_RayTracing(std::shared_ptr grid) while (particle.alive) { // Get the current cell - const auto& cell = grid->cells[particle.cell_id]; + const auto& cell = grid->GetGlobalCell(particle.cell_id); // Perform the trace to the next surface auto destination_info = ray_tracer.TraceRay(cell, particle.position, particle.direction); diff --git a/test/unit/linear_boltzmann_solver/cmfd/cmfd_coarse_mesh_test.cc b/test/unit/linear_boltzmann_solver/cmfd/cmfd_coarse_mesh_test.cc index 863be3e947..3c193460e5 100644 --- a/test/unit/linear_boltzmann_solver/cmfd/cmfd_coarse_mesh_test.cc +++ b/test/unit/linear_boltzmann_solver/cmfd/cmfd_coarse_mesh_test.cc @@ -67,7 +67,7 @@ TEST(CMFDCoarseMesh, LocalAggregationBuildsConnectedCoarseCells) for (const auto fine_cell_id : coarse_cell.fine_cell_ids) { EXPECT_EQ(coarse_mesh.MapFineCell(fine_cell_id), coarse_cell.global_id); - expected_volume += grid->cells[fine_cell_id].volume; + expected_volume += grid->GetGlobalCell(fine_cell_id).volume; } EXPECT_DOUBLE_EQ(coarse_cell.volume, expected_volume); EXPECT_FALSE(coarse_cell.faces.empty()); @@ -86,8 +86,8 @@ TEST(CMFDCoarseMesh, LocalAggregationBuildsConnectedCoarseCells) EXPECT_EQ(coarse_mesh.MapFineCell(2), second.global_id); EXPECT_EQ(coarse_mesh.MapFineCell(3), second.global_id); - EXPECT_DOUBLE_EQ(first.volume, grid->cells[0].volume + grid->cells[1].volume); - EXPECT_DOUBLE_EQ(second.volume, grid->cells[2].volume + grid->cells[3].volume); + EXPECT_DOUBLE_EQ(first.volume, grid->GetGlobalCell(0).volume + grid->GetGlobalCell(1).volume); + EXPECT_DOUBLE_EQ(second.volume, grid->GetGlobalCell(2).volume + grid->GetGlobalCell(3).volume); ASSERT_EQ(first.faces.size(), 2); ASSERT_EQ(second.faces.size(), 2); @@ -145,7 +145,7 @@ TEST(CMFDCoarseMesh, LocalAggregationMergesFineFacesOnSameCoarseInterface) double expected_area = 0.0; for (const auto& fine_face : coarse_face.fine_faces) - expected_area += grid->cells[fine_face.cell_id].faces[fine_face.face_index].area; + expected_area += grid->GetGlobalCell(fine_face.cell_id).faces[fine_face.face_index].area; EXPECT_DOUBLE_EQ(coarse_face.area, expected_area); found_merged_face = true;