Nektar++
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< StdRegions::StdExpansionSharedPtr > &pColLExp)
 
const std::shared_ptr< VecVec_tGetJacInterLeave (std::vector< StdRegions::StdExpansionSharedPtr > &pCollExp, int nElmts)
 
const Array< OneD, const NekDouble > & GetJacWithStdWeights (std::vector< StdRegions::StdExpansionSharedPtr > &pColLExp)
 
const Array< TwoD, const NekDouble > & GetDerivFactors (std::vector< StdRegions::StdExpansionSharedPtr > &pColLExp)
 
const std::shared_ptr< VecVec_tGetDerivFactorsInterLeave (std::vector< StdRegions::StdExpansionSharedPtr > &pCollExp, int nElmts)
 
bool IsDeformed (std::vector< StdRegions::StdExpansionSharedPtr > &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< StdRegions::StdExpansionSharedPtr > &  pColLExp)

Definition at line 216 of file CoalescedGeomData.cpp.

218{
219 if (m_twoDGeomData.count(eDerivFactors) == 0)
220 {
221 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
222
223 int nElmts = pCollExp.size();
224 int npts = pCollExp[0]->GetTotPoints();
225 const int coordim = pCollExp[0]->GetCoordim();
226 int dim = ptsKeys.size();
227
228 // set up Cached Jacobians to be continuous
229 Array<TwoD, NekDouble> newDFac;
230
231 if (IsDeformed(pCollExp))
232 {
233 newDFac = Array<TwoD, NekDouble>(dim * coordim, npts * nElmts);
234 }
235 else
236 {
237 newDFac = Array<TwoD, NekDouble>(dim * coordim, nElmts);
238 }
239
240 // copy Jacobians into a continuous list and set new chatched value
241 int cnt = 0;
242 for (int i = 0; i < nElmts; ++i)
243 {
244 const StdRegions::StdExpansion *sep = &(*pCollExp[i]);
245 const LocalRegions::Expansion *lep =
246 dynamic_cast<const LocalRegions::Expansion *>(sep);
247
248 const Array<TwoD, const NekDouble> Dfac =
249 lep->GetMetricInfo()->GetDerivFactors(ptsKeys);
250
251 if (IsDeformed(pCollExp))
252 {
253 for (int j = 0; j < dim * coordim; ++j)
254 {
255 Vmath::Vcopy(npts, &Dfac[j][0], 1, &newDFac[j][cnt], 1);
256 }
257 }
258 else
259 {
260 for (int j = 0; j < dim * coordim; ++j)
261 {
262 newDFac[j][i] = Dfac[j][0];
263 }
264 }
265 cnt += npts;
266 }
267
268 m_twoDGeomData[eDerivFactors] = newDFac;
269 }
270
272}
bool IsDeformed(std::vector< StdRegions::StdExpansionSharedPtr > &pCollExp)
std::map< GeomData, Array< TwoD, NekDouble > > m_twoDGeomData
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:231
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

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

Referenced by GetDerivFactorsInterLeave().

◆ GetDerivFactorsInterLeave()

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

Definition at line 274 of file CoalescedGeomData.cpp.

276{
278 {
279 ASSERTL1(nElmt % vec_t::width == 0,
280 "Number of elements not divisible by vector "
281 "width, padding not yet implemented.");
282
283 int nBlocks = nElmt / vec_t::width;
284
285 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
286 const int coordim = pCollExp[0]->GetCoordim();
287 int dim = ptsKeys.size();
288
289 unsigned int n_df = coordim * dim;
290 alignas(vec_t::alignment) NekDouble vec[vec_t::width];
291
292 const Array<TwoD, const NekDouble> df = GetDerivFactors(pCollExp);
293 int dfsize = df.GetColumns();
294
295 VecVec_t newdf;
296
297 int npts = pCollExp[0]->GetTotPoints();
298
299 if (IsDeformed(pCollExp))
300 {
301 newdf.resize(nBlocks * n_df * npts);
302 auto *df_ptr = &newdf[0];
303 for (int e = 0; e < nBlocks; ++e)
304 {
305 for (int q = 0; q < npts; q++)
306 {
307 for (int dir = 0; dir < n_df; ++dir, ++df_ptr)
308 {
309 for (int j = 0; j < vec_t::width; ++j)
310 {
311 // manage padding
312 if ((vec_t::width * e + j) * npts + q < dfsize)
313 {
314 vec[j] =
315 df[dir][(vec_t::width * e + j) * npts + q];
316 }
317 else
318 {
319 vec[j] = 0.0;
320 }
321 }
322 (*df_ptr).load(&vec[0]);
323 }
324 }
325 }
326 }
327 else
328 {
329 newdf.resize(nBlocks * n_df);
330 for (int e = 0; e < nBlocks; ++e)
331 {
332 for (int dir = 0; dir < n_df; ++dir)
333 {
334 for (int j = 0; j < vec_t::width; ++j)
335 {
336 // padding
337 if (vec_t::width * e + j < dfsize)
338 {
339 vec[j] = df[dir][vec_t::width * e + j];
340 }
341 else
342 {
343 vec[j] = 0.0;
344 }
345 }
346 // Must have all vec_t::width elemnts aligned to do a load.
347 newdf[e * n_df + dir].load(&vec[0]);
348 }
349 }
350 }
351
354 }
355
357}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
std::map< GeomData, std::shared_ptr< VecVec_t > > m_twoDGeomDataInterLeave
const Array< TwoD, const NekDouble > & GetDerivFactors(std::vector< StdRegions::StdExpansionSharedPtr > &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)
double NekDouble

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

◆ GetJac()

const Array< OneD, const NekDouble > & Nektar::Collections::CoalescedGeomData::GetJac ( std::vector< StdRegions::StdExpansionSharedPtr > &  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 StdRegions::StdExpansion *sep = &(*pCollExp[i]);
63 const LocalRegions::Expansion *lep =
64 dynamic_cast<const LocalRegions::Expansion *>(sep);
65
66 const Array<OneD, const NekDouble> jac =
67 lep->GetMetricInfo()->GetJac(ptsKeys);
68
69 Vmath::Vcopy(npts, &jac[0], 1, &newjac[cnt], 1);
70
71 cnt += npts;
72 }
73
74 m_oneDGeomData[eJac] = newjac;
75 }
76 else
77 {
78 Array<OneD, NekDouble> newjac(nElmts);
79 // copy Jacobians into a continuous list
80 for (int i = 0; i < nElmts; ++i)
81 {
82 const StdRegions::StdExpansion *sep = &(*pCollExp[i]);
83 const LocalRegions::Expansion *lep =
84 dynamic_cast<const LocalRegions::Expansion *>(sep);
85
86 const Array<OneD, const NekDouble> jac =
87 lep->GetMetricInfo()->GetJac(ptsKeys);
88
89 newjac[i] = jac[0];
90 }
91 m_oneDGeomData[eJac] = newjac;
92 }
93 }
94
95 return m_oneDGeomData[eJac];
96}
std::map< GeomData, Array< OneD, NekDouble > > m_oneDGeomData

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

Referenced by GetJacInterLeave().

◆ GetJacInterLeave()

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

Definition at line 98 of file CoalescedGeomData.cpp.

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

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

◆ GetJacWithStdWeights()

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

Definition at line 175 of file CoalescedGeomData.cpp.

177{
178 if (m_oneDGeomData.count(eJacWithStdWeights) == 0)
179 {
180 LibUtilities::PointsKeyVector ptsKeys = pCollExp[0]->GetPointsKeys();
181 int nElmts = pCollExp.size();
182 int npts = pCollExp[0]->GetTotPoints();
183
184 // copy Jacobians into a continuous list and set new chatched value
185 Array<OneD, NekDouble> newjac(npts * nElmts), tmp;
186 int cnt = 0;
187 for (int i = 0; i < nElmts; ++i)
188 {
189 const StdRegions::StdExpansion *sep = &(*pCollExp[i]);
190 const LocalRegions::Expansion *lep =
191 dynamic_cast<const LocalRegions::Expansion *>(sep);
192
193 const Array<OneD, const NekDouble> jac =
194 lep->GetMetricInfo()->GetJac(ptsKeys);
195
196 if (lep->GetMetricInfo()->GetGtype() == SpatialDomains::eDeformed)
197 {
198 Vmath::Vcopy(npts, &jac[0], 1, &newjac[cnt], 1);
199 }
200 else
201 {
202 Vmath::Fill(npts, jac[0], &newjac[cnt], 1);
203 }
204
205 pCollExp[0]->MultiplyByStdQuadratureMetric(newjac + cnt,
206 tmp = newjac + cnt);
207 cnt += npts;
208 }
209
211 }
212
214}
@ 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(), Nektar::LocalRegions::Expansion::GetMetricInfo(), m_oneDGeomData, and Vmath::Vcopy().

◆ IsDeformed()

bool Nektar::Collections::CoalescedGeomData::IsDeformed ( std::vector< StdRegions::StdExpansionSharedPtr > &  pCollExp)

Definition at line 359 of file CoalescedGeomData.cpp.

361{
362 const StdRegions::StdExpansion *sep = &(*pCollExp[0]);
363 const LocalRegions::Expansion *lep =
364 dynamic_cast<const LocalRegions::Expansion *>(sep);
365 return lep->GetMetricInfo()->GetGtype() == SpatialDomains::eDeformed;
366}

References Nektar::SpatialDomains::eDeformed, and Nektar::LocalRegions::Expansion::GetMetricInfo().

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().