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 {
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;
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.
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.
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.
87 
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
std::string m_name
Definition: Iocgns_StructuredZoneData.h:55
void resolve_zgc_split_donor(std::vector< Iocgns::StructuredZoneData *> &zones)
Definition: Iocgns_StructuredZoneData.C:362
int m_splitOrdinal
Definition: Iocgns_StructuredZoneData.h:80
StructuredZoneData * m_child1
Definition: Iocgns_StructuredZoneData.h:85
Ioss::IJK_t m_ordinal
Definition: Iocgns_StructuredZoneData.h:56
bool is_active() const
Definition: Iocgns_StructuredZoneData.h:93
A namespace for the CGNS database format.
Definition: Iocgns_DatabaseIO.C:89
size_t work() const
Definition: Iocgns_StructuredZoneData.h:102
Definition: json.h:1157
std::pair< StructuredZoneData *, StructuredZoneData * > split(int zone_id, double avg_work, double balance, int rank)
Definition: Iocgns_StructuredZoneData.C:247
StructuredZoneData * m_adam
Definition: Iocgns_StructuredZoneData.h:69
StructuredZoneData * m_parent
Definition: Iocgns_StructuredZoneData.h:75
int m_lineOrdinal
Definition: Iocgns_StructuredZoneData.h:63
std::array< int, 3 > IJK_t
Definition: Ioss_CodeTypes.h:45
void update_zgc_processor(std::vector< Iocgns::StructuredZoneData *> &zones)
Definition: Iocgns_StructuredZoneData.C:410
StructuredZoneData * m_sibling
Definition: Iocgns_StructuredZoneData.h:88
std::vector< Ioss::ZoneConnectivity > m_zoneConnectivity
Definition: Iocgns_StructuredZoneData.h:90
int rank
Definition: Iocgns_DecompositionData.C:52
StructuredZoneData(std::string name, int zone, int ni, int nj, int nk)
Definition: Iocgns_StructuredZoneData.h:49
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:71
StructuredZoneData()
Definition: Iocgns_StructuredZoneData.h:47
int m_zone
Definition: Iocgns_StructuredZoneData.h:65
Definition: Iocgns_StructuredZoneData.h:44
StructuredZoneData * m_child2
Definition: Iocgns_StructuredZoneData.h:86
Ioss::IJK_t m_offset
Definition: Iocgns_StructuredZoneData.h:60
int m_proc
Definition: Iocgns_StructuredZoneData.h:77