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