Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Nektar::Collections::CoalescedGeomData Class Reference

#include <CoalescedGeomData.h>

Public Member Functions

 CoalescedGeomData (void)=default
 
virtual ~CoalescedGeomData (void)=default
 
const Array< OneD, const NekDouble > & GetJac (std::vector< LocalRegions::ExpansionSharedPtr > &pColLExp)
 
const std::shared_ptr< VecVec_tGetJacInterLeave (std::vector< LocalRegions::ExpansionSharedPtr > &pCollExp, int nElmts)
 
const Array< OneD, const NekDouble > & GetJacWithStdWeights (std::vector< LocalRegions::ExpansionSharedPtr > &pColLExp)
 
const Array< TwoD, const NekDouble > & GetDerivFactors (std::vector< LocalRegions::ExpansionSharedPtr > &pColLExp)
 
const std::shared_ptr< VecVec_tGetDerivFactorsInterLeave (std::vector< LocalRegions::ExpansionSharedPtr > &pCollExp, int nElmts)
 
bool IsDeformed (std::vector< LocalRegions::ExpansionSharedPtr > &pCollExp)
 

Private Attributes

std::map< GeomData, Array< OneD, NekDouble > > m_oneDGeomData
 
std::map< GeomData, Array< TwoD, NekDouble > > m_twoDGeomData
 
std::map< GeomData, std::shared_ptr< VecVec_t > > m_oneDGeomDataInterLeave
 
std::map< GeomData, std::shared_ptr< VecVec_t > > m_twoDGeomDataInterLeave
 

Detailed Description

Definition at line 57 of file CoalescedGeomData.h.

Constructor & Destructor Documentation

◆ CoalescedGeomData()

Nektar::Collections::CoalescedGeomData::CoalescedGeomData ( void  )
default

◆ ~CoalescedGeomData()

virtual Nektar::Collections::CoalescedGeomData::~CoalescedGeomData ( void  )
virtualdefault

Member Function Documentation

◆ GetDerivFactors()

const Array< TwoD, const NekDouble > & Nektar::Collections::CoalescedGeomData::GetDerivFactors ( std::vector< LocalRegions::ExpansionSharedPtr > &  pColLExp)

Definition at line 205 of file CoalescedGeomData.cpp.

207{
208 if (m_twoDGeomData.count(eDerivFactors) == 0)
209 {
210 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
211
212 int nElmts = pCollExp.size();
213 int npts = pCollExp[0]->GetTotPoints();
214 const int coordim = pCollExp[0]->GetCoordim();
215 int dim = ptsKeys.size();
216
217 // set up Cached Jacobians to be continuous
218 Array<TwoD, NekDouble> newDFac;
219
220 if (IsDeformed(pCollExp))
221 {
222 newDFac = Array<TwoD, NekDouble>(dim * coordim, npts * nElmts);
223 }
224 else
225 {
226 newDFac = Array<TwoD, NekDouble>(dim * coordim, nElmts);
227 }
228
229 // copy Jacobians into a continuous list and set new chatched value
230 int cnt = 0;
231 for (int i = 0; i < nElmts; ++i)
232 {
233 const Array<TwoD, const NekDouble> Dfac =
234 pCollExp[i]->GetGeomFactors()->GetDerivFactors();
235
236 if (IsDeformed(pCollExp))
237 {
238 for (int j = 0; j < dim * coordim; ++j)
239 {
240 Vmath::Vcopy(npts, &Dfac[j][0], 1, &newDFac[j][cnt], 1);
241 }
242 }
243 else
244 {
245 for (int j = 0; j < dim * coordim; ++j)
246 {
247 newDFac[j][i] = Dfac[j][0];
248 }
249 }
250 cnt += npts;
251 }
252
253 m_twoDGeomData[eDerivFactors] = newDFac;
254 }
255
257}
bool IsDeformed(std::vector< LocalRegions::ExpansionSharedPtr > &pCollExp)
std::map< GeomData, Array< TwoD, NekDouble > > m_twoDGeomData
std::vector< PointsKey > PointsKeyVector
Definition Points.h:313
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References Nektar::Collections::eDerivFactors, IsDeformed(), m_twoDGeomData, and Vmath::Vcopy().

Referenced by GetDerivFactorsInterLeave().

◆ GetDerivFactorsInterLeave()

const std::shared_ptr< VecVec_t > Nektar::Collections::CoalescedGeomData::GetDerivFactorsInterLeave ( std::vector< LocalRegions::ExpansionSharedPtr > &  pCollExp,
int  nElmts 
)

Definition at line 259 of file CoalescedGeomData.cpp.

261{
263 {
264 ASSERTL1(nElmt % vec_t::width == 0,
265 "Number of elements not divisible by vector "
266 "width, padding not yet implemented.");
267
268 int nBlocks = nElmt / vec_t::width;
269
270 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
271 const int coordim = pCollExp[0]->GetCoordim();
272 int dim = ptsKeys.size();
273
274 unsigned int n_df = coordim * dim;
275 alignas(vec_t::alignment) NekDouble vec[vec_t::width];
276
277 const Array<TwoD, const NekDouble> df = GetDerivFactors(pCollExp);
278 int dfsize = df.GetColumns();
279
280 VecVec_t newdf;
281
282 int npts = pCollExp[0]->GetTotPoints();
283
284 if (IsDeformed(pCollExp))
285 {
286 newdf.resize(nBlocks * n_df * npts);
287 auto *df_ptr = &newdf[0];
288 for (int e = 0; e < nBlocks; ++e)
289 {
290 for (int q = 0; q < npts; q++)
291 {
292 for (int dir = 0; dir < n_df; ++dir, ++df_ptr)
293 {
294 for (int j = 0; j < vec_t::width; ++j)
295 {
296 // manage padding
297 if ((vec_t::width * e + j) * npts + q < dfsize)
298 {
299 vec[j] =
300 df[dir][(vec_t::width * e + j) * npts + q];
301 }
302 else
303 {
304 vec[j] = 0.0;
305 }
306 }
307 (*df_ptr).load(&vec[0]);
308 }
309 }
310 }
311 }
312 else
313 {
314 newdf.resize(nBlocks * n_df);
315 for (int e = 0; e < nBlocks; ++e)
316 {
317 for (int dir = 0; dir < n_df; ++dir)
318 {
319 for (int j = 0; j < vec_t::width; ++j)
320 {
321 // padding
322 if (vec_t::width * e + j < dfsize)
323 {
324 vec[j] = df[dir][vec_t::width * e + j];
325 }
326 else
327 {
328 vec[j] = 0.0;
329 }
330 }
331 // Must have all vec_t::width elemnts aligned to do a load.
332 newdf[e * n_df + dir].load(&vec[0]);
333 }
334 }
335 }
336
339 }
340
342}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
std::map< GeomData, std::shared_ptr< VecVec_t > > m_twoDGeomDataInterLeave
const Array< TwoD, const NekDouble > & GetDerivFactors(std::vector< LocalRegions::ExpansionSharedPtr > &pColLExp)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::vector< vec_t, tinysimd::allocator< vec_t > > VecVec_t
std::vector< double > q(NPUPPER *NPUPPER)

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL1, Nektar::Collections::eDerivFactors, GetDerivFactors(), IsDeformed(), and m_twoDGeomDataInterLeave.

◆ GetJac()

const Array< OneD, const NekDouble > & Nektar::Collections::CoalescedGeomData::GetJac ( std::vector< LocalRegions::ExpansionSharedPtr > &  pColLExp)

Definition at line 44 of file CoalescedGeomData.cpp.

46{
47
48 if (m_oneDGeomData.count(eJac) == 0)
49 {
50 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
51 int nElmts = pCollExp.size();
52 int npts = pCollExp[0]->GetTotPoints();
53
54 if (IsDeformed(pCollExp))
55 {
56 Array<OneD, NekDouble> newjac(npts * nElmts);
57
58 // copy Jacobians into a continuous list and set new chatched value
59 int cnt = 0;
60 for (int i = 0; i < nElmts; ++i)
61 {
62 const Array<OneD, const NekDouble> jac =
63 pCollExp[i]->GetGeomFactors()->GetJac();
64
65 Vmath::Vcopy(npts, &jac[0], 1, &newjac[cnt], 1);
66
67 cnt += npts;
68 }
69
70 m_oneDGeomData[eJac] = newjac;
71 }
72 else
73 {
74 Array<OneD, NekDouble> newjac(nElmts);
75 // copy Jacobians into a continuous list
76 for (int i = 0; i < nElmts; ++i)
77 {
78 const Array<OneD, const NekDouble> jac =
79 pCollExp[i]->GetGeomFactors()->GetJac();
80
81 newjac[i] = jac[0];
82 }
83 m_oneDGeomData[eJac] = newjac;
84 }
85 }
86
87 return m_oneDGeomData[eJac];
88}
std::map< GeomData, Array< OneD, NekDouble > > m_oneDGeomData

References Nektar::Collections::eJac, IsDeformed(), m_oneDGeomData, and Vmath::Vcopy().

Referenced by GetJacInterLeave().

◆ GetJacInterLeave()

const std::shared_ptr< VecVec_t > Nektar::Collections::CoalescedGeomData::GetJacInterLeave ( std::vector< LocalRegions::ExpansionSharedPtr > &  pCollExp,
int  nElmts 
)

Definition at line 90 of file CoalescedGeomData.cpp.

92{
93
94 if (m_oneDGeomDataInterLeave.count(eJac) == 0)
95 {
96 const Array<OneD, const NekDouble> jac = GetJac(pCollExp);
97 int jacsize = jac.size();
98 int npts = pCollExp[0]->GetTotPoints();
99
100 ASSERTL1(nElmt % vec_t::width == 0,
101 "Number of elements not divisible by vector "
102 "width, padding not yet implemented.");
103 int nBlocks = nElmt / vec_t::width;
104
105 VecVec_t newjac;
106
107 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
108
109 if (IsDeformed(pCollExp))
110 {
111 newjac.resize(nBlocks * npts);
112
113 alignas(vec_t::alignment) NekDouble tmp[vec_t::width];
114
115 for (size_t block = 0; block < nBlocks; ++block)
116 {
117 size_t nblock_width = block * npts * vec_t::width;
118 for (size_t q = 0; q < npts; q++)
119 {
120 for (int j = 0; j < vec_t::width; ++j)
121 {
122 if (nblock_width + npts * j + q < jacsize)
123 {
124 tmp[j] = jac[nblock_width + npts * j + q];
125 }
126 else
127 {
128 tmp[j] = 0.0;
129 }
130 }
131
132 // Order is [block][quadpt]
133 newjac[block * npts + q].load(&tmp[0]);
134 }
135 }
136 }
137 else
138 {
139 newjac.resize(nBlocks);
140
141 alignas(vec_t::alignment) NekDouble tmp[vec_t::width];
142 for (size_t i = 0; i < nBlocks; ++i)
143 {
144 for (int j = 0; j < vec_t::width; ++j)
145 {
146 if (vec_t::width * i + j < jacsize)
147 {
148 tmp[j] = jac[vec_t::width * i + j];
149 }
150 else
151 {
152 tmp[j] = 0.0;
153 }
154 }
155
156 newjac[i].load(&tmp[0]);
157 }
158 }
159
162 }
163
165}
std::map< GeomData, std::shared_ptr< VecVec_t > > m_oneDGeomDataInterLeave
const Array< OneD, const NekDouble > & GetJac(std::vector< LocalRegions::ExpansionSharedPtr > &pColLExp)

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL1, Nektar::Collections::eJac, GetJac(), IsDeformed(), and m_oneDGeomDataInterLeave.

◆ GetJacWithStdWeights()

const Array< OneD, const NekDouble > & Nektar::Collections::CoalescedGeomData::GetJacWithStdWeights ( std::vector< LocalRegions::ExpansionSharedPtr > &  pColLExp)

Definition at line 167 of file CoalescedGeomData.cpp.

169{
170 if (m_oneDGeomData.count(eJacWithStdWeights) == 0)
171 {
172 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
173 int nElmts = pCollExp.size();
174 int npts = pCollExp[0]->GetTotPoints();
175
176 // copy Jacobians into a continuous list and set new chatched value
177 Array<OneD, NekDouble> newjac(npts * nElmts), tmp;
178 int cnt = 0;
179 for (int i = 0; i < nElmts; ++i)
180 {
181 const Array<OneD, const NekDouble> jac =
182 pCollExp[i]->GetGeomFactors()->GetJac();
183
184 if (pCollExp[i]->GetGeomFactors()->GetGtype() ==
186 {
187 Vmath::Vcopy(npts, &jac[0], 1, &newjac[cnt], 1);
188 }
189 else
190 {
191 Vmath::Fill(npts, jac[0], &newjac[cnt], 1);
192 }
193
194 pCollExp[0]->MultiplyByStdQuadratureMetric(newjac + cnt,
195 tmp = newjac + cnt);
196 cnt += npts;
197 }
198
200 }
201
203}
@ eDeformed
Geometry is curved or has non-constant factors.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition Vmath.hpp:54

References Nektar::SpatialDomains::eDeformed, Nektar::Collections::eJacWithStdWeights, Vmath::Fill(), m_oneDGeomData, and Vmath::Vcopy().

◆ IsDeformed()

bool Nektar::Collections::CoalescedGeomData::IsDeformed ( std::vector< LocalRegions::ExpansionSharedPtr > &  pCollExp)

Definition at line 344 of file CoalescedGeomData.cpp.

346{
347 return pCollExp[0]->GetGeomFactors()->GetGtype() ==
349}

References Nektar::SpatialDomains::eDeformed.

Referenced by GetDerivFactors(), GetDerivFactorsInterLeave(), GetJac(), and GetJacInterLeave().

Member Data Documentation

◆ m_oneDGeomData

std::map<GeomData, Array<OneD, NekDouble> > Nektar::Collections::CoalescedGeomData::m_oneDGeomData
private

Definition at line 82 of file CoalescedGeomData.h.

Referenced by GetJac(), and GetJacWithStdWeights().

◆ m_oneDGeomDataInterLeave

std::map<GeomData, std::shared_ptr<VecVec_t> > Nektar::Collections::CoalescedGeomData::m_oneDGeomDataInterLeave
private

Definition at line 84 of file CoalescedGeomData.h.

Referenced by GetJacInterLeave().

◆ m_twoDGeomData

std::map<GeomData, Array<TwoD, NekDouble> > Nektar::Collections::CoalescedGeomData::m_twoDGeomData
private

Definition at line 83 of file CoalescedGeomData.h.

Referenced by GetDerivFactors().

◆ m_twoDGeomDataInterLeave

std::map<GeomData, std::shared_ptr<VecVec_t> > Nektar::Collections::CoalescedGeomData::m_twoDGeomDataInterLeave
private

Definition at line 85 of file CoalescedGeomData.h.

Referenced by GetDerivFactorsInterLeave().