IOSS  2.0
Ioex_Utils.h
Go to the documentation of this file.
1 /*
2  * Copyright(C) 1999-2020 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  * See packages/seacas/LICENSE for details
7  */
8 #ifndef IOEX_UTILS_H
9 #define IOEX_UTILS_H
10 #include <Ioss_CoordinateFrame.h>
11 #include <Ioss_ElementBlock.h>
12 #include <Ioss_ElementTopology.h>
13 #include <Ioss_Utils.h>
14 
15 #include <cassert>
16 #include <exodusII.h>
17 #include <set>
18 #include <string>
19 #include <vector>
20 
21 // Contains code that is common between the file-per-processor and
22 // parallel exodus and base exodus classes.
23 
24 namespace Ioss {
25  class GroupingEntity;
26  using CoordinateFrameContainer = std::vector<CoordinateFrame>;
27 } // namespace Ioss
28 
29 namespace Ioex {
30  using EntityIdSet = std::set<std::pair<int64_t, int64_t>>;
31  using SideSetSet = std::set<std::string>;
32  using SideSetMap = std::map<std::string, const std::string, std::less<const std::string>>;
33 
35  {
36  bool operator()(const std::pair<std::string, const Ioss::ElementTopology *> &lhs,
37  const std::pair<std::string, const Ioss::ElementTopology *> &rhs) const
38  {
39  assert(lhs.second != nullptr);
40  assert(rhs.second != nullptr);
41  return lhs.first < rhs.first ||
42  (!(rhs.first < lhs.first) && lhs.second->name() < rhs.second->name());
43  }
44  };
45 
46  using TopologyMap =
47  std::map<std::pair<std::string, const Ioss::ElementTopology *>, int, TopologyMapCompare>;
48 
49  const char *Version();
50  bool check_processor_info(int exodusFilePtr, int processor_count, int processor_id);
51 
52  Ioss::EntityType map_exodus_type(ex_entity_type type);
53  ex_entity_type map_exodus_type(Ioss::EntityType type);
54 
55  void update_last_time_attribute(int exodusFilePtr, double value);
56  bool read_last_time_attribute(int exodusFilePtr, double *value);
57 
58  bool type_match(const std::string &type, const char *substring);
59  int64_t extract_id(const std::string &name_id);
60  bool set_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset);
61  int64_t get_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset);
63  const std::string &name);
64  void fix_bad_name(char *name);
65 
66  void exodus_error(int exoid, int lineno, const char *function, const char *filename,
67  const std::string &extra = {});
68 
69  int add_map_fields(int exoid, Ioss::ElementBlock *block, int64_t my_element_count,
70  size_t name_length);
71 
72  void add_coordinate_frames(int exoid, Ioss::Region *region);
73  void write_coordinate_frames(int exoid, const Ioss::CoordinateFrameContainer &frames);
74 
75  bool find_displacement_field(Ioss::NameList &fields, const Ioss::GroupingEntity *block, int ndim,
76  std::string *disp_name);
77 
78  std::string get_entity_name(int exoid, ex_entity_type type, int64_t id,
79  const std::string &basename, int length, bool &db_has_name);
80 
81  void filter_element_list(Ioss::Region *region, Ioss::Int64Vector &elements,
82  Ioss::Int64Vector &sides, bool remove_omitted_elements);
83 
85  const std::vector<unsigned char> &node_connectivity_status);
86 
87  template <typename T>
88  void filter_node_list(T *data, std::vector<T> &dbvals,
89  const std::vector<int64_t> &active_node_index)
90  {
91  for (size_t i = 0; i < active_node_index.size(); i++) {
92  data[i] = dbvals[active_node_index[i]];
93  }
94  }
95 
96  void filter_element_list(Ioss::Region *region, Ioss::Int64Vector &elements,
97  Ioss::Int64Vector &sides, bool remove_omitted_elements);
98 
100  Ioss::Region *region, Ioex::TopologyMap &topo_map,
101  Ioex::TopologyMap & side_map,
102  Ioss::SurfaceSplitType split_type,
103  const std::string & surface_name);
104 
105  void write_reduction_attributes(int exoid, const Ioss::GroupingEntity *ge);
106  template <typename T> void write_reduction_attributes(int exoid, const std::vector<T *> &entities)
107  {
108  // For the entity, write all "reduction attributes"
109  for (const auto &ge : entities) {
110  write_reduction_attributes(exoid, ge);
111  }
112  }
113 } // namespace Ioex
114 #endif
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:510
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:27
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:36
Ioex::read_last_time_attribute
bool read_last_time_attribute(int exodusFilePtr, double *value)
Definition: Ioex_Utils.C:154
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:451
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
Ioex::check_processor_info
bool check_processor_info(int exodusFilePtr, int processor_count, int processor_id)
Definition: Ioex_Utils.C:185
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:78
Ioss::SurfaceSplitType
SurfaceSplitType
Method used to split sidesets into homogeneous blocks.
Definition: Ioss_SurfaceSplit.h:12
Ioex::fix_bad_name
void fix_bad_name(char *name)
Definition: Ioex_Utils.C:435
Ioex::SideSetSet
std::set< std::string > SideSetSet
Definition: Ioex_Utils.h:31
Ioss_ElementBlock.h
Ioss::EntityType
EntityType
The particular type of GroupingEntity.
Definition: Ioss_EntityType.h:13
Ioex::exodus_error
void exodus_error(int exoid, int lineno, const char *function, const char *filename, const std::string &extra)
Definition: Ioex_Utils.C:490
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:627
Ioex::update_last_time_attribute
void update_last_time_attribute(int exodusFilePtr, double value)
Definition: Ioex_Utils.C:97
Ioex::add_coordinate_frames
void add_coordinate_frames(int exoid, Ioss::Region *region)
Definition: Ioex_Utils.C:554
Ioex::write_reduction_attributes
void write_reduction_attributes(int exoid, const Ioss::GroupingEntity *ge)
Definition: Ioex_Utils.C:694
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:402
Ioex
A namespace for the exodus database format.
Definition: Ioex_BaseDatabaseIO.C:101
Ioss::CoordinateFrameContainer
std::vector< CoordinateFrame > CoordinateFrameContainer
Definition: Ioex_Utils.h:26
Ioss::Int64Vector
std::vector< int64_t > Int64Vector
Definition: Ioss_CodeTypes.h:26
Ioss_Utils.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:254
Ioex::filter_node_list
bool filter_node_list(Ioss::Int64Vector &nodes, const std::vector< unsigned char > &node_connectivity_status)
Definition: Ioex_Utils.C:564
Ioex::map_exodus_type
Ioss::EntityType map_exodus_type(ex_entity_type type)
Definition: Ioex_Utils.C:116
Ioex::write_coordinate_frames
void write_coordinate_frames(int exoid, const Ioss::CoordinateFrameContainer &frames)
Definition: Ioex_Utils.C:544
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:23
Ioss_CoordinateFrame.h
Ioex::type_match
bool type_match(const std::string &type, const char *substring)
Definition: Ioex_Utils.C:237
Ioex::get_id
int64_t get_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset)
Definition: Ioex_Utils.C:339
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:48
Ioex::TopologyMapCompare
Definition: Ioex_Utils.h:35
Ioex::SideSetMap
std::map< std::string, const std::string, std::less< const std::string > > SideSetMap
Definition: Ioex_Utils.h:32
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:590
Ioex::EntityIdSet
std::set< std::pair< int64_t, int64_t > > EntityIdSet
Definition: Ioex_BaseDatabaseIO.h:70
anonymous_namespace{io_info.C}::name
std::string name(const Ioss::GroupingEntity *entity)
Definition: io_info.C:65
Ioex::TopologyMap
std::map< std::pair< std::string, const Ioss::ElementTopology * >, int, TopologyMapCompare > TopologyMap
Definition: Ioex_Utils.h:47
Ioex::extract_id
int64_t extract_id(const std::string &name_id)
Definition: Ioex_Utils.C:320
Ioss::GroupingEntity
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:68
Ioex::set_id
bool set_id(const Ioss::GroupingEntity *entity, ex_entity_type type, Ioex::EntityIdSet *idset)
Definition: Ioex_Utils.C:292
Ioss_ElementTopology.h
Ioex::Version
const char * Version()
Definition: Ioex_Utils.C:95