https://mooseframework.inl.gov
Loading...
Searching...
No Matches
EFAFuncs.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
17namespace Efa
18{
19
20template <typename T>
21bool
22deleteFromMap(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
36template <typename T>
37unsigned int
38getNewID(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
47template <class T>
48unsigned int
49numCommonElems(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
57template <class T>
58unsigned int
59numCommonElems(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
67template <class T>
68std::vector<T>
69getCommonElems(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
77double linearQuadShape2D(unsigned int node_id, std::vector<double> & xi_2d);
78
79double linearTriShape2D(unsigned int node_id, std::vector<double> & xi_2d);
80
81double linearHexShape3D(unsigned int node_id, std::vector<double> & xi_3d);
82
83double linearTetShape3D(unsigned int node_id, std::vector<double> & xi_3d);
84
85} // namespace Efa
const double T
Definition EFAFuncs.h:18
std::vector< T > getCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition EFAFuncs.h:69
bool deleteFromMap(std::map< unsigned int, T * > &theMap, T *elemToDelete, bool delete_elem=true)
Definition EFAFuncs.h:22
double linearHexShape3D(unsigned int node_id, std::vector< double > &xi_3d)
Definition EFAFuncs.C:33
double linearTriShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition EFAFuncs.C:23
double linearTetShape3D(unsigned int node_id, std::vector< double > &xi_3d)
Definition EFAFuncs.C:48
unsigned int getNewID(std::map< unsigned int, T * > &theMap)
Definition EFAFuncs.h:38
unsigned int numCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition EFAFuncs.h:49
double linearQuadShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition EFAFuncs.C:16