IOSS  2.0
Ioss_ElementTopology.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 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_Ioss_Element_Topology_h
34 #define IOSS_Ioss_Element_Topology_h
35 
36 #include <Ioss_CodeTypes.h>
37 #include <map> // for map, map<>::value_compare
38 #include <string> // for string, operator<
39 #include <vector> // for vector
40 namespace Ioss {
41  class ElementTopology;
42 } // namespace Ioss
43 
44 namespace Ioss {
46 
47  using ElementTopologyMap = std::map<std::string, ElementTopology *, std::less<std::string>>;
48  using ETM_VP = ElementTopologyMap::value_type;
49 
50  class ETRegistry
51  {
52  public:
53  void insert(const Ioss::ETM_VP &value, bool delete_me);
54  ElementTopologyMap::iterator begin() { return m_registry.begin(); }
55  ElementTopologyMap::iterator end() { return m_registry.end(); }
56  ElementTopologyMap::iterator find(const std::string &type) { return m_registry.find(type); }
57 
58  ~ETRegistry();
59  std::map<std::string, std::string> customFieldTypes;
60 
61  private:
63  std::vector<Ioss::ElementTopology *> m_deleteThese;
64  };
65 
66  // ========================================================================
67 
68  /** \brief Represents an element topology.
69  *
70  * Defines node, edge, and face connectivity information of an element.
71  */
73  {
74  public:
75  void alias(const std::string &base, const std::string &syn);
76  bool is_alias(const std::string &my_alias) const;
77 
78  ElementTopology(const ElementTopology &) = delete;
79  ElementTopology &operator=(const ElementTopology &) = delete;
80 
81  virtual ~ElementTopology();
82 
83  const std::string &name() const { return name_; }
84 
85  //: Return the Sierra master element name corresponding to this
86  //: element topology. Somewhat klugy coupling between IO subsystem
87  //: and Sierra, but least klugy I could think of...
88  std::string master_element_name() const { return masterElementName_; }
89 
90  //: Return basic shape...
91  virtual ElementShape shape() const = 0;
92 
93  //: Return whether the topology describes an "element". If it
94  //: isn't an element, then it is a component of an element. For
95  // example, a quadrilater Shell is an element, but a QuadFace is
96  // not.
97  //
98  // Default implementation returns true if spatial_dimension() ==
99  // parametric_dimension(), otherwise returns false;
100  // "Structural" elements (shells, rods, trusses, particles) need
101  // to override.
102  virtual bool is_element() const;
103  virtual int spatial_dimension() const = 0;
104  virtual int parametric_dimension() const = 0;
105  virtual int order() const = 0;
106 
107  virtual bool edges_similar() const; // true if all edges have same topology
108  virtual bool faces_similar() const; // true if all faces have same topology
109 
110  virtual int number_corner_nodes() const = 0;
111  virtual int number_nodes() const = 0;
112  virtual int number_edges() const = 0;
113  virtual int number_faces() const = 0;
114  int number_boundaries() const;
115 
116  virtual int number_nodes_edge(int edge = 0) const = 0;
117  virtual int number_nodes_face(int face = 0) const = 0;
118  virtual int number_edges_face(int face = 0) const = 0;
119 
120  IntVector boundary_connectivity(int edge_number) const;
121  virtual IntVector edge_connectivity(int edge_number) const = 0;
122  virtual IntVector face_connectivity(int face_number) const = 0;
123  virtual IntVector element_connectivity() const = 0;
124 
125  // These have default implementations in ElementTopology.
126  // The defaults simply fill in the vector with 0..num.
127  // For 'face_edge_connectivity', this is sufficient for 2d
128  // elements, 3d need to override.
129  // For 'element_edge_connectivity', this works for all elements.
130  virtual IntVector face_edge_connectivity(int face_number) const;
132 
133  ElementTopology * boundary_type(int face_number = 0) const;
134  virtual ElementTopology *face_type(int face_number = 0) const = 0;
135  virtual ElementTopology *edge_type(int edge_number = 0) const = 0;
136 
137  static ElementTopology *factory(const std::string &type, bool ok_to_fail = false);
138  static ElementTopology *factory(unsigned int unique_id);
139  static unsigned int get_unique_id(const std::string &type);
140  static int describe(NameList *names);
141 
142  protected:
143  ElementTopology(std::string type, std::string master_elem_name, bool delete_me = false);
144 
145  private:
146  const std::string name_;
147  const std::string masterElementName_;
148 
149  static ETRegistry &registry();
150  };
151 } // namespace Ioss
152 #endif
Ioss::ETRegistry::insert
void insert(const Ioss::ETM_VP &value, bool delete_me)
Definition: Ioss_ElementTopology.C:46
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:53
Ioss::ElementTopology::number_corner_nodes
virtual int number_corner_nodes() const =0
Ioss::ElementShape::POINT
Ioss::ElementTopology::number_faces
virtual int number_faces() const =0
Ioss::ElementTopology::get_unique_id
static unsigned int get_unique_id(const std::string &type)
Definition: Ioss_ElementTopology.C:149
Ioss::ElementTopology::boundary_connectivity
IntVector boundary_connectivity(int edge_number) const
Definition: Ioss_ElementTopology.C:261
Ioss::ElementShape::QUAD
Ioss::ElementTopology::face_edge_connectivity
virtual IntVector face_edge_connectivity(int face_number) const
Definition: Ioss_ElementTopology.C:185
Ioss::ElementTopology::name_
const std::string name_
Definition: Ioss_ElementTopology.h:146
Ioss::ETRegistry::begin
ElementTopologyMap::iterator begin()
Definition: Ioss_ElementTopology.h:54
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:51
Ioss::ElementShape::PYRAMID
Ioss::ElementTopology::element_connectivity
virtual IntVector element_connectivity() const =0
Ioss::ElementTopology::describe
static int describe(NameList *names)
Get the names of element topologies known to Ioss.
Definition: Ioss_ElementTopology.C:175
Ioss::ETRegistry::m_deleteThese
std::vector< Ioss::ElementTopology * > m_deleteThese
Definition: Ioss_ElementTopology.h:63
Ioss::ETRegistry::m_registry
Ioss::ElementTopologyMap m_registry
Definition: Ioss_ElementTopology.h:62
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
Ioss::ETRegistry::customFieldTypes
std::map< std::string, std::string > customFieldTypes
Definition: Ioss_ElementTopology.h:59
Ioss::ElementShape::UNKNOWN
Ioss::ElementTopology::master_element_name
std::string master_element_name() const
Definition: Ioss_ElementTopology.h:88
Ioss::ElementTopology::edge_type
virtual ElementTopology * edge_type(int edge_number=0) const =0
Ioss::ETRegistry::~ETRegistry
~ETRegistry()
Definition: Ioss_ElementTopology.C:54
Ioss::ElementTopology::number_nodes_edge
virtual int number_nodes_edge(int edge=0) const =0
Ioss::ElementTopology::faces_similar
virtual bool faces_similar() const
Definition: Ioss_ElementTopology.C:92
Ioss::ElementTopology::number_edges
virtual int number_edges() const =0
Ioss::ElementTopology::number_nodes_face
virtual int number_nodes_face(int face=0) const =0
Ioss::ElementTopology::edges_similar
virtual bool edges_similar() const
Definition: Ioss_ElementTopology.C:91
Ioss::ETRegistry::find
ElementTopologyMap::iterator find(const std::string &type)
Definition: Ioss_ElementTopology.h:56
Ioss::ETRegistry
Definition: Ioss_ElementTopology.h:50
Ioss::ElementTopology::parametric_dimension
virtual int parametric_dimension() const =0
Ioss::ElementTopology::operator=
ElementTopology & operator=(const ElementTopology &)=delete
Ioss::ElementTopology::number_boundaries
int number_boundaries() const
Definition: Ioss_ElementTopology.C:228
Ioss::ElementTopology::order
virtual int order() const =0
Ioss::ElementTopology::edge_connectivity
virtual IntVector edge_connectivity(int edge_number) const =0
Ioss::ElementShape::TRI
Ioss::ElementShape::WEDGE
Ioss::ElementTopology::number_edges_face
virtual int number_edges_face(int face=0) const =0
Ioss::ElementTopology::face_connectivity
virtual IntVector face_connectivity(int face_number) const =0
Ioss::ElementTopology::shape
virtual ElementShape shape() const =0
Ioss::ElementTopology
Represents an element topology.
Definition: Ioss_ElementTopology.h:72
Ioss::ElementTopology::is_alias
bool is_alias(const std::string &my_alias) const
Definition: Ioss_ElementTopology.C:211
Ioss::ElementTopology::name
const std::string & name() const
Definition: Ioss_ElementTopology.h:83
Ioss::ElementTopology::element_edge_connectivity
IntVector element_edge_connectivity() const
Definition: Ioss_ElementTopology.C:200
Ioss::ElementTopology::boundary_type
ElementTopology * boundary_type(int face_number=0) const
Definition: Ioss_ElementTopology.C:299
Ioss::ElementTopology::number_nodes
virtual int number_nodes() const =0
Ioss::ElementTopology::masterElementName_
const std::string masterElementName_
Definition: Ioss_ElementTopology.h:147
Ioss::ElementTopologyMap
std::map< std::string, ElementTopology *, std::less< std::string > > ElementTopologyMap
Definition: Ioss_ElementTopology.h:47
Ioss::ETRegistry::end
ElementTopologyMap::iterator end()
Definition: Ioss_ElementTopology.h:55
Ioss::ElementShape
ElementShape
Definition: Ioss_ElementTopology.h:45
Ioss::ElementShape::TET
Ioss::ETM_VP
ElementTopologyMap::value_type ETM_VP
Definition: Ioss_ElementTopology.h:48
Ioss::ElementShape::LINE
Ioss::ElementShape::HEX
Ioss::ElementTopology::registry
static ETRegistry & registry()
Definition: Ioss_ElementTopology.C:83
Ioss::ElementTopology::factory
static ElementTopology * factory(const std::string &type, bool ok_to_fail=false)
Definition: Ioss_ElementTopology.C:94
Ioss::ElementTopology::spatial_dimension
virtual int spatial_dimension() const =0
Ioss::ElementTopology::is_element
virtual bool is_element() const
Definition: Ioss_ElementTopology.C:221
Ioss_CodeTypes.h
Ioss::ElementTopology::ElementTopology
ElementTopology(const ElementTopology &)=delete
Ioss::ElementTopology::alias
void alias(const std::string &base, const std::string &syn)
Definition: Ioss_ElementTopology.C:74
Ioss::ElementTopology::face_type
virtual ElementTopology * face_type(int face_number=0) const =0
Ioss::ElementTopology::~ElementTopology
virtual ~ElementTopology()