IOSS 2.0

Ioad_Helper.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2010 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 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Ioad_Helper_h
34 #define IOSS_Ioad_Helper_h
35
36 #include <map>
37 #include <set>
38 #include <string>
39
40 #include "Ioss_GroupingEntity.h" // for GroupingEntity
41 #include "Ioss_SideSet.h" // for SideBlockContainer, SideSet
42
43 namespace Ioad {
44
45 template <typename T>
46 using DerivedFromIossGroupingEntity =
47 typename std::enable_if<std::is_base_of<Ioss::GroupingEntity, T>::value, bool>::type;
48
49 template <typename T>
50 using IossHas3ParametersConstructor =
51 decltype(DerivedFromIossGroupingEntity<T>{}, T(nullptr, std::string{}, int64_t{}));
52
53 template <typename T>
54 using IossHas4ParametersConstructor = decltype(
55 DerivedFromIossGroupingEntity<T>{}, T(nullptr, std::string{}, std::string{}, int64_t{}));
56
57 // Takes an extra unused parameter "entity_type" to match the API of the function
58 // "NewEntity" used for objects that are not EntitySets which require that parameter.
59 // Having matching APIs allows to call this function from generic templated functions
60 // that do not have to be specialized to call this function with a different number of
61 // parameters.
62 template <typename T>
63 auto NewEntity(Ioss::DatabaseIO *io_database, const std::string &my_name,
64 const std::string & /*entity_type*/, size_t entity_count)
65 -> IossHas3ParametersConstructor<T> *
66 {
67 return new T(io_database, my_name, entity_count);
68 }
69
70 template <typename T>
71 auto NewEntity(Ioss::DatabaseIO *io_database, const std::string &my_name,
72 const std::string &entity_type, size_t entity_count)
73 -> IossHas4ParametersConstructor<T> *
74 {
75 return new T(io_database, my_name, entity_type, entity_count);
76 }
77
78 int find_field_in_mapset(const std::string &entity_type, const std::string &field_name,
79 const std::map<std::string, std::set<std::string>> &mapset);
80
81 std::string get_property_variable_name(const std::string &property_name);
82 std::vector<std::string> properties_to_save(const Ioss::GroupingEntity *const entity_block);
83
84 std::string stringify_side_block_names(const Ioss::SideBlockContainer &sblocks);
85
86 std::string encode_field_name(std::vector<std::string> names);
87
88 std::string encode_sideblock_name(const std::string &type_string, const std::string &name);
89
90 bool is_sideblock_name(const std::string &name);
91
92 bool use_transformed_storage(const Ioss::Field &field, const std::string &entity_type,
93 const std::string &field_name);
94
95 } // namespace Ioad
96
97 #endif
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
Ioss::GroupingEntity
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:93
Ioad::use_transformed_storage
bool use_transformed_storage(const Ioss::Field &field, const std::string &entity_type, const std::string &field_name)
Definition: Ioad_Helper.C:109
Ioad::NewEntity
auto NewEntity(Ioss::DatabaseIO *io_database, const std::string &my_name, const std::string &, size_t entity_count) -> IossHas3ParametersConstructor< T > *
Definition: Ioad_Helper.h:63
Ioad::find_field_in_mapset
int find_field_in_mapset(const std::string &entity_type, const std::string &field_name, const std::map< std::string, std::set< std::string >> &mapset)
Definition: Ioad_Helper.C:38
Ioad::encode_field_name
std::string encode_field_name(std::vector< std::string > names)
Definition: Ioad_Helper.C:85
Ioad::is_sideblock_name
bool is_sideblock_name(const std::string &name)
Definition: Ioad_Helper.C:103
Ioad::IossHas3ParametersConstructor
decltype(DerivedFromIossGroupingEntity< T >{}, T(nullptr, std::string{}, int64_t{})) IossHas3ParametersConstructor
Definition: Ioad_Helper.h:51
Ioad::get_property_variable_name
std::string get_property_variable_name(const std::string &property_name)
Definition: Ioad_Helper.C:52
Ioss::SideBlockContainer
std::vector< SideBlock * > SideBlockContainer
Definition: Ioss_SideSet.h:55
Ioad::encode_sideblock_name
std::string encode_sideblock_name(const std::string &type_string, const std::string &name)
Definition: Ioad_Helper.C:98
Ioss_SideSet.h
Ioad::IossHas4ParametersConstructor
decltype(DerivedFromIossGroupingEntity< T >{}, T(nullptr, std::string{}, std::string{}, int64_t{})) IossHas4ParametersConstructor
Definition: Ioad_Helper.h:55
Ioad::properties_to_save
std::vector< std::string > properties_to_save(const Ioss::GroupingEntity *const entity_block)
Definition: Ioad_Helper.C:57
Ioad
A namespace for the adios database format.
Definition: AdiosWrapper.C:37
anonymous_namespace{Ioss_Field.C}::type_string
std::string type_string(Ioss::Field::BasicType type)
Definition: Ioss_Field.C:50
Ioad::stringify_side_block_names
std::string stringify_side_block_names(const Ioss::SideBlockContainer &sblocks)
Definition: Ioad_Helper.C:76
anonymous_namespace{io_info.C}::name
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:87
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Ioad::DerivedFromIossGroupingEntity
typename std::enable_if< std::is_base_of< Ioss::GroupingEntity, T >::value, bool >::type DerivedFromIossGroupingEntity
Definition: Ioad_Helper.h:47
anonymous_namespace{Iovs_DatabaseIO.C}::entity_type
entity_type
Definition: Iovs_DatabaseIO.C:81
Ioss_GroupingEntity.h