MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
sub_elem_node_map.h
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef __mast_sub_elem_node_map_h__
21 #define __mast_sub_elem_node_map_h__
22 
23 // C++ includes
24 #include <unordered_map>
25 #include <functional> // std::hash
26 
27 // libMesh includes
28 #include "libmesh/mesh_base.h"
29 
30 namespace MAST{
31 
32 
34 
35  // borrowing this from libMesh::TopologyMap
36  struct myhash {
37  public:
38  template <typename T1, typename T2>
39  std::size_t operator()(const std::pair<T1, T2> & x) const
40  {
41  return 3 * std::hash<T1>()(x.first) + std::hash<T2>()(x.second);
42  }
43  };
44 
45 
46  // first pair is the key, which identifies the bounding nodes on a
47  // parent edge where the node is created.
48  // second pair is the set of nodes used by the adjacent elements on the
49  // positive and negative sides of the level set function. Specifying
50  // both to be same will allow a weak discontinuity, while specifying
51  // both to be different will allow a strong discontinuity
52  typedef
53  std::unordered_map
54  <std::pair<libMesh::dof_id_type, libMesh::dof_id_type>,
55  std::pair<libMesh::Node*, libMesh::Node*>, MAST::SubElemNodeMap::myhash> map_type;
56 
57 
58  public:
59 
61 
62 
63  virtual ~SubElemNodeMap();
64 
65 
66  void clear() { _map.clear(); }
67 
68 
69  bool empty() const { return _map.empty(); }
70 
71 
72  unsigned int
73  count(libMesh::dof_id_type bracket_node1, libMesh::dof_id_type bracket_node2) const;
74 
75 
76  std::pair<libMesh::Node*, libMesh::Node*>&
77  add(libMesh::dof_id_type bracket_node1, libMesh::dof_id_type bracket_node2);
78 
79 
80  protected:
81 
82 
84  };
85 
86 }
87 
88 
89 #endif // __mast_sub_elem_node_map_h__
std::size_t operator()(const std::pair< T1, T2 > &x) const
MAST::SubElemNodeMap::map_type _map
unsigned int count(libMesh::dof_id_type bracket_node1, libMesh::dof_id_type bracket_node2) const
std::pair< libMesh::Node *, libMesh::Node * > & add(libMesh::dof_id_type bracket_node1, libMesh::dof_id_type bracket_node2)
std::unordered_map< std::pair< libMesh::dof_id_type, libMesh::dof_id_type >, std::pair< libMesh::Node *, libMesh::Node * >, MAST::SubElemNodeMap::myhash > map_type