make an orthonormal projection from one set of points specified in the basis key to a lower number given by m_npts.
Project to Orthonormal basis: fB[p][i] = Ortho_p(x_i} 0 <= i,p,<npFrom (square matrix) so fB \hat{u}_p = u_i --> \hat{u}_p = inv(fB) u_i filter top modes: \hat{u}^f = diag(F)(\hat{u}} = diag(F) inv(fB) u_i Evaluate at lower points: tB[q][j] = Ortho_p(x_j) 0 <= j,q < npTo u^to_i = tB \hat{u}^f = tB diag(F) inv(fB) u_i
make an orthonormal projection from one set of points specified in the basis key to a lower order given by m_npts and return the projection back to the original points
51{
52 const auto basis =
BasisManager()[basisDataKey.m_basisKey];
53 const auto basisDataType = basisDataKey.m_basisDataType;
54
55 switch (basisDataType)
56 {
58 {
59 return MemoryRegion<TData>::template FromArray<MemSpace>(
60 basis->GetBdata());
61 break;
62 }
64 {
65 return MemoryRegion<TData>::template FromArray<MemSpace>(
66 basis->GetDbdata());
67 break;
68 }
70 {
71 auto ndata = basis->GetW().size();
72 Array<OneD, double> wTmp(ndata);
73
74 switch (basis->GetBasisType())
75 {
78 {
79 if (basis->GetPointsType() == eGaussRadauMAlpha1Beta0 ||
81 {
83 wTmp.data(), 1);
84 }
85 else
86 {
87 const auto z = basis->GetZ();
88 const auto w = basis->GetW();
89 for (unsigned int i = 0; i < ndata; ++i)
90 {
91 wTmp[i] = 0.5 * (1 -
z[i]) * w[i];
92 }
93 }
94 }
95 break;
100 {
101 if (basis->GetPointsType() == eGaussRadauMAlpha2Beta0)
102 {
104 wTmp.data(), 1);
105 }
106 else if (basis->GetPointsType() ==
107 eGaussRadauMAlpha1Beta0 ||
109 {
110 const auto z = basis->GetZ();
111 const auto w = basis->GetW();
112 for (unsigned int i = 0; i < ndata; ++i)
113 {
114 wTmp[i] = 0.25 * (1 -
z[i]) * w[i];
115 }
116 }
117 else
118 {
119 const auto z = basis->GetZ();
120 const auto w = basis->GetW();
121 for (unsigned int i = 0; i < ndata; ++i)
122 {
123 wTmp[i] = 0.25 * (1 -
z[i]) * (1 - z[i]) *
w[i];
124 }
125 }
126 break;
127 }
128 default:
129 {
130 Vmath::Vcopy(ndata, basis->GetW().data(), 1, wTmp.data(),
131 1);
132 break;
133 }
134 }
135
136 return MemoryRegion<TData>::template FromArray<MemSpace>(wTmp);
137 }
138 break;
140 {
141 return MemoryRegion<TData>::template FromArray<MemSpace>(
142 basis->GetZ());
143 }
144 break;
146 {
147 return MemoryRegion<TData>::template FromArray<MemSpace>(
148 basis->GetD()->GetPtr());
149 }
150 break;
152 {
153 const auto npTo = basisDataKey.m_npts;
154
155
156
159 ? basis->GetPointsType()
160 : basisDataKey.m_toPointsType;
161 LibUtilities::PointsKey toPkey(npTo, ptype);
162
163
165 ->GetI(toPkey)
166 ->GetPtr();
167
168 auto D = basis->GetD()->GetPtr();
169
170 auto npFrom = basis->GetNumPoints();
171 Array<OneD, double> ID(npTo * npFrom);
172
173
174 for (unsigned i = 0; i < npTo; ++i)
175 {
176 for (unsigned j = 0; j < npFrom; ++j)
177 {
179 for (unsigned k = 0; k < npFrom; ++k)
180 {
181 sum += I[i + k * npTo] * D[k + j * npFrom];
182 }
183 ID[i + npTo * j] =
sum;
184 }
185 }
186
187 return MemoryRegion<TData>::template FromArray<MemSpace>(ID);
188 }
189 break;
191 {
192 const auto npTo = basisDataKey.m_npts;
193
194
195
197 ? basis->GetPointsType()
198 : basisDataKey.m_toPointsType;
199 PointsKey toPkey(npTo, ptype);
200
201
202 auto I =
203 PointsManager()[basis->GetPointsKey()]->GetI(toPkey)->GetPtr();
204
205 return MemoryRegion<TData>::template FromArray<MemSpace>(I);
206 }
207 break;
209 {
210 const auto npTo = basisDataKey.m_npts;
211
212
213
215 ? basis->GetPointsType()
216 : basisDataKey.m_toPointsType;
217 PointsKey toPkey(npTo, ptype);
218
219
220 auto I =
221 PointsManager()[basis->GetPointsKey()]->GetI(toPkey)->GetPtr();
222
223
224 const auto npFrom = basis->GetPointsKey().GetNumPoints();
225 Array<OneD, double> tmpI(npFrom * npTo);
226 for (int i = 0; i < npFrom; ++i)
227 {
228 for (int j = 0; j < npTo; ++j)
229 {
230 tmpI[i + j * npFrom] = I[j + i * npTo];
231 }
232 }
233
234 return MemoryRegion<TData>::template FromArray<MemSpace>(tmpI);
235 }
236 break;
238 {
239 const auto npFrom = basisDataKey.m_npts;
240
241
244 ? basis->GetPointsType()
245 : basisDataKey.m_toPointsType;
246 LibUtilities::PointsKey fromPkey(npFrom, ptype);
247
248
249
250
251
252
253
254
255
257 ->GetGalerkinProjection(fromPkey)
258 ->GetPtr();
259
260 return MemoryRegion<TData>::template FromArray<MemSpace>(GP);
261 }
262 break;
263
264
265
266
267
268
269
270
271
272
273
275 {
277 "Need to define a points key to project down to");
278
279 const auto npTo = basisDataKey.m_npts;
280 const auto npFrom = basisDataKey.m_basisKey.GetNumPoints();
281
282 ASSERTL1(npTo < npFrom,
"This method assumes you are projecting to "
283 "a lower number of points");
284
285
286 LibUtilities::BasisKey fromOrth(
288 basisDataKey.m_basisKey.GetPointsKey());
291
292
293 Array<OneD, double> fB_data = fbasis->GetBdata();
294 NekMatrix<double> fBinv(npFrom, npFrom, fB_data);
295 fBinv.Invert();
296
297
298
299
300
301
302 for (unsigned j = 0; j < npFrom; ++j)
303 {
305 fBinv.GetRawPtr() + j * npFrom + npTo, 1);
306 }
307
308
309 LibUtilities::PointsKey toPkey(npTo, basisDataKey.m_toPointsType);
311 toPkey);
314 Array<OneD, double> tB_data = tbasis->GetBdata();
315
316
317
318 Array<OneD, double> tmpI(npFrom * npTo);
319 for (unsigned i = 0; i < npTo; ++i)
320 {
321 for (unsigned j = 0; j < npFrom; ++j)
322 {
324 for (unsigned k = 0; k < npFrom; ++k)
325 {
326 sum += tB_data[k * npTo + i] * fBinv.GetValue(k, j);
327 }
328 tmpI[i + j * npTo] =
sum;
329 }
330 }
331 return LibUtilities::MemoryRegion<TData>::template FromArray<
332 MemSpace>(tmpI);
333 }
334 break;
335
336
337
339 {
341 "Need to define a points key to project down to");
342
343 const auto npFilter = basisDataKey.m_npts;
344 const auto np = basisDataKey.m_basisKey.GetNumPoints();
345
346 ASSERTL1(npFilter < np,
"This method assumes you are filtering to "
347 "a lower number of points");
348
349
350 LibUtilities::BasisKey fromOrth(
352 basisDataKey.m_basisKey.GetPointsKey());
355
356
357 Array<OneD, double> fB_data = fbasis->GetBdata();
358 NekMatrix<double> fBinv(np, np, fB_data);
359 fBinv.Invert();
360
361
362
363 for (unsigned j = 0; j < np; ++j)
364 {
366 fBinv.GetRawPtr() + j * np + npFilter, 1);
367 }
368
369
370 LibUtilities::PointsKey toPkey(np, basisDataKey.m_toPointsType);
374 Array<OneD, double> tB_data = tbasis->GetBdata();
375
376
377
378 Array<OneD, double> tmpI(np * np);
379 for (unsigned i = 0; i < np; ++i)
380 {
381 for (unsigned j = 0; j < np; ++j)
382 {
384 for (unsigned k = 0; k < np; ++k)
385 {
386 sum += tB_data[k * np + i] * fBinv.GetValue(k, j);
387 }
388 tmpI[j * np + i] =
sum;
389 }
390 }
391 return LibUtilities::MemoryRegion<TData>::template FromArray<
392 MemSpace>(tmpI);
393 }
394 break;
396 {
397 const auto z = basis->GetZ();
398 Array<OneD, double> Tmp(
z.size());
399
400 for (
unsigned int i = 0; i <
z.size(); ++i)
401 {
402 Tmp[i] = 0.5 * (1.0 +
z[i]);
403 }
404
405 return MemoryRegion<TData>::template FromArray<MemSpace>(Tmp);
406 }
407 break;
409 {
410 const auto z = basis->GetZ();
412 Array<OneD, double> Tmp(n);
413
414 for (unsigned int i = 0; i < n; ++i)
415 {
416 Tmp[i] = 2 / (1.0 -
z[i]);
417 }
418
419 return MemoryRegion<TData>::template FromArray<MemSpace>(Tmp);
420 }
421 break;
422 default:
424 return MemoryRegion<TData>(0);
425 break;
426 }
427}
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
std::map< int64_t, double > sum
BasisManagerT & BasisManager(void)
std::shared_ptr< Basis > BasisSharedPtr
PointsManagerT & PointsManager(void)
@ eGaussGaussAlpha1Beta0
1D Gauss-Jacobi quadrature points,
@ eModified_B
Principle Modified Functions .
@ eOrtho_A
Principle Orthogonal Functions .
@ eModified_C
Principle Modified Functions .
@ eOrtho_C
Principle Orthogonal Functions .
@ eModifiedPyr_C
Principle Modified Functions.
@ eOrtho_B
Principle Orthogonal Functions .
@ eOrthoPyr_C
Principle Orthogonal Functions .
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)