Zellij
All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Cell.h
Go to the documentation of this file.
1// Copyright(C) 2021, 2022 National Technology & Engineering Solutions
2// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3// NTESS, the U.S. Government retains certain rights in this software.
4//
5// See packages/seacas/LICENSE for details
6#pragma once
7
8//
9// `Cell`:
10// -- for each location:
11// -- i,j location (could be calculated, but easier if entry knows it...)
12// -- reference to unit_cell region
13// -- global node offset for node ids (over all ranks if parallel)
14// -- local node offset for node ids (for this rank only if parallel)
15// -- global element block offsets for element ids for each element block (over all ranks if
16// parallel)
17// -- local element block offsets for element ids for each element block (for this rank only
18// if parallel)
19// -- offX, offY -- coordinate offsets for nodes (can be calculated?)
20// -- rank (for parallel -- which rank does this entry exist on)
21//
22
23#include <array>
24#include <memory>
25#include <string>
26#include <utility>
27#include <vector>
28
29#include "UnitCell.h"
31
32// Each entry in grid will have the following information:
33enum class Axis { X, Y, Z };
34enum class Mode { GLOBAL, PROCESSOR };
35enum class Loc { C = 0, BL, B, BR, L, R, TL, T, TR };
36
37class Cell
38{
39public:
40 Cell() = default;
41 Cell(const Cell &) = default;
42
43 std::pair<double, double> get_coordinate_range(enum Axis) const;
44 void initialize(size_t i, size_t j, std::shared_ptr<UnitCell> unit_cell);
45
47 std::shared_ptr<UnitCell> unit() const { return m_unitCell; }
48
50 std::shared_ptr<Ioss::Region> region() const { return m_unitCell->m_region; }
51
53 bool has_neighbor_i() const { return m_i > 0; }
54
56 bool has_neighbor_j() const { return m_j > 0; }
57
60 bool has_neighbor(enum Loc loc) const { return m_ranks[(int)loc] != -1; }
61
67 bool processor_boundary(enum Loc loc) const
68 {
69 return m_ranks[(int)loc] >= 0 && (m_ranks[(int)Loc::C] != m_ranks[(int)loc]);
70 }
71
74 size_t added_node_count(enum Mode mode, bool equivalence_nodes) const;
75
81 size_t processor_boundary_node_count() const;
82
83 template <typename INT>
84 void populate_node_communication_map(const std::vector<INT> &node_map, std::vector<INT> &nodes,
85 std::vector<INT> &procs) const;
86
91 std::array<int, 9> categorize_processor_boundary_nodes(int rank) const;
92
94 int rank(enum Loc loc) const { return m_ranks[(int)loc]; }
95
97 void set_rank(enum Loc loc, int my_rank) { m_ranks[(int)loc] = my_rank; }
98
105 std::vector<int> categorize_nodes(enum Mode mode) const;
106
107 template <typename INT>
108 std::vector<INT> generate_node_map(Mode mode, bool equivalance_nodes, INT /*dummy*/) const;
109
110 template <typename INT>
111 void populate_neighbor(Loc location, const std::vector<INT> &map, const Cell &neighbor) const;
112
116 mutable std::vector<int64_t> min_I_nodes;
117
121 mutable std::vector<int64_t> min_J_nodes;
122
124 size_t m_i{0};
126 size_t m_j{0};
127
130
133 mutable size_t m_communicationNodeOffset{0};
134
136 mutable size_t m_communicationNodeCount{0};
137
138 std::map<std::string, size_t> m_globalElementIdOffset;
139 std::map<std::string, size_t> m_localElementIdOffset;
140
143 std::map<std::string, size_t> m_localSurfaceOffset;
144
148 double m_offX{0.0};
149
153 double m_offY{0.0};
154
155private:
157 std::shared_ptr<UnitCell> m_unitCell;
158
163 std::array<int, 9> m_ranks{{0, -1, -1, -1, -1, -1, -1, -1, -1}};
164};
Mode
Definition Cell.h:34
@ GLOBAL
@ PROCESSOR
Loc
Definition Cell.h:35
Axis
Definition Cell.h:33
Definition Cell.h:38
double m_offY
Definition Cell.h:153
bool has_neighbor_j() const
True if this cell has a neighbor "below it" (lower j)
Definition Cell.h:56
std::vector< int64_t > min_I_nodes
Definition Cell.h:116
int64_t m_globalNodeIdOffset
Definition Cell.h:128
std::shared_ptr< Ioss::Region > region() const
Provide access to the Ioss::Region in the unit_cell that this cell uses.
Definition Cell.h:50
bool has_neighbor_i() const
True if this cell has a neighbor to its "left" (lower i)
Definition Cell.h:53
size_t added_node_count(enum Mode mode, bool equivalence_nodes) const
Definition Cell.C:124
std::array< int, 9 > m_ranks
Definition Cell.h:163
std::array< int, 9 > categorize_processor_boundary_nodes(int rank) const
Definition Cell.C:174
std::vector< int > categorize_nodes(enum Mode mode) const
Definition Cell.C:365
std::map< std::string, size_t > m_localSurfaceOffset
Definition Cell.h:143
size_t m_j
The j location of this entry in the grid.
Definition Cell.h:126
void populate_node_communication_map(const std::vector< INT > &node_map, std::vector< INT > &nodes, std::vector< INT > &procs) const
Definition Cell.C:298
size_t processor_boundary_node_count() const
Definition Cell.C:250
Cell(const Cell &)=default
std::vector< INT > generate_node_map(Mode mode, bool equivalance_nodes, INT) const
Definition Cell.C:410
Cell()=default
void initialize(size_t i, size_t j, std::shared_ptr< UnitCell > unit_cell)
Definition Cell.C:97
void populate_neighbor(Loc location, const std::vector< INT > &map, const Cell &neighbor) const
Definition Cell.C:504
std::map< std::string, size_t > m_globalElementIdOffset
Definition Cell.h:138
size_t m_communicationNodeOffset
Definition Cell.h:133
bool has_neighbor(enum Loc loc) const
Definition Cell.h:60
bool processor_boundary(enum Loc loc) const
Definition Cell.h:67
size_t m_i
The i location of this entry in the grid.
Definition Cell.h:124
double m_offX
Definition Cell.h:148
std::shared_ptr< UnitCell > m_unitCell
The UnitCell that occupies this location in the grid / latice.
Definition Cell.h:157
int64_t m_localNodeIdOffset
Definition Cell.h:129
std::map< std::string, size_t > m_localElementIdOffset
Definition Cell.h:139
int rank(enum Loc loc) const
The mpi rank that this cell, or the neighboring cells, will be on in a parallel run.
Definition Cell.h:94
std::pair< double, double > get_coordinate_range(enum Axis) const
Definition Cell.C:111
size_t m_communicationNodeCount
The number of node/proc pairs that this cell adds to the communication node map.
Definition Cell.h:136
std::vector< int64_t > min_J_nodes
Definition Cell.h:121
std::shared_ptr< UnitCell > unit() const
Provide access to the UnitCell that this cell uses.
Definition Cell.h:47
void set_rank(enum Loc loc, int my_rank)
The mpi rank that this cell will be on in a parallel run.
Definition Cell.h:97