IOSS 2.0

Ioex_Utils.h
Go to the documentation of this file.
1 /*
2 * Copyright(C) 1999-2017 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of NTESS nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 #ifndef IOEX_UTILS_H
35 #define IOEX_UTILS_H
36 #include <Ioss_CoordinateFrame.h>
37 #include <Ioss_ElementBlock.h>
38 #include <Ioss_ElementTopology.h>
39 #include <Ioss_Utils.h>
40
41 #include <cassert>
42 #include <exodusII.h>
43 #include <set>
44 #include <string>
45 #include <vector>
46
47 // Contains code that is common between the file-per-processor (Iofx)
48 // and parallel exodus (Iopx) and base exodus (Ioex) classes.
49
50 namespace Ioss {
51 class GroupingEntity;
52 using CoordinateFrameContainer = std::vector<CoordinateFrame>;
53 } // namespace Ioss
54
55 namespace Ioex {
56 using EntityIdSet = std::set<std::pair<int64_t, int64_t>>;
57 using SideSetSet = std::set<std::string>;
58 using SideSetMap = std::map<std::string, const std::string, std::less<const std::string>>;
59
60 struct TopologyMapCompare
61 {
62 bool operator()(const std::pair<std::string, const Ioss::ElementTopology *> &lhs,
63 const std::pair<std::string, const Ioss::ElementTopology *> &rhs) const
64 {
65 assert(lhs.second != nullptr);
66 assert(rhs.second != nullptr);
67 return lhs.first < rhs.first ||
68 (!(rhs.first < lhs.first) && lhs.second->name() < rhs.second->name());
69 }
70 };
71
72 using TopologyMap =
73 std::map<std::pair<std::string, const Ioss::ElementTopology *>, int, TopologyMapCompare>;
74
75 const char *Version();
76 bool check_processor_info(int exodusFilePtr, int processor_count, int processor_id);
77
78 void update_last_time_attribute(int exodusFilePtr, double value);
79 bool read_last_time_attribute(int exodusFilePtr, double *value);
80
81 bool type_match(const std::string &type, const char *substring);
82 int64_t extract_id(const std::string &name_id);
83 bool set_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset);
84 int64_t get_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset);
85 void decode_surface_name(Ioex::SideSetMap &fs_map, Ioex::SideSetSet &fs_set,
86 const std::string &name);
87 void fix_bad_name(char *name);
88
89 void exodus_error(int exoid, int lineno, const char *function, const char *filename,
90 const std::string &extra = {});
91
92 int add_map_fields(int exoid, Ioss::ElementBlock *block, int64_t my_element_count,
93 size_t name_length);
94
95 void add_coordinate_frames(int exoid, Ioss::Region *region);
96 void write_coordinate_frames(int exoid, const Ioss::CoordinateFrameContainer &frames);
97
98 bool find_displacement_field(Ioss::NameList &fields, const Ioss::GroupingEntity *block, int ndim,
99 std::string *disp_name);
100
101 std::string get_entity_name(int exoid, ex_entity_type type, int64_t id,
102 const std::string &basename, int length, bool &db_has_name);
103
104 void filter_element_list(Ioss::Region *region, Ioss::Int64Vector &elements,
105 Ioss::Int64Vector &sides, bool remove_omitted_elements);
106
107 bool filter_node_list(Ioss::Int64Vector & nodes,
108 const std::vector<unsigned char> &node_connectivity_status);
109
110 template <typename T>
111 void filter_node_list(T *data, std::vector<T> &dbvals,
112 const std::vector<int64_t> &active_node_index)
113 {
114 for (size_t i = 0; i < active_node_index.size(); i++) {
115 data[i] = dbvals[active_node_index[i]];
116 }
117 }
118
119 void filter_element_list(Ioss::Region *region, Ioss::Int64Vector &elements,
120 Ioss::Int64Vector &sides, bool remove_omitted_elements);
121
122 void separate_surface_element_sides(Ioss::Int64Vector &element, Ioss::Int64Vector &sides,
123 Ioss::Region *region, Ioex::TopologyMap &topo_map,
124 Ioex::TopologyMap & side_map,
125 Ioss::SurfaceSplitType split_type,
126 const std::string & surface_name);
127 } // namespace Ioex
128 #endif
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:44
Ioex::find_displacement_field
bool find_displacement_field(Ioss::NameList &fields, const Ioss::GroupingEntity *block, int ndim, std::string *disp_name)
Definition: Ioex_Utils.C:382
Ioex::TopologyMapCompare::operator()
bool operator()(const std::pair< std::string, const Ioss::ElementTopology *> &lhs, const std::pair< std::string, const Ioss::ElementTopology *> &rhs) const
Definition: Ioex_Utils.h:62
Ioex::SideSetMap
std::map< std::string, const std::string, std::less< const std::string > > SideSetMap
Definition: Ioex_Utils.h:58
Ioex::extract_id
int64_t extract_id(const std::string &name_id)
Definition: Ioex_Utils.C:300
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Ioss::CoordinateFrameContainer
std::vector< CoordinateFrame > CoordinateFrameContainer
Definition: Ioex_Utils.h:52
Ioex::get_id
int64_t get_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset)
Definition: Ioex_Utils.C:319
Ioss::GroupingEntity
Base class for all &#39;grouping&#39; entities. The following derived classes are typical: ...
Definition: Ioss_GroupingEntity.h:93
Ioex::filter_node_list
void filter_node_list(T *data, std::vector< T > &dbvals, const std::vector< int64_t > &active_node_index)
Definition: Ioex_Utils.h:111
Ioex::separate_surface_element_sides
void separate_surface_element_sides(Ioss::Int64Vector &element, Ioss::Int64Vector &sides, Ioss::Region *region, Ioex::TopologyMap &topo_map, Ioex::TopologyMap &side_map, Ioss::SurfaceSplitType split_type, const std::string &surface_name)
Definition: Ioex_Utils.C:609
Ioex::type_match
bool type_match(const std::string &type, const char *substring)
Definition: Ioex_Utils.C:216
Ioex::write_coordinate_frames
void write_coordinate_frames(int exoid, const Ioss::CoordinateFrameContainer &frames)
Definition: Ioex_Utils.C:526
Ioex::add_map_fields
int add_map_fields(int exoid, Ioss::ElementBlock *block, int64_t my_element_count, size_t name_length)
Definition: Ioex_Utils.C:492
Ioex::EntityIdSet
std::set< std::pair< int64_t, int64_t > > EntityIdSet
Definition: Ioex_DatabaseIO.h:94
Ioex::get_entity_name
std::string get_entity_name(int exoid, ex_entity_type type, int64_t id, const std::string &basename, int length, bool &db_has_name)
Definition: Ioex_Utils.C:431
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Ioex::TopologyMap
std::map< std::pair< std::string, const Ioss::ElementTopology * >, int, TopologyMapCompare > TopologyMap
Definition: Ioex_Utils.h:73
Ioex::set_id
bool set_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset)
Definition: Ioex_Utils.C:271
Ioex::fix_bad_name
void fix_bad_name(char *name)
Definition: Ioex_Utils.C:415
anonymous_namespace{Iodw_DatabaseIO.C}::Version
const char * Version()
Definition: Iodw_DatabaseIO.C:66
Ioss_Utils.h
Ioex
A namespace for the exodus database format.
Definition: Ioex_IOFactory.C:61
Ioex::filter_element_list
void filter_element_list(Ioss::Region *region, Ioss::Int64Vector &elements, Ioss::Int64Vector &sides, bool remove_omitted_elements)
Definition: Ioex_Utils.C:572
Ioss_CoordinateFrame.h
Ioss::Int64Vector
std::vector< int64_t > Int64Vector
Definition: Ioss_CodeTypes.h:43
Ioex::add_coordinate_frames
void add_coordinate_frames(int exoid, Ioss::Region *region)
Definition: Ioex_Utils.C:536
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
Ioss::SurfaceSplitType
SurfaceSplitType
Method used to split sidesets into homogenous blocks.
Definition: Ioss_SurfaceSplit.h:38
Ioex::check_processor_info
bool check_processor_info(int exodusFilePtr, int processor_count, int processor_id)
Definition: Ioex_Utils.C:169
anonymous_namespace{io_info.C}::name
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:71
Ioex::exodus_error
void exodus_error(int exoid, int lineno, const char *function, const char *filename, const std::string &extra)
Definition: Ioex_Utils.C:469
Ioex::TopologyMapCompare
Definition: Ioex_Utils.h:60
Ioex::SideSetSet
std::set< std::string > SideSetSet
Definition: Ioex_Utils.h:57
Ioss_ElementTopology.h
Ioex::decode_surface_name
void decode_surface_name(Ioex::SideSetMap &fs_map, Ioex::SideSetSet &fs_set, const std::string &name)
Definition: Ioex_Utils.C:233
Ioex::read_last_time_attribute
bool read_last_time_attribute(int exodusFilePtr, double *value)
Definition: Ioex_Utils.C:138
anonymous_namespace{Ioss_Utils.C}::data
std::vector< char > data
Definition: Ioss_Utils.C:78
Ioex::update_last_time_attribute
void update_last_time_attribute(int exodusFilePtr, double value)
Definition: Ioex_Utils.C:119
Ioss_ElementBlock.h