Chi-Tech
fv_01b_createcellmappings.cc
Go to the documentation of this file.
1#include "FiniteVolume.h"
2
5
7{
8
10{
11 constexpr std::string_view fname = "chi_math::SpatialDiscretization_FV::"
12 "CreateCellMappings";
13
14 auto MakeCellMapping = [this, fname](const chi_mesh::Cell& cell)
15 {
16 using namespace std;
17 using namespace chi_math;
18 std::unique_ptr<chi_math::CellMapping> mapping;
19
20 switch (cell.Type())
21 {
25 {
26 typedef std::vector<std::vector<int>> FaceDofMapping;
27 mapping = make_unique<cell_mapping::FiniteVolumeMapping>(
29 cell,
30 cell.centroid_,
31 FaceDofMapping(cell.faces_.size(), {-1}));
32 break;
33 }
34 default:
35 throw std::logic_error(std::string(fname) +
36 std::string(": Invalid cell type encountered."));
37 }
38 return mapping;
39 };
40
41 for (const auto& cell : ref_grid_.local_cells)
42 cell_mappings_.push_back(MakeCellMapping(cell));
43
44 const auto ghost_ids = ref_grid_.cells.GetGhostGlobalIDs();
45 for (uint64_t ghost_id : ghost_ids)
46 {
47 auto ghost_mapping = MakeCellMapping(ref_grid_.cells[ghost_id]);
48 nb_cell_mappings_.insert(
49 std::make_pair(ghost_id, std::move(ghost_mapping)));
50 }
51}
52
53} // namespace chi_math::spatial_discretization
std::vector< std::unique_ptr< CellMapping > > cell_mappings_
std::map< uint64_t, std::shared_ptr< CellMapping > > nb_cell_mappings_
const chi_mesh::MeshContinuum & ref_grid_
std::vector< uint64_t > GetGhostGlobalIDs() const
LocalCellHandler local_cells
GlobalCellHandler cells