Go to the documentation of this file.
7 #ifndef IOSS_Ioss_GroupingEntity_h
8 #define IOSS_Ioss_GroupingEntity_h
24 #ifdef SEACAS_HAVE_KOKKOS
25 #include <Kokkos_Core.hpp>
122 bool is_alias(
const std::string &my_name)
const;
174 void property_update(
const std::string &property, int64_t value)
const;
175 void property_update(
const std::string &property,
const std::string &value)
const;
194 int64_t
get_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
196 int64_t
put_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
201 template <
typename T>
204 template <
typename T>
205 int64_t
put_field_data(
const std::string &field_name,
const std::vector<T> &
data)
const;
206 template <
typename T>
209 #ifdef SEACAS_HAVE_KOKKOS
215 template <
typename T,
typename... Args>
216 int64_t
get_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &
data)
const;
218 template <
typename T,
typename... Args>
219 int64_t
get_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &
data)
const;
221 template <
typename T,
typename... Args>
222 int64_t
put_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &
data)
const;
224 template <
typename T,
typename... Args>
225 int64_t
put_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &
data)
const;
272 size_t data_size = 0)
const = 0;
274 size_t data_size = 0)
const = 0;
278 #if defined(IOSS_THREADSAFE)
279 mutable std::mutex m_;
313 properties.erase(property_name);
323 return properties.exists(property_name);
334 return properties.get(property_name);
344 return properties.describe(names);
350 return properties.describe(origin, names);
369 fields.erase(field_name);
380 return fields.exists(field_name);
391 return fields.get(field_name);
402 return fields.getref(field_name);
413 return fields.describe(names);
425 return fields.describe(role, names);
441 template <
typename T>
443 std::vector<T> &
data)
const
445 verify_field_exists(field_name,
"input");
451 size_t data_size =
data.size() *
sizeof(T);
452 auto retval = internal_get_field_data(field,
data.data(), data_size);
469 template <
typename T>
471 const std::vector<T> &
data)
const
473 verify_field_exists(field_name,
"output");
477 size_t data_size =
data.size() *
sizeof(T);
480 std::vector<T> nc_data(
data);
482 return internal_put_field_data(field, nc_data.data(), data_size);
485 T *my_data =
const_cast<T *
>(
data.data());
486 return internal_put_field_data(field, my_data, data_size);
489 template <
typename T>
491 std::vector<T> &
data)
const
493 verify_field_exists(field_name,
"output");
497 size_t data_size =
data.size() *
sizeof(T);
498 T * my_data =
const_cast<T *
>(
data.data());
500 return internal_put_field_data(field, my_data, data_size);
503 #ifdef SEACAS_HAVE_KOKKOS
514 template <
typename T,
typename... Args>
516 Kokkos::View<T *, Args...> &
data)
const
518 typedef Kokkos::View<T *, Args...> ViewType;
520 verify_field_exists(field_name,
"input");
526 Kokkos::resize(
data, new_view_size);
527 size_t data_size = new_view_size *
sizeof(T);
530 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
533 T *host_data_ptr = host_data.data();
536 auto retval = internal_get_field_data(field, host_data_ptr, data_size);
543 Kokkos::deep_copy(
data, host_data);
557 template <
typename T,
typename... Args>
559 Kokkos::View<T **, Args...> &
data)
const
561 typedef Kokkos::View<T **, Args...> ViewType;
563 verify_field_exists(field_name,
"input");
568 int new_view_size_left = field.
raw_count();
570 Kokkos::resize(
data, new_view_size_left, new_view_size_right);
571 size_t data_size = new_view_size_left * new_view_size_right *
sizeof(T);
577 T *data_array =
new T[data_size];
580 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
583 auto retval = internal_get_field_data(field, data_array, data_size);
595 for (
int i = 0; i < new_view_size_left; ++i) {
596 for (
int j = 0; j < new_view_size_right; ++j) {
597 host_data(i, j) = data_array[new_view_size_right * i + j];
605 Kokkos::deep_copy(
data, host_data);
619 template <
typename T,
typename... Args>
621 Kokkos::View<T *, Args...> &
data)
const
623 typedef Kokkos::View<T *, Args...> ViewType;
625 verify_field_exists(field_name,
"output");
631 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
634 Kokkos::deep_copy(host_data,
data);
637 T *host_data_ptr = host_data.data();
643 return internal_put_field_data(field, host_data_ptr, data_size);
655 template <
typename T,
typename... Args>
657 Kokkos::View<T **, Args...> &
data)
const
659 typedef Kokkos::View<T **, Args...> ViewType;
661 verify_field_exists(field_name,
"output");
665 int view_size_left =
data.extent(0);
666 int view_size_right =
data.extent(1);
669 if (view_size_left * view_size_right *
sizeof(T) != data_size) {
670 std::ostringstream errmsg;
671 errmsg <<
"\nERROR: View dimensions are inconsistent with field raw count or raw storage "
673 <<
"for field" << field_name <<
"\n\n";
678 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
681 Kokkos::deep_copy(host_data,
data);
687 T *data_array =
new T[data_size];
695 for (
int i = 0; i < view_size_left; ++i) {
696 for (
int j = 0; j < view_size_right; ++j) {
697 data_array[view_size_right * i + j] = host_data(i, j);
705 auto retval = internal_put_field_data(field, data_array, data_size);
bool is_alias(const std::string &my_name) const
Definition: Ioss_GroupingEntity.C:92
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:27
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:22
void really_delete_database()
Definition: Ioss_GroupingEntity.C:69
virtual std::string contains_string() const =0
What does this entity contain.
bool set_state(State new_state)
Definition: Ioss_GroupingEntity.h:248
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:400
State entityState
Definition: Ioss_GroupingEntity.h:290
virtual const GroupingEntity * contained_in() const
Definition: Ioss_GroupingEntity.C:75
virtual EntityType type() const =0
Get the EntityType, which indicates the particular type of GroupingEntity this is.
bool has_transform() const
Definition: Ioss_Field.h:146
A collection of Ioss::Field objects.
Definition: Ioss_FieldManager.h:26
static Ioss::Field::BasicType get_field_type(char)
Definition: Ioss_Field.h:38
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
State
Access states for a database.
Definition: Ioss_State.h:16
PropertyManager properties
Definition: Ioss_GroupingEntity.h:268
unsigned int hash_
Definition: Ioss_GroupingEntity.h:291
void property_add(const Property &new_prop)
Add a property to the entity's property manager.
Definition: Ioss_GroupingEntity.h:299
void check_type(BasicType the_type) const
Definition: Ioss_Field.C:149
virtual int64_t internal_put_field_data(const Field &field, void *data, size_t data_size=0) const =0
bool transform(void *data)
Definition: Ioss_Field.C:228
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:24
virtual Property get_implicit_property(const std::string &my_name) const =0
Calculate and get an implicit property.
Definition: Ioss_GroupingEntity.C:159
@ INT64
Definition: Ioss_Field.h:32
void set_database(DatabaseIO *io_database)
Definition: Ioss_GroupingEntity.C:118
EntityType
The particular type of GroupingEntity.
Definition: Ioss_EntityType.h:13
Ioss::Field::BasicType field_int_type() const
Definition: Ioss_GroupingEntity.h:232
DatabaseIO * get_database() const
Definition: Ioss_GroupingEntity.C:98
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:378
virtual void delete_database()
Definition: Ioss_GroupingEntity.C:67
virtual void block_membership(std::vector< std::string > &)
Get list of blocks that the entities in this GroupingEntity "touch".
Definition: Ioss_GroupingEntity.h:132
void verify_field_exists(const std::string &field_name, const std::string &inout) const
Definition: Ioss_GroupingEntity.C:291
std::string generic_name() const
Get a generated name based on the type of the entity and the id.
Definition: Ioss_GroupingEntity.C:83
virtual std::string type_string() const =0
Get the name of the particular type of entity.
int field_describe(NameList *names) const
Get the names of all fields in the entity's field manager.
Definition: Ioss_GroupingEntity.h:411
void set_name(const std::string &new_name)
Set the name of the entity.
Definition: Ioss_GroupingEntity.h:107
std::string get_filename() const
Get the file name associated with the database containing this entity.
Definition: Ioss_GroupingEntity.C:108
An input or output Database.
Definition: Ioss_DatabaseIO.h:59
int64_t attributeCount
Definition: Ioss_GroupingEntity.h:289
#define IOSS_ERROR(errmsg)
Definition: Ioss_Utils.h:32
size_t property_count() const
Get the number of properties defined in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:357
void add(const Property &new_prop)
Add a property to the property manager.
Definition: Ioss_PropertyManager.C:36
void property_erase(const std::string &property_name)
Remove a property from the entity's property manager.
Definition: Ioss_GroupingEntity.h:311
virtual std::string short_type_string() const =0
Get a short name of the particular type of entity.
void field_erase(const std::string &field_name)
Remove a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:367
int64_t 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:220
int property_describe(NameList *names) const
Get the names of all properties in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:342
unsigned int hash() const
Definition: Ioss_GroupingEntity.h:241
void property_update(const std::string &property, int64_t value) const
Definition: Ioss_GroupingEntity.C:303
DatabaseIO * database_
Definition: Ioss_GroupingEntity.h:287
int64_t get_int() const
Get the property value if it is of type INTEGER.
Definition: Ioss_Property.C:235
size_t raw_count() const
Definition: Ioss_Field.h:116
std::string entityName
Definition: Ioss_GroupingEntity.h:285
Field get_field(const std::string &field_name) const
Get a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:389
@ INT32
Definition: Ioss_Field.h:31
Property get_property(const std::string &property_name) const
Get the Property from the property manager associated with the entity.
Definition: Ioss_GroupingEntity.h:332
Origin
Definition: Ioss_Property.h:27
std::vector< char > data
Definition: cth_pressure_map.C:48
const std::string & name() const
Get name of entity.
Definition: Ioss_GroupingEntity.h:101
bool property_exists(const std::string &property_name) const
Checks if a property exists in the entity's property manager.
Definition: Ioss_GroupingEntity.h:321
virtual ~GroupingEntity()
Definition: Ioss_GroupingEntity.C:59
int64_t entityCount
Definition: Ioss_GroupingEntity.h:276
const VariableType * raw_storage() const
Definition: Ioss_Field.h:113
size_t field_count() const
Get the number of fields in the entity's field manager.
Definition: Ioss_GroupingEntity.h:432
void reset_database(DatabaseIO *io_database)
Definition: Ioss_GroupingEntity.C:125
void field_add(Field new_field)
Add a field to the entity's field manager.
Definition: Ioss_GroupingEntity.C:182
BasicType
The basic data type held in the field.
Definition: Ioss_Field.h:26
@ STATE_CLOSED
Definition: Ioss_State.h:23
RoleType
Definition: Ioss_Field.h:49
void count_attributes() const
Definition: Ioss_GroupingEntity.C:268
int64_t entity_count() const
Definition: Ioss_GroupingEntity.h:243
A named value that has a known type.
Definition: Ioss_Property.h:24
int64_t 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:244
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:68
GroupingEntity & operator=(const GroupingEntity &)=delete
State get_state() const
Get the current Ioss::State of the entity.
Definition: Ioss_GroupingEntity.C:148
FieldManager fields
Definition: Ioss_GroupingEntity.h:269
virtual int64_t internal_get_field_data(const Field &field, void *data, size_t data_size=0) const =0
int component_count() const
Definition: Ioss_VariableType.h:103