IOSS 2.0

Iocgns_StructuredZoneData.h
Go to the documentation of this file.
1 /*
2 * Copyright(C) 1999-2017 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 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of NTESS nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 #ifndef IOCGNS_STRUCTUREDZONEDATA_H
35 #define IOCGNS_STRUCTUREDZONEDATA_H
36
37 #include <Ioss_CodeTypes.h>
38 #include <Ioss_StructuredBlock.h>
39 #include <cstddef>
40 #include <cstdint>
41 #include <utility>
42
43 namespace Iocgns {
44 class StructuredZoneData
45 {
46 public:
47 StructuredZoneData() { m_adam = this; }
48
49 StructuredZoneData(std::string name, int zone, int ni, int nj, int nk)
50 : m_name(std::move(name)), m_ordinal{{ni, nj, nk}}, m_zone(zone)
51 {
52 m_adam = this;
53 }
54
55 // Used for regression tests to make it easier to define...
56 // Last argument is of the form "5x12x32"
57 StructuredZoneData(int zone, const std::string &nixnjxnk);
58
59 std::string m_name{};
60 Ioss::IJK_t m_ordinal{{0, 0, 0}};
61
62 // Offset of this block relative to its
63 // adam block. ijk_adam = ijk_me + m_offset[ijk];
64 Ioss::IJK_t m_offset{{0, 0, 0}};
65
66 // If value is 0, 1, or 2, then do not split along that ordinal
67 int m_lineOrdinal{-1};
68
69 int m_zone{0};
70
71 // The zone in the undecomposed model that this zone is a
72 // descendant of. If not decomposed, then m_zone == m_adam;
73 StructuredZoneData *m_adam{nullptr};
74
75 // If this zone was the result of splitting another zone, then
76 // what is the zone number of that zone. Zones are kept in a
77 // vector and the zone number is its position in that vector+1
78 // to make it 1-based and match numbering on file.
79 StructuredZoneData *m_parent{nullptr};
80
81 int m_proc{-1}; // The processor this block might be run on...
82
83 // Which ordinal of the parent was split to generate this zone and its sibling.
84 int m_splitOrdinal{0};
85
86 // The two zones that were split off from this zone.
87 // Might be reasonable to do a 3-way or n-way split, but for now
88 // just do a 2-way.
89 StructuredZoneData *m_child1{nullptr};
90 StructuredZoneData *m_child2{nullptr};
91
92 StructuredZoneData *m_sibling{nullptr};
93
94 std::vector<Ioss::ZoneConnectivity> m_zoneConnectivity;
95
96 // ========================================================================
97 bool is_active() const
98 {
99 // Zone is active if it hasn't been split.
100 return m_child1 == nullptr && m_child2 == nullptr;
101 }
102
103 // ========================================================================
104 // Assume the "work" or computational effort required for a
105 // block is proportional to the number of cells.
106 size_t work() const { return (size_t)m_ordinal[0] * m_ordinal[1] * m_ordinal[2]; }
107
108 std::pair<StructuredZoneData *, StructuredZoneData *> split(int zone_id, double avg_work,
109 double balance, int rank);
110 void resolve_zgc_split_donor(std::vector<Iocgns::StructuredZoneData *> &zones);
111 void update_zgc_processor(std::vector<Iocgns::StructuredZoneData *> &zones);
112 };
113 } // namespace Iocgns
114
115 #endif
Ioss_CodeTypes.h
Iocgns::StructuredZoneData::m_name
std::string m_name
Definition: Iocgns_StructuredZoneData.h:59
Iocgns::StructuredZoneData::resolve_zgc_split_donor
void resolve_zgc_split_donor(std::vector< Iocgns::StructuredZoneData *> &zones)
Definition: Iocgns_StructuredZoneData.C:379
Iocgns::StructuredZoneData::m_splitOrdinal
int m_splitOrdinal
Definition: Iocgns_StructuredZoneData.h:84
Iocgns::StructuredZoneData::m_child1
StructuredZoneData * m_child1
Definition: Iocgns_StructuredZoneData.h:89
Iocgns::StructuredZoneData::m_ordinal
Ioss::IJK_t m_ordinal
Definition: Iocgns_StructuredZoneData.h:60
Iocgns::StructuredZoneData::is_active
bool is_active() const
Definition: Iocgns_StructuredZoneData.h:97
Iocgns
A namespace for the CGNS database format.
Definition: Iocgns_DatabaseIO.C:392
Iocgns::StructuredZoneData::work
size_t work() const
Definition: Iocgns_StructuredZoneData.h:106
Iocgns::StructuredZoneData::split
std::pair< StructuredZoneData *, StructuredZoneData * > split(int zone_id, double avg_work, double balance, int rank)
Definition: Iocgns_StructuredZoneData.C:266
Iocgns::StructuredZoneData::m_adam
StructuredZoneData * m_adam
Definition: Iocgns_StructuredZoneData.h:73
Iocgns::StructuredZoneData::m_parent
StructuredZoneData * m_parent
Definition: Iocgns_StructuredZoneData.h:79
Ioss_StructuredBlock.h
Iocgns::StructuredZoneData::m_lineOrdinal
int m_lineOrdinal
Definition: Iocgns_StructuredZoneData.h:67
Ioss::IJK_t
std::array< int, 3 > IJK_t
Definition: Ioss_CodeTypes.h:46
Iocgns::StructuredZoneData::update_zgc_processor
void update_zgc_processor(std::vector< Iocgns::StructuredZoneData *> &zones)
Definition: Iocgns_StructuredZoneData.C:427
Iocgns::StructuredZoneData::m_sibling
StructuredZoneData * m_sibling
Definition: Iocgns_StructuredZoneData.h:92
Iocgns::StructuredZoneData::m_zoneConnectivity
std::vector< Ioss::ZoneConnectivity > m_zoneConnectivity
Definition: Iocgns_StructuredZoneData.h:94
anonymous_namespace{Iocgns_DecompositionData.C}::rank
int rank
Definition: Iocgns_DecompositionData.C:54
Iocgns::StructuredZoneData::StructuredZoneData
StructuredZoneData(std::string name, int zone, int ni, int nj, int nk)
Definition: Iocgns_StructuredZoneData.h:49
anonymous_namespace{io_info.C}::name
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:88
Iocgns::StructuredZoneData::StructuredZoneData
StructuredZoneData()
Definition: Iocgns_StructuredZoneData.h:47
Iocgns::StructuredZoneData::m_zone
int m_zone
Definition: Iocgns_StructuredZoneData.h:69
Iocgns::StructuredZoneData
Definition: Iocgns_StructuredZoneData.h:44
Iocgns::StructuredZoneData::m_child2
StructuredZoneData * m_child2
Definition: Iocgns_StructuredZoneData.h:90
Iocgns::StructuredZoneData::m_offset
Ioss::IJK_t m_offset
Definition: Iocgns_StructuredZoneData.h:64
Iocgns::StructuredZoneData::m_proc
int m_proc
Definition: Iocgns_StructuredZoneData.h:81