Chi-Tech
chi_meshcontinuum_localcellhandler.cc
Go to the documentation of this file.
1#include "chi_meshcontinuum.h"
2
3//###################################################################
4/**Returns a reference to a local cell, given a local cell index.*/
6 operator[](uint64_t cell_local_index)
7{
8 if (native_cells.empty())
9 {
10 std::stringstream ostr;
11 ostr
12 << "LocalCells attempted to access local cell "
13 << cell_local_index
14 << " but there are no local cells. This normally indicates"
15 << " a partitioning problem.";
16 throw std::invalid_argument(ostr.str());
17 }
18
19 if (cell_local_index >= native_cells.size())
20 {
21 std::stringstream ostr;
22 ostr
23 << "LocalCells attempted to access local cell "
24 << cell_local_index
25 << " but index out of range [0, "
26 << native_cells.size() - 1 << "].";
27 throw std::invalid_argument(ostr.str());
28 }
29
30 return *native_cells[cell_local_index];
31}
32
33//###################################################################
34/**Returns a const reference to a local cell, given a local cell index.*/
36operator[](uint64_t cell_local_index) const
37{
38 if (native_cells.empty())
39 {
40 std::stringstream ostr;
41 ostr
42 << "LocalCells attempted to access local cell "
43 << cell_local_index
44 << " but there are no local cells. This normally indicates"
45 << " a partitioning problem.";
46 throw std::invalid_argument(ostr.str());
47 }
48
49 if (cell_local_index >= native_cells.size())
50 {
51 std::stringstream ostr;
52 ostr
53 << "LocalCells attempted to access local cell "
54 << cell_local_index
55 << " but index out of range [0, "
56 << native_cells.size() - 1 << "].";
57 throw std::invalid_argument(ostr.str());
58 }
59
60 return *native_cells[cell_local_index];
61}
62
chi_mesh::Cell & operator[](uint64_t cell_local_index)
std::vector< std::unique_ptr< chi_mesh::Cell > > & native_cells