-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeshCache.hh
116 lines (97 loc) · 2.92 KB
/
MeshCache.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef _MESHCACHE_HH_
#define _MESHCACHE_HH_
#include "MeshDefs.hh"
#include "MeshFramework.hh"
struct MeshCacheData{
RaggedArray_DualView<Coordinates> cell_coordinates;
RaggedArray_DualView<Entity_ID> cell_nodes;
RaggedArray_DualView<Entity_ID> cell_faces;
Point_DualView node_coordinates;
};
template<MemSpace_type MEM = MemSpace_type::DEVICE>
struct MeshCache{
private:
MeshCacheData & data_;
bool cell_coordinates_cached = false;
bool cell_nodes_cached = false;
bool node_coordinates_cached = false;
bool cell_geometry_cached = false;
const MeshFramework* mesh_framework_;
public:
MeshCache(MeshCacheData& d, const MeshFramework& mf): data_(d), mesh_framework_(&mf) {}
template<AccessPattern AP = AccessPattern::DEFAULT>
KOKKOS_INLINE_FUNCTION
cPoint_View getCellCoordinates(const Entity_ID c) const{
return RaggedGetter<MEM,AP>::get(
*this,
cell_coordinates_cached,
data_.cell_coordinates,
nullptr,
[&](const Entity_ID nn, const std::string& s){
return MeshAlgorithms::getCellCoordinates(*this,nn);
},
__func__,
c);
}
template<AccessPattern AP = AccessPattern::DEFAULT>
KOKKOS_INLINE_FUNCTION
decltype(auto) // Coordinates
getNodeCoordinate(const Entity_ID n) const {
return Getter<MEM,AP>::get(
*this,
node_coordinates_cached,
data_.node_coordinates,
[&](const Entity_ID nn, const std::string& s){
if(mesh_framework_)
return mesh_framework_->getNodeCoordinate(nn);
assert(false);
return Coordinates{};
},
nullptr,
__func__,
n);
}
template<AccessPattern AP = AccessPattern::DEFAULT>
KOKKOS_INLINE_FUNCTION
cEntity_ID_View getCellNodes(const Entity_ID c) const
{
return RaggedGetter<MEM,AP>::get(
*this,
cell_nodes_cached,
data_.cell_nodes,
[&](const Entity_ID nn, const std::string& s){
if(mesh_framework_){
cEntity_ID_View cnodes;
mesh_framework_->getCellNodes(nn, cnodes);
return cnodes;
}
assert(false);
return cEntity_ID_View{};
},
nullptr,
__func__,
c);
}
template<AccessPattern AP = AccessPattern::DEFAULT>
KOKKOS_INLINE_FUNCTION
cEntity_ID_View getCellFaces(const Entity_ID c) const
{
return RaggedGetter<MEM,AP>::get(
*this,
cell_geometry_cached,
data_.cell_faces,
[&](const Entity_ID nn, const std::string& s){
if(mesh_framework_){
cEntity_ID_View cfaces;
mesh_framework_->getCellFaces(nn,cfaces);
return cfaces;
}
assert(false);
return cEntity_ID_View{};
},
nullptr,
__func__,
c);
}
};
#endif