Chi-Tech
fv_04a_mappings.cc
Go to the documentation of this file.
1#include "FiniteVolume.h"
2
4#include "mesh/Cell/cell.h"
5
6#include "chi_runtime.h"
7#include "chi_log.h"
8
9#define sc_int64 static_cast<int64_t>
10
12{
13
14// ###################################################################
15/**Maps a finite volume degree of freedom using an unknown manager.*/
17 const chi_mesh::Cell& cell,
18 const unsigned int,
19 const chi_math::UnknownManager& unknown_manager,
20 const unsigned int unknown_id,
21 const unsigned int component) const
22{
23 auto storage = unknown_manager.dof_storage_type_;
24
25 const size_t num_unknowns = unknown_manager.GetTotalUnknownStructureSize();
26 const size_t block_id = unknown_manager.MapUnknown(unknown_id, component);
27 const size_t num_local_cells = ref_grid_.local_cells.size();
28
29 if (component >= num_unknowns) return -1;
30
31 int64_t address = -1;
33 {
35 address = sc_int64(local_block_address_) * num_unknowns +
36 num_local_cells * block_id + cell.local_id_;
37 else if (storage == chi_math::UnknownStorageType::NODAL)
38 address = sc_int64(local_block_address_) * num_unknowns +
39 cell.local_id_ * num_unknowns + block_id;
40 }
41 else
42 {
43 const uint64_t ghost_local_id =
45
47 address =
48 sc_int64(locJ_block_address_[cell.partition_id_]) * num_unknowns +
49 locJ_block_size_[cell.partition_id_] * block_id + ghost_local_id;
50 else if (storage == chi_math::UnknownStorageType::NODAL)
51 address =
52 sc_int64(locJ_block_address_[cell.partition_id_]) * num_unknowns +
53 ghost_local_id * num_unknowns + block_id;
54 }
55
56 return address;
57}
58
59// ###################################################################
60/**Maps a finite volume degree of freedom to a local address using
61 * an unknown manager.*/
62int64_t
64 const chi_mesh::Cell& cell,
65 const unsigned int,
66 const chi_math::UnknownManager& unknown_manager,
67 const unsigned int unknown_id,
68 const unsigned int component) const
69{
70 auto storage = unknown_manager.dof_storage_type_;
71
72 const size_t num_unknowns = unknown_manager.GetTotalUnknownStructureSize();
73 const size_t block_id = unknown_manager.MapUnknown(unknown_id, component);
74 const size_t num_local_cells = ref_grid_.local_cells.size();
75
76 if (component >= num_unknowns) return -1;
77
78 int64_t address = -1;
80 {
82 address = sc_int64(num_local_cells) * block_id + cell.local_id_;
83 else if (storage == chi_math::UnknownStorageType::NODAL)
84 address = sc_int64(cell.local_id_) * num_unknowns + block_id;
85 }
86 else
87 {
88 const size_t num_local_dofs = GetNumLocalDOFs(unknown_manager);
89 const size_t num_ghost_nodes = GetNumGhostDOFs(UNITARY_UNKNOWN_MANAGER);
90 const uint64_t ghost_local_id =
92
94 address = sc_int64(num_local_dofs) +
95 sc_int64(num_ghost_nodes) * block_id + ghost_local_id;
96 else if (storage == chi_math::UnknownStorageType::NODAL)
97 address = sc_int64(num_local_dofs) +
98 num_unknowns * sc_int64(ghost_local_id) + block_id;
99 }
100
101 return address;
102}
103
104} // namespace chi_math::spatial_discretization
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
const int & location_id
Current process rank.
Definition: mpi_info.h:26
std::vector< uint64_t > locJ_block_size_
size_t GetNumLocalDOFs(const UnknownManager &unknown_manager) const
const UnknownManager UNITARY_UNKNOWN_MANAGER
std::vector< uint64_t > locJ_block_address_
const chi_mesh::MeshContinuum & ref_grid_
unsigned int MapUnknown(unsigned int unknown_id, unsigned int component=0) const
UnknownStorageType dof_storage_type_
unsigned int GetTotalUnknownStructureSize() const
size_t GetNumGhostDOFs(const UnknownManager &unknown_manager) const override
Definition: fv_05_utils.cc:14
int64_t MapDOF(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const override
int64_t MapDOFLocal(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const override
std::map< uint64_t, uint64_t > neighbor_cell_local_ids_
Definition: FiniteVolume.h:17
uint64_t local_id_
Definition: cell.h:76
uint64_t partition_id_
Definition: cell.h:77
uint64_t global_id_
Definition: cell.h:75
uint64_t GetGhostLocalID(uint64_t cell_global_index) const
LocalCellHandler local_cells
GlobalCellHandler cells
#define sc_int64