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 std::string m_name{};
56 Ioss::IJK_t m_ordinal{{0, 0, 0}};
57
58 // Offset of this block relative to its
59 // adam block. ijk_adam = ijk_me + m_offset[ijk];
60 Ioss::IJK_t m_offset{{0, 0, 0}};
61
62 // If value is 0, 1, or 2, then do not split along that ordinal
63 int m_lineOrdinal{-1};
64
65 int m_zone{0};
66
67 // The zone in the undecomposed model that this zone is a
68 // descendant of. If not decomposed, then m_zone == m_adam;
69 StructuredZoneData *m_adam{nullptr};
70
71 // If this zone was the result of splitting another zone, then
72 // what is the zone number of that zone. Zones are kept in a
73 // vector and the zone number is its position in that vector+1
74 // to make it 1-based and match numbering on file.
75 StructuredZoneData *m_parent{nullptr};
76
77 int m_proc{-1}; // The processor this block might be run on...
78
79 // Which ordinal of the parent was split to generate this zone and its sibling.
80 int m_splitOrdinal{0};
81
82 // The two zones that were split off from this zone.
83 // Might be reasonable to do a 3-way or n-way split, but for now
84 // just do a 2-way.
85 StructuredZoneData *m_child1{nullptr};
86 StructuredZoneData *m_child2{nullptr};
87
88 StructuredZoneData *m_sibling{nullptr};
89
90 std::vector<Ioss::ZoneConnectivity> m_zoneConnectivity;
91
92 // ========================================================================
93 bool is_active() const
94 {
95 // Zone is active if it hasn't been split.
96 return m_child1 == nullptr && m_child2 == nullptr;
97 }
98
99 // ========================================================================
100 // Assume the "work" or computational effort required for a
101 // block is proportional to the number of cells.
102 size_t work() const { return m_ordinal[0] * m_ordinal[1] * m_ordinal[2]; }
103
104 std::pair<StructuredZoneData *, StructuredZoneData *> split(int zone_id, double avg_work,
105 double balance, int rank);
106 void resolve_zgc_split_donor(std::vector<Iocgns::StructuredZoneData *> &zones);
107 void update_zgc_processor(std::vector<Iocgns::StructuredZoneData *> &zones);
108 };
109 } // namespace Iocgns
110
111 #endif
Ioss_CodeTypes.h
Iocgns::StructuredZoneData::m_name
std::string m_name
Definition: Iocgns_StructuredZoneData.h:55
Iocgns::StructuredZoneData::resolve_zgc_split_donor
void resolve_zgc_split_donor(std::vector< Iocgns::StructuredZoneData *> &zones)
Definition: Iocgns_StructuredZoneData.C:362
Iocgns::StructuredZoneData::m_splitOrdinal
int m_splitOrdinal
Definition: Iocgns_StructuredZoneData.h:80
Iocgns::StructuredZoneData::m_child1
StructuredZoneData * m_child1
Definition: Iocgns_StructuredZoneData.h:85
Iocgns::StructuredZoneData::m_ordinal
Ioss::IJK_t m_ordinal
Definition: Iocgns_StructuredZoneData.h:56
Iocgns::StructuredZoneData::is_active
bool is_active() const
Definition: Iocgns_StructuredZoneData.h:93
Iocgns
A namespace for the CGNS database format.
Definition: Iocgns_DatabaseIO.C:89
Iocgns::StructuredZoneData::work
size_t work() const
Definition: Iocgns_StructuredZoneData.h:102
std
Definition: json.h:1157
Iocgns::StructuredZoneData::split
std::pair< StructuredZoneData *, StructuredZoneData * > split(int zone_id, double avg_work, double balance, int rank)
Definition: Iocgns_StructuredZoneData.C:247
Iocgns::StructuredZoneData::m_adam
StructuredZoneData * m_adam
Definition: Iocgns_StructuredZoneData.h:69
Iocgns::StructuredZoneData::m_parent
StructuredZoneData * m_parent
Definition: Iocgns_StructuredZoneData.h:75
Ioss_StructuredBlock.h
Iocgns::StructuredZoneData::m_lineOrdinal
int m_lineOrdinal
Definition: Iocgns_StructuredZoneData.h:63
Ioss::IJK_t
std::array< int, 3 > IJK_t
Definition: Ioss_CodeTypes.h:45
Iocgns::StructuredZoneData::update_zgc_processor
void update_zgc_processor(std::vector< Iocgns::StructuredZoneData *> &zones)
Definition: Iocgns_StructuredZoneData.C:410
Iocgns::StructuredZoneData::m_sibling
StructuredZoneData * m_sibling
Definition: Iocgns_StructuredZoneData.h:88
Iocgns::StructuredZoneData::m_zoneConnectivity
std::vector< Ioss::ZoneConnectivity > m_zoneConnectivity
Definition: Iocgns_StructuredZoneData.h:90
anonymous_namespace{Iocgns_DecompositionData.C}::rank
int rank
Definition: Iocgns_DecompositionData.C:52
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:71
Iocgns::StructuredZoneData::StructuredZoneData
StructuredZoneData()
Definition: Iocgns_StructuredZoneData.h:47
Iocgns::StructuredZoneData::m_zone
int m_zone
Definition: Iocgns_StructuredZoneData.h:65
Iocgns::StructuredZoneData
Definition: Iocgns_StructuredZoneData.h:44
Iocgns::StructuredZoneData::m_child2
StructuredZoneData * m_child2
Definition: Iocgns_StructuredZoneData.h:86
Iocgns::StructuredZoneData::m_offset
Ioss::IJK_t m_offset
Definition: Iocgns_StructuredZoneData.h:60
Iocgns::StructuredZoneData::m_proc
int m_proc
Definition: Iocgns_StructuredZoneData.h:77