Skip to content

Commit cf1a98d

Browse files
committed
pad nodes consistently
1 parent a501b19 commit cf1a98d

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

Common/include/geometry/dual_grid/CEdge.hpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class CEdge {
4343
using NodeArray = C2DContainer<Index, Index, StorageType::ColumnMajor, 64, DynamicSize, 2>;
4444
NodeArray Nodes; /*!< \brief Vector to store the node indices of the edge. */
4545
su2activematrix Normal; /*!< \brief Normal (area) of the edge. */
46+
const Index nEdge, nEdgeSIMD;
4647

4748
friend class CPhysicalGeometry;
4849

@@ -70,11 +71,25 @@ class CEdge {
7071
inline unsigned long GetNode(unsigned long iEdge, unsigned long iNode) const { return Nodes(iEdge,iNode); }
7172

7273
/*!
73-
* \brief SIMD version of GetNode, iNode returned for multiple iEdges.
74+
* \brief SIMD version of GetNode, iNode returned for contiguous iEdges.
7475
*/
7576
template<class T, size_t N>
76-
FORCEINLINE simd::Array<T,N> GetNode(simd::Array<T,N> iEdges, unsigned long iNode) const {
77-
return simd::Array<T,N>(Nodes[iNode], iEdges);
77+
FORCEINLINE simd::Array<T,N> GetNode(simd::Array<T,N> iEdge, unsigned long iNode) const {
78+
return simd::Array<T,N>(&Nodes(iEdge[0],iNode));
79+
}
80+
81+
/*!
82+
* \brief Sets the tail of "Nodes" to repeat one of the last edges.
83+
* \note This is needed when using the SIMD version of GetNode and
84+
* the number of edges is not a multiple of the simd width.
85+
*/
86+
void SetPaddingNodes() {
87+
for (auto iEdge = nEdge; iEdge < nEdgeSIMD; ++iEdge) {
88+
/*--- Pad nodes by repeating the first edge in the last SIMD group. ---*/
89+
const auto iEdge0 = nEdgeSIMD - simd::preferredLen<su2double>();
90+
Nodes(iEdge, LEFT) = Nodes(iEdge0, LEFT);
91+
Nodes(iEdge, RIGHT) = Nodes(iEdge0, RIGHT);
92+
}
7893
}
7994

8095
/*!

Common/src/geometry/CGeometry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ void CGeometry::SetEdges(void) {
13981398
}
13991399
}
14001400
}
1401+
edges->SetPaddingNodes();
14011402
}
14021403

14031404
void CGeometry::SetFaces(void) {

Common/src/geometry/dual_grid/CEdge.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131

3232
using namespace GeometryToolbox;
3333

34-
CEdge::CEdge(unsigned long nEdge, unsigned long nDim) {
34+
CEdge::CEdge(unsigned long nEdge_, unsigned long nDim)
35+
: nEdge(nEdge_),
36+
nEdgeSIMD(nextMultiple(nEdge_, simd::preferredLen<su2double>())) {
3537
/*--- Allocate with padding. ---*/
36-
const auto nEdgeSIMD = nextMultiple(nEdge, simd::preferredLen<su2double>());
3738
Nodes.resize(nEdgeSIMD,2) = 0;
3839
Normal.resize(nEdgeSIMD,nDim) = su2double(0.0);
3940
}

0 commit comments

Comments
 (0)