MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::dg::projection Namespace Reference

Functions

template<MInt nDim>
void indices (const MInt i, const MInt n, MInt *const ids)
 Calculate the 2D/3D indices for a given scalar id for accessing a field of n^nDim points. More...
 

Function Documentation

◆ indices()

template<MInt nDim>
void maia::dg::projection::indices ( const MInt  i,
const MInt  n,
MInt *const  ids 
)
inline
Author
Ansgar Niemoeller (ansgar) a.nie.nosp@m.moel.nosp@m.ler@a.nosp@m.ia.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de
Date
2016-06-01
Parameters
[in]iScalar index.
[in]nNumber of points in one dimension.
[out]idsComputed indices for all spatial directions.

This function is the inverse of, e.g. computing a (square) matrix entry position in memory as i*n+j. The last dimension always varies the fastest.

Definition at line 364 of file dgcartesiangalerkinprojection.h.

364 {
365 const MInt f1 = i / n;
366
367 IF_CONSTEXPR(nDim == 2) {
368 ids[0] = f1;
369 ids[1] = i - f1 * n;
370 }
371 else {
372 const MInt f2 = i / (n * n);
373
374 ids[0] = f2;
375 ids[1] = f1 - f2 * n;
376 ids[2] = i - f1 * n;
377 }
378}
int32_t MInt
Definition: maiatypes.h:62