| 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 <cgnsconfig.h> |
| 8 |
#if CG_BUILD_PARALLEL |
| 9 |
#include "cgns/Iocgns_Defines.h" |
| 10 |
|
| 11 |
#include "Ioss_CodeTypes.h" |
| 12 |
#include "Ioss_ParallelUtils.h" |
| 13 |
#include "Ioss_SmartAssert.h" |
| 14 |
#include "Ioss_Sort.h" |
| 15 |
#include "Ioss_StructuredBlock.h" |
| 16 |
#include "Ioss_Utils.h" |
| 17 |
#include "cgns/Iocgns_DecompositionData.h" |
| 18 |
#include "cgns/Iocgns_Utils.h" |
| 19 |
#include <fmt/color.h> |
| 20 |
#include <fmt/format.h> |
| 21 |
#include <fmt/ostream.h> |
| 22 |
#include <tokenize.h> |
| 23 |
|
| 24 |
#include <cgnsconfig.h> |
| 25 |
#include <pcgnslib.h> |
| 26 |
|
| 27 |
#include <algorithm> |
| 28 |
#include <cassert> |
| 29 |
#include <iomanip> |
| 30 |
#include <numeric> |
| 31 |
|
| 32 |
namespace { |
| 33 |
int rank = 0; |
| 34 |
|
| 35 |
// ZOLTAN Callback functions... |
| 36 |
|
| 37 |
#if !defined(NO_ZOLTAN_SUPPORT) |
| 38 |
int zoltan_num_dim(void *data, int *ierr) |
| 39 |
{ |
| 40 |
// Return dimensionality of coordinate data. |
| 41 |
auto *zdata = (Iocgns::DecompositionDataBase *)(data); |
| 42 |
|
| 43 |
*ierr = ZOLTAN_OK; |
| 44 |
return zdata->spatial_dimension(); |
| 45 |
} |
| 46 |
|
| 47 |
int zoltan_num_obj(void *data, int *ierr) |
| 48 |
{ |
| 49 |
// Return number of objects (element count) on this processor... |
| 50 |
auto *zdata = (Iocgns::DecompositionDataBase *)(data); |
| 51 |
|
| 52 |
*ierr = ZOLTAN_OK; |
| 53 |
return zdata->decomp_elem_count(); |
| 54 |
} |
| 55 |
|
| 56 |
void zoltan_obj_list(void *data, int ngid_ent, int /* nlid_ent */, ZOLTAN_ID_PTR gids, |
| 57 |
ZOLTAN_ID_PTR lids, int wdim, float *wgts, int *ierr) |
| 58 |
{ |
| 59 |
// Return list of object IDs, both local and global. |
| 60 |
auto *zdata = (Iocgns::DecompositionDataBase *)(data); |
| 61 |
|
| 62 |
// At the time this is called, we don't have much information |
| 63 |
// These routines are the ones that are developing that |
| 64 |
// information... |
| 65 |
size_t element_count = zdata->decomp_elem_count(); |
| 66 |
size_t element_offset = zdata->decomp_elem_offset(); |
| 67 |
|
| 68 |
*ierr = ZOLTAN_OK; |
| 69 |
|
| 70 |
if (lids != nullptr) { |
| 71 |
std::iota(lids, lids + element_count, 0); |
| 72 |
} |
| 73 |
|
| 74 |
if (wdim != 0) { |
| 75 |
std::fill(wgts, wgts + element_count, 1.0); |
| 76 |
} |
| 77 |
|
| 78 |
if (ngid_ent == 1) { |
| 79 |
std::iota(gids, gids + element_count, element_offset); |
| 80 |
} |
| 81 |
else if (ngid_ent == 2) { |
| 82 |
auto *global_ids = (int64_t *)gids; |
| 83 |
std::iota(global_ids, global_ids + element_count, element_offset); |
| 84 |
} |
| 85 |
else { |
| 86 |
*ierr = ZOLTAN_FATAL; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
void zoltan_geom(void *data, int /* ngid_ent */, int /* nlid_ent */, int /* nobj */, |
| 91 |
ZOLTAN_ID_PTR /* gids */, ZOLTAN_ID_PTR /* lids */, int /* ndim */, double *geom, |
| 92 |
int *ierr) |
| 93 |
{ |
| 94 |
// Return coordinates for objects. |
| 95 |
auto *zdata = (Iocgns::DecompositionDataBase *)(data); |
| 96 |
|
| 97 |
std::copy(zdata->centroids().begin(), zdata->centroids().end(), &geom[0]); |
| 98 |
|
| 99 |
*ierr = ZOLTAN_OK; |
| 100 |
} |
| 101 |
#endif |
| 102 |
|
| 103 |
// These are used for structured parallel decomposition... |
| 104 |
void create_zone_data(int cgns_file_ptr, std::vector<Iocgns::StructuredZoneData *> &zones, |
| 105 |
Ioss_MPI_Comm comm) |
| 106 |
{ |
| 107 |
Ioss::ParallelUtils par_util(comm); |
| 108 |
int myProcessor = par_util.parallel_rank(); // To make error macro work... |
| 109 |
int base = 1; |
| 110 |
int num_zones = 0; |
| 111 |
|
| 112 |
CGCHECK(cg_nzones(cgns_file_ptr, base, &num_zones)); |
| 113 |
|
| 114 |
std::map<std::string, int> zone_name_map; |
| 115 |
|
| 116 |
for (cgsize_t zone = 1; zone <= num_zones; zone++) { |
| 117 |
cgsize_t size[9]; |
| 118 |
char zone_name[CGNS_MAX_NAME_LENGTH + 1]; |
| 119 |
CGCHECK(cg_zone_read(cgns_file_ptr, base, zone, zone_name, size)); |
| 120 |
zone_name_map[zone_name] = zone; |
| 121 |
|
| 122 |
SMART_ASSERT(size[0] - 1 == size[3])(size[0])(size[3]); |
| 123 |
SMART_ASSERT(size[1] - 1 == size[4])(size[1])(size[4]); |
| 124 |
SMART_ASSERT(size[2] - 1 == size[5])(size[2])(size[5]); |
| 125 |
|
| 126 |
assert(size[6] == 0); |
| 127 |
assert(size[7] == 0); |
| 128 |
assert(size[8] == 0); |
| 129 |
|
| 130 |
auto *zone_data = new Iocgns::StructuredZoneData(zone_name, zone, size[3], size[4], size[5]); |
| 131 |
zones.push_back(zone_data); |
| 132 |
|
| 133 |
// Handle zone-grid-connectivity... |
| 134 |
int nconn = 0; |
| 135 |
CGCHECK(cg_n1to1(cgns_file_ptr, base, zone, &nconn)); |
| 136 |
for (int i = 0; i < nconn; i++) { |
| 137 |
char connectname[CGNS_MAX_NAME_LENGTH + 1]; |
| 138 |
char donorname[CGNS_MAX_NAME_LENGTH + 1]; |
| 139 |
std::array<cgsize_t, 6> range; |
| 140 |
std::array<cgsize_t, 6> donor_range; |
| 141 |
Ioss::IJK_t transform; |
| 142 |
|
| 143 |
CGCHECK(cg_1to1_read(cgns_file_ptr, base, zone, i + 1, connectname, donorname, Data(range), |
| 144 |
Data(donor_range), Data(transform))); |
| 145 |
|
| 146 |
// Get number of nodes shared with other "previous" zones... |
| 147 |
// A "previous" zone will have a lower zone number this this zone... |
| 148 |
int donor_zone = -1; |
| 149 |
auto donor_iter = zone_name_map.find(donorname); |
| 150 |
if (donor_iter != zone_name_map.end()) { |
| 151 |
donor_zone = (*donor_iter).second; |
| 152 |
} |
| 153 |
Ioss::IJK_t range_beg{{(int)range[0], (int)range[1], (int)range[2]}}; |
| 154 |
Ioss::IJK_t range_end{{(int)range[3], (int)range[4], (int)range[5]}}; |
| 155 |
Ioss::IJK_t donor_beg{{(int)donor_range[0], (int)donor_range[1], (int)donor_range[2]}}; |
| 156 |
Ioss::IJK_t donor_end{{(int)donor_range[3], (int)donor_range[4], (int)donor_range[5]}}; |
| 157 |
|
| 158 |
#if IOSS_DEBUG_OUTPUT |
| 159 |
if (rank == 0) { |
| 160 |
fmt::print(Ioss::DebugOut(), "Adding zgc {} to {} donor: {}\n", connectname, zone_name, |
| 161 |
donorname); |
| 162 |
} |
| 163 |
#endif |
| 164 |
zone_data->m_zoneConnectivity.emplace_back(connectname, zone, donorname, donor_zone, |
| 165 |
transform, range_beg, range_end, donor_beg, |
| 166 |
donor_end); |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
// If there are any Structured blocks, need to iterate them and their 1-to-1 connections |
| 171 |
// and update the donor_zone id for zones that had not yet been processed at the time of |
| 172 |
// definition... |
| 173 |
for (auto &zone : zones) { |
| 174 |
for (auto &conn : zone->m_zoneConnectivity) { |
| 175 |
if (conn.m_donorZone < 0) { |
| 176 |
auto donor_iter = zone_name_map.find(conn.m_donorName); |
| 177 |
assert(donor_iter != zone_name_map.end()); |
| 178 |
conn.m_donorZone = (*donor_iter).second; |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
} // namespace |
| 184 |
|
| 185 |
namespace Iocgns { |
| 186 |
template DecompositionData<int>::DecompositionData(const Ioss::PropertyManager &props, |
| 187 |
Ioss_MPI_Comm communicator); |
| 188 |
template DecompositionData<int64_t>::DecompositionData(const Ioss::PropertyManager &props, |
| 189 |
Ioss_MPI_Comm communicator); |
| 190 |
|
| 191 |
template <typename INT> |
| 192 |
DecompositionData<INT>::DecompositionData(const Ioss::PropertyManager &props, |
| 193 |
Ioss_MPI_Comm communicator) |
| 194 |
: DecompositionDataBase(), m_decomposition(props, communicator) |
| 195 |
{ |
| 196 |
rank = m_decomposition.m_processor; |
| 197 |
|
| 198 |
if (props.exists("LOAD_BALANCE_THRESHOLD")) { |
| 199 |
if (props.get("LOAD_BALANCE_THRESHOLD").get_type() == Ioss::Property::STRING) { |
| 200 |
std::string lb_thresh = props.get("LOAD_BALANCE_THRESHOLD").get_string(); |
| 201 |
m_loadBalanceThreshold = std::stod(lb_thresh); |
| 202 |
} |
| 203 |
else if (props.get("LOAD_BALANCE_THRESHOLD").get_type() == Ioss::Property::REAL) { |
| 204 |
m_loadBalanceThreshold = props.get("LOAD_BALANCE_THRESHOLD").get_real(); |
| 205 |
} |
| 206 |
} |
| 207 |
if (props.exists("LINE_DECOMPOSITION")) { |
| 208 |
m_lineDecomposition = props.get("LINE_DECOMPOSITION").get_string(); |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
template <typename INT> |
| 213 |
void DecompositionData<INT>::decompose_model(int filePtr, Ioss::MeshType mesh_type) |
| 214 |
{ |
| 215 |
if (mesh_type == Ioss::MeshType::UNSTRUCTURED) { |
| 216 |
decompose_unstructured(filePtr); |
| 217 |
} |
| 218 |
else if (mesh_type == Ioss::MeshType::STRUCTURED) { |
| 219 |
decompose_structured(filePtr); |
| 220 |
} |
| 221 |
#if IOSS_ENABLE_HYBRID |
| 222 |
else if (mesh_type == Ioss::MeshType::HYBRID) { |
| 223 |
IOSS_ERROR("ERROR: CGNS: The mesh type is HYBRID which is not supported for parallel " |
| 224 |
"decomposition yet."); |
| 225 |
} |
| 226 |
#endif |
| 227 |
else { |
| 228 |
IOSS_ERROR("ERROR: CGNS: The mesh type is not Unstructured or Structured " |
| 229 |
"which are the only types currently supported"); |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
template <typename INT> void DecompositionData<INT>::decompose_structured(int filePtr) |
| 234 |
{ |
| 235 |
m_decomposition.show_progress(__func__); |
| 236 |
create_zone_data(filePtr, m_structuredZones, m_decomposition.m_comm); |
| 237 |
if (m_structuredZones.empty()) { |
| 238 |
return; |
| 239 |
} |
| 240 |
|
| 241 |
#if IOSS_DEBUG_OUTPUT |
| 242 |
bool verbose = true; |
| 243 |
#else |
| 244 |
bool verbose = false; |
| 245 |
#endif |
| 246 |
|
| 247 |
// Determine whether user has specified "line decompositions" for any of the zones. |
| 248 |
// The line decomposition is an ordinal which will not be split during the |
| 249 |
// decomposition. |
| 250 |
if (!m_lineDecomposition.empty()) { |
| 251 |
// See if the ordinal is specified as "__ordinal_{ijk}" which is used for testing... |
| 252 |
if (m_lineDecomposition.find("__ordinal_") == 0) { |
| 253 |
auto sub = m_lineDecomposition.substr(10); |
| 254 |
unsigned int ord = 0; |
| 255 |
for (size_t i = 0; i < sub.size(); i++) { |
| 256 |
char ordinal = sub[i]; |
| 257 |
ord |= ordinal == 'i' ? Ordinal::I : ordinal == 'j' ? Ordinal::J : Ordinal::K; |
| 258 |
} |
| 259 |
for (auto &zone : m_structuredZones) { |
| 260 |
if (zone->is_active()) { |
| 261 |
zone->m_lineOrdinal |= ord; |
| 262 |
} |
| 263 |
} |
| 264 |
} |
| 265 |
else { |
| 266 |
Utils::set_line_decomposition(filePtr, m_lineDecomposition, m_structuredZones, rank, |
| 267 |
verbose); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
// Do the processor decomposition. |
| 272 |
Utils::decompose_model(m_structuredZones, m_decomposition.m_processorCount, rank, |
| 273 |
m_loadBalanceThreshold, verbose); |
| 274 |
|
| 275 |
Ioss::sort(m_structuredZones.begin(), m_structuredZones.end(), |
| 276 |
[](Iocgns::StructuredZoneData *a, Iocgns::StructuredZoneData *b) { |
| 277 |
return a->m_zone < b->m_zone; |
| 278 |
}); |
| 279 |
|
| 280 |
for (auto &zone : m_structuredZones) { |
| 281 |
if (zone->is_active()) { |
| 282 |
zone->resolve_zgc_split_donor(m_structuredZones); |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
// Update and Output the processor assignments |
| 287 |
for (auto &zone : m_structuredZones) { |
| 288 |
if (zone->is_active()) { |
| 289 |
zone->update_zgc_processor(m_structuredZones); |
| 290 |
#if IOSS_DEBUG_OUTPUT |
| 291 |
if (rank == 0) { |
| 292 |
auto zone_node_count = |
| 293 |
(zone->m_ordinal[0] + 1) * (zone->m_ordinal[1] + 1) * (zone->m_ordinal[2] + 1); |
| 294 |
fmt::print( |
| 295 |
Ioss::DebugOut(), |
| 296 |
"Zone {}({}) assigned to processor {}, Adam zone = {}, Cells = {}, Nodes = {}\n", |
| 297 |
zone->m_name, zone->m_zone, zone->m_proc, zone->m_adam->m_zone, zone->work(), |
| 298 |
zone_node_count); |
| 299 |
auto zgcs = zone->m_zoneConnectivity; |
| 300 |
#if 0 |
| 301 |
// This should work, but doesn't... |
| 302 |
fmt::print(Ioss::DebugOut(), "{}\n", fmt::join(zgcs, "\n")); |
| 303 |
#else |
| 304 |
for (auto &zgc : zgcs) { |
| 305 |
fmt::print(Ioss::DebugOut(), "{}\n", zgc); |
| 306 |
} |
| 307 |
#endif |
| 308 |
} |
| 309 |
#endif |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
// Output the processor assignments in form similar to 'split' file |
| 314 |
if (rank == 0) { |
| 315 |
int z = 1; |
| 316 |
fmt::print( |
| 317 |
Ioss::OUTPUT(), |
| 318 |
" n proc parent imin imax jmin jmax kmin kmax work\n"); |
| 319 |
auto tmp_zone(m_structuredZones); |
| 320 |
Ioss::sort(tmp_zone.begin(), tmp_zone.end(), |
| 321 |
[](Iocgns::StructuredZoneData *a, Iocgns::StructuredZoneData *b) { |
| 322 |
return a->m_proc < b->m_proc; |
| 323 |
}); |
| 324 |
|
| 325 |
for (auto &zone : tmp_zone) { |
| 326 |
if (zone->is_active()) { |
| 327 |
fmt::print(Ioss::OUTPUT(), "{:6d}{:8d}{:8d}{:8d}{:8d}{:8d}{:8d}{:8d}{:8d}{:14}\n", z++, |
| 328 |
zone->m_proc, zone->m_adam->m_zone, zone->m_offset[0] + 1, |
| 329 |
zone->m_ordinal[0] + zone->m_offset[0] + 1, zone->m_offset[1] + 1, |
| 330 |
zone->m_ordinal[1] + zone->m_offset[1] + 1, zone->m_offset[2] + 1, |
| 331 |
zone->m_ordinal[2] + zone->m_offset[2] + 1, fmt::group_digits(zone->work())); |
| 332 |
} |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
for (auto &zone : m_structuredZones) { |
| 337 |
if (!zone->is_active()) { |
| 338 |
zone->m_proc = -1; |
| 339 |
} |
| 340 |
} |
| 341 |
|
| 342 |
#if IOSS_DEBUG_OUTPUT |
| 343 |
MPI_Barrier(m_decomposition.m_comm); |
| 344 |
if (rank == 0) { |
| 345 |
fmt::print(Ioss::DebugOut(), "{}", |
| 346 |
fmt::format(fg(fmt::color::green), "Returning from decomposition\n")); |
| 347 |
} |
| 348 |
#endif |
| 349 |
} |
| 350 |
|
| 351 |
template <typename INT> void DecompositionData<INT>::decompose_unstructured(int filePtr) |
| 352 |
{ |
| 353 |
m_decomposition.show_progress(__func__); |
| 354 |
|
| 355 |
// Initial decomposition is linear where processor #p contains |
| 356 |
// elements from (#p * #element/#proc) to (#p+1 * #element/#proc) |
| 357 |
|
| 358 |
// ======================================================================== |
| 359 |
// Get the number of zones (element blocks) in the mesh... |
| 360 |
int num_zones = 0; |
| 361 |
int base = 1; // Only single base supported so far. |
| 362 |
|
| 363 |
{ |
| 364 |
int cell_dimension = 0; |
| 365 |
int phys_dimension = 0; |
| 366 |
char base_name[CGNS_MAX_NAME_LENGTH + 1]; |
| 367 |
CGCHECK2(cg_base_read(filePtr, base, base_name, &cell_dimension, &phys_dimension)); |
| 368 |
m_decomposition.m_spatialDimension = phys_dimension; |
| 369 |
} |
| 370 |
|
| 371 |
CGCHECK2(cg_nzones(filePtr, base, &num_zones)); |
| 372 |
m_zones.resize(num_zones + 1); // Use 1-based zones. |
| 373 |
|
| 374 |
size_t global_cell_node_count = 0; |
| 375 |
size_t global_element_count = 0; |
| 376 |
for (int zone = 1; zone <= num_zones; zone++) { |
| 377 |
// All zones are "Unstructured" since this was checked prior to |
| 378 |
// calling this function... |
| 379 |
cgsize_t size[3]; |
| 380 |
char zone_name[CGNS_MAX_NAME_LENGTH + 1]; |
| 381 |
CGCHECK2(cg_zone_read(filePtr, base, zone, zone_name, size)); |
| 382 |
|
| 383 |
INT total_block_nodes = size[0]; |
| 384 |
INT total_block_elem = size[1]; |
| 385 |
|
| 386 |
m_zones[zone].m_nodeCount = total_block_nodes; |
| 387 |
m_zones[zone].m_nodeOffset = global_cell_node_count; |
| 388 |
m_zones[zone].m_name = zone_name; |
| 389 |
m_zones[zone].m_elementOffset = global_element_count; |
| 390 |
global_cell_node_count += total_block_nodes; |
| 391 |
global_element_count += total_block_elem; |
| 392 |
} |
| 393 |
|
| 394 |
if (global_element_count < (size_t)m_decomposition.m_processorCount) { |
| 395 |
IOSS_ERROR( |
| 396 |
fmt::format("ERROR: CGNS: Element Count ({}) is less than Processor Count ({}). No " |
| 397 |
"decomposition possible.", |
| 398 |
global_element_count, m_decomposition.m_processorCount)); |
| 399 |
} |
| 400 |
|
| 401 |
// Generate element_dist/node_dist -- size m_decomposition.m_processorCount + 1 |
| 402 |
// processor p contains all elements/nodes from X_dist[p] .. X_dist[p+1] |
| 403 |
m_decomposition.generate_entity_distributions(global_cell_node_count, global_element_count); |
| 404 |
|
| 405 |
generate_adjacency_list(filePtr, m_decomposition); |
| 406 |
|
| 407 |
// Get min and max node used on this processor... |
| 408 |
auto min_max = |
| 409 |
std::minmax_element(m_decomposition.m_adjacency.begin(), m_decomposition.m_adjacency.end()); |
| 410 |
INT min_node = *(min_max.first); |
| 411 |
INT max_node = *(min_max.second); |
| 412 |
generate_zone_shared_nodes(filePtr, min_node, max_node); |
| 413 |
|
| 414 |
// Now iterate adjacency list and update any "zone_shared_node" nodes |
| 415 |
// with their "sharee" |
| 416 |
if (!m_zoneSharedMap.empty()) { |
| 417 |
for (auto &node : m_decomposition.m_adjacency) { |
| 418 |
auto alias = m_zoneSharedMap.find(node); |
| 419 |
if (alias != m_zoneSharedMap.end()) { |
| 420 |
node = (*alias).second; |
| 421 |
} |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
#if IOSS_DEBUG_OUTPUT |
| 426 |
if (rank == 0) { |
| 427 |
fmt::print(Ioss::DebugOut(), |
| 428 |
"Processor {0} has {1} elements; offset = {2}\n" |
| 429 |
"Processor {0} has {3} nodes; offset = {4}.\n", |
| 430 |
m_decomposition.m_processor, decomp_elem_count(), decomp_elem_offset(), |
| 431 |
decomp_node_count(), decomp_node_offset()); |
| 432 |
} |
| 433 |
#endif |
| 434 |
|
| 435 |
if (m_decomposition.needs_centroids()) { |
| 436 |
// Get my coordinate data using direct cgns calls |
| 437 |
std::vector<double> x(decomp_node_count()); |
| 438 |
std::vector<double> y; |
| 439 |
std::vector<double> z; |
| 440 |
|
| 441 |
get_file_node_coordinates(filePtr, 0, Data(x)); |
| 442 |
if (m_decomposition.m_spatialDimension > 1) { |
| 443 |
y.resize(decomp_node_count()); |
| 444 |
get_file_node_coordinates(filePtr, 1, Data(y)); |
| 445 |
} |
| 446 |
if (m_decomposition.m_spatialDimension > 2) { |
| 447 |
z.resize(decomp_node_count()); |
| 448 |
get_file_node_coordinates(filePtr, 2, Data(z)); |
| 449 |
} |
| 450 |
|
| 451 |
m_decomposition.calculate_element_centroids(x, y, z); |
| 452 |
} |
| 453 |
|
| 454 |
#if !defined(NO_ZOLTAN_SUPPORT) |
| 455 |
float version = 0.0; |
| 456 |
Zoltan_Initialize(0, nullptr, &version); |
| 457 |
|
| 458 |
Zoltan zz(m_decomposition.m_comm); |
| 459 |
|
| 460 |
// Register Zoltan Callback functions... |
| 461 |
zz.Set_Num_Obj_Fn(zoltan_num_obj, this); |
| 462 |
zz.Set_Obj_List_Fn(zoltan_obj_list, this); |
| 463 |
zz.Set_Num_Geom_Fn(zoltan_num_dim, this); |
| 464 |
zz.Set_Geom_Multi_Fn(zoltan_geom, this); |
| 465 |
#endif |
| 466 |
|
| 467 |
m_decomposition.decompose_model( |
| 468 |
#if !defined(NO_ZOLTAN_SUPPORT) |
| 469 |
zz, |
| 470 |
#endif |
| 471 |
m_elementBlocks); |
| 472 |
|
| 473 |
if (!m_sideSets.empty()) { |
| 474 |
// Create elemGTL map which is used for sidesets (also element sets) |
| 475 |
build_global_to_local_elem_map(); |
| 476 |
} |
| 477 |
|
| 478 |
get_sideset_data(filePtr); |
| 479 |
|
| 480 |
// Have all the decomposition data needed |
| 481 |
// Can now populate the Ioss metadata... |
| 482 |
} |
| 483 |
|
| 484 |
template <typename INT> |
| 485 |
void DecompositionData<INT>::generate_zone_shared_nodes(int filePtr, INT min_node, INT max_node) |
| 486 |
{ |
| 487 |
// Begin of Zone-Shared node information |
| 488 |
|
| 489 |
// Modify adjacency list based on shared nodes between zones... |
| 490 |
// Need the map from "global" to "global-shared" |
| 491 |
// * This is not necessarily nodes only on my processor since connectivity can include |
| 492 |
// nodes other than those I own. |
| 493 |
// * Potentially large number of shared nodes; practically small(?) |
| 494 |
|
| 495 |
// * Maintain hash map from old id to new (if any) |
| 496 |
// * TODO: Make more scalable |
| 497 |
|
| 498 |
int base = 1; // Only single base supported so far. |
| 499 |
|
| 500 |
// Donor zone is always lower numbered, so zone 1 has no donor zone. Start at zone 2. |
| 501 |
for (cgsize_t zone = 2; zone < (cgsize_t)m_zones.size(); zone++) { |
| 502 |
|
| 503 |
// Determine number of "shared" nodes (shared with other zones) |
| 504 |
int nconn = 0; |
| 505 |
CGCHECK2(cg_nconns(filePtr, base, zone, &nconn)); |
| 506 |
for (int i = 0; i < nconn; i++) { |
| 507 |
char connectname[CGNS_MAX_NAME_LENGTH + 1]; |
| 508 |
CGNS_ENUMT(GridLocation_t) location; |
| 509 |
CGNS_ENUMT(GridConnectivityType_t) connect_type; |
| 510 |
CGNS_ENUMT(PointSetType_t) ptset_type; |
| 511 |
cgsize_t npnts = 0; |
| 512 |
char donorname[CGNS_MAX_NAME_LENGTH + 1]; |
| 513 |
CGNS_ENUMT(ZoneType_t) donor_zonetype; |
| 514 |
CGNS_ENUMT(PointSetType_t) donor_ptset_type; |
| 515 |
CGNS_ENUMT(DataType_t) donor_datatype; |
| 516 |
cgsize_t ndata_donor; |
| 517 |
|
| 518 |
CGCHECK2(cg_conn_info(filePtr, base, zone, i + 1, connectname, &location, &connect_type, |
| 519 |
&ptset_type, &npnts, donorname, &donor_zonetype, &donor_ptset_type, |
| 520 |
&donor_datatype, &ndata_donor)); |
| 521 |
|
| 522 |
if (connect_type != CGNS_ENUMV(Abutting1to1) || ptset_type != CGNS_ENUMV(PointList) || |
| 523 |
donor_ptset_type != CGNS_ENUMV(PointListDonor)) { |
| 524 |
IOSS_ERROR(fmt::format("ERROR: CGNS: Zone {} adjacency data is not correct type. Require " |
| 525 |
"Abutting1to1 and PointList. {}\t{}\t{}", |
| 526 |
zone, connect_type, ptset_type, donor_ptset_type)); |
| 527 |
} |
| 528 |
|
| 529 |
// Verify data consistency... |
| 530 |
if (npnts != ndata_donor) { |
| 531 |
IOSS_ERROR(fmt::format( |
| 532 |
"ERROR: CGNS: Zone {} point count ({}) does not match donor point count ({}).", zone, |
| 533 |
npnts, ndata_donor)); |
| 534 |
} |
| 535 |
|
| 536 |
// Get number of nodes shared with other "previous" zones... |
| 537 |
// A "previous" zone will have a lower zone number this this zone... |
| 538 |
std::string dz_name(donorname); |
| 539 |
int dz = 1; |
| 540 |
for (; dz < zone; dz++) { |
| 541 |
if (m_zones[dz].m_name == dz_name) |
| 542 |
break; |
| 543 |
} |
| 544 |
|
| 545 |
if (dz != zone) { |
| 546 |
#if IOSS_DEBUG_OUTPUT |
| 547 |
if (m_decomposition.m_processor == 0) { |
| 548 |
fmt::print(Ioss::DebugOut(), "Zone {} shares {} nodes with {}\n", zone, npnts, |
| 549 |
donorname); |
| 550 |
} |
| 551 |
#endif |
| 552 |
// The 'ids' in 'points' and 'donors' will be zone-local 1-based. |
| 553 |
CGNSIntVector points(npnts); |
| 554 |
CGNSIntVector donors(npnts); |
| 555 |
|
| 556 |
CGCHECK2( |
| 557 |
cg_conn_read(filePtr, base, zone, i + 1, Data(points), donor_datatype, Data(donors))); |
| 558 |
|
| 559 |
for (int j = 0; j < npnts; j++) { |
| 560 |
// Convert to 0-based global id by subtracting 1 and adding zone.m_nodeOffset |
| 561 |
cgsize_t point = points[j] - 1 + m_zones[zone].m_nodeOffset; |
| 562 |
cgsize_t donor = donors[j] - 1 + m_zones[dz].m_nodeOffset; |
| 563 |
|
| 564 |
// See if 'donor' is mapped to a different node already |
| 565 |
auto donor_map = m_zoneSharedMap.find(donor); |
| 566 |
if (donor_map != m_zoneSharedMap.end()) { |
| 567 |
donor = (*donor_map).second; |
| 568 |
} |
| 569 |
m_zoneSharedMap.insert({point, donor}); |
| 570 |
#if IOSS_DEBUG_OUTPUT |
| 571 |
if (m_decomposition.m_processor == 0) { |
| 572 |
fmt::print(Ioss::DebugOut(), "Inserted {} to {}\n", point, donor); |
| 573 |
} |
| 574 |
#endif |
| 575 |
} |
| 576 |
} |
| 577 |
} |
| 578 |
} |
| 579 |
// Filter m_zoneSharedMap down to nodes on this processor... |
| 580 |
// This processor contains global zone ids from `min_node` to `max_node` |
| 581 |
// global zone ids are the first entry in m_zoneShardedMap. |
| 582 |
for (auto it = m_zoneSharedMap.cbegin(); it != m_zoneSharedMap.cend(); /* no increment */) { |
| 583 |
if ((*it).first < min_node || (*it).first > max_node) { |
| 584 |
it = m_zoneSharedMap.erase(it); |
| 585 |
} |
| 586 |
else { |
| 587 |
++it; |
| 588 |
} |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
template <typename INT> |
| 593 |
void DecompositionData<INT>::generate_adjacency_list(int filePtr, |
| 594 |
Ioss::Decomposition<INT> &decomposition) |
| 595 |
{ |
| 596 |
int base = 1; // Only single base supported so far. |
| 597 |
|
| 598 |
// Range of elements currently handled by this processor [) |
| 599 |
size_t p_start = decomp_elem_offset(); |
| 600 |
size_t p_end = p_start + decomp_elem_count(); |
| 601 |
|
| 602 |
size_t sum = 0; // Size of adjacency vector. |
| 603 |
size_t offset = 0; |
| 604 |
|
| 605 |
int num_zones = 0; |
| 606 |
INT zone_node_offset = 0; |
| 607 |
|
| 608 |
CGCHECK2(cg_nzones(filePtr, base, &num_zones)); |
| 609 |
for (int zone = 1; zone <= num_zones; zone++) { |
| 610 |
// ======================================================================== |
| 611 |
// Read the ZoneBC_t node to get list of SideBlocks to define on this zone |
| 612 |
// The BC_t nodes in the ZoneBC_t give the element range for each SideBlock |
| 613 |
// which can be matched up below with the Elements_t nodes to get contents |
| 614 |
// of the SideBlocks. |
| 615 |
auto zonebc = |
| 616 |
Utils::parse_zonebc_sideblocks(filePtr, base, zone, m_decomposition.m_processor); |
| 617 |
|
| 618 |
cgsize_t size[3]; |
| 619 |
char zone_name[CGNS_MAX_NAME_LENGTH + 1]; |
| 620 |
CGCHECK2(cg_zone_read(filePtr, base, zone, zone_name, size)); |
| 621 |
|
| 622 |
INT total_elements = size[1]; |
| 623 |
// NOTE: A Zone will have a single set of nodes, but can have |
| 624 |
// multiple sections each with their own element type... |
| 625 |
// Keep treating sections as element blocks until we |
| 626 |
// have handled 'size[1]' number of elements; the remaining |
| 627 |
// sections are then the boundary faces (?) |
| 628 |
int num_sections = 0; |
| 629 |
CGCHECK2(cg_nsections(filePtr, base, zone, &num_sections)); |
| 630 |
|
| 631 |
size_t last_blk_location = 0; |
| 632 |
for (int is = 1; is <= num_sections; is++) { |
| 633 |
char section_name[CGNS_MAX_NAME_LENGTH + 1]; |
| 634 |
CGNS_ENUMT(ElementType_t) e_type; |
| 635 |
cgsize_t el_start = 0; |
| 636 |
cgsize_t el_end = 0; |
| 637 |
int num_bndry = 0; |
| 638 |
int parent_flag = 0; |
| 639 |
|
| 640 |
// Get the type of elements in this section... |
| 641 |
CGCHECK2(cg_section_read(filePtr, base, zone, is, section_name, &e_type, &el_start, &el_end, |
| 642 |
&num_bndry, &parent_flag)); |
| 643 |
|
| 644 |
INT num_entity = el_end - el_start + 1; |
| 645 |
|
| 646 |
if (parent_flag == 0 && total_elements > 0) { |
| 647 |
total_elements -= num_entity; |
| 648 |
|
| 649 |
// Range of elements in element block b [) |
| 650 |
size_t b_start = offset; // offset is index of first element in this block... |
| 651 |
offset += num_entity; |
| 652 |
size_t b_end = offset; |
| 653 |
|
| 654 |
int element_nodes; |
| 655 |
CGCHECK2(cg_npe(e_type, &element_nodes)); |
| 656 |
|
| 657 |
if (b_start < p_end && p_start < b_end) { |
| 658 |
// Some of this blocks elements are on this processor... |
| 659 |
size_t overlap = std::min(b_end, p_end) - std::max(b_start, p_start); |
| 660 |
sum += overlap * element_nodes; |
| 661 |
} |
| 662 |
|
| 663 |
Ioss::BlockDecompositionData block; |
| 664 |
block.zone_ = zone; |
| 665 |
block.section_ = is; |
| 666 |
block.name_ = zone_name; |
| 667 |
block.topologyType = Utils::map_cgns_to_topology_type(e_type); |
| 668 |
block.nodesPerEntity = element_nodes; |
| 669 |
block.fileCount = num_entity; |
| 670 |
block.zoneNodeOffset = zone_node_offset; |
| 671 |
|
| 672 |
last_blk_location = m_elementBlocks.size(); |
| 673 |
m_elementBlocks.push_back(block); |
| 674 |
} |
| 675 |
else { |
| 676 |
// This is a boundary-condition -- sideset (?) |
| 677 |
std::string bc_name(section_name); |
| 678 |
std::string ss_name; |
| 679 |
// Search zonebc (if it exists) for an entry such that the element ranges overlap. |
| 680 |
if (!zonebc.empty()) { |
| 681 |
size_t i = 0; |
| 682 |
for (; i < zonebc.size(); i++) { |
| 683 |
if (zonebc[i].range_beg >= el_start && zonebc[i].range_end <= el_end) { |
| 684 |
break; |
| 685 |
} |
| 686 |
} |
| 687 |
if (i < zonebc.size()) { |
| 688 |
ss_name = zonebc[i].name; |
| 689 |
} |
| 690 |
} |
| 691 |
else { |
| 692 |
ss_name = section_name; |
| 693 |
} |
| 694 |
|
| 695 |
Ioss::SetDecompositionData sset; |
| 696 |
sset.zone_ = zone; |
| 697 |
sset.section_ = is; |
| 698 |
sset.name_ = bc_name; |
| 699 |
sset.ss_name_ = ss_name; |
| 700 |
sset.fileCount = num_entity; |
| 701 |
sset.topologyType = Utils::map_cgns_to_topology_type(e_type); |
| 702 |
sset.parentBlockIndex = last_blk_location; |
| 703 |
m_sideSets.emplace_back(std::move(sset)); |
| 704 |
} |
| 705 |
} |
| 706 |
zone_node_offset += size[0]; |
| 707 |
} |
| 708 |
int block_count = (int)m_elementBlocks.size(); |
| 709 |
|
| 710 |
// Get the global element block index list at this time also. |
| 711 |
// The global element at index 'I' (0-based) is on block B |
| 712 |
// if global_block_index[B] <= I && global_block_index[B+1] < I |
| 713 |
// allocate and TODO: Fill |
| 714 |
m_decomposition.m_fileBlockIndex.reserve(block_count + 1); |
| 715 |
for (auto &block : m_elementBlocks) { |
| 716 |
m_decomposition.m_fileBlockIndex.push_back(block.file_count()); |
| 717 |
} |
| 718 |
m_decomposition.m_fileBlockIndex.push_back(0); |
| 719 |
Ioss::Utils::generate_index(m_decomposition.m_fileBlockIndex); |
| 720 |
|
| 721 |
// Make sure 'sum' can fit in INT... |
| 722 |
INT tmp_sum = (INT)sum; |
| 723 |
if ((size_t)tmp_sum != sum) { |
| 724 |
IOSS_ERROR( |
| 725 |
"ERROR: The decomposition of this mesh requires 64-bit integers, but is being\n" |
| 726 |
" run with 32-bit integer code. Please rerun with the property INTEGER_SIZE_API\n" |
| 727 |
" set to 8. The details of how to do this vary with the code that is being run.\n" |
| 728 |
" Contact [email protected] for more details.\n"); |
| 729 |
} |
| 730 |
|
| 731 |
// Now, populate the vectors... |
| 732 |
decomposition.m_pointer.reserve(decomp_elem_count() + 1); |
| 733 |
decomposition.m_adjacency.reserve(sum); |
| 734 |
offset = 0; |
| 735 |
sum = 0; // Size of adjacency vector. |
| 736 |
|
| 737 |
for (auto &block : m_elementBlocks) { |
| 738 |
// Range of elements in element block b [) |
| 739 |
size_t b_start = offset; // offset is index of first element in this block... |
| 740 |
offset += block.file_count(); |
| 741 |
size_t b_end = b_start + block.file_count(); |
| 742 |
|
| 743 |
int64_t overlap = std::min(b_end, p_end) - std::max(b_start, p_start); |
| 744 |
overlap = std::max(overlap, (int64_t)0); |
| 745 |
block.fileCount = overlap; |
| 746 |
size_t element_nodes = block.nodesPerEntity; |
| 747 |
int zone = block.zone_; |
| 748 |
int section = block.section_; |
| 749 |
|
| 750 |
// Get the connectivity (raw) for this portion of elements... |
| 751 |
CGNSIntVector connectivity(overlap * element_nodes); |
| 752 |
INT blk_start = std::max(b_start, p_start) - b_start + 1; |
| 753 |
INT blk_end = blk_start + overlap - 1; |
| 754 |
blk_start = blk_start < 0 ? 0 : blk_start; |
| 755 |
blk_end = blk_end < 0 ? 0 : blk_end; |
| 756 |
#if IOSS_DEBUG_OUTPUT |
| 757 |
if (rank == 0) { |
| 758 |
fmt::print(Ioss::DebugOut(), |
| 759 |
"Processor {} has {} elements on element block {}\t({} to {})\n", |
| 760 |
m_decomposition.m_processor, overlap, block.name(), blk_start, blk_end); |
| 761 |
} |
| 762 |
#endif |
| 763 |
block.fileSectionOffset = blk_start; |
| 764 |
CGCHECK2(cgp_elements_read_data(filePtr, base, zone, section, blk_start, blk_end, |
| 765 |
Data(connectivity))); |
| 766 |
size_t el = 0; |
| 767 |
INT zone_offset = block.zoneNodeOffset; |
| 768 |
|
| 769 |
for (size_t elem = 0; elem < static_cast<size_t>(overlap); elem++) { |
| 770 |
decomposition.m_pointer.push_back(decomposition.m_adjacency.size()); |
| 771 |
for (size_t k = 0; k < element_nodes; k++) { |
| 772 |
INT node = connectivity[el++] - 1 + zone_offset; // 0-based node |
| 773 |
decomposition.m_adjacency.push_back(node); |
| 774 |
} |
| 775 |
} |
| 776 |
sum += overlap * element_nodes; |
| 777 |
} |
| 778 |
decomposition.m_pointer.push_back(decomposition.m_adjacency.size()); |
| 779 |
} |
| 780 |
|
| 781 |
template <typename INT> void DecompositionData<INT>::get_sideset_data(int filePtr) |
| 782 |
{ |
| 783 |
// NOTE: Not currently used; assume can read all on single processor... |
| 784 |
// Calculate the max "buffer" size usable for storing sideset |
| 785 |
// elemlists. This is basically the space used to store the file |
| 786 |
// decomposition nodal coordinates. The "decomp_node_count()/2*2" is to |
| 787 |
// equalize the decomp_node_count() among processors since some procs have 1 |
| 788 |
// more node than others. For small models, assume we can handle |
| 789 |
// at least 10000 nodes. |
| 790 |
// size_t max_size = std::max(10000, (decomp_node_count() / 2) * 2 * 3 *sizeof(double) / |
| 791 |
// sizeof(cgsize_t)); |
| 792 |
|
| 793 |
bool subsetting = false; |
| 794 |
|
| 795 |
if (subsetting) { |
| 796 |
assert(1 == 0); |
| 797 |
} |
| 798 |
else { |
| 799 |
for (auto &sset : m_sideSets) { |
| 800 |
|
| 801 |
auto topology = Ioss::ElementTopology::factory(sset.topologyType, true); |
| 802 |
int nodes_per_face = topology->number_nodes(); |
| 803 |
CGNSIntVector nodes(nodes_per_face * sset.file_count()); |
| 804 |
|
| 805 |
// We get: |
| 806 |
// * num_to_get parent elements, |
| 807 |
// * num_to_get zeros (other parent element for face, but on boundary so 0) |
| 808 |
// * num_to_get face_on_element |
| 809 |
// * num_to_get zeros (face on other parent element) |
| 810 |
CGNSIntVector parent(4 * sset.file_count()); |
| 811 |
|
| 812 |
int base = 1; // Only single base supported so far. |
| 813 |
CGCHECK2(cg_elements_read(filePtr, base, sset.zone(), sset.section(), Data(nodes), |
| 814 |
Data(parent))); |
| 815 |
|
| 816 |
if (parent[0] == 0) { |
| 817 |
// Get rid of 'parent' list -- not used. |
| 818 |
Ioss::Utils::clear(parent); |
| 819 |
|
| 820 |
// This model does not contain parent/face data; it only contains the |
| 821 |
// face connectivity (nodes) data. Need to construct parent/face data |
| 822 |
// The faces in the list should all be boundaries of the block and should |
| 823 |
// therefore, not be shared with another block or shared across processors. |
| 824 |
// If we check the 'corner_node_cnt' nodes of the face and they are all |
| 825 |
// on this processor, then assume the face is on this processor... |
| 826 |
if (m_boundaryFaces[sset.zone()].empty()) { |
| 827 |
// Need map of proc-zone-implicit element ids to global-zone-implicit ids |
| 828 |
// so we can assign the correct element id to the faces. |
| 829 |
auto blk = m_elementBlocks[sset.zone() - 1]; |
| 830 |
std::vector<INT> file_data(blk.fileCount); |
| 831 |
std::iota(file_data.begin(), file_data.end(), blk.fileSectionOffset); |
| 832 |
std::vector<INT> zone_local_zone_global(blk.iossCount); |
| 833 |
communicate_element_data(Data(file_data), Data(zone_local_zone_global), 1); |
| 834 |
Ioss::Utils::clear(file_data); |
| 835 |
|
| 836 |
std::vector<INT> connectivity(blk.ioss_count() * blk.nodesPerEntity); |
| 837 |
get_block_connectivity(filePtr, Data(connectivity), sset.zone() - 1, true); |
| 838 |
|
| 839 |
auto topo = Ioss::ElementTopology::factory(blk.topologyType, true); |
| 840 |
// Should map the connectivity from cgns to ioss, but only use the lower order which is |
| 841 |
// same. |
| 842 |
Iocgns::Utils::generate_block_faces(topo, blk.ioss_count(), connectivity, |
| 843 |
m_boundaryFaces[sset.zone()], |
| 844 |
zone_local_zone_global); |
| 845 |
} |
| 846 |
|
| 847 |
// TODO: Should we filter down to just corner nodes? |
| 848 |
// Now, iterate the face connectivity vector and see if |
| 849 |
// there is a match in `m_boundaryFaces` |
| 850 |
size_t offset = 0; |
| 851 |
auto &boundary = m_boundaryFaces[sset.zone()]; |
| 852 |
int num_corner_nodes = topology->number_corner_nodes(); |
| 853 |
SMART_ASSERT(num_corner_nodes == 3 || num_corner_nodes == 4)(num_corner_nodes); |
| 854 |
|
| 855 |
for (size_t iface = 0; iface < sset.file_count(); iface++) { |
| 856 |
std::array<size_t, 4> conn = {{0, 0, 0, 0}}; |
| 857 |
|
| 858 |
for (int i = 0; i < num_corner_nodes; i++) { |
| 859 |
conn[i] = nodes[offset + i]; |
| 860 |
} |
| 861 |
offset += nodes_per_face; |
| 862 |
|
| 863 |
Ioss::Face face(conn); |
| 864 |
// See if face is in m_boundaryFaces |
| 865 |
// If not, then owned by another rank |
| 866 |
// If so, then get parent element and element side. |
| 867 |
auto it = boundary.find(face); |
| 868 |
if (it != boundary.end()) { |
| 869 |
sset.entitylist_map.push_back(iface); |
| 870 |
} |
| 871 |
} |
| 872 |
} |
| 873 |
else { |
| 874 |
size_t zone_element_id_offset = m_zones[sset.zone()].m_elementOffset; |
| 875 |
for (size_t i = 0; i < sset.file_count(); i++) { |
| 876 |
cgsize_t elem = parent[i] + zone_element_id_offset; |
| 877 |
// See if elem owned by this processor... |
| 878 |
if (i_own_elem(elem)) { |
| 879 |
// Save elem in this processors element list for this set. |
| 880 |
// The saved data is this elements location in the global |
| 881 |
// element list (parent) for this set. |
| 882 |
sset.entitylist_map.push_back(i); |
| 883 |
} |
| 884 |
} |
| 885 |
} |
| 886 |
} |
| 887 |
|
| 888 |
// Each processor knows how many of the sideset elems it owns; |
| 889 |
// broadcast that information (the count) to the other |
| 890 |
// processors. The first processor with non-zero elem count is |
| 891 |
// the "root" for this sideset. |
| 892 |
{ |
| 893 |
std::vector<int> has_elems_local(m_sideSets.size()); |
| 894 |
for (size_t i = 0; i < m_sideSets.size(); i++) { |
| 895 |
has_elems_local[i] = m_sideSets[i].entitylist_map.empty() ? 0 : 1; |
| 896 |
} |
| 897 |
|
| 898 |
std::vector<int> has_elems(m_sideSets.size() * m_decomposition.m_processorCount); |
| 899 |
MPI_Allgather(Data(has_elems_local), has_elems_local.size(), MPI_INT, Data(has_elems), |
| 900 |
has_elems_local.size(), MPI_INT, m_decomposition.m_comm); |
| 901 |
|
| 902 |
for (size_t i = 0; i < m_sideSets.size(); i++) { |
| 903 |
m_sideSets[i].hasEntities.resize(m_decomposition.m_processorCount); |
| 904 |
m_sideSets[i].root_ = m_decomposition.m_processorCount; |
| 905 |
for (int p = 0; p < m_decomposition.m_processorCount; p++) { |
| 906 |
if (p < m_sideSets[i].root_ && has_elems[p * m_sideSets.size() + i] != 0) { |
| 907 |
m_sideSets[i].root_ = p; |
| 908 |
} |
| 909 |
m_sideSets[i].hasEntities[p] = has_elems[p * m_sideSets.size() + i]; |
| 910 |
} |
| 911 |
int color = m_sideSets[i].hasEntities[m_decomposition.m_processor] ? 1 : MPI_UNDEFINED; |
| 912 |
MPI_Comm_split(m_decomposition.m_comm, color, m_decomposition.m_processor, |
| 913 |
&m_sideSets[i].setComm_); |
| 914 |
} |
| 915 |
} |
| 916 |
} |
| 917 |
} |
| 918 |
|
| 919 |
template <typename INT> |
| 920 |
void DecompositionData<INT>::get_file_node_coordinates(int filePtr, int direction, |
| 921 |
double *data) const |
| 922 |
{ |
| 923 |
int base = 1; // Only single base supported so far. |
| 924 |
cgsize_t beg = 0; |
| 925 |
cgsize_t end = 0; |
| 926 |
cgsize_t offset = 0; |
| 927 |
cgsize_t node_count = decomp_node_count(); |
| 928 |
cgsize_t node_offset = decomp_node_offset(); |
| 929 |
|
| 930 |
int num_zones = (int)m_zones.size() - 1; |
| 931 |
for (int zone = 1; zone <= num_zones; zone++) { |
| 932 |
end += m_zones[zone].m_nodeCount; |
| 933 |
|
| 934 |
cgsize_t start = std::max(node_offset, beg); |
| 935 |
cgsize_t finish = std::min(end, node_offset + node_count); |
| 936 |
cgsize_t count = (finish > start) ? finish - start : 0; |
| 937 |
|
| 938 |
// Now adjust start for 1-based node numbering and the start of this zone... |
| 939 |
start = start - beg + 1; |
| 940 |
finish = finish - beg; |
| 941 |
if (count == 0) { |
| 942 |
start = 0; |
| 943 |
finish = 0; |
| 944 |
} |
| 945 |
#if IOSS_DEBUG_OUTPUT |
| 946 |
if (rank == 0) { |
| 947 |
fmt::print( |
| 948 |
Ioss::DebugOut(), |
| 949 |
"{}: reading {} nodes from zone {} starting at {} with an offset of {} ending at {}\n", |
| 950 |
m_decomposition.m_processor, count, zone, start, offset, finish); |
| 951 |
} |
| 952 |
#endif |
| 953 |
double *coords = nullptr; |
| 954 |
if (count > 0) { |
| 955 |
coords = &data[offset]; |
| 956 |
} |
| 957 |
CGCHECK2(cgp_coord_read_data(filePtr, base, zone, direction + 1, &start, &finish, coords)); |
| 958 |
offset += count; |
| 959 |
beg = end; |
| 960 |
} |
| 961 |
} |
| 962 |
|
| 963 |
template <typename INT> |
| 964 |
void DecompositionData<INT>::get_node_coordinates(int filePtr, double *ioss_data, |
| 965 |
const Ioss::Field &field) const |
| 966 |
{ |
| 967 |
std::vector<double> tmp(decomp_node_count()); |
| 968 |
if (field.get_name() == "mesh_model_coordinates_x") { |
| 969 |
get_file_node_coordinates(filePtr, 0, Data(tmp)); |
| 970 |
communicate_node_data(Data(tmp), ioss_data, 1); |
| 971 |
} |
| 972 |
|
| 973 |
else if (field.get_name() == "mesh_model_coordinates_y") { |
| 974 |
get_file_node_coordinates(filePtr, 1, Data(tmp)); |
| 975 |
communicate_node_data(Data(tmp), ioss_data, 1); |
| 976 |
} |
| 977 |
|
| 978 |
else if (field.get_name() == "mesh_model_coordinates_z") { |
| 979 |
get_file_node_coordinates(filePtr, 2, Data(tmp)); |
| 980 |
communicate_node_data(Data(tmp), ioss_data, 1); |
| 981 |
} |
| 982 |
|
| 983 |
else if (field.get_name() == "mesh_model_coordinates") { |
| 984 |
// Data required by upper classes store x0, y0, z0, ... xn, |
| 985 |
// yn, zn. Data stored in cgns file is x0, ..., xn, y0, |
| 986 |
// ..., yn, z0, ..., zn so we have to allocate some scratch |
| 987 |
// memory to read in the data and then map into supplied |
| 988 |
// 'data' |
| 989 |
|
| 990 |
std::vector<double> ioss_tmp(ioss_node_count()); |
| 991 |
|
| 992 |
// This implementation trades off extra communication for |
| 993 |
// reduced memory overhead. |
| 994 |
// * This method uses 'ioss_node_count' extra memory; 3 |
| 995 |
// reads; and 3 communicate_node_data calls. |
| 996 |
// |
| 997 |
// * Other method uses 6*ioss_node_count extra memory; 3 reads; |
| 998 |
// and 1 communicate_node_data call. |
| 999 |
// |
| 1000 |
for (int d = 0; d < m_decomposition.m_spatialDimension; d++) { |
| 1001 |
get_file_node_coordinates(filePtr, d, Data(tmp)); |
| 1002 |
communicate_node_data(Data(tmp), Data(ioss_tmp), 1); |
| 1003 |
|
| 1004 |
size_t index = d; |
| 1005 |
for (size_t i = 0; i < ioss_node_count(); i++) { |
| 1006 |
ioss_data[index] = ioss_tmp[i]; |
| 1007 |
index += m_decomposition.m_spatialDimension; |
| 1008 |
} |
| 1009 |
} |
| 1010 |
} |
| 1011 |
} |
| 1012 |
|
| 1013 |
template <typename INT> |
| 1014 |
void DecompositionData<INT>::get_node_field(int filePtr, int step, int field_offset, |
| 1015 |
double *ioss_data) const |
| 1016 |
{ |
| 1017 |
std::vector<double> tmp(decomp_node_count()); |
| 1018 |
|
| 1019 |
int base = 1; // Only single base supported so far. |
| 1020 |
cgsize_t beg = 0; |
| 1021 |
cgsize_t end = 0; |
| 1022 |
cgsize_t offset = 0; |
| 1023 |
cgsize_t node_count = decomp_node_count(); |
| 1024 |
cgsize_t node_offset = decomp_node_offset(); |
| 1025 |
|
| 1026 |
int num_zones = (int)m_zones.size() - 1; |
| 1027 |
for (int zone = 1; zone <= num_zones; zone++) { |
| 1028 |
end += m_zones[zone].m_nodeCount; |
| 1029 |
|
| 1030 |
int solution_index = |
| 1031 |
Utils::find_solution_index(filePtr, base, zone, step, CGNS_ENUMV(Vertex)); |
| 1032 |
|
| 1033 |
cgsize_t start = std::max(node_offset, beg); |
| 1034 |
cgsize_t finish = std::min(end, node_offset + node_count); |
| 1035 |
cgsize_t count = (finish > start) ? finish - start : 0; |
| 1036 |
|
| 1037 |
// Now adjust start for 1-based node numbering and the start of this zone... |
| 1038 |
start = (count == 0) ? 0 : start - beg + 1; |
| 1039 |
finish = (count == 0) ? 0 : finish - beg; |
| 1040 |
|
| 1041 |
double *data = (count > 0) ? &tmp[offset] : nullptr; |
| 1042 |
cgsize_t range_min[1] = {start}; |
| 1043 |
cgsize_t range_max[1] = {finish}; |
| 1044 |
|
| 1045 |
CGCHECK2(cgp_field_read_data(filePtr, base, zone, solution_index, field_offset, range_min, |
| 1046 |
range_max, data)); |
| 1047 |
|
| 1048 |
offset += count; |
| 1049 |
beg = end; |
| 1050 |
} |
| 1051 |
communicate_node_data(Data(tmp), ioss_data, 1); |
| 1052 |
} |
| 1053 |
|
| 1054 |
template void DecompositionData<int>::get_sideset_element_side( |
| 1055 |
int filePtr, const Ioss::SetDecompositionData &sset, int *data) const; |
| 1056 |
template void DecompositionData<int64_t>::get_sideset_element_side( |
| 1057 |
int filePtr, const Ioss::SetDecompositionData &sset, int64_t *data) const; |
| 1058 |
template <typename INT> |
| 1059 |
void DecompositionData<INT>::get_sideset_element_side(int filePtr, |
| 1060 |
const Ioss::SetDecompositionData &sset, |
| 1061 |
INT *ioss_data) const |
| 1062 |
{ |
| 1063 |
std::vector<INT> element_side; |
| 1064 |
int base = 1; |
| 1065 |
|
| 1066 |
auto topology = Ioss::ElementTopology::factory(sset.topologyType, true); |
| 1067 |
int nodes_per_face = topology->number_nodes(); |
| 1068 |
CGNSIntVector nodes(nodes_per_face * sset.file_count()); |
| 1069 |
|
| 1070 |
CGNSIntVector parent(4 * sset.file_count()); |
| 1071 |
|
| 1072 |
CGCHECK2( |
| 1073 |
cg_elements_read(filePtr, base, sset.zone(), sset.section(), Data(nodes), Data(parent))); |
| 1074 |
|
| 1075 |
if (parent[0] == 0) { |
| 1076 |
// Get rid of 'parent' list -- not used. |
| 1077 |
Ioss::Utils::clear(parent); |
| 1078 |
|
| 1079 |
// This model does not contain parent/face data; it only contains the |
| 1080 |
// face connectivity (nodes) data. Need to construct parent/face data |
| 1081 |
// The faces in the list should all be boundaries of the block and should |
| 1082 |
// therefore, not be shared with another block or shared across processors. |
| 1083 |
// If we check the 'corner_node_cnt' nodes of the face and they are all |
| 1084 |
// on this processor, then assume the face is on this processor... |
| 1085 |
|
| 1086 |
// TODO: Should we filter down to just corner nodes? |
| 1087 |
CGNSIntVector face_nodes(sset.entitylist_map.size() * nodes_per_face); |
| 1088 |
communicate_set_data(Data(nodes), Data(face_nodes), sset, nodes_per_face); |
| 1089 |
|
| 1090 |
// Now, iterate the face connectivity vector and find a match in `m_boundaryFaces` |
| 1091 |
size_t offset = 0; |
| 1092 |
size_t j = 0; |
| 1093 |
|
| 1094 |
// NOTE: The boundary face generation doesn't filter proc-boundary faces, |
| 1095 |
// so all zones will have boundary faces generated in 'get_sideset_data` |
| 1096 |
assert(!m_boundaryFaces[sset.zone()].empty()); |
| 1097 |
auto &boundary = m_boundaryFaces[sset.zone()]; |
| 1098 |
|
| 1099 |
int num_corner_nodes = topology->number_corner_nodes(); |
| 1100 |
SMART_ASSERT(num_corner_nodes == 3 || num_corner_nodes == 4)(num_corner_nodes); |
| 1101 |
|
| 1102 |
for (size_t iface = 0; iface < sset.ioss_count(); iface++) { |
| 1103 |
std::array<size_t, 4> conn = {{0, 0, 0, 0}}; |
| 1104 |
|
| 1105 |
for (int i = 0; i < num_corner_nodes; i++) { |
| 1106 |
conn[i] = face_nodes[offset + i]; |
| 1107 |
} |
| 1108 |
offset += nodes_per_face; |
| 1109 |
|
| 1110 |
size_t zone_element_id_offset = m_zones[sset.zone()].m_elementOffset; |
| 1111 |
Ioss::Face face(conn); |
| 1112 |
// See if face is in m_boundaryFaces |
| 1113 |
// If not, error |
| 1114 |
// If so, then get parent element and element side. |
| 1115 |
auto it = boundary.find(face); |
| 1116 |
if (it != boundary.end()) { |
| 1117 |
cgsize_t fid = (*it).element[0]; |
| 1118 |
#if IOSS_DEBUG_OUTPUT |
| 1119 |
fmt::print(Ioss::DebugOut(), "Connectivity: {} {} {} {} maps to element {}, face {}\n", |
| 1120 |
conn[0], conn[1], conn[2], conn[3], fid / 10, fid % 10 + 1); |
| 1121 |
#endif |
| 1122 |
ioss_data[j++] = fid / 10 + zone_element_id_offset; |
| 1123 |
ioss_data[j++] = fid % 10 + 1; |
| 1124 |
} |
| 1125 |
else { |
| 1126 |
IOSS_ERROR( |
| 1127 |
fmt::format("ERROR: CGNS: Could not find face with connectivity {} {} {} {} on " |
| 1128 |
"sideblock {}.", |
| 1129 |
conn[0], conn[1], conn[2], conn[3], sset.name())); |
| 1130 |
} |
| 1131 |
} |
| 1132 |
} |
| 1133 |
else { |
| 1134 |
// Get rid of 'nodes' list -- not used. |
| 1135 |
Ioss::Utils::clear(nodes); |
| 1136 |
|
| 1137 |
// `parent` contains: |
| 1138 |
// `num_to_get` parent elements, followed by -- |
| 1139 |
// `num_to_get` zeros (other parent element for face, but on boundary so 0) |
| 1140 |
// `num_to_get` face_on_element |
| 1141 |
// `num_to_get` zeros (face on other parent element) |
| 1142 |
|
| 1143 |
// Move from 'parent' to 'element_side' and interleave. element, side, element, side, ... |
| 1144 |
element_side.reserve(sset.file_count() * 2); |
| 1145 |
size_t zone_element_id_offset = m_zones[sset.zone()].m_elementOffset; |
| 1146 |
for (size_t i = 0; i < sset.file_count(); i++) { |
| 1147 |
element_side.push_back(parent[0 * sset.file_count() + i] + zone_element_id_offset); |
| 1148 |
element_side.push_back(parent[2 * sset.file_count() + i]); |
| 1149 |
} |
| 1150 |
auto blk = m_elementBlocks[sset.zone() - 1]; |
| 1151 |
auto topo = Ioss::ElementTopology::factory(blk.topologyType, true); |
| 1152 |
Utils::map_cgns_face_to_ioss(topo, sset.file_count(), Data(element_side)); |
| 1153 |
// The above was all on root processor for this side set, now need to send data to other |
| 1154 |
// processors that own any of the elements in the sideset. |
| 1155 |
communicate_set_data(Data(element_side), ioss_data, sset, 2); |
| 1156 |
} |
| 1157 |
} |
| 1158 |
|
| 1159 |
#ifndef DOXYGEN_SKIP_THIS |
| 1160 |
template void DecompositionData<int>::get_block_connectivity(int filePtr, int *data, int blk_seq, |
| 1161 |
bool raw_ids) const; |
| 1162 |
template void DecompositionData<int64_t>::get_block_connectivity(int filePtr, int64_t *data, |
| 1163 |
int blk_seq, bool raw_ids) const; |
| 1164 |
#endif |
| 1165 |
|
| 1166 |
template <typename INT> |
| 1167 |
void DecompositionData<INT>::get_block_connectivity(int filePtr, INT *data, int blk_seq, |
| 1168 |
bool raw_ids) const |
| 1169 |
{ |
| 1170 |
auto blk = m_elementBlocks[blk_seq]; |
| 1171 |
CGNSIntVector file_conn(blk.file_count() * blk.nodesPerEntity); |
| 1172 |
int base = 1; |
| 1173 |
CGCHECK2(cgp_elements_read_data(filePtr, base, blk.zone(), blk.section(), blk.fileSectionOffset, |
| 1174 |
blk.fileSectionOffset + blk.file_count() - 1, Data(file_conn))); |
| 1175 |
|
| 1176 |
if (!raw_ids) { |
| 1177 |
// Map from zone-local node numbers to global implicit |
| 1178 |
if (blk.zoneNodeOffset != 0) { |
| 1179 |
for (auto &node : file_conn) { |
| 1180 |
node += blk.zoneNodeOffset; |
| 1181 |
} |
| 1182 |
} |
| 1183 |
|
| 1184 |
if (!m_zoneSharedMap.empty()) { |
| 1185 |
for (auto &node : file_conn) { |
| 1186 |
ZoneSharedMap::const_iterator alias = m_zoneSharedMap.find(node - 1); |
| 1187 |
if (alias != m_zoneSharedMap.end()) { |
| 1188 |
node = (*alias).second + 1; |
| 1189 |
} |
| 1190 |
} |
| 1191 |
} |
| 1192 |
} |
| 1193 |
|
| 1194 |
communicate_block_data(Data(file_conn), data, blk, (size_t)blk.nodesPerEntity); |
| 1195 |
} |
| 1196 |
|
| 1197 |
#ifndef DOXYGEN_SKIP_THIS |
| 1198 |
template void DecompositionData<int>::get_element_field(int filePtr, int solution_index, |
| 1199 |
int blk_seq, int field_index, |
| 1200 |
double *data) const; |
| 1201 |
template void DecompositionData<int64_t>::get_element_field(int filePtr, int solution_index, |
| 1202 |
int blk_seq, int field_index, |
| 1203 |
double *data) const; |
| 1204 |
#endif |
| 1205 |
|
| 1206 |
template <typename INT> |
| 1207 |
void DecompositionData<INT>::get_element_field(int filePtr, int solution_index, int blk_seq, |
| 1208 |
int field_index, double *data) const |
| 1209 |
{ |
| 1210 |
const auto blk = m_elementBlocks[blk_seq]; |
| 1211 |
std::vector<double> cgns_data(blk.file_count()); |
| 1212 |
int base = 1; |
| 1213 |
cgsize_t range_min[1] = {(cgsize_t)blk.fileSectionOffset}; |
| 1214 |
cgsize_t range_max[1] = {(cgsize_t)(blk.fileSectionOffset + blk.file_count() - 1)}; |
| 1215 |
|
| 1216 |
CGCHECK2(cgp_field_read_data(filePtr, base, blk.zone(), solution_index, field_index, range_min, |
| 1217 |
range_max, Data(cgns_data))); |
| 1218 |
|
| 1219 |
communicate_block_data(Data(cgns_data), data, blk, (size_t)1); |
| 1220 |
} |
| 1221 |
|
| 1222 |
DecompositionDataBase::~DecompositionDataBase() |
| 1223 |
{ |
| 1224 |
for (const auto &zone : m_structuredZones) { |
| 1225 |
delete zone; |
| 1226 |
} |
| 1227 |
} |
| 1228 |
|
| 1229 |
#ifndef DOXYGEN_SKIP_THIS |
| 1230 |
template void DecompositionDataBase::communicate_node_data(int *file_data, int *ioss_data, |
| 1231 |
size_t comp_count) const; |
| 1232 |
template void DecompositionDataBase::communicate_node_data(int64_t *file_data, int64_t *ioss_data, |
| 1233 |
size_t comp_count) const; |
| 1234 |
template void DecompositionDataBase::communicate_node_data(double *file_data, double *ioss_data, |
| 1235 |
size_t comp_count) const; |
| 1236 |
#endif |
| 1237 |
|
| 1238 |
template <typename T> |
| 1239 |
void DecompositionDataBase::communicate_node_data(T *file_data, T *ioss_data, |
| 1240 |
size_t comp_count) const |
| 1241 |
{ |
| 1242 |
if (int_size() == sizeof(int)) { |
| 1243 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1244 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1245 |
this32->communicate_node_data(file_data, ioss_data, comp_count); |
| 1246 |
} |
| 1247 |
else { |
| 1248 |
const DecompositionData<int64_t> *this64 = |
| 1249 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1250 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1251 |
this64->communicate_node_data(file_data, ioss_data, comp_count); |
| 1252 |
} |
| 1253 |
} |
| 1254 |
|
| 1255 |
#ifndef DOXYGEN_SKIP_THIS |
| 1256 |
template void DecompositionDataBase::communicate_element_data(int *file_data, int *ioss_data, |
| 1257 |
size_t comp_count) const; |
| 1258 |
template void DecompositionDataBase::communicate_element_data(int64_t *file_data, |
| 1259 |
int64_t *ioss_data, |
| 1260 |
size_t comp_count) const; |
| 1261 |
template void DecompositionDataBase::communicate_element_data(double *file_data, |
| 1262 |
double *ioss_data, |
| 1263 |
size_t comp_count) const; |
| 1264 |
#endif |
| 1265 |
|
| 1266 |
template <typename T> |
| 1267 |
void DecompositionDataBase::communicate_element_data(T *file_data, T *ioss_data, |
| 1268 |
size_t comp_count) const |
| 1269 |
{ |
| 1270 |
if (int_size() == sizeof(int)) { |
| 1271 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1272 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1273 |
this32->communicate_element_data(file_data, ioss_data, comp_count); |
| 1274 |
} |
| 1275 |
else { |
| 1276 |
const DecompositionData<int64_t> *this64 = |
| 1277 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1278 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1279 |
this64->communicate_element_data(file_data, ioss_data, comp_count); |
| 1280 |
} |
| 1281 |
} |
| 1282 |
|
| 1283 |
void DecompositionDataBase::get_node_entity_proc_data(void *entity_proc, |
| 1284 |
const Ioss::MapContainer &node_map, |
| 1285 |
bool do_map) const |
| 1286 |
{ |
| 1287 |
if (int_size() == sizeof(int)) { |
| 1288 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1289 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1290 |
this32->m_decomposition.get_node_entity_proc_data((int *)entity_proc, node_map, do_map); |
| 1291 |
} |
| 1292 |
else { |
| 1293 |
const DecompositionData<int64_t> *this64 = |
| 1294 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1295 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1296 |
this64->m_decomposition.get_node_entity_proc_data((int64_t *)entity_proc, node_map, do_map); |
| 1297 |
} |
| 1298 |
} |
| 1299 |
|
| 1300 |
void DecompositionDataBase::get_block_connectivity(int filePtr, void *data, int blk_seq, |
| 1301 |
bool raw_ids) const |
| 1302 |
{ |
| 1303 |
if (int_size() == sizeof(int)) { |
| 1304 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1305 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1306 |
this32->get_block_connectivity(filePtr, (int *)data, blk_seq, raw_ids); |
| 1307 |
} |
| 1308 |
else { |
| 1309 |
const DecompositionData<int64_t> *this64 = |
| 1310 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1311 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1312 |
this64->get_block_connectivity(filePtr, (int64_t *)data, blk_seq, raw_ids); |
| 1313 |
} |
| 1314 |
} |
| 1315 |
|
| 1316 |
void DecompositionDataBase::get_element_field(int filePtr, int solution_index, int blk_seq, |
| 1317 |
int field_index, double *data) const |
| 1318 |
{ |
| 1319 |
if (int_size() == sizeof(int)) { |
| 1320 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1321 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1322 |
this32->get_element_field(filePtr, solution_index, blk_seq, field_index, data); |
| 1323 |
} |
| 1324 |
else { |
| 1325 |
const DecompositionData<int64_t> *this64 = |
| 1326 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1327 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1328 |
this64->get_element_field(filePtr, solution_index, blk_seq, field_index, data); |
| 1329 |
} |
| 1330 |
} |
| 1331 |
|
| 1332 |
void DecompositionDataBase::get_node_field(int filePtr, int step, int field_index, |
| 1333 |
double *data) const |
| 1334 |
{ |
| 1335 |
if (int_size() == sizeof(int)) { |
| 1336 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1337 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1338 |
this32->get_node_field(filePtr, step, field_index, data); |
| 1339 |
} |
| 1340 |
else { |
| 1341 |
const DecompositionData<int64_t> *this64 = |
| 1342 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1343 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1344 |
this64->get_node_field(filePtr, step, field_index, data); |
| 1345 |
} |
| 1346 |
} |
| 1347 |
|
| 1348 |
void DecompositionDataBase::get_sideset_element_side(int filePtr, |
| 1349 |
const Ioss::SetDecompositionData &sset, |
| 1350 |
void *data) const |
| 1351 |
{ |
| 1352 |
if (int_size() == sizeof(int)) { |
| 1353 |
const DecompositionData<int> *this32 = dynamic_cast<const DecompositionData<int> *>(this); |
| 1354 |
Ioss::Utils::check_dynamic_cast(this32); |
| 1355 |
this32->get_sideset_element_side(filePtr, sset, (int *)data); |
| 1356 |
} |
| 1357 |
else { |
| 1358 |
const DecompositionData<int64_t> *this64 = |
| 1359 |
dynamic_cast<const DecompositionData<int64_t> *>(this); |
| 1360 |
Ioss::Utils::check_dynamic_cast(this64); |
| 1361 |
this64->get_sideset_element_side(filePtr, sset, (int64_t *)data); |
| 1362 |
} |
| 1363 |
} |
| 1364 |
} // namespace Iocgns |
| 1365 |
#else |
| 1366 |
/* |
| 1367 |
* Prevent warning in some versions of ranlib(1) because the object |
| 1368 |
* file has no symbols. |
| 1369 |
*/ |
| 1370 |
const char ioss_cgns_decomposition_data_unused_symbol_dummy = '\0'; |
| 1371 |
#endif |