Chi-Tech
lagD_04_mappings.cc
Go to the documentation of this file.
2
3#include "chi_runtime.h"
4#include "chi_log.h"
5#include "chi_mpi.h"
6
7#define sc_int64 static_cast<int64_t>
8
10{
11// ###################################################################
12/**Provides a mapping of cell's DOF from a DFEM perspective.*/
14 const chi_mesh::Cell& cell,
15 const unsigned int node,
16 const chi_math::UnknownManager& unknown_manager,
17 const unsigned int unknown_id,
18 const unsigned int component) const
19{
20 auto storage = unknown_manager.dof_storage_type_;
21
22 size_t num_unknowns = unknown_manager.GetTotalUnknownStructureSize();
23 size_t block_id = unknown_manager.MapUnknown(unknown_id, component);
24
26 {
28 {
29 int64_t address = sc_int64(local_block_address_ * num_unknowns) +
31 local_base_block_size_ * block_id + node;
32 return address;
33 }
34 else if (storage == chi_math::UnknownStorageType::NODAL)
35 {
36 int64_t address =
37 sc_int64(local_block_address_ * num_unknowns) +
38 cell_local_block_address_[cell.local_id_] * num_unknowns +
39 node * num_unknowns + block_id;
40 return address;
41 }
42 }
43 else
44 {
45 int index = 0;
46 bool found = false;
47 for (auto neighbor_info : neighbor_cell_block_address_)
48 {
49 if (neighbor_info.first == cell.global_id_)
50 {
51 found = true;
52 break;
53 }
54 ++index;
55 }
56
57 if (!found)
58 {
60 << "SpatialDiscretization_PWL::MapDFEMDOF. Mapping failed for cell "
61 << "with global index " << cell.global_id_ << " and partition-ID "
62 << cell.partition_id_;
63 Chi::Exit(EXIT_FAILURE);
64 }
65
67 {
68 int64_t address = sc_int64(neighbor_cell_block_address_[index].second) +
69 locJ_block_size_[cell.partition_id_] * block_id + node;
70 return address;
71 }
72 else if (storage == chi_math::UnknownStorageType::NODAL)
73 {
74 int64_t address =
75 sc_int64(neighbor_cell_block_address_[index].second * num_unknowns) +
76 node * num_unknowns + block_id;
77 return address;
78 }
79 }
80
81 return -1;
82}
83
84// ###################################################################
85/**Provides a mapping of cell's DOF from a DFEM perspective.*/
87 const chi_mesh::Cell& cell,
88 const unsigned int node,
89 const chi_math::UnknownManager& unknown_manager,
90 const unsigned int unknown_id,
91 const unsigned int component) const
92{
93 auto storage = unknown_manager.dof_storage_type_;
94
95 size_t num_unknowns = unknown_manager.GetTotalUnknownStructureSize();
96 size_t block_id = unknown_manager.MapUnknown(unknown_id, component);
97
99 {
101 {
102 int64_t address = sc_int64(cell_local_block_address_[cell.local_id_]) +
103 local_base_block_size_ * block_id + node;
104 return address;
105 }
106 else if (storage == chi_math::UnknownStorageType::NODAL)
107 {
108 int64_t address =
109 sc_int64(cell_local_block_address_[cell.local_id_] * num_unknowns) +
110 node * num_unknowns + block_id;
111 return address;
112 }
113 }
114 else
115 {
116 int index = 0;
117 bool found = false;
118 for (auto neighbor_info : neighbor_cell_block_address_)
119 {
120 if (neighbor_info.first == cell.global_id_)
121 {
122 found = true;
123 break;
124 }
125 ++index;
126 }
127
128 if (!found)
129 {
131 << "SpatialDiscretization_PWL::MapDFEMDOF. Mapping failed for cell "
132 << "with global index " << cell.global_id_ << " and partition-ID "
133 << cell.partition_id_;
134 Chi::Exit(EXIT_FAILURE);
135 }
136
138 {
139 int64_t address = sc_int64(neighbor_cell_block_address_[index].second) +
140 locJ_block_size_[cell.partition_id_] * block_id + node;
141 return address;
142 }
143 else if (storage == chi_math::UnknownStorageType::NODAL)
144 {
145 int64_t address =
146 sc_int64(neighbor_cell_block_address_[index].second * num_unknowns) +
147 node * num_unknowns + block_id;
148 return address;
149 }
150 }
151
152 return -1;
153}
154
155} // namespace chi_math::spatial_discretization
static void Exit(int error_code)
Definition: chi_runtime.cc:342
static chi::ChiLog & log
Definition: chi_runtime.h:81
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
LogStream LogAllError()
Definition: chi_log.h:239
const int & location_id
Current process rank.
Definition: mpi_info.h:26
std::vector< uint64_t > locJ_block_size_
unsigned int MapUnknown(unsigned int unknown_id, unsigned int component=0) const
UnknownStorageType dof_storage_type_
unsigned int GetTotalUnknownStructureSize() const
int64_t MapDOFLocal(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const override
int64_t MapDOF(const chi_mesh::Cell &cell, unsigned int node, const UnknownManager &unknown_manager, unsigned int unknown_id, unsigned int component) const override
std::vector< std::pair< uint64_t, int64_t > > neighbor_cell_block_address_
uint64_t local_id_
Definition: cell.h:76
uint64_t partition_id_
Definition: cell.h:77
uint64_t global_id_
Definition: cell.h:75
#define sc_int64