9#include "ioss_export.h"
25#ifdef SEACAS_HAVE_KOKKOS
26#include <Kokkos_Core.hpp>
83 virtual void delete_database();
106 void set_name(
const std::string &new_name) { entityName = new_name; }
164 void property_add(
const Property &new_prop);
165 void property_erase(
const std::string &property_name);
166 IOSS_NODISCARD bool property_exists(
const std::string &property_name)
const;
168 IOSS_NODISCARD int64_t get_optional_property(
const std::string &property,
169 int64_t optional_value)
const;
170 IOSS_NODISCARD std::string get_optional_property(
const std::string &property_name,
171 const std::string &optional_value)
const;
173 int property_describe(
NameList *names)
const;
179 void property_update(
const std::string &property, int64_t value)
const;
180 void property_update(
const std::string &property,
const std::string &value)
const;
186 void field_add(
Field new_field);
187 void field_erase(
const std::string &field_name);
189 IOSS_NODISCARD bool field_exists(
const std::string &field_name)
const;
192 int field_describe(
NameList *names)
const;
205 int64_t get_field_data(
const std::string &field_name,
void *data,
size_t data_size)
const;
207 int64_t
put_field_data(
const std::string &field_name,
void *data,
size_t data_size)
const;
213 int64_t get_field_data(
const std::string &field_name,
void **data,
size_t *data_size)
const;
218 template <
typename T>
219 int64_t get_field_data(
const std::string &field_name, std::vector<T> &data)
const;
221 template <
typename T>
222 int64_t
put_field_data(
const std::string &field_name,
const std::vector<T> &data)
const;
223 template <
typename T>
224 int64_t
put_field_data(
const std::string &field_name, std::vector<T> &data)
const;
226#ifdef SEACAS_HAVE_KOKKOS
232 template <
typename T,
typename... Args>
233 int64_t get_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &data)
const;
235 template <
typename T,
typename... Args>
236 int64_t get_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &data)
const;
238 template <
typename T,
typename... Args>
239 int64_t
put_field_data(
const std::string &field_name, Kokkos::View<T *, Args...> &data)
const;
241 template <
typename T,
typename... Args>
242 int64_t
put_field_data(
const std::string &field_name, Kokkos::View<T **, Args...> &data)
const;
251 if (database_ ==
nullptr || get_database()->int_byte_size_api() == 4) {
268 void count_attributes()
const;
272 entityState = new_state;
279 void really_delete_database();
294 size_t data_size = 0)
const = 0;
296 size_t data_size = 0)
const = 0;
299 size_t *data_size)
const = 0;
301 int64_t entityCount = 0;
303#if defined(IOSS_THREADSAFE)
304 mutable std::mutex m_;
310 void verify_field_exists(
const std::string &field_name,
const std::string &inout)
const;
312 std::string entityName{};
316 mutable int64_t attributeCount = 0;
318 unsigned int hash_ = 0;
340 properties.erase(property_name);
350 return properties.exists(property_name);
361 return properties.get(property_name);
365 int64_t optional_value)
const
367 return properties.get_optional(property_name, optional_value);
372 const std::string &optional_value)
const
374 return properties.get_optional(property_name, optional_value);
383 return properties.describe();
393 return properties.describe(names);
398 return properties.describe(origin);
404 return properties.describe(origin, names);
429 fields.erase(field_name);
440 return fields.exists(field_name);
451 return fields.get(field_name);
462 return fields.getref(field_name);
480 return fields.describe(names);
491 return fields.describe(role);
503 return fields.describe(role, names);
521 std::vector<T> &data)
const
523 verify_field_exists(field_name,
"input");
529 size_t data_size = data.size() *
sizeof(T);
530 auto retval = internal_get_field_data(field,
Data(data), data_size);
549 const std::vector<T> &data)
const
551 verify_field_exists(field_name,
"output");
555 size_t data_size = data.size() *
sizeof(T);
558 std::vector<T> nc_data(data);
560 return internal_put_field_data(field,
Data(nc_data), data_size);
563 T *my_data =
const_cast<T *
>(
Data(data));
564 return internal_put_field_data(field, my_data, data_size);
569 std::vector<T> &data)
const
571 verify_field_exists(field_name,
"output");
575 size_t data_size = data.size() *
sizeof(T);
576 T *my_data =
const_cast<T *
>(
Data(data));
578 return internal_put_field_data(field, my_data, data_size);
581#ifdef SEACAS_HAVE_KOKKOS
592template <
typename T,
typename... Args>
594 Kokkos::View<T *, Args...> &data)
const
596 typedef Kokkos::View<T *, Args...> ViewType;
598 verify_field_exists(field_name,
"input");
604 Kokkos::resize(data, new_view_size);
605 size_t data_size = new_view_size *
sizeof(T);
608 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
611 T *host_data_ptr = host_data.data();
614 auto retval = internal_get_field_data(field, host_data_ptr, data_size);
621 Kokkos::deep_copy(data, host_data);
635template <
typename T,
typename... Args>
637 Kokkos::View<T **, Args...> &data)
const
639 typedef Kokkos::View<T **, Args...> ViewType;
641 verify_field_exists(field_name,
"input");
646 int new_view_size_left = field.
raw_count();
648 Kokkos::resize(data, new_view_size_left, new_view_size_right);
649 size_t data_size = new_view_size_left * new_view_size_right *
sizeof(T);
655 T *data_array =
new T[data_size];
658 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
661 auto retval = internal_get_field_data(field, data_array, data_size);
673 for (
int i = 0; i < new_view_size_left; ++i) {
674 for (
int j = 0; j < new_view_size_right; ++j) {
675 host_data(i, j) = data_array[new_view_size_right * i + j];
683 Kokkos::deep_copy(data, host_data);
697template <
typename T,
typename... Args>
699 Kokkos::View<T *, Args...> &data)
const
701 typedef Kokkos::View<T *, Args...> ViewType;
703 verify_field_exists(field_name,
"output");
709 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
712 Kokkos::deep_copy(host_data, data);
715 T *host_data_ptr = host_data.data();
721 return internal_put_field_data(field, host_data_ptr, data_size);
733template <
typename T,
typename... Args>
735 Kokkos::View<T **, Args...> &data)
const
737 typedef Kokkos::View<T **, Args...> ViewType;
739 verify_field_exists(field_name,
"output");
743 int view_size_left =
data.extent(0);
744 int view_size_right =
data.extent(1);
747 if (view_size_left * view_size_right *
sizeof(T) != data_size) {
748 std::ostringstream errmsg;
749 errmsg <<
"\nERROR: View dimensions are inconsistent with field raw count or raw storage "
751 <<
"for field" << field_name <<
"\n\n";
756 typename ViewType::HostMirror host_data = Kokkos::create_mirror_view(data);
759 Kokkos::deep_copy(host_data, data);
773 for (
int i = 0; i < view_size_left; ++i) {
774 for (
int j = 0; j < view_size_right; ++j) {
775 data_array[view_size_right * i + j] = host_data(i, j);
783 auto retval = internal_put_field_data(field, data_array, data_size);
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
IOSS_NODISCARD constexpr T * Data(std::vector< T > &vec)
Definition Ioss_Utils.h:56
void IOSS_ERROR(const std::ostringstream &errmsg)
Definition Ioss_Utils.h:38
void put_field_data(std::string field_name, int local_size, size_t component_count, Entity *e)
Definition Ut_ioad.C:276
An input or output Database.
Definition Ioss_DatabaseIO.h:63
A collection of Ioss::Field objects.
Definition Ioss_FieldManager.h:35
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
IOSS_NODISCARD const VariableType * raw_storage() const
Definition Ioss_Field.h:168
IOSS_NODISCARD bool has_transform() const
Definition Ioss_Field.h:220
BasicType
The basic data type held in the field.
Definition Ioss_Field.h:29
@ INT64
Definition Ioss_Field.h:35
@ INT32
Definition Ioss_Field.h:34
IOSS_NODISCARD size_t raw_count() const
Definition Ioss_Field.h:171
RoleType
Definition Ioss_Field.h:69
bool transform(void *data)
Definition Ioss_Field.C:309
void check_type(BasicType the_type) const
Definition Ioss_Field.C:201
static IOSS_NODISCARD Ioss::Field::BasicType get_field_type(char)
Definition Ioss_Field.h:43
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
virtual IOSS_NODISCARD std::string short_type_string() const =0
Get a short name of the particular type of entity.
virtual int64_t internal_get_field_data(const Field &field, void *data, size_t data_size=0) const =0
IOSS_NODISCARD Ioss::Field::BasicType field_int_type() const
Definition Ioss_GroupingEntity.h:249
virtual IOSS_NODISCARD EntityType type() const =0
Get the EntityType, which indicates the particular type of GroupingEntity this is.
FieldManager fields
Definition Ioss_GroupingEntity.h:291
virtual IOSS_NODISCARD std::string type_string() const =0
Get the name of the particular type of entity.
IOSS_NODISCARD int64_t get_optional_property(const std::string &property, int64_t optional_value) const
Definition Ioss_GroupingEntity.h:364
IOSS_NODISCARD NameList property_describe() const
Get the names of all properties in the property manager for this entity.
Definition Ioss_GroupingEntity.h:381
IOSS_NODISCARD Property get_property(const std::string &property_name) const
Get the Property from the property manager associated with the entity.
Definition Ioss_GroupingEntity.h:359
GroupingEntity & operator=(const GroupingEntity &rhs)=delete
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:254
IOSS_NODISCARD Field get_field(const std::string &field_name) const
Get a field from the entity's field manager.
Definition Ioss_GroupingEntity.h:449
IOSS_NODISCARD 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:438
IOSS_NODISCARD unsigned int hash() const
Definition Ioss_GroupingEntity.h:258
IOSS_NODISCARD int64_t entity_count() const
Definition Ioss_GroupingEntity.h:260
virtual int64_t internal_put_field_data(const Field &field, void *data, size_t data_size=0) const =0
void field_erase(const std::string &field_name)
Remove a field from the entity's field manager.
Definition Ioss_GroupingEntity.h:427
PropertyManager properties
Definition Ioss_GroupingEntity.h:290
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:302
IOSS_NODISCARD 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:460
IOSS_NODISCARD const std::string & name() const
Get name of entity.
Definition Ioss_GroupingEntity.h:100
bool set_state(State new_state)
Definition Ioss_GroupingEntity.h:270
void property_add(const Property &new_prop)
Add a property to the entity's property manager.
Definition Ioss_GroupingEntity.h:326
void property_erase(const std::string &property_name)
Remove a property from the entity's property manager.
Definition Ioss_GroupingEntity.h:338
IOSS_NODISCARD size_t property_count() const
Get the number of properties defined in the property manager for this entity.
Definition Ioss_GroupingEntity.h:411
virtual void block_membership(Ioss::NameList &)
Get list of blocks that the entities in this GroupingEntity "touch".
Definition Ioss_GroupingEntity.h:131
IOSS_NODISCARD size_t field_count() const
Get the number of fields in the entity's field manager.
Definition Ioss_GroupingEntity.h:510
virtual IOSS_NODISCARD std::string contains_string() const =0
What does this entity contain.
void set_name(const std::string &new_name)
Set the name of the entity.
Definition Ioss_GroupingEntity.h:106
IOSS_NODISCARD bool property_exists(const std::string &property_name) const
Checks if a property exists in the entity's property manager.
Definition Ioss_GroupingEntity.h:348
virtual int64_t internal_get_zc_field_data(const Field &field, void **data, size_t *data_size) const =0
IOSS_NODISCARD NameList field_describe() const
Get the names of all fields in the entity's field manager.
Definition Ioss_GroupingEntity.h:470
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
void add(const Property &new_prop)
Add a property to the property manager.
Definition Ioss_PropertyManager.C:21
A named value that has a known type.
Definition Ioss_Property.h:27
Origin
Definition Ioss_Property.h:30
IOSS_NODISCARD int component_count() const
Definition Ioss_VariableType.h:154
size_t data_size(const Ioss::Field &f)
Definition Iofaodel_FieldSerialization.C:17
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
State
Access states for a database.
Definition Ioss_State.h:15
@ STATE_CLOSED
Definition Ioss_State.h:22
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
EntityType
The particular type of GroupingEntity.
Definition Ioss_EntityType.h:12
std::vector< char > data
Definition cth_pressure_map.C:46