| 1 |
/* |
| 2 |
* Copyright(C) 1999-2022, 2024 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "Ioss_CodeTypes.h" |
| 11 |
#include "Ioss_StructuredBlock.h" |
| 12 |
#include <cstddef> |
| 13 |
#include <cstdint> |
| 14 |
#include <string> |
| 15 |
#include <utility> |
| 16 |
#include <vector> |
| 17 |
|
| 18 |
#include "Ioss_ZoneConnectivity.h" |
| 19 |
#include "iocgns_export.h" |
| 20 |
|
| 21 |
namespace Iocgns { |
| 22 |
enum Ordinal { |
| 23 |
I = 1, |
| 24 |
J = 2, |
| 25 |
K = 4, |
| 26 |
}; |
| 27 |
|
| 28 |
class IOCGNS_EXPORT StructuredZoneData |
| 29 |
{ |
| 30 |
public: |
| 31 |
StructuredZoneData() { m_adam = this; } |
| 32 |
|
| 33 |
StructuredZoneData(std::string name, int zone, int ni, int nj, int nk) |
| 34 |
: m_name(std::move(name)), m_ordinal{{ni, nj, nk}}, m_zone(zone) |
| 35 |
{ |
| 36 |
m_adam = this; |
| 37 |
} |
| 38 |
|
| 39 |
// Used for regression tests to make it easier to define... |
| 40 |
// Last argument is of the form "5x12x32" |
| 41 |
StructuredZoneData(int zone, const std::string &nixnjxnk); |
| 42 |
|
| 43 |
std::string m_name{}; |
| 44 |
Ioss::IJK_t m_ordinal{{0, 0, 0}}; |
| 45 |
|
| 46 |
// Offset of this block relative to its |
| 47 |
// adam block. ijk_adam = ijk_me + m_offset[ijk]; |
| 48 |
Ioss::IJK_t m_offset{{0, 0, 0}}; |
| 49 |
|
| 50 |
// If value is 0, 1, or 2, then do not split along that ordinal |
| 51 |
unsigned int m_lineOrdinal{0}; |
| 52 |
|
| 53 |
int m_zone{0}; |
| 54 |
|
| 55 |
// The zone in the undecomposed model that this zone is a |
| 56 |
// descendant of. If not decomposed, then m_zone == m_adam; |
| 57 |
StructuredZoneData *m_adam{nullptr}; |
| 58 |
|
| 59 |
// If this zone was the result of splitting another zone, then |
| 60 |
// what is the zone number of that zone. Zones are kept in a |
| 61 |
// vector and the zone number is its position in that vector+1 |
| 62 |
// to make it 1-based and match numbering on file. |
| 63 |
StructuredZoneData *m_parent{nullptr}; |
| 64 |
|
| 65 |
int m_proc{-1}; // The processor this block might be run on... |
| 66 |
|
| 67 |
// Which ordinal of the parent was split to generate this zone and its sibling. |
| 68 |
int m_splitOrdinal{0}; |
| 69 |
|
| 70 |
// The two zones that were split off from this zone. |
| 71 |
// Might be reasonable to do a 3-way or n-way split, but for now |
| 72 |
// just do a 2-way. |
| 73 |
StructuredZoneData *m_child1{nullptr}; |
| 74 |
StructuredZoneData *m_child2{nullptr}; |
| 75 |
|
| 76 |
StructuredZoneData *m_sibling{nullptr}; |
| 77 |
|
| 78 |
std::vector<Ioss::ZoneConnectivity> m_zoneConnectivity{}; |
| 79 |
|
| 80 |
// ======================================================================== |
| 81 |
IOSS_NODISCARD bool is_active() const |
| 82 |
{ |
| 83 |
// Zone is active if it hasn't been split. |
| 84 |
return m_child1 == nullptr && m_child2 == nullptr; |
| 85 |
} |
| 86 |
|
| 87 |
// ======================================================================== |
| 88 |
// Assume the "work" or computational effort required for a |
| 89 |
// block is proportional to the number of cells. |
| 90 |
IOSS_NODISCARD size_t work() const |
| 91 |
{ |
| 92 |
return (size_t)m_ordinal[0] * m_ordinal[1] * m_ordinal[2]; |
| 93 |
} |
| 94 |
IOSS_NODISCARD size_t cell_count() const |
| 95 |
{ |
| 96 |
return (size_t)m_ordinal[0] * m_ordinal[1] * m_ordinal[2]; |
| 97 |
} |
| 98 |
|
| 99 |
IOSS_NODISCARD size_t node_count() const |
| 100 |
{ |
| 101 |
return (size_t)(m_ordinal[0] + 1) * (m_ordinal[1] + 1) * (m_ordinal[2] + 1); |
| 102 |
} |
| 103 |
|
| 104 |
IOSS_NODISCARD std::pair<StructuredZoneData *, StructuredZoneData *> |
| 105 |
split(int zone_id, double avg_work, int rank, bool verbose); |
| 106 |
void resolve_zgc_split_donor(const std::vector<Iocgns::StructuredZoneData *> &zones); |
| 107 |
void update_zgc_processor(const std::vector<Iocgns::StructuredZoneData *> &zones); |
| 108 |
}; |
| 109 |
} // namespace Iocgns |