33 #ifndef IOSS_Ioss_GroupingEntity_h 34 #define IOSS_Ioss_GroupingEntity_h 50 #ifdef SEACAS_HAVE_KOKKOS 51 #include <Kokkos_Core.hpp> 137 bool is_alias(
const std::string &my_name)
const;
188 void property_update(
const std::string &property, int64_t value)
const;
189 void property_update(
const std::string &property,
const std::string &value)
const;
208 int get_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
210 int put_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
215 template <
typename T>
218 template <
typename T>
220 template <
typename T>
223 #ifdef SEACAS_HAVE_KOKKOS 229 template <
typename T,
typename... Args>
230 int get_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &
data)
const;
232 template <
typename T,
typename... Args>
233 int get_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &
data)
const;
235 template <
typename T,
typename... Args>
236 int put_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &
data)
const;
238 template <
typename T,
typename... Args>
239 int put_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &
data)
const;
286 size_t data_size = 0)
const = 0;
288 size_t data_size = 0)
const = 0;
292 #if defined(IOSS_THREADSAFE) 293 mutable std::mutex m_;
327 properties.erase(property_name);
337 return properties.exists(property_name);
348 return properties.get(property_name);
358 return properties.describe(names);
377 fields.erase(field_name);
388 return fields.exists(field_name);
399 return fields.get(field_name);
410 return fields.getref(field_name);
421 return fields.describe(names);
433 return fields.describe(role, names);
449 template <
typename T>
452 verify_field_exists(field_name,
"input");
458 size_t data_size =
data.size() *
sizeof(T);
459 int retval = internal_get_field_data(field,
TOPTR(
data), data_size);
476 template <
typename T>
478 const std::vector<T> &
data)
const 480 verify_field_exists(field_name,
"output");
484 size_t data_size =
data.size() *
sizeof(T);
487 std::vector<T> nc_data(
data);
489 return internal_put_field_data(field, nc_data.data(), data_size);
492 T *my_data = const_cast<T *>(
data.data());
493 return internal_put_field_data(field, my_data, data_size);
496 template <
typename T>
499 verify_field_exists(field_name,
"output");
503 size_t data_size =
data.size() *
sizeof(T);
504 T * my_data = const_cast<T *>(
data.data());
506 return internal_put_field_data(field, my_data, data_size);
509 #ifdef SEACAS_HAVE_KOKKOS 520 template <
typename T,
typename... Args>
522 Kokkos::View<T *, Args...> &
data)
const 524 typedef Kokkos::View<T *, Args...> ViewType;
526 verify_field_exists(field_name,
"input");
532 Kokkos::resize(
data, new_view_size);
533 size_t data_size = new_view_size *
sizeof(T);
536 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
539 T *host_data_ptr = host_data.data();
542 int retval = internal_get_field_data(field, host_data_ptr, data_size);
549 Kokkos::deep_copy(
data, host_data);
563 template <
typename T,
typename... Args>
565 Kokkos::View<T **, Args...> &
data)
const 567 typedef Kokkos::View<T **, Args...> ViewType;
569 verify_field_exists(field_name,
"input");
574 int new_view_size_left = field.
raw_count();
576 Kokkos::resize(
data, new_view_size_left, new_view_size_right);
577 size_t data_size = new_view_size_left * new_view_size_right *
sizeof(T);
583 T *data_array =
new T[data_size];
586 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
589 int retval = internal_get_field_data(field, data_array, data_size);
601 for (
int i = 0; i < new_view_size_left; ++i) {
602 for (
int j = 0; j < new_view_size_right; ++j) {
603 host_data(i, j) = data_array[new_view_size_right * i + j];
611 Kokkos::deep_copy(
data, host_data);
625 template <
typename T,
typename... Args>
627 Kokkos::View<T *, Args...> &
data)
const 629 typedef Kokkos::View<T *, Args...> ViewType;
631 verify_field_exists(field_name,
"output");
637 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
640 Kokkos::deep_copy(host_data,
data);
643 T *host_data_ptr = host_data.data();
649 return internal_put_field_data(field, host_data_ptr, data_size);
661 template <
typename T,
typename... Args>
663 Kokkos::View<T **, Args...> &
data)
const 665 typedef Kokkos::View<T **, Args...> ViewType;
667 verify_field_exists(field_name,
"output");
671 int view_size_left =
data.extent(0);
672 int view_size_right =
data.extent(1);
675 if (view_size_left * view_size_right *
sizeof(T) != data_size) {
676 std::ostringstream errmsg;
677 errmsg <<
"\nERROR: View dimensions are inconsistent with field raw count or raw storage " 679 <<
"for field" << field_name <<
"\n\n";
684 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
687 Kokkos::deep_copy(host_data,
data);
693 T *data_array =
new T[data_size];
701 for (
int i = 0; i < view_size_left; ++i) {
702 for (
int j = 0; j < view_size_right; ++j) {
703 data_array[view_size_right * i + j] = host_data(i, j);
711 int retval = internal_put_field_data(field, data_array, data_size);
void set_name(const std::string &new_name)
Set the name of the entity.
Definition: Ioss_GroupingEntity.h:122
std::string entityName
Definition: Ioss_GroupingEntity.h:299
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:45
A named value that has a known type.
Definition: Ioss_Property.h:47
Field get_field(const std::string &field_name) const
Get a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:397
void verify_field_exists(const std::string &field_name, const std::string &inout) const
Definition: Ioss_GroupingEntity.C:285
int64_t attributeCount
Definition: Ioss_GroupingEntity.h:303
size_t property_count() const
Get the number of properties defined in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:365
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
virtual std::string type_string() const =0
Get the name of the particular type of entity.
virtual ~GroupingEntity()
Definition: Ioss_GroupingEntity.C:80
std::string get_filename() const
Get the file name associated with the database containing this entity.
Definition: Ioss_GroupingEntity.C:121
int property_describe(NameList *names) const
Get the names of all properties in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:356
const std::string & name() const
Get name of entity.
Definition: Ioss_GroupingEntity.h:116
void property_update(const std::string &property, int64_t value) const
Definition: Ioss_GroupingEntity.C:297
int64_t entityCount
Definition: Ioss_GroupingEntity.h:290
DatabaseIO * database_
Definition: Ioss_GroupingEntity.h:301
int64_t get_int() const
Get the property value if it is of type INTEGER.
Definition: Ioss_Property.C:199
size_t field_count() const
Get the number of fields in the entity's field manager.
Definition: Ioss_GroupingEntity.h:440
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:93
RoleType
Definition: Ioss_Field.h:75
void check_type(BasicType the_type) const
Definition: Ioss_Field.C:175
void property_erase(const std::string &property_name)
Remove a property from the entity's property manager.
Definition: Ioss_GroupingEntity.h:325
Definition: Ioss_Field.h:57
void field_erase(const std::string &field_name)
Remove a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:375
virtual std::string short_type_string() const =0
Get a short name of the particular type of entity.
Property get_property(const std::string &property_name) const
Get the Property from the property manager associated with the entity.
Definition: Ioss_GroupingEntity.h:346
State
Access states for a database.
Definition: Ioss_State.h:42
int get_field_data(const std::string &field_name, void *data, size_t data_size) const
Read field data from the database file into memory using a pointer.
Definition: Ioss_GroupingEntity.C:214
bool is_alias(const std::string &my_name) const
Definition: Ioss_GroupingEntity.C:105
void add(const Property &new_prop)
Add a property to the property manager.
Definition: Ioss_PropertyManager.C:62
bool property_exists(const std::string &property_name) const
Checks if a property exists in the entity's property manager.
Definition: Ioss_GroupingEntity.h:335
virtual int64_t internal_get_field_data(const Field &field, void *data, size_t data_size=0) const =0
const Field & get_fieldref(const std::string &field_name) const
Get a reference to a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:408
void count_attributes() const
Definition: Ioss_GroupingEntity.C:262
FieldManager fields
Definition: Ioss_GroupingEntity.h:283
virtual std::string contains_string() const =0
What does this entity contain.
void really_delete_database()
Definition: Ioss_GroupingEntity.C:90
int64_t entity_count() const
Definition: Ioss_GroupingEntity.h:257
State get_state() const
Get the current Ioss::State of the entity.
Definition: Ioss_GroupingEntity.C:155
Definition: Ioss_State.h:49
void field_add(const Field &new_field)
Add a field to the entity's field manager.
Definition: Ioss_GroupingEntity.C:189
GroupingEntity & operator=(const GroupingEntity &)=delete
int component_count() const
Definition: Ioss_VariableType.h:129
bool set_state(State new_state)
Definition: Ioss_GroupingEntity.h:262
void property_add(const Property &new_prop)
Add a property to the entity's property manager.
Definition: Ioss_GroupingEntity.h:313
virtual int64_t internal_put_field_data(const Field &field, void *data, size_t data_size=0) const =0
const VariableType * raw_storage() const
Definition: Ioss_Field.h:133
size_t raw_count() const
Definition: Ioss_Field.h:136
std::vector< char > data
Definition: cth_pressure_map.C:73
virtual EntityType type() const =0
Get the EntityType, which indicates the particular type of GroupingEntity this is.
DatabaseIO * get_database() const
Definition: Ioss_GroupingEntity.C:111
void set_database(DatabaseIO *io_database)
Definition: Ioss_GroupingEntity.C:131
BasicType
The basic data type held in the field.
Definition: Ioss_Field.h:52
State entityState
Definition: Ioss_GroupingEntity.h:304
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
bool field_exists(const std::string &field_name) const
Checks if a field with a given name exists in the entity's field manager.
Definition: Ioss_GroupingEntity.h:386
virtual Property get_implicit_property(const std::string &my_name) const =0
Calculate and get an implicit property.
Definition: Ioss_GroupingEntity.C:166
virtual void delete_database()
Definition: Ioss_GroupingEntity.C:88
bool transform(void *data)
Definition: Ioss_Field.C:254
Ioss::Field::BasicType field_int_type() const
Definition: Ioss_GroupingEntity.h:246
bool has_transform() const
Definition: Ioss_Field.h:166
EntityType
The particular type of GroupingEntity.
Definition: Ioss_EntityType.h:39
int put_field_data(const std::string &field_name, void *data, size_t data_size) const
Write field data from memory into the database file using a pointer.
Definition: Ioss_GroupingEntity.C:238
std::string generic_name() const
Get a generated name based on the type of the entity and the id.
Definition: Ioss_GroupingEntity.C:96
virtual void block_membership(std::vector< std::string > &)
Get list of blocks that the entities in this GroupingEntity "touch".
Definition: Ioss_GroupingEntity.h:147
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Definition: Ioss_Field.h:58
int field_describe(NameList *names) const
Get the names of all fields in the entity's field manager.
Definition: Ioss_GroupingEntity.h:419
static Ioss::Field::BasicType get_field_type(char)
Definition: Ioss_Field.h:64
PropertyManager properties
Definition: Ioss_GroupingEntity.h:282
unsigned int hash() const
Definition: Ioss_GroupingEntity.h:255
A collection of Ioss::Field objects.
Definition: Ioss_FieldManager.h:51
#define IOSS_ERROR(errmsg)
Definition: Ioss_Utils.h:65
unsigned int hash_
Definition: Ioss_GroupingEntity.h:305
#define TOPTR(x)
Definition: Ioss_Utils.h:62