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;
184 void property_update(
const std::string &property, int64_t value)
const;
185 void property_update(
const std::string &property,
const std::string &value)
const;
204 int get_field_data(
const std::string &field_name,
void *
data,
size_t data_size)
const;
206 int put_field_data(
const std::string &field_name,
void *data,
size_t data_size)
const;
211 template <
typename T>
212 int get_field_data(
const std::string &field_name, std::vector<T> &data)
const;
214 template <
typename T>
215 int put_field_data(
const std::string &field_name,
const std::vector<T> &data)
const;
216 template <
typename T>
217 int put_field_data(
const std::string &field_name, std::vector<T> &data)
const;
219 #ifdef SEACAS_HAVE_KOKKOS 225 template <
typename T,
typename... Args>
226 int get_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &data)
const;
228 template <
typename T,
typename... Args>
229 int get_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &data)
const;
231 template <
typename T,
typename... Args>
232 int put_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &data)
const;
234 template <
typename T,
typename... Args>
235 int put_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &data)
const;
282 size_t data_size = 0)
const = 0;
284 size_t data_size = 0)
const = 0;
288 #if defined(IOSS_THREADSAFE) 289 mutable std::mutex m_;
445 template <
typename T>
454 size_t data_size = data.size() *
sizeof(T);
472 template <
typename T>
474 const std::vector<T> &
data)
const 480 size_t data_size = data.size() *
sizeof(T);
483 std::vector<T> nc_data(data);
488 T *my_data =
const_cast<T *
>(data.data());
492 template <
typename T>
499 size_t data_size = data.size() *
sizeof(T);
500 T * my_data =
const_cast<T *
>(data.data());
505 #ifdef SEACAS_HAVE_KOKKOS 516 template <
typename T,
typename... Args>
518 Kokkos::View<T *, Args...> &
data)
const 520 typedef Kokkos::View<T *, Args...> ViewType;
528 Kokkos::resize(data, new_view_size);
529 size_t data_size = new_view_size *
sizeof(T);
532 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
537 T *host_data_ptr = host_data.ptr_on_device();
547 Kokkos::deep_copy(data, host_data);
561 template <
typename T,
typename... Args>
563 Kokkos::View<T **, Args...> &
data)
const 565 typedef Kokkos::View<T **, Args...> ViewType;
572 int new_view_size_left = field.
raw_count();
574 Kokkos::resize(data, new_view_size_left, new_view_size_right);
575 size_t data_size = new_view_size_left * new_view_size_right *
sizeof(T);
581 T *data_array =
new T[data_size];
584 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
599 for (
int i = 0; i < new_view_size_left; ++i) {
600 for (
int j = 0; j < new_view_size_right; ++j) {
601 host_data(i, j) = data_array[new_view_size_right * i + j];
609 Kokkos::deep_copy(data, host_data);
623 template <
typename T,
typename... Args>
625 Kokkos::View<T *, Args...> &
data)
const 627 typedef Kokkos::View<T *, Args...> ViewType;
635 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
638 Kokkos::deep_copy(host_data, data);
643 T *host_data_ptr = host_data.ptr_on_device();
661 template <
typename T,
typename... Args>
663 Kokkos::View<T **, Args...> &
data)
const 665 typedef Kokkos::View<T **, Args...> ViewType;
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);
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:295
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:44
A named value that has a known type.
Definition: Ioss_Property.h:47
int describe(NameList *names) const
Get the names of all properties in the property manager.
Definition: Ioss_PropertyManager.C:121
Field get_field(const std::string &field_name) const
Get a field from the entity's field manager.
Definition: Ioss_GroupingEntity.h:393
void erase(const std::string &field_name)
Remove a field from the field manager.
Definition: Ioss_FieldManager.C:106
void verify_field_exists(const std::string &field_name, const std::string &inout) const
Definition: Ioss_GroupingEntity.C:286
Property get(const std::string &property_name) const
Get a property object from the property manager.
Definition: Ioss_PropertyManager.C:88
int64_t attributeCount
Definition: Ioss_GroupingEntity.h:299
size_t property_count() const
Get the number of properties defined in the property manager for this entity.
Definition: Ioss_GroupingEntity.h:361
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
An input or output Database.
Definition: Ioss_DatabaseIO.h:80
bool exists(const std::string &property_name) const
Checks if a property exists in the database.
Definition: Ioss_PropertyManager.C:77
virtual std::string type_string() const =0
Get the name of the particular type of entity.
virtual ~GroupingEntity()
Definition: Ioss_GroupingEntity.C:79
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:352
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:299
int64_t entityCount
Definition: Ioss_GroupingEntity.h:286
DatabaseIO * database_
Definition: Ioss_GroupingEntity.h:297
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:436
Base class for all 'grouping' entities. The following derived classes are typical: ...
Definition: Ioss_GroupingEntity.h:93
RoleType
Definition: Ioss_Field.h:75
const Field & getref(const std::string &field_name) const
Get a reference to a field from the field manager.
Definition: Ioss_FieldManager.C:91
void check_type(BasicType the_type) const
Definition: Ioss_Field.C:172
void property_erase(const std::string &property_name)
Remove a property from the entity's property manager.
Definition: Ioss_GroupingEntity.h:321
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:371
virtual std::string short_type_string() const =0
Get a short name of the particular type of entity.
Field get(const std::string &field_name) const
Get a field from the field manager.
Definition: Ioss_FieldManager.C:76
Property get_property(const std::string &property_name) const
Get the Property from the property manager associated with the entity.
Definition: Ioss_GroupingEntity.h:342
int describe(NameList *names) const
Get the names of all fields in the field manager.
Definition: Ioss_FieldManager.C:123
void erase(const std::string &property_name)
Remove a property from the property manager.
Definition: Ioss_PropertyManager.C:107
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:215
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:331
virtual int64_t internal_get_field_data(const Field &field, void *data, size_t data_size=0) const =0
size_t count() const
Get the number of fields in the field manager.
Definition: Ioss_FieldManager.C:164
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:404
void count_attributes() const
Definition: Ioss_GroupingEntity.C:263
FieldManager fields
Definition: Ioss_GroupingEntity.h:279
size_t count() const
Definition: Ioss_PropertyManager.C:137
bool exists(const std::string &field_name) const
Checks if a field with a given name exists in the field manager.
Definition: Ioss_FieldManager.C:63
void really_delete_database()
Definition: Ioss_GroupingEntity.C:89
int64_t entity_count() const
Definition: Ioss_GroupingEntity.h:253
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:136
bool set_state(State new_state)
Definition: Ioss_GroupingEntity.h:258
void property_add(const Property &new_prop)
Add a property to the entity's property manager.
Definition: Ioss_GroupingEntity.h:309
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
virtual void block_membership(std::vector< std::string > &block_members)
Get list of blocks that the entities in this GroupingEntity "touch".
Definition: Ioss_GroupingEntity.h:149
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:300
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:382
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:87
bool transform(void *data)
Definition: Ioss_Field.C:251
Ioss::Field::BasicType field_int_type() const
Definition: Ioss_GroupingEntity.h:242
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:239
std::string generic_name() const
Get a generated name based on the type of the entity and the id.
Definition: Ioss_GroupingEntity.C:96
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:415
std::vector< char > data
Definition: Ioss_Utils.C:78
static Ioss::Field::BasicType get_field_type(char)
Definition: Ioss_Field.h:64
PropertyManager properties
Definition: Ioss_GroupingEntity.h:278
unsigned int hash() const
Definition: Ioss_GroupingEntity.h:251
A collection of Ioss::Field objects.
Definition: Ioss_FieldManager.h:51
#define IOSS_ERROR(errmsg)
Definition: Ioss_Utils.h:64
unsigned int hash_
Definition: Ioss_GroupingEntity.h:301
#define TOPTR(x)
Definition: Ioss_Utils.h:61