ivutils
Loading...
Searching...
No Matches
UniformGrid< value_tt, interleave, index_t, data_structure_t > Class Template Reference

uniform grid in space More...

#include <grid.h>

Inheritance diagram for UniformGrid< value_tt, interleave, index_t, data_structure_t >:
Collaboration diagram for UniformGrid< value_tt, interleave, index_t, data_structure_t >:

Public Member Functions

iterator get_same (const iterator &it) const
 returns iterator with the same indicies but this parent grid
 
template<class T , size_t il>
 UniformGrid (const UniformGrid< T, il, index_t, data_structure_t > &other)
 constructs grid with the same geometrical layout
 
template<class T , size_t il>
void init (const UniformGrid< T, il, index_t, data_structure_t > &other)
 initializes grid with the same geometrical layout as the other
 
void init (const Vector_3 &v1, const Vector_3 &v2, const int dir, const index_t *sz, const index_t *start=NULL, const index_t *end=NULL)
 v1, v2 are opposite points of the box which confines the grid sz is array form 3 numbers specifying grid nodes numbers along 3 directions dir is wierd construction.
 
void SetIteratorRange (const index_t *start=NULL, const index_t *end=NULL)
 sets limits for iterator
 
void SetInterpolationRange (const index_t *start=NULL, const index_t *end=NULL)
 sets limits for interpolation
 
void SetMemoryRange (const index_t *start=NULL, const index_t *end=NULL)
 set memory block ranges to be addressed
 
size_t msize (int dir=-1) const
 gets active array size in memory
 
size_t size () const
 gets full size in memory (including auxilliary cells)
 
Vector_3 get_total_surface () const
 get total grid surface, if grid is 2D in 3D space
 
Vector_3 Position (index_t ix, index_t iy, index_t iz) const
 
index_t get_range1 (index_t shift) const
 gets the loop ranges for two loops: [0, range1) and [range1, nintz) which must be performed for each interleave bank for convolution with given positive shift returns: bank section point: range1 bank shift for the first loop (the other one is dbank0+1), shifts for the first and the second loop
 
bool check_interpolation_ind (index_t ix, index_t iy, index_t iz) const
 validity check for interpolation index
 
bool check_memory_ind (index_t ix, index_t iy, index_t iz) const
 validity check for memory index
 
bool check_iterator_ind (index_t ix, index_t iy, index_t iz) const
 validity check for iterator index
 
template<typename iter_t >
bool check_iterator_ind (const iter_t &it) const
 validity check for iterator index
 
bool check_iterator_ind_comp (int comp, index_t ix) const
 validity check for memory index by component
 
int GetCoeff (const Vector_3 &place, index_t *int_ind, vec_type *values, int force_external=0, std::vector< Vector_3 > *nonlocal=NULL, bool all_nonlocal=false) const
 Gets interpolation coefficients (int_ind - index ararys, values - coefficients in interpolation).
 
int test_local (const Vector_3 &place) const
 if point indices are inside interpolation region
 
value_tt Interpolate (const Vector_3 &place, int force_external=0) const
 interpolate value using array ptr
 
int AddValue (const Vector_3 &place, value_tt value, int force_external=0)
 distributes the value being added between nearest grid points
 

Protected Member Functions

void set_range (index_t *st, index_t *en, index_t *gr, const index_t *start, const index_t *end)
 sets range to st, en and gr uses start and end for st and en, or nst and nen, if start = end = NULL
 
virtual void get_1d_coeff (const Vector_3 &p, index_t *ind, vec_type *c, bool nonlocal=false) const
 gets 1d interpolation coefficiencts for projection on dir axis
 
template<typename descendant >
 UniformGrid (descendant *des)
 Constructor to be used in descendant classes.
 

Protected Attributes

Vector_3 dx
 data array
 
Vector_3 pref
 space step
 
Vector_3 ds
 from where grid starts. wierd construction, delete it
 
Box b
 surface area of one elementary cell
 
index_t ngr [3]
 grid is confined within this box
 
index_t igr [3]
 iterator settings. iterator starts, ends and moves correspondingly to this settings
 
index_t mgr [3]
 memory settings
 
size_t GSZ
 mgr[1]*mgr[2]
 
index_t nintz
 total used memory size
 

Friends

template<class A , class B >
class UniformGridIt
 
template<class A , class B >
class VecGridIt
 

Detailed Description

template<class value_tt, size_t interleave = 1, class index_t = int, class data_structure_t = array_data_t<index_t, interleave>>
class UniformGrid< value_tt, interleave, index_t, data_structure_t >

uniform grid in space

grid can interpolate value at its internal points (which are inside box b) by function GetCoeff, return iterator on its nodes, organize memory access to values at its nodes by functions pack_ind and unpack_ind

grid size (gr), start node (st), end node (en) along each direction for these these functionalities are defined by arrays with names starting with n (interpolation), i (interpolation), m (memory)

usually they are the same for each functionality, but for some special cases (like parallel implementation) could be different

memory access is managed by interleave parameter. here we explain it using example of 1d grid of 10 elements. if interleave = 1, then data is stored in the natural order: 0 1 2 3 4 5 6 7 8 9 if interleave = 2, then data is stored in a different way: 0 2 4 6 8 1 3 5 7 9 if interleave = 5, then we have: 0 5 1 6 2 7 3 8 4 9 total grid size GSZ should be multiple if interleave: GSZ = interleave * nintz, where nintz is some integer number

in 3d case, index change order is z(2), y(1), x(0), for example for grid 4x4x4 (inerleave=1): 111 112 113 114 121 122 123 124 131 132 133 134 141 142 143 144 211 212 213 214 221 222 223 224 231 232 233 234 241 242 243 244 311 312 313 314 321 322 323 324 331 332 333 334 341 342 343 344 411 412 413 414 421 422 423 424 431 432 433 434 441 442 443 444

for interleave!=1 there are two possible cases: global_il!=0 or global_il=0 which we consider on example interleave=2:

if global_il!=0, then interleave works "globaly": 111 113 121 123 131 133 141 143 211 213 221 223, etc in this case grid size could be extended by auxiliary cells in order to be multiple of interleave

if global_il=0, then interleave works only for fastest z-direction: 111 113 112 114 121 123 122 124, etc if this case grid size aling z-direction must be multiple of interleave

Constructor & Destructor Documentation

◆ UniformGrid()

template<class value_tt , size_t interleave = 1, class index_t = int, class data_structure_t = array_data_t<index_t, interleave>>
template<typename descendant >
UniformGrid< value_tt, interleave, index_t, data_structure_t >::UniformGrid ( descendant *  des)
inlineprotected

Constructor to be used in descendant classes.

If we use any other constructor, data_structure_t will get UniformGrid * as argument, not a descendant pointer. So it won't see it's member fields.

Member Function Documentation

◆ AddValue()

template<class value_tt , size_t il, class index_t , class data_t >
int UniformGrid< value_tt, il, index_t, data_t >::AddValue ( const Vector_3 place,
value_tt  value,
int  force_external = 0 
)

distributes the value being added between nearest grid points

Returns
the number of grid points affected

◆ GetCoeff()

template<class value_tt , size_t il, class index_t , class data_t >
int UniformGrid< value_tt, il, index_t, data_t >::GetCoeff ( const Vector_3 place,
index_t *  int_ind,
vec_type *  values,
int  force_external = 0,
std::vector< Vector_3 > *  nonlocal = NULL,
bool  all_nonlocal = false 
) const

Gets interpolation coefficients (int_ind - index ararys, values - coefficients in interpolation).

the arrays must be at least 8 elements long. if force_external, then point which is outside box will be interpolated as well. if nonlocal is not NULL,
the negative indicies in int_ind correspond to absent grid points, the space location of kth absent point is pushed_back to nonlocal[-int_ind[k]-1]. returns number of elements in interpolation

◆ init()

template<class value_tt , size_t il, class index_t , class data_t >
void UniformGrid< value_tt, il, index_t, data_t >::init ( const Vector_3 v1,
const Vector_3 v2,
const int  dir,
const index_t *  sz,
const index_t *  start = NULL,
const index_t *  end = NULL 
)

v1, v2 are opposite points of the box which confines the grid sz is array form 3 numbers specifying grid nodes numbers along 3 directions dir is wierd construction.

if dir!=0, then for abs(dir)-1 ds is calculated, and sign of dir corresponds to ds direction if start and end are not NULL, then interpolation, iterator and memory ranges will be specified by start and end

◆ Position()

template<class value_tt , size_t interleave = 1, class index_t = int, class data_structure_t = array_data_t<index_t, interleave>>
Vector_3 UniformGrid< value_tt, interleave, index_t, data_structure_t >::Position ( index_t  ix,
index_t  iy,
index_t  iz 
) const
inline
Returns
the position of a given grid point

◆ SetMemoryRange()

template<class value_tt , size_t interleave = 1, class index_t = int, class data_structure_t = array_data_t<index_t, interleave>>
void UniformGrid< value_tt, interleave, index_t, data_structure_t >::SetMemoryRange ( const index_t *  start = NULL,
const index_t *  end = NULL 
)
inline

set memory block ranges to be addressed

if interleave is global and nonunity, memory size is extended to be a multiple of the interleave if interleave is local and nonunity, memory size in direction 2 must be a multiple of the interleave

Member Data Documentation

◆ ngr

template<class value_tt , size_t interleave = 1, class index_t = int, class data_structure_t = array_data_t<index_t, interleave>>
index_t UniformGrid< value_tt, interleave, index_t, data_structure_t >::ngr[3]
protected

grid is confined within this box

interpolation settings: default

◆ nintz

template<class value_tt , size_t interleave = 1, class index_t = int, class data_structure_t = array_data_t<index_t, interleave>>
index_t UniformGrid< value_tt, interleave, index_t, data_structure_t >::nintz
protected

total used memory size

if interleave is global then GSZ = interleave*nintz (GSZ can be extended to satisfy this this) if interleave is local, then mgr[2] = interleave*nintz *(mgr[2] must be multiple of interleave)


The documentation for this class was generated from the following files: