| 1 |
// Copyright(C) 1999-2021, 2023, 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_DatabaseIO.h" |
| 8 |
#include "Ioss_Field.h" |
| 9 |
#include "Ioss_NodeBlock.h" |
| 10 |
#include "Ioss_Property.h" |
| 11 |
#include <cassert> |
| 12 |
#include <cstddef> |
| 13 |
#include <string> |
| 14 |
|
| 15 |
#include "Ioss_BoundingBox.h" |
| 16 |
#include "Ioss_CodeTypes.h" |
| 17 |
#include "Ioss_EntityBlock.h" |
| 18 |
#include "Ioss_FieldManager.h" |
| 19 |
#include "Ioss_PropertyManager.h" |
| 20 |
|
| 21 |
/** \brief Create a node block. |
| 22 |
* |
| 23 |
* \param[in] io_database The database associated with the region containing the node block. |
| 24 |
* \param[in] my_name The node block's name. |
| 25 |
* \param[in] node_count The number of nodes in the node block. |
| 26 |
* \param[in] degrees_of_freedom The number of degrees of freedom (or coordinates) per node. |
| 27 |
*/ |
| 28 |
Ioss::NodeBlock::NodeBlock(Ioss::DatabaseIO *io_database, const std::string &my_name, |
| 29 |
int64_t node_count, int64_t degrees_of_freedom) |
| 30 |
: Ioss::EntityBlock(io_database, my_name, "node", node_count) |
| 31 |
{ |
| 32 |
properties.add(Ioss::Property("component_degree", static_cast<int>(degrees_of_freedom))); |
| 33 |
|
| 34 |
std::string vector_name; |
| 35 |
assert(degrees_of_freedom == 1 || degrees_of_freedom == 2 || degrees_of_freedom == 3); |
| 36 |
|
| 37 |
if (degrees_of_freedom == 1) { |
| 38 |
vector_name = IOSS_SCALAR(); |
| 39 |
} |
| 40 |
else if (degrees_of_freedom == 2) { |
| 41 |
vector_name = IOSS_VECTOR_2D(); |
| 42 |
} |
| 43 |
else if (degrees_of_freedom == 3) { |
| 44 |
vector_name = IOSS_VECTOR_3D(); |
| 45 |
} |
| 46 |
|
| 47 |
fields.add(Ioss::Field("mesh_model_coordinates", Ioss::Field::REAL, vector_name, |
| 48 |
Ioss::Field::MESH, node_count)); |
| 49 |
|
| 50 |
// Permit access 1-coordinate at a time |
| 51 |
fields.add(Ioss::Field("mesh_model_coordinates_x", Ioss::Field::REAL, IOSS_SCALAR(), |
| 52 |
Ioss::Field::MESH, node_count)); |
| 53 |
if (degrees_of_freedom > 1) { |
| 54 |
fields.add(Ioss::Field("mesh_model_coordinates_y", Ioss::Field::REAL, IOSS_SCALAR(), |
| 55 |
Ioss::Field::MESH, node_count)); |
| 56 |
} |
| 57 |
|
| 58 |
if (degrees_of_freedom > 2) { |
| 59 |
fields.add(Ioss::Field("mesh_model_coordinates_z", Ioss::Field::REAL, IOSS_SCALAR(), |
| 60 |
Ioss::Field::MESH, node_count)); |
| 61 |
} |
| 62 |
|
| 63 |
fields.add(Ioss::Field("node_connectivity_status", Ioss::Field::CHARACTER, IOSS_SCALAR(), |
| 64 |
Ioss::Field::MESH, node_count)); |
| 65 |
|
| 66 |
// The 1..global_node_count id. In a parallel-decomposed run, |
| 67 |
// if maps the node back to its implicit position in the serial |
| 68 |
// undecomposed mesh file. This is ONLY provided for backward- |
| 69 |
// compatibility and should not be used unless absolutely required. |
| 70 |
fields.add( |
| 71 |
Ioss::Field("implicit_ids", field_int_type(), IOSS_SCALAR(), Ioss::Field::MESH, node_count)); |
| 72 |
|
| 73 |
fields.add(Ioss::Field("owning_processor", Ioss::Field::INT32, IOSS_SCALAR(), Ioss::Field::MESH, |
| 74 |
node_count)); |
| 75 |
} |
| 76 |
|
| 77 |
Ioss::NodeBlock::NodeBlock(const Ioss::NodeBlock &other) = default; |
| 78 |
|
| 79 |
Ioss::Property Ioss::NodeBlock::get_implicit_property(const std::string &my_name) const |
| 80 |
{ |
| 81 |
return Ioss::EntityBlock::get_implicit_property(my_name); |
| 82 |
} |
| 83 |
|
| 84 |
int64_t Ioss::NodeBlock::internal_get_field_data(const Ioss::Field &field, void *data, |
| 85 |
size_t data_size) const |
| 86 |
{ |
| 87 |
return get_database()->get_field(this, field, data, data_size); |
| 88 |
} |
| 89 |
|
| 90 |
int64_t Ioss::NodeBlock::internal_put_field_data(const Ioss::Field &field, void *data, |
| 91 |
size_t data_size) const |
| 92 |
{ |
| 93 |
return get_database()->put_field(this, field, data, data_size); |
| 94 |
} |
| 95 |
|
| 96 |
int64_t Ioss::NodeBlock::internal_get_zc_field_data(const Field &field, void **data, |
| 97 |
size_t *data_size) const |
| 98 |
{ |
| 99 |
return get_database()->get_zc_field(this, field, data, data_size); |
| 100 |
} |
| 101 |
|
| 102 |
Ioss::AxisAlignedBoundingBox Ioss::NodeBlock::get_bounding_box() const |
| 103 |
{ |
| 104 |
return get_database()->get_bounding_box(this); |
| 105 |
} |
| 106 |
|
| 107 |
bool Ioss::NodeBlock::operator==(const Ioss::NodeBlock &rhs) const |
| 108 |
{ |
| 109 |
return Ioss::EntityBlock::operator==(rhs); |
| 110 |
} |
| 111 |
|
| 112 |
bool Ioss::NodeBlock::operator!=(const Ioss::NodeBlock &rhs) const { return !(*this == rhs); } |
| 113 |
|
| 114 |
bool Ioss::NodeBlock::equal(const Ioss::NodeBlock &rhs) const |
| 115 |
{ |
| 116 |
return Ioss::EntityBlock::equal(rhs); |
| 117 |
} |