Debian Codegraph @

packages/seacas/libraries/ioss/src/adios/Ioad_Helper.h

raw
1 // Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6
7 #pragma once
8
9 #include "ioad_export.h"
10
11 #include <map>
12 #include <set>
13 #include <string>
14
15 #include "Ioss_GroupingEntity.h" // for GroupingEntity
16 #include "Ioss_SideSet.h" // for SideBlockContainer, SideSet
17
18 namespace Ioad {
19
20 template <typename T>
21 using DerivedFromIossGroupingEntity =
22 typename std::enable_if<std::is_base_of<Ioss::GroupingEntity, T>::value, bool>::type;
23
24 template <typename T>
25 using IossHas3ParametersConstructor =
26 decltype(DerivedFromIossGroupingEntity<T>{}, T(nullptr, std::string{}, int64_t{}));
27
28 template <typename T>
29 using IossHas4ParametersConstructor =
30 decltype(DerivedFromIossGroupingEntity<T>{},
31 T(nullptr, std::string{}, std::string{}, int64_t{}));
32
33 // Takes an extra unused parameter "entity_type" to match the API of the function
34 // "NewEntity" used for objects that are not EntitySets which require that parameter.
35 // Having matching APIs allows to call this function from generic templated functions
36 // that do not have to be specialized to call this function with a different number of
37 // parameters.
38 template <typename T>
39 auto NewEntity(Ioss::DatabaseIO *io_database, const std::string &my_name,
40 const std::string & /*entity_type*/,
41 size_t entity_count) -> IossHas3ParametersConstructor<T> *
42 {
43 return new T(io_database, my_name, entity_count);
44 }
45
46 template <typename T>
47 auto NewEntity(Ioss::DatabaseIO *io_database, const std::string &my_name,
48 const std::string &entity_type,
49 size_t entity_count) -> IossHas4ParametersConstructor<T> *
50 {
51 return new T(io_database, my_name, entity_type, entity_count);
52 }
53
54 IOAD_EXPORT int find_field_in_mapset(const std::string &entity_type,
55 const std::string &field_name,
56 const std::map<std::string, std::set<std::string>> &mapset);
57
58 IOAD_EXPORT std::string get_property_variable_name(const std::string &property_name);
59 IOAD_EXPORT std::vector<std::string>
60 properties_to_save(const Ioss::GroupingEntity *const entity_block);
61
62 IOAD_EXPORT std::string stringify_side_block_names(const Ioss::SideBlockContainer &sblocks);
63
64 IOAD_EXPORT std::string encode_field_name(std::vector<std::string> names);
65
66 IOAD_EXPORT std::string encode_sideblock_name(const std::string &type_string,
67 const std::string &name);
68
69 IOAD_EXPORT bool is_sideblock_name(const std::string &name);
70
71 IOAD_EXPORT bool use_transformed_storage(const Ioss::Field &field, const std::string &entity_type,
72 const std::string &field_name);
73
74 } // namespace Ioad