www.mooseframework.org
EFAFuncs.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #ifndef EFAFUNCS_H
9 #define EFAFUNCS_H
10 
11 #include <map>
12 #include <set>
13 #include <vector>
14 #include <algorithm>
15 
16 namespace Efa
17 {
18 
19 template <typename T>
20 bool
21 deleteFromMap(std::map<unsigned int, T *> & theMap, T * elemToDelete, bool delete_elem = true)
22 {
23  bool didIt = false;
24  typename std::map<unsigned int, T *>::iterator i = theMap.find(elemToDelete->id());
25  if (i != theMap.end())
26  {
27  if (delete_elem)
28  delete i->second;
29  theMap.erase(i);
30  didIt = true;
31  }
32  return didIt;
33 }
34 
35 template <typename T>
36 unsigned int
37 getNewID(std::map<unsigned int, T *> & theMap)
38 {
39  typename std::map<unsigned int, T *>::reverse_iterator last_elem = theMap.rbegin();
40  unsigned int new_elem_id = 0;
41  if (last_elem != theMap.rend())
42  new_elem_id = last_elem->first + 1;
43  return new_elem_id;
44 }
45 
46 template <class T>
47 unsigned int
48 numCommonElems(std::set<T> & v1, std::set<T> & v2)
49 {
50  std::vector<T> common_elems;
51  std::set_intersection(
52  v1.begin(), v1.end(), v2.begin(), v2.end(), std::inserter(common_elems, common_elems.end()));
53  return common_elems.size();
54 }
55 
56 template <class T>
57 unsigned int
58 numCommonElems(std::set<T> & v1, std::vector<T> & v2)
59 {
60  std::vector<T> common_elems;
61  std::set_intersection(
62  v1.begin(), v1.end(), v2.begin(), v2.end(), std::inserter(common_elems, common_elems.end()));
63  return common_elems.size();
64 }
65 
66 template <class T>
67 std::vector<T>
68 getCommonElems(std::set<T> & v1, std::set<T> & v2)
69 {
70  std::vector<T> common_elems;
71  std::set_intersection(
72  v1.begin(), v1.end(), v2.begin(), v2.end(), std::inserter(common_elems, common_elems.end()));
73  return common_elems;
74 }
75 
76 double linearQuadShape2D(unsigned int node_id, std::vector<double> & xi_2d);
77 
78 double linearTriShape2D(unsigned int node_id, std::vector<double> & xi_2d);
79 
80 double linearHexShape3D(unsigned int node_id, std::vector<double> & xi_3d);
81 
82 double linearTetShape3D(unsigned int node_id, std::vector<double> & xi_3d);
83 
84 } // namespace Efa
85 
86 #endif
bool deleteFromMap(std::map< unsigned int, T * > &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:21
double linearTetShape3D(unsigned int node_id, std::vector< double > &xi_3d)
Definition: EFAFuncs.C:46
unsigned int numCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:48
double linearHexShape3D(unsigned int node_id, std::vector< double > &xi_3d)
Definition: EFAFuncs.C:31
Definition: EFAFuncs.h:16
double linearQuadShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition: EFAFuncs.C:14
std::vector< T > getCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:68
unsigned int getNewID(std::map< unsigned int, T * > &theMap)
Definition: EFAFuncs.h:37
double linearTriShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition: EFAFuncs.C:21