Go to the documentation of this file.
33 #ifndef IOSS_Ioss_GroupingEntity_h
34 #define IOSS_Ioss_GroupingEntity_h
50 #ifdef SEACAS_HAVE_KOKKOS
51 #include <Kokkos_Core.hpp>
147 bool is_alias(
const std::string &my_name)
const;
198 void property_update(
const std::string &property, int64_t value)
const;
199 void property_update(
const std::string &property,
const std::string &value)
const;
218 int64_t
get_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
220 int64_t
put_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
225 template <
typename T>
228 template <
typename T>
229 int64_t
put_field_data(
const std::string &field_name,
const std::vector<T> &
data)
const;
230 template <
typename T>
233 #ifdef SEACAS_HAVE_KOKKOS
239 template <
typename T,
typename... Args>
240 int64_t
get_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &
data)
const;
242 template <
typename T,
typename... Args>
243 int64_t
get_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &
data)
const;
245 template <
typename T,
typename... Args>
246 int64_t
put_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &
data)
const;
248 template <
typename T,
typename... Args>
249 int64_t
put_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &
data)
const;
296 size_t data_size = 0)
const = 0;
298 size_t data_size = 0)
const = 0;
302 #if defined(IOSS_THREADSAFE)
303 mutable std::mutex m_;
337 properties.erase(property_name);
347 return properties.exists(property_name);
358 return properties.get(property_name);
368 return properties.describe(names);
387 fields.erase(field_name);
398 return fields.exists(field_name);
409 return fields.get(field_name);
420 return fields.getref(field_name);
431 return fields.describe(names);
443 return fields.describe(role, names);
459 template <
typename T>
461 std::vector<T> &
data)
const
463 verify_field_exists(field_name,
"input");
469 size_t data_size =
data.size() *
sizeof(T);
470 auto retval = internal_get_field_data(field,
TOPTR(
data), data_size);
487 template <
typename T>
489 const std::vector<T> &
data)
const
491 verify_field_exists(field_name,
"output");
495 size_t data_size =
data.size() *
sizeof(T);
498 std::vector<T> nc_data(
data);
500 return internal_put_field_data(field, nc_data.data(), data_size);
503 T *my_data = const_cast<T *>(
data.data());
504 return internal_put_field_data(field, my_data, data_size);
507 template <
typename T>
509 std::vector<T> &
data)
const
511 verify_field_exists(field_name,
"output");
515 size_t data_size =
data.size() *
sizeof(T);
516 T * my_data = const_cast<T *>(
data.data());
518 return internal_put_field_data(field, my_data, data_size);
521 #ifdef SEACAS_HAVE_KOKKOS
532 template <
typename T,
typename... Args>
534 Kokkos::View<T *, Args...> &
data)
const
536 typedef Kokkos::View<T *, Args...> ViewType;
538 verify_field_exists(field_name,
"input");
544 Kokkos::resize(
data, new_view_size);
545 size_t data_size = new_view_size *
sizeof(T);
548 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
551 T *host_data_ptr = host_data.data();
554 auto retval = internal_get_field_data(field, host_data_ptr, data_size);
561 Kokkos::deep_copy(
data, host_data);
575 template <
typename T,
typename... Args>
577 Kokkos::View<T **, Args...> &
data)
const
579 typedef Kokkos::View<T **, Args...> ViewType;
581 verify_field_exists(field_name,
"input");
586 int new_view_size_left = field.
raw_count();
588 Kokkos::resize(
data, new_view_size_left, new_view_size_right);
589 size_t data_size = new_view_size_left * new_view_size_right *
sizeof(T);
595 T *data_array =
new T[data_size];
598 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
601 auto retval = internal_get_field_data(field, data_array, data_size);
613 for (
int i = 0; i < new_view_size_left; ++i) {
614 for (
int j = 0; j < new_view_size_right; ++j) {
615 host_data(i, j) = data_array[new_view_size_right * i + j];
623 Kokkos::deep_copy(
data, host_data);
637 template <
typename T,
typename... Args>
639 Kokkos::View<T *, Args...> &
data)
const
641 typedef Kokkos::View<T *, Args...> ViewType;
643 verify_field_exists(field_name,
"output");
649 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
652 Kokkos::deep_copy(host_data,
data);
655 T *host_data_ptr = host_data.data();
661 return internal_put_field_data(field, host_data_ptr, data_size);
673 template <
typename T,
typename... Args>
675 Kokkos::View<T **, Args...> &
data)
const
677 typedef Kokkos::View<T **, Args...> ViewType;
679 verify_field_exists(field_name,
"output");
683 int view_size_left =
data.extent(0);
684 int view_size_right =
data.extent(1);
687 if (view_size_left * view_size_right *
sizeof(T) != data_size) {
688 std::ostringstream errmsg;
689 errmsg <<
"\nERROR: View dimensions are inconsistent with field raw count or raw storage "
691 <<
"for field" << field_name <<
"\n\n";
696 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(
data);
699 Kokkos::deep_copy(host_data,
data);
705 T *data_array =
new T[data_size];
713 for (
int i = 0; i < view_size_left; ++i) {
714 for (
int j = 0; j < view_size_right; ++j) {
715 data_array[view_size_right * i + j] = host_data(i, j);
723 auto retval = internal_put_field_data(field, data_array, data_size);
bool is_alias(const std::string &my_name) const
Definition: Ioss_GroupingEntity.C:111
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:53
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
void really_delete_database()
Definition: Ioss_GroupingEntity.C:88
virtual std::string contains_string() const =0
What does this entity contain.
bool set_state(State new_state)
Definition: Ioss_GroupingEntity.h:272
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:418
State entityState
Definition: Ioss_GroupingEntity.h:314
virtual const GroupingEntity * contained_in() const
Definition: Ioss_GroupingEntity.C:94
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:167
A collection of Ioss::Field objects.
Definition: Ioss_FieldManager.h:51
static Ioss::Field::BasicType get_field_type(char)
Definition: Ioss_Field.h:64
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
void field_add(const Field &new_field)
Add a field to the entity's field manager.
Definition: Ioss_GroupingEntity.C:195
State
Access states for a database.
Definition: Ioss_State.h:42
PropertyManager properties
Definition: Ioss_GroupingEntity.h:292
unsigned int hash_
Definition: Ioss_GroupingEntity.h:315
void property_add(const Property &new_prop)
Add a property to the entity's property manager.
Definition: Ioss_GroupingEntity.h:323
void check_type(BasicType the_type) const
Definition: Ioss_Field.C:175
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:254
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
virtual Property get_implicit_property(const std::string &my_name) const =0
Calculate and get an implicit property.
Definition: Ioss_GroupingEntity.C:172
Definition: Ioss_Field.h:58
void set_database(DatabaseIO *io_database)
Definition: Ioss_GroupingEntity.C:137
EntityType
The particular type of GroupingEntity.
Definition: Ioss_EntityType.h:39
Ioss::Field::BasicType field_int_type() const
Definition: Ioss_GroupingEntity.h:256
DatabaseIO * get_database() const
Definition: Ioss_GroupingEntity.C:117
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:396
virtual void delete_database()
Definition: Ioss_GroupingEntity.C:86
virtual void block_membership(std::vector< std::string > &)
Get list of blocks that the entities in this GroupingEntity "touch".
Definition: Ioss_GroupingEntity.h:157
void verify_field_exists(const std::string &field_name, const std::string &inout) const
Definition: Ioss_GroupingEntity.C:299
std::string generic_name() const
Get a generated name based on the type of the entity and the id.
Definition: Ioss_GroupingEntity.C:102
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:429
void set_name(const std::string &new_name)
Set the name of the entity.
Definition: Ioss_GroupingEntity.h:132
std::string get_filename() const
Get the file name associated with the database containing this entity.
Definition: Ioss_GroupingEntity.C:127
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
int64_t attributeCount
Definition: Ioss_GroupingEntity.h:313
#define IOSS_ERROR(errmsg)
Definition: Ioss_Utils.h:65
size_t property_count() const
Get the number of properties defined in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:375
void add(const Property &new_prop)
Add a property to the property manager.
Definition: Ioss_PropertyManager.C:62
void property_erase(const std::string &property_name)
Remove a property from the entity's property manager.
Definition: Ioss_GroupingEntity.h:335
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:385
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:228
int property_describe(NameList *names) const
Get the names of all properties in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:366
unsigned int hash() const
Definition: Ioss_GroupingEntity.h:265
void property_update(const std::string &property, int64_t value) const
Definition: Ioss_GroupingEntity.C:311
DatabaseIO * database_
Definition: Ioss_GroupingEntity.h:311
int64_t get_int() const
Get the property value if it is of type INTEGER.
Definition: Ioss_Property.C:188
size_t raw_count() const
Definition: Ioss_Field.h:137
std::string entityName
Definition: Ioss_GroupingEntity.h:309
Field get_field(const std::string &field_name) const
Get a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:407
#define TOPTR(x)
Definition: Ioss_Utils.h:62
Definition: Ioss_Field.h:57
Property get_property(const std::string &property_name) const
Get the Property from the property manager associated with the entity.
Definition: Ioss_GroupingEntity.h:356
std::vector< char > data
Definition: cth_pressure_map.C:74
const std::string & name() const
Get name of entity.
Definition: Ioss_GroupingEntity.h:126
bool property_exists(const std::string &property_name) const
Checks if a property exists in the entity's property manager.
Definition: Ioss_GroupingEntity.h:345
virtual ~GroupingEntity()
Definition: Ioss_GroupingEntity.C:78
int64_t entityCount
Definition: Ioss_GroupingEntity.h:300
const VariableType * raw_storage() const
Definition: Ioss_Field.h:134
size_t field_count() const
Get the number of fields in the entity's field manager.
Definition: Ioss_GroupingEntity.h:450
BasicType
The basic data type held in the field.
Definition: Ioss_Field.h:52
Definition: Ioss_State.h:49
RoleType
Definition: Ioss_Field.h:75
void count_attributes() const
Definition: Ioss_GroupingEntity.C:276
int64_t entity_count() const
Definition: Ioss_GroupingEntity.h:267
A named value that has a known type.
Definition: Ioss_Property.h:47
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:252
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:93
GroupingEntity & operator=(const GroupingEntity &)=delete
State get_state() const
Get the current Ioss::State of the entity.
Definition: Ioss_GroupingEntity.C:161
FieldManager fields
Definition: Ioss_GroupingEntity.h:293
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:129