| 1 |
// Copyright(C) 1999-2024 National Technology & Engineering Solutions |
| 2 |
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
// NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
// |
| 5 |
// See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
#include "Ioss_BoundingBox.h" // for AxisAlignedBoundingBox |
| 8 |
#include "Ioss_DatabaseIO.h" // for DatabaseIO |
| 9 |
#include "Ioss_Field.h" // for Field, etc |
| 10 |
#include "Ioss_FieldManager.h" // for FieldManager |
| 11 |
#include "Ioss_Hex8.h" |
| 12 |
#include "Ioss_Property.h" // for Property |
| 13 |
#include "Ioss_SmartAssert.h" |
| 14 |
#include "Ioss_Sort.h" |
| 15 |
#include "Ioss_StructuredBlock.h" |
| 16 |
#include <cmath> |
| 17 |
#include <cstddef> // for size_t |
| 18 |
#include <fmt/format.h> |
| 19 |
#include <fmt/ostream.h> |
| 20 |
#include <fmt/ranges.h> |
| 21 |
#include <iostream> |
| 22 |
#include <stdlib.h> |
| 23 |
#include <string> // for string |
| 24 |
#include <vector> // for vector |
| 25 |
|
| 26 |
#include "Ioss_CodeTypes.h" |
| 27 |
#include "Ioss_EntityBlock.h" |
| 28 |
#include "Ioss_NodeBlock.h" |
| 29 |
#include "Ioss_ParallelUtils.h" |
| 30 |
#include "Ioss_PropertyManager.h" |
| 31 |
#include "Ioss_Utils.h" |
| 32 |
#include "Ioss_ZoneConnectivity.h" |
| 33 |
|
| 34 |
namespace { |
| 35 |
template <typename T> bool vec_equal(const std::vector<T> &lhs, const std::vector<T> &rhs) |
| 36 |
{ |
| 37 |
bool same = true; |
| 38 |
if (lhs.size() != rhs.size()) { |
| 39 |
same = false; |
| 40 |
} |
| 41 |
auto size = std::min(lhs.size(), rhs.size()); |
| 42 |
for (size_t i = 0; i < size; i++) { |
| 43 |
if (!lhs[i].equal(rhs[i])) { |
| 44 |
same = false; |
| 45 |
} |
| 46 |
} |
| 47 |
return same; |
| 48 |
} |
| 49 |
|
| 50 |
int64_t get_cell_count(int ni, int nj, int nk, int index_dim) |
| 51 |
{ |
| 52 |
int64_t cell_count = 0; |
| 53 |
if (index_dim == 1) { |
| 54 |
cell_count = static_cast<int64_t>(ni); |
| 55 |
} |
| 56 |
else if (index_dim == 2) { |
| 57 |
cell_count = static_cast<int64_t>(ni) * nj; |
| 58 |
} |
| 59 |
else if (index_dim == 3) { |
| 60 |
cell_count = static_cast<int64_t>(ni) * nj * (nk == 0 ? 1 : nk); |
| 61 |
} |
| 62 |
return cell_count; |
| 63 |
} |
| 64 |
|
| 65 |
int64_t get_node_count(int ni, int nj, int nk, int index_dim) |
| 66 |
{ |
| 67 |
int64_t cell_count = get_cell_count(ni, nj, nk, index_dim); |
| 68 |
int64_t node_count = 0; |
| 69 |
if (cell_count > 0) { |
| 70 |
if (index_dim == 1) { |
| 71 |
node_count = static_cast<int64_t>(ni + 1); |
| 72 |
} |
| 73 |
else if (index_dim == 2) { |
| 74 |
node_count = static_cast<int64_t>(ni + 1) * (nj + 1); |
| 75 |
} |
| 76 |
else if (index_dim == 3) { |
| 77 |
node_count = static_cast<int64_t>(ni + 1) * (nj + 1) * (nk + 1); |
| 78 |
} |
| 79 |
} |
| 80 |
return node_count; |
| 81 |
} |
| 82 |
|
| 83 |
int64_t get_cell_count(const Ioss::IJK_t &ijk, int index_dim) |
| 84 |
{ |
| 85 |
return get_cell_count(ijk[0], ijk[1], ijk[2], index_dim); |
| 86 |
} |
| 87 |
|
| 88 |
int64_t get_node_count(const Ioss::IJK_t &ijk, int index_dim) |
| 89 |
{ |
| 90 |
return get_node_count(ijk[0], ijk[1], ijk[2], index_dim); |
| 91 |
} |
| 92 |
} // namespace |
| 93 |
|
| 94 |
namespace Ioss { |
| 95 |
|
| 96 |
/** \brief Create a structured block. |
| 97 |
* |
| 98 |
* \param[in] io_database The database associated with the region containing the structured |
| 99 |
* block. |
| 100 |
* \param[in] my_name The structured block's name. |
| 101 |
* \param[in] index_dim The dimensionality of the block -- 1D, 2D, 3D |
| 102 |
* \param[in] ni The number of intervals in the (i) direction. |
| 103 |
* \param[in] nj The number of intervals in the (j) direction. Zero if 1D |
| 104 |
* \param[in] nk The number of intervals in the (k) direction. Zero if 2D |
| 105 |
*/ |
| 106 |
// Serial |
| 107 |
StructuredBlock::StructuredBlock(DatabaseIO *io_database, const std::string &my_name, |
| 108 |
int index_dim, int ni, int nj, int nk) |
| 109 |
: StructuredBlock(io_database, my_name, index_dim, ni, nj, nk, 0, 0, 0, ni, nj, nk) |
| 110 |
{ |
| 111 |
} |
| 112 |
|
| 113 |
// Parallel |
| 114 |
StructuredBlock::StructuredBlock(DatabaseIO *io_database, const std::string &my_name, |
| 115 |
int index_dim, const Ioss::IJK_t &ordinal, |
| 116 |
const Ioss::IJK_t &offset, const Ioss::IJK_t &global_ordinal) |
| 117 |
: StructuredBlock(io_database, my_name, index_dim, ordinal[0], ordinal[1], ordinal[2], |
| 118 |
offset[0], offset[1], offset[2], global_ordinal[0], global_ordinal[1], |
| 119 |
global_ordinal[2]) |
| 120 |
{ |
| 121 |
} |
| 122 |
|
| 123 |
// Serial |
| 124 |
StructuredBlock::StructuredBlock(DatabaseIO *io_database, const std::string &my_name, |
| 125 |
int index_dim, Ioss::IJK_t &ordinal) |
| 126 |
: StructuredBlock(io_database, my_name, index_dim, ordinal[0], ordinal[1], ordinal[2], 0, 0, |
| 127 |
0, ordinal[0], ordinal[1], ordinal[2]) |
| 128 |
{ |
| 129 |
} |
| 130 |
|
| 131 |
// Parallel |
| 132 |
StructuredBlock::StructuredBlock(DatabaseIO *io_database, const std::string &my_name, |
| 133 |
int index_dim, int ni, int nj, int nk, int off_i, int off_j, |
| 134 |
int off_k, int glo_ni, int glo_nj, int glo_nk) |
| 135 |
: EntityBlock(io_database, my_name, Ioss::Hex8::name, get_cell_count(ni, nj, nk, index_dim)), |
| 136 |
m_ijk{ni, nj, nk}, m_offset{off_i, off_j, off_k}, |
| 137 |
m_nodeBlock(io_database, my_name + "_nodes", |
| 138 |
get_node_count(m_ijk[0], m_ijk[1], m_ijk[2], index_dim), index_dim) |
| 139 |
{ |
| 140 |
m_nodeBlock.property_add(Property("IOSS_INTERNAL_CONTAINED_IN", this)); |
| 141 |
|
| 142 |
SMART_ASSERT(index_dim == 1 || index_dim == 2 || index_dim == 3)(index_dim); |
| 143 |
|
| 144 |
m_ijkGlobal[0] = (glo_ni == 0 ? m_ijk[0] : glo_ni); |
| 145 |
m_ijkGlobal[1] = (glo_nj == 0 ? m_ijk[1] : glo_nj); |
| 146 |
m_ijkGlobal[2] = (glo_nk == 0 ? m_ijk[2] : glo_nk); |
| 147 |
|
| 148 |
int64_t cell_count = get_cell_count(m_ijk, index_dim); |
| 149 |
int64_t node_count = get_node_count(m_ijk, index_dim); |
| 150 |
int64_t global_cell_count = get_cell_count(m_ijkGlobal, index_dim); |
| 151 |
int64_t global_node_count = get_node_count(m_ijkGlobal, index_dim); |
| 152 |
|
| 153 |
SMART_ASSERT(global_cell_count >= cell_count)(global_cell_count)(cell_count); |
| 154 |
SMART_ASSERT(global_node_count >= node_count)(global_node_count)(node_count); |
| 155 |
|
| 156 |
if ((m_ijkGlobal[0] < m_ijk[0] + m_offset[0]) || (m_ijkGlobal[1] < m_ijk[1] + m_offset[1]) || |
| 157 |
(m_ijkGlobal[2] < m_ijk[2] + m_offset[2])) { |
| 158 |
auto util = get_database()->util(); |
| 159 |
std::ostringstream errmsg; |
| 160 |
fmt::print(errmsg, |
| 161 |
"\nERROR: Inconsistent Structured Block parameters for block {} on rank {}.\n" |
| 162 |
" Global IJK: {} x {} x {}; Local IJK: {} x {} x {}; Offset: {} x {} x {}\n" |
| 163 |
" Global must be >= Local + Offset.\n", |
| 164 |
my_name, util.parallel_rank(), m_ijkGlobal[0], m_ijkGlobal[1], m_ijkGlobal[2], |
| 165 |
m_ijk[0], m_ijk[1], m_ijk[2], m_offset[0], m_offset[1], m_offset[2]); |
| 166 |
std::cerr << errmsg.str(); |
| 167 |
IOSS_ERROR(errmsg); |
| 168 |
} |
| 169 |
|
| 170 |
SMART_ASSERT(m_ijkGlobal[0] >= m_ijk[0])(m_ijkGlobal[0])(m_ijk[0]); |
| 171 |
SMART_ASSERT(m_ijkGlobal[1] >= m_ijk[1])(m_ijkGlobal[1])(m_ijk[1]); |
| 172 |
SMART_ASSERT(m_ijkGlobal[2] >= m_ijk[2])(m_ijkGlobal[2])(m_ijk[2]); |
| 173 |
SMART_ASSERT(m_ijkGlobal[0] >= m_ijk[0] + m_offset[0])(m_ijkGlobal[0])(m_ijk[0])(m_offset[0]); |
| 174 |
SMART_ASSERT(m_ijkGlobal[1] >= m_ijk[1] + m_offset[1])(m_ijkGlobal[1])(m_ijk[1])(m_offset[1]); |
| 175 |
SMART_ASSERT(m_ijkGlobal[2] >= m_ijk[2] + m_offset[2])(m_ijkGlobal[2])(m_ijk[2])(m_offset[2]); |
| 176 |
|
| 177 |
properties.add(Property("component_degree", index_dim)); |
| 178 |
properties.add(Property("node_count", node_count)); |
| 179 |
properties.add(Property("cell_count", cell_count)); |
| 180 |
properties.add(Property("global_node_count", global_node_count)); |
| 181 |
properties.add(Property("global_cell_count", global_cell_count)); |
| 182 |
|
| 183 |
properties.add(Property("ni", m_ijk[0])); |
| 184 |
properties.add(Property("nj", m_ijk[1])); |
| 185 |
properties.add(Property("nk", m_ijk[2])); |
| 186 |
|
| 187 |
properties.add(Property(this, "ni_global", Ioss::Property::INTEGER)); |
| 188 |
properties.add(Property(this, "nj_global", Ioss::Property::INTEGER)); |
| 189 |
properties.add(Property(this, "nk_global", Ioss::Property::INTEGER)); |
| 190 |
|
| 191 |
properties.add(Property(this, "offset_i", Ioss::Property::INTEGER)); |
| 192 |
properties.add(Property(this, "offset_j", Ioss::Property::INTEGER)); |
| 193 |
properties.add(Property(this, "offset_k", Ioss::Property::INTEGER)); |
| 194 |
|
| 195 |
std::string vector_name; |
| 196 |
if (index_dim == 1) { |
| 197 |
vector_name = IOSS_SCALAR(); |
| 198 |
} |
| 199 |
else if (index_dim == 2) { |
| 200 |
vector_name = IOSS_VECTOR_2D(); |
| 201 |
} |
| 202 |
else if (index_dim == 3) { |
| 203 |
vector_name = IOSS_VECTOR_3D(); |
| 204 |
} |
| 205 |
fields.add(Ioss::Field("cell_ids", Ioss::Field::INTEGER, IOSS_SCALAR(), Ioss::Field::MESH, |
| 206 |
cell_count)); |
| 207 |
|
| 208 |
fields.add(Ioss::Field("cell_node_ids", Ioss::Field::INTEGER, IOSS_SCALAR(), Ioss::Field::MESH, |
| 209 |
node_count)); |
| 210 |
|
| 211 |
fields.add(Ioss::Field("mesh_model_coordinates", Ioss::Field::REAL, vector_name, |
| 212 |
Ioss::Field::MESH, node_count)); |
| 213 |
|
| 214 |
// Permit access 1-coordinate at a time |
| 215 |
fields.add(Ioss::Field("mesh_model_coordinates_x", Ioss::Field::REAL, IOSS_SCALAR(), |
| 216 |
Ioss::Field::MESH, node_count)); |
| 217 |
if (index_dim > 1) { |
| 218 |
fields.add(Ioss::Field("mesh_model_coordinates_y", Ioss::Field::REAL, IOSS_SCALAR(), |
| 219 |
Ioss::Field::MESH, node_count)); |
| 220 |
} |
| 221 |
if (index_dim > 2) { |
| 222 |
fields.add(Ioss::Field("mesh_model_coordinates_z", Ioss::Field::REAL, IOSS_SCALAR(), |
| 223 |
Ioss::Field::MESH, node_count)); |
| 224 |
} |
| 225 |
} |
| 226 |
|
| 227 |
StructuredBlock *StructuredBlock::clone(DatabaseIO *database) const |
| 228 |
{ |
| 229 |
int index_dim = properties.get("component_degree").get_int(); |
| 230 |
auto *block = new StructuredBlock(database, name(), index_dim, m_ijk, m_offset, m_ijkGlobal); |
| 231 |
|
| 232 |
block->m_zoneConnectivity = m_zoneConnectivity; |
| 233 |
block->m_boundaryConditions = m_boundaryConditions; |
| 234 |
block->m_blockLocalNodeIndex = m_blockLocalNodeIndex; |
| 235 |
block->m_globalIdMap = m_globalIdMap; |
| 236 |
|
| 237 |
return block; |
| 238 |
} |
| 239 |
|
| 240 |
void StructuredBlock::set_ijk_offset(int axis, size_t offset) |
| 241 |
{ |
| 242 |
SMART_ASSERT(axis == 0 || axis == 1 || axis == 2)(axis); |
| 243 |
if (axis == 0) { |
| 244 |
m_offset[0] = offset; |
| 245 |
} |
| 246 |
else if (axis == 1) { |
| 247 |
m_offset[1] = offset; |
| 248 |
} |
| 249 |
else if (axis == 2) { |
| 250 |
m_offset[2] = offset; |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
void StructuredBlock::set_ijk_global(int axis, size_t global) |
| 255 |
{ |
| 256 |
SMART_ASSERT(axis == 0 || axis == 1 || axis == 2)(axis); |
| 257 |
if (axis == 0) { |
| 258 |
m_ijkGlobal[0] = global; |
| 259 |
SMART_ASSERT(m_ijkGlobal[0] >= m_ijk[0] + m_offset[0])(m_ijkGlobal[0])(m_ijk[0])(m_offset[0]); |
| 260 |
} |
| 261 |
else if (axis == 1) { |
| 262 |
m_ijkGlobal[1] = global; |
| 263 |
SMART_ASSERT(m_ijkGlobal[1] >= m_ijk[1] + m_offset[1])(m_ijkGlobal[1])(m_ijk[1])(m_offset[1]); |
| 264 |
} |
| 265 |
else if (axis == 2) { |
| 266 |
m_ijkGlobal[2] = global; |
| 267 |
SMART_ASSERT(m_ijkGlobal[2] >= m_ijk[2] + m_offset[2])(m_ijkGlobal[2])(m_ijk[2])(m_offset[2]); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
void StructuredBlock::set_ijk_offset(const IJK_t &offset) { m_offset = offset; } |
| 272 |
|
| 273 |
void StructuredBlock::set_ijk_global(const IJK_t &global) |
| 274 |
{ |
| 275 |
m_ijkGlobal = global; |
| 276 |
|
| 277 |
SMART_ASSERT(m_ijkGlobal[0] >= m_ijk[0] + m_offset[0])(m_ijkGlobal[0])(m_ijk[0])(m_offset[0]); |
| 278 |
SMART_ASSERT(m_ijkGlobal[1] >= m_ijk[1] + m_offset[1])(m_ijkGlobal[1])(m_ijk[1])(m_offset[1]); |
| 279 |
SMART_ASSERT(m_ijkGlobal[2] >= m_ijk[2] + m_offset[2])(m_ijkGlobal[2])(m_ijk[2])(m_offset[2]); |
| 280 |
} |
| 281 |
|
| 282 |
Property StructuredBlock::get_implicit_property(const std::string &my_name) const |
| 283 |
{ |
| 284 |
if (my_name == "ni_global") { |
| 285 |
return {my_name, m_ijkGlobal[0]}; |
| 286 |
} |
| 287 |
if (my_name == "nj_global") { |
| 288 |
return {my_name, m_ijkGlobal[1]}; |
| 289 |
} |
| 290 |
if (my_name == "nk_global") { |
| 291 |
return {my_name, m_ijkGlobal[2]}; |
| 292 |
} |
| 293 |
if (my_name == "offset_i") { |
| 294 |
return {my_name, m_offset[0]}; |
| 295 |
} |
| 296 |
if (my_name == "offset_j") { |
| 297 |
return {my_name, m_offset[1]}; |
| 298 |
} |
| 299 |
if (my_name == "offset_k") { |
| 300 |
return {my_name, m_offset[2]}; |
| 301 |
} |
| 302 |
return EntityBlock::get_implicit_property(my_name); |
| 303 |
} |
| 304 |
|
| 305 |
int64_t StructuredBlock::internal_get_field_data(const Field &field, void *data, |
| 306 |
size_t data_size) const |
| 307 |
{ |
| 308 |
return get_database()->get_field(this, field, data, data_size); |
| 309 |
} |
| 310 |
|
| 311 |
int64_t StructuredBlock::internal_put_field_data(const Field &field, void *data, |
| 312 |
size_t data_size) const |
| 313 |
{ |
| 314 |
return get_database()->put_field(this, field, data, data_size); |
| 315 |
} |
| 316 |
|
| 317 |
int64_t StructuredBlock::internal_get_zc_field_data(const Field &field, void **data, |
| 318 |
size_t *data_size) const |
| 319 |
{ |
| 320 |
return get_database()->get_zc_field(this, field, data, data_size); |
| 321 |
} |
| 322 |
|
| 323 |
AxisAlignedBoundingBox StructuredBlock::get_bounding_box() const |
| 324 |
{ |
| 325 |
return get_database()->get_bounding_box(this); |
| 326 |
} |
| 327 |
|
| 328 |
size_t BoundaryCondition::get_face_count() const |
| 329 |
{ |
| 330 |
if (m_rangeBeg[0] == 0 || m_rangeEnd[0] == 0 || m_rangeBeg[1] == 0 || m_rangeEnd[1] == 0 || |
| 331 |
m_rangeBeg[2] == 0 || m_rangeEnd[2] == 0) { |
| 332 |
return 0; |
| 333 |
} |
| 334 |
|
| 335 |
auto diff0 = std::abs(m_rangeEnd[0] - m_rangeBeg[0]); |
| 336 |
auto diff1 = std::abs(m_rangeEnd[1] - m_rangeBeg[1]); |
| 337 |
auto diff2 = std::abs(m_rangeEnd[2] - m_rangeBeg[2]); |
| 338 |
|
| 339 |
int same_count = (diff0 == 0 ? 1 : 0) + (diff1 == 0 ? 1 : 0) + (diff2 == 0 ? 1 : 0); |
| 340 |
|
| 341 |
if (same_count > 1) { |
| 342 |
return 0; |
| 343 |
} |
| 344 |
diff0 = std::max(diff0, 1); |
| 345 |
diff1 = std::max(diff1, 1); |
| 346 |
diff2 = std::max(diff2, 1); |
| 347 |
|
| 348 |
return diff0 * diff1 * diff2; |
| 349 |
} |
| 350 |
|
| 351 |
bool BoundaryCondition::is_valid() const |
| 352 |
{ |
| 353 |
// Return true/false if range specifies a valid face |
| 354 |
bool is_x = m_rangeBeg[0] == m_rangeEnd[0]; |
| 355 |
bool is_y = m_rangeBeg[1] == m_rangeEnd[1]; |
| 356 |
bool is_z = m_rangeBeg[2] == m_rangeEnd[2]; |
| 357 |
|
| 358 |
return ((is_x ? 1 : 0) + (is_y ? 1 : 0) + (is_z ? 1 : 0) == 1); |
| 359 |
} |
| 360 |
|
| 361 |
int BoundaryCondition::which_face() const |
| 362 |
{ |
| 363 |
if (m_face == -1) { |
| 364 |
// Determine which "face" of the parent block this BC is applied to. |
| 365 |
// min X, max X, min Y, max Y, min Z, max Z -- 0, 3, 1, 4, 2, 5 |
| 366 |
if (m_rangeBeg[0] == 0 || m_rangeEnd[0] == 0 || m_rangeBeg[1] == 0 || m_rangeEnd[1] == 0 || |
| 367 |
m_rangeBeg[2] == 0 || m_rangeEnd[2] == 0) { |
| 368 |
m_face = -1; |
| 369 |
} |
| 370 |
else if (m_rangeBeg[0] == m_rangeEnd[0]) { |
| 371 |
m_face = (m_rangeBeg[0] == 1) ? 0 : 3; |
| 372 |
} |
| 373 |
else if (m_rangeBeg[1] == m_rangeEnd[1]) { |
| 374 |
m_face = (m_rangeBeg[1] == 1) ? 1 : 4; |
| 375 |
} |
| 376 |
else if (m_rangeBeg[2] == m_rangeEnd[2]) { |
| 377 |
m_face = (m_rangeBeg[2] == 1) ? 2 : 5; |
| 378 |
} |
| 379 |
} |
| 380 |
return m_face; |
| 381 |
} |
| 382 |
|
| 383 |
std::ostream &operator<<(std::ostream &os, const BoundaryCondition &bc) |
| 384 |
{ |
| 385 |
fmt::print(os, "\t\tBC Name '{}' owns {:10} faces.\tRange: [{}..{}, {}..{}, {}..{}]", |
| 386 |
bc.m_bcName, fmt::group_digits(bc.get_face_count()), bc.m_rangeBeg[0], |
| 387 |
bc.m_rangeEnd[0], bc.m_rangeBeg[1], bc.m_rangeEnd[1], bc.m_rangeBeg[2], |
| 388 |
bc.m_rangeEnd[2]); |
| 389 |
return os; |
| 390 |
} |
| 391 |
|
| 392 |
bool BoundaryCondition::equal_(const Ioss::BoundaryCondition &rhs, bool quiet) const |
| 393 |
{ |
| 394 |
// If `quiet` is true, then this is a helper function for the operator= |
| 395 |
// and should return as soon as the equal/not-equal status is determined |
| 396 |
// |
| 397 |
// If `quiet` is false, then this is a helper function for the mesh compare |
| 398 |
// utility and should report as many differences as it finds, so don't |
| 399 |
// return until end... |
| 400 |
bool same = true; |
| 401 |
|
| 402 |
if (this->m_bcName != rhs.m_bcName) { |
| 403 |
if (quiet) { |
| 404 |
return false; |
| 405 |
} |
| 406 |
fmt::print(Ioss::OUTPUT(), "BoundaryCondition: m_bcName MISMATCH ('{}' vs. '{}')\n", |
| 407 |
this->m_bcName, rhs.m_bcName); |
| 408 |
same = false; |
| 409 |
} |
| 410 |
|
| 411 |
if (this->m_famName != rhs.m_famName) { |
| 412 |
if (quiet) { |
| 413 |
return false; |
| 414 |
} |
| 415 |
fmt::print(Ioss::OUTPUT(), "BoundaryCondition: m_famName MISMATCH ('{}' vs. '{}')\n", |
| 416 |
this->m_famName, rhs.m_famName); |
| 417 |
same = false; |
| 418 |
} |
| 419 |
|
| 420 |
if (this->m_rangeBeg != rhs.m_rangeBeg) { |
| 421 |
if (quiet) { |
| 422 |
return false; |
| 423 |
} |
| 424 |
fmt::print(Ioss::OUTPUT(), "BoundaryCondition: m_rangeBeg MISMATCH ({} vs. {})\n", |
| 425 |
fmt::join(this->m_rangeBeg, ":"), fmt::join(rhs.m_rangeBeg, ":")); |
| 426 |
same = false; |
| 427 |
} |
| 428 |
|
| 429 |
if (this->m_rangeEnd != rhs.m_rangeEnd) { |
| 430 |
if (quiet) { |
| 431 |
return false; |
| 432 |
} |
| 433 |
fmt::print(Ioss::OUTPUT(), "BoundaryCondition: m_rangeEnd MISMATCH ({} vs. {})\n", |
| 434 |
fmt::join(this->m_rangeEnd, ":"), fmt::join(rhs.m_rangeEnd, ":")); |
| 435 |
same = false; |
| 436 |
} |
| 437 |
return same; |
| 438 |
} |
| 439 |
|
| 440 |
bool BoundaryCondition::operator==(const Ioss::BoundaryCondition &rhs) const |
| 441 |
{ |
| 442 |
return equal_(rhs, true); |
| 443 |
} |
| 444 |
|
| 445 |
bool BoundaryCondition::equal(const Ioss::BoundaryCondition &rhs) const |
| 446 |
{ |
| 447 |
return equal_(rhs, false); |
| 448 |
} |
| 449 |
|
| 450 |
bool StructuredBlock::equal_(const Ioss::StructuredBlock &rhs, bool quiet) const |
| 451 |
{ |
| 452 |
bool same = true; |
| 453 |
if (this->m_ijk != rhs.m_ijk) { |
| 454 |
if (quiet) { |
| 455 |
return false; |
| 456 |
} |
| 457 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: N mismatch ({} vs. {})\n", |
| 458 |
fmt::join(this->m_ijk, ":"), fmt::join(rhs.m_ijk, ":")); |
| 459 |
same = false; |
| 460 |
} |
| 461 |
|
| 462 |
if (this->m_offset != rhs.m_offset) { |
| 463 |
if (quiet) { |
| 464 |
return false; |
| 465 |
} |
| 466 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: OFFSET mismatch ({} vs. {})\n", |
| 467 |
fmt::join(this->m_offset, ":"), fmt::join(rhs.m_offset, ":")); |
| 468 |
same = false; |
| 469 |
} |
| 470 |
|
| 471 |
if (this->m_ijkGlobal != rhs.m_ijkGlobal) { |
| 472 |
if (quiet) { |
| 473 |
return false; |
| 474 |
} |
| 475 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Global N mismatch ({} vs. {})\n", |
| 476 |
fmt::join(this->m_ijkGlobal, ":"), fmt::join(rhs.m_ijkGlobal, ":")); |
| 477 |
same = false; |
| 478 |
} |
| 479 |
|
| 480 |
if (this->m_nodeOffset != rhs.m_nodeOffset) { |
| 481 |
if (quiet) { |
| 482 |
return false; |
| 483 |
} |
| 484 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Node Offset mismatch ({} vs. {})\n", |
| 485 |
this->m_nodeOffset, rhs.m_nodeOffset); |
| 486 |
same = false; |
| 487 |
} |
| 488 |
|
| 489 |
if (this->m_cellOffset != rhs.m_cellOffset) { |
| 490 |
if (quiet) { |
| 491 |
return false; |
| 492 |
} |
| 493 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Cell Offset mismatch ({} vs. {})\n", |
| 494 |
this->m_cellOffset, rhs.m_cellOffset); |
| 495 |
same = false; |
| 496 |
} |
| 497 |
|
| 498 |
if (this->m_nodeGlobalOffset != rhs.m_nodeGlobalOffset) { |
| 499 |
if (!quiet) { |
| 500 |
return false; |
| 501 |
} |
| 502 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Node Global Offset mismatch ({} vs. {})\n", |
| 503 |
this->m_nodeGlobalOffset, rhs.m_nodeGlobalOffset); |
| 504 |
same = false; |
| 505 |
} |
| 506 |
|
| 507 |
if (this->m_cellGlobalOffset != rhs.m_cellGlobalOffset) { |
| 508 |
if (quiet) { |
| 509 |
return false; |
| 510 |
} |
| 511 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Cell Global Offset mismatch ({} vs. {})\n", |
| 512 |
this->m_cellGlobalOffset, rhs.m_cellGlobalOffset); |
| 513 |
same = false; |
| 514 |
} |
| 515 |
|
| 516 |
if (this->m_blockLocalNodeIndex != rhs.m_blockLocalNodeIndex) { |
| 517 |
if (quiet) { |
| 518 |
return false; |
| 519 |
} |
| 520 |
fmt::print(Ioss::OUTPUT(), |
| 521 |
"StructuredBlock: Block Local Node Index mismatch ({} entries vs. {} entries)\n", |
| 522 |
this->m_blockLocalNodeIndex.size(), rhs.m_blockLocalNodeIndex.size()); |
| 523 |
same = false; |
| 524 |
} |
| 525 |
|
| 526 |
// NOTE: this comparison assumes that the elements of this vector will |
| 527 |
// appear in the same order in two databases that are equivalent. |
| 528 |
if (this->m_globalIdMap != rhs.m_globalIdMap) { |
| 529 |
if (quiet) { |
| 530 |
return false; |
| 531 |
} |
| 532 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Global ID Map mismatch\n"); |
| 533 |
|
| 534 |
same = false; |
| 535 |
} |
| 536 |
|
| 537 |
if (quiet && this->m_zoneConnectivity != rhs.m_zoneConnectivity) { |
| 538 |
return false; |
| 539 |
} |
| 540 |
{ |
| 541 |
auto lhzc = this->m_zoneConnectivity; |
| 542 |
auto rhzc = rhs.m_zoneConnectivity; |
| 543 |
Ioss::sort(lhzc.begin(), lhzc.end(), |
| 544 |
[](const ZoneConnectivity &l, const ZoneConnectivity &r) { |
| 545 |
return l.m_connectionName < r.m_connectionName; |
| 546 |
}); |
| 547 |
Ioss::sort(rhzc.begin(), rhzc.end(), |
| 548 |
[](const ZoneConnectivity &l, const ZoneConnectivity &r) { |
| 549 |
return l.m_connectionName < r.m_connectionName; |
| 550 |
}); |
| 551 |
if (!vec_equal(lhzc, rhzc)) { |
| 552 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Zone Connectivity mismatch (size {} vs {})\n", |
| 553 |
this->m_zoneConnectivity.size(), rhs.m_zoneConnectivity.size()); |
| 554 |
same = false; |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
if (quiet && this->m_boundaryConditions != rhs.m_boundaryConditions) { |
| 559 |
return false; |
| 560 |
} |
| 561 |
|
| 562 |
{ |
| 563 |
auto lhbc = this->m_boundaryConditions; |
| 564 |
auto rhbc = rhs.m_boundaryConditions; |
| 565 |
Ioss::sort(lhbc.begin(), lhbc.end(), |
| 566 |
[](const BoundaryCondition &l, const BoundaryCondition &r) { |
| 567 |
return l.m_bcName < r.m_bcName; |
| 568 |
}); |
| 569 |
Ioss::sort(rhbc.begin(), rhbc.end(), |
| 570 |
[](const BoundaryCondition &l, const BoundaryCondition &r) { |
| 571 |
return l.m_bcName < r.m_bcName; |
| 572 |
}); |
| 573 |
if (!vec_equal(lhbc, rhbc)) { |
| 574 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: Boundary Conditions mismatch\n"); |
| 575 |
same = false; |
| 576 |
} |
| 577 |
} |
| 578 |
|
| 579 |
if (!quiet) { |
| 580 |
if (!Ioss::EntityBlock::equal(rhs)) { |
| 581 |
fmt::print(Ioss::OUTPUT(), "StructuredBlock: EntityBlock mismatch\n"); |
| 582 |
same = false; |
| 583 |
} |
| 584 |
} |
| 585 |
else { |
| 586 |
if (Ioss::EntityBlock::operator!=(rhs)) { |
| 587 |
return false; |
| 588 |
} |
| 589 |
} |
| 590 |
|
| 591 |
return same; |
| 592 |
} |
| 593 |
|
| 594 |
bool StructuredBlock::operator==(const Ioss::StructuredBlock &rhs) const |
| 595 |
{ |
| 596 |
return equal_(rhs, true); |
| 597 |
} |
| 598 |
|
| 599 |
bool StructuredBlock::operator!=(const Ioss::StructuredBlock &rhs) const |
| 600 |
{ |
| 601 |
return !(*this == rhs); |
| 602 |
} |
| 603 |
|
| 604 |
bool StructuredBlock::equal(const Ioss::StructuredBlock &rhs) const { return equal_(rhs, false); } |
| 605 |
} // namespace Ioss |