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  // 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;
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.
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.
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.
91 
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  size_t cell_count() const { return (size_t)m_ordinal[0] * m_ordinal[1] * m_ordinal[2]; }
108 
109  size_t node_count() const
110  {
111  return (size_t)(m_ordinal[0] + 1) * (m_ordinal[1] + 1) * (m_ordinal[2] + 1);
112  }
113 
114  std::pair<StructuredZoneData *, StructuredZoneData *> split(int zone_id, double avg_work,
115  int rank, bool verbose);
116  void resolve_zgc_split_donor(std::vector<Iocgns::StructuredZoneData *> &zones);
117  void update_zgc_processor(std::vector<Iocgns::StructuredZoneData *> &zones);
118  };
119 } // namespace Iocgns
120 
121 #endif
Iocgns::StructuredZoneData::StructuredZoneData
StructuredZoneData()
Definition: Iocgns_StructuredZoneData.h:47
Iocgns::StructuredZoneData::node_count
size_t node_count() const
Definition: Iocgns_StructuredZoneData.h:109
Iocgns::StructuredZoneData::m_proc
int m_proc
Definition: Iocgns_StructuredZoneData.h:81
Iocgns::StructuredZoneData::m_child2
StructuredZoneData * m_child2
Definition: Iocgns_StructuredZoneData.h:90
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::m_zone
int m_zone
Definition: Iocgns_StructuredZoneData.h:69
Iocgns::StructuredZoneData
Definition: Iocgns_StructuredZoneData.h:44
Iocgns::StructuredZoneData::StructuredZoneData
StructuredZoneData(std::string name, int zone, int ni, int nj, int nk)
Definition: Iocgns_StructuredZoneData.h:49
Ioss_StructuredBlock.h
Iocgns::StructuredZoneData::m_splitOrdinal
int m_splitOrdinal
Definition: Iocgns_StructuredZoneData.h:84
anonymous_namespace{Iocgns_DecompositionData.C}::rank
int rank
Definition: Iocgns_DecompositionData.C:55
Iocgns::StructuredZoneData::m_parent
StructuredZoneData * m_parent
Definition: Iocgns_StructuredZoneData.h:79
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:381
Iocgns::StructuredZoneData::cell_count
size_t cell_count() const
Definition: Iocgns_StructuredZoneData.h:107
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:54
Iocgns::StructuredZoneData::split
std::pair< StructuredZoneData *, StructuredZoneData * > split(int zone_id, double avg_work, int rank, bool verbose)
Definition: Iocgns_StructuredZoneData.C:265
Iocgns::StructuredZoneData::is_active
bool is_active() const
Definition: Iocgns_StructuredZoneData.h:97
Iocgns::StructuredZoneData::m_adam
StructuredZoneData * m_adam
Definition: Iocgns_StructuredZoneData.h:73
Iocgns::StructuredZoneData::m_offset
Ioss::IJK_t m_offset
Definition: Iocgns_StructuredZoneData.h:64
Iocgns::StructuredZoneData::m_zoneConnectivity
std::vector< Ioss::ZoneConnectivity > m_zoneConnectivity
Definition: Iocgns_StructuredZoneData.h:94
Iocgns::StructuredZoneData::m_sibling
StructuredZoneData * m_sibling
Definition: Iocgns_StructuredZoneData.h:92
anonymous_namespace{io_info.C}::name
std::string name(const Ioss::GroupingEntity *entity)
Definition: io_info.C:89
Iocgns::StructuredZoneData::work
size_t work() const
Definition: Iocgns_StructuredZoneData.h:106
Iocgns::StructuredZoneData::update_zgc_processor
void update_zgc_processor(std::vector< Iocgns::StructuredZoneData * > &zones)
Definition: Iocgns_StructuredZoneData.C:429
Iocgns
A namespace for the CGNS database format.
Definition: Iocgns_DatabaseIO.C:444
Ioss_CodeTypes.h