Chi-Tech
pwlc_05_utils.cc
Go to the documentation of this file.
2
3#include "chi_runtime.h"
4
6
7#define sc_int64 static_cast<int64_t>
8
10{
11
12// ###################################################################
13/**Get the number of ghost degrees-of-freedom.*/
15 const chi_math::UnknownManager& unknown_manager) const
16{
17 unsigned int N = unknown_manager.GetTotalUnknownStructureSize();
18
19 return ghost_node_mapping_.size() * N;
20}
21
22// ###################################################################
23/**Returns the ghost DOF indices.*/
25 const chi_math::UnknownManager& unknown_manager) const
26{
27 std::vector<int64_t> dof_ids;
28 dof_ids.reserve(GetNumGhostDOFs(unknown_manager));
29
30 const size_t num_unknown_comps =
31 unknown_manager.GetTotalUnknownStructureSize();
32 const auto storage = unknown_manager.dof_storage_type_;
33 const size_t num_unknowns = unknown_manager.unknowns_.size();
34
35 for (const auto& vid_gnid : ghost_node_mapping_)
36 {
37 const int64_t global_id = vid_gnid.second;
38
39 for (size_t u = 0; u < num_unknowns; ++u)
40 {
41 const auto& unkn = unknown_manager.unknowns_[u];
42 const size_t num_comps = unkn.num_components_;
43 for (size_t c = 0; c < num_comps; ++c)
44 {
45 size_t block_id = unknown_manager.MapUnknown(u, c);
46 int64_t address = -1;
48 {
49 for (int locJ = 0; locJ < Chi::mpi.process_count; ++locJ)
50 {
51 const int64_t local_id =
52 global_id - sc_int64(locJ_block_address_[locJ]);
53
54 if (local_id < 0 or local_id >= locJ_block_size_[locJ]) continue;
55
56 address = sc_int64(locJ_block_address_[locJ] * num_unknown_comps) +
57 sc_int64(locJ_block_size_[locJ] * block_id) + local_id;
58 break;
59 }
60 }
61 else if (storage == chi_math::UnknownStorageType::NODAL)
62 address =
63 global_id * sc_int64(num_unknown_comps) + sc_int64(block_id);
64
65 dof_ids.push_back(address);
66 } // for c
67 } // for u
68 }
69
70 return dof_ids;
71}
72
73} // namespace chi_math::spatial_discretization
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
const int & process_count
Total number of processes.
Definition: mpi_info.h:27
std::vector< uint64_t > locJ_block_size_
std::vector< uint64_t > locJ_block_address_
unsigned int MapUnknown(unsigned int unknown_id, unsigned int component=0) const
std::vector< Unknown > unknowns_
UnknownStorageType dof_storage_type_
unsigned int GetTotalUnknownStructureSize() const
std::vector< int64_t > GetGhostDOFIndices(const UnknownManager &unknown_manager) const override
size_t GetNumGhostDOFs(const UnknownManager &unknown_manager) const override
#define sc_int64
Definition: pwlc_05_utils.cc:7