OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid > Class Template Reference

Implementation of the staggered grid. More...

Detailed Description

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
class staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >

Implementation of the staggered grid.

Parameters
dimDimensionality of the staggered grid
eleelements object on each dimensional objects, must be a stag_elements
        +--#--+--#--+--#--+--#--+--#--+--#--+
        |     |     |     |     |     |     |
        #  *  #  *  #  *  #  *  #  *  #  *  #
        |     |     |     |     |     |     |
        +--#--+--#--+--#--+--#--+--#--+--#--+
        |     |     |     |     |     |     |
        #  *  #  *  #  *  #  *  #  *  #  *  #
        |     |     |     |     |     |     |
        +--#--+--#--+--#--+--#--+--#--+--#--+
        |     |     |     |     |     |     |
        #  *  #  *  #  *  #  *  #  *  #  *  #
        |     |     |     |     |     |     |
        +--#--+--#--+--#--+--#--+--#--+--#--+
        |     |     |     |     |     |     |
        #  *  #  *  #  *  #  *  #  *  #  *  #
        |     |     |     |     |     |     |
        +--#--+--#--+--#--+--#--+--#--+--#--+
        |     |     |     |     |     |     |
        #  *  #  *  #  *  #  *  #  *  #  *  #
        |     |     |     |     |     |     |
        +--#--+--#--+--#--+--#--+--#--+--#--+
    In the case of a 2D staggered grid we have 3 (in general dim+1 ) elements

    + = vertex
    # = edge
      = volume

    ele = stag_ele<scalar<float>,Point_test<float>,scalar<float>>

    It place a scalar on (*) an object Point_test<float> on (#) and an object scalar<float> on (+)

Definition at line 63 of file staggered_dist_grid.hpp.

#include <staggered_dist_grid.hpp>

+ Inheritance diagram for staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >:

Public Types

typedef T value_type
 Properties for each grid point.
 
- Public Types inherited from grid_dist_id< dim, St, T, Decomposition, Memory, device_grid >
typedef device_grid d_grid
 Which kind of grid the structure store.
 
typedef Decomposition decomposition
 Decomposition used.
 
typedef T value_type
 value_type
 
typedef St stype
 Type of space.
 
typedef Memory memory_type
 Type of Memory.
 
typedef device_grid device_grid_type
 Type of device grid.
 

Public Member Functions

template<typename H >
 staggered_grid_dist (const grid_dist_id< dim, St, H, typename Decomposition::base_type, Memory, grid_cpu< dim, H >> &g, const Ghost< dim, long int > &gh, Box< dim, size_t > ext)
 This constructor is special, it construct an expanded grid that perfectly overlap with the previous. More...
 
 staggered_grid_dist (const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, St > &ghost)
 Constructor. More...
 
template<unsigned int p>
void setStagPosition (openfpm::vector< comb< dim >> &cmb)
 set the staggered positions of the properties More...
 
void setDefaultStagPosition ()
 It set all the properties defined to be staggered on the default location. More...
 
template<typename Grid_dst , unsigned int... pos>
bool to_normal (Grid_dst &g_dst, const Padding< dim > &pd, const long int(&start)[dim], const long int(&stop)[dim])
 Copy the staggered grid into a normal one. More...
 
const openfpm::vector (&getStagPositions())[T
 Get the staggered positions. More...
 
void write (std::string str)
 Write a vtk file with the information of the staggered grid. More...
 
bool is_staggered_prop (size_t prp)
 Return if the properties is a staggered property or not. More...
 
bool is_staggered ()
 Return if the grid is staggered. More...
 
- Public Member Functions inherited from grid_dist_id< dim, St, T, Decomposition, Memory, device_grid >
const Box< dim, St > getDomain () const
 Get the domain where the grid is defined. More...
 
Point< dim, St > getOffset (size_t i)
 Get the point where it start the origin of the grid of the sub-domain i. More...
 
St spacing (size_t i) const
 Get the spacing of the grid in direction i. More...
 
size_t size () const
 Return the total number of points in the grid. More...
 
size_t size (size_t i) const
 Return the total number of points in the grid. More...
 
template<typename H >
 grid_dist_id (const grid_dist_id< dim, St, H, typename Decomposition::base_type, Memory, grid_cpu< dim, H >> &g, const Ghost< dim, long int > &gh, Box< dim, size_t > ext)
 This constructor is special, it construct an expanded grid that perfectly overlap with the previous. More...
 
 grid_dist_id (const Decomposition &dec, const size_t(&g_sz)[dim], const Ghost< dim, St > &ghost)
 
 grid_dist_id (Decomposition &&dec, const size_t(&g_sz)[dim], const Ghost< dim, St > &ghost)
 
 grid_dist_id (const Decomposition &dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
 
 grid_dist_id (Decomposition &&dec, const size_t(&g_sz)[dim], const Ghost< dim, long int > &g)
 
 grid_dist_id (const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, St > &g)
 
 grid_dist_id (const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, long int > &g)
 
 grid_dist_id (const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, St > &g, const periodicity< dim > &p)
 
 grid_dist_id (const size_t(&g_sz)[dim], const Box< dim, St > &domain, const Ghost< dim, long int > &g, const periodicity< dim > &p)
 
const grid_sm< dim, T > & getGridInfo () const
 Get an object containing the grid informations. More...
 
const grid_sm< dim, void > & getGridInfoVoid () const
 Get an object containing the grid informations without type. More...
 
DecompositiongetDecomposition ()
 Get the object that store the information about the decomposition. More...
 
const DecompositiongetDecomposition () const
 Get the object that store the information about the decomposition. More...
 
const CellDecomposer_sm< dim,
St, shift< dim, St > > & 
getCellDecomposer () const
 Return the cell decomposer. More...
 
bool isInside (const grid_key_dx< dim > &gk) const
 Check that the global grid key is inside the grid domain. More...
 
size_t getLocalDomainSize () const
 Get the total number of grid points for the calling processor. More...
 
size_t getLocalDomainWithGhostSize () const
 Get the total number of grid points with ghost for the calling processor. More...
 
const openfpm::vector< GBoxes
< device_grid::dims > > & 
getLocalGridsInfo ()
 It return the informations about the local grids. More...
 
void getGlobalGridsInfo (openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_global) const
 It gathers the information about local grids for all of the processors. More...
 
grid_dist_iterator< dim,
device_grid, FREE > 
getOldDomainIterator () const
 It return an iterator that span the full grid domain (each processor span its local domain) More...
 
grid_dist_iterator< dim,
device_grid, FREE > 
getDomainIterator () const
 It return an iterator that span the full grid domain (each processor span its local domain) More...
 
template<unsigned int Np>
grid_dist_iterator< dim,
device_grid, FREE,
stencil_offset_compute< dim,
Np > > 
getDomainIteratorStencil (const grid_key_dx< dim >(&stencil_pnt)[Np]) const
 It return an iterator that span the full grid domain (each processor span its local domain) More...
 
grid_dist_iterator< dim,
device_grid, FIXED > 
getDomainGhostIterator () const
 It return an iterator that span the grid domain + ghost part. More...
 
grid_dist_iterator_sub< dim,
device_grid > 
getSubDomainIterator (const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop) const
 It return an iterator that span the grid domain only in the specified part. More...
 
grid_dist_iterator_sub< dim,
device_grid > 
getSubDomainIterator (const long int(&start)[dim], const long int(&stop)[dim]) const
 It return an iterator that span the grid domain only in the specified part. More...
 
 ~grid_dist_id ()
 Destructor.
 
VclustergetVC ()
 Get the Virtual Cluster machine. More...
 
bool is_staggered ()
 Indicate that this grid is not staggered. More...
 
template<unsigned int p = 0>
auto get (const grid_dist_key_dx< dim > &v1) const -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto get (const grid_dist_key_dx< dim > &v1) -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto get (grid_dist_g_dx< device_grid > &v1) const -> typename std::add_lvalue_reference< decltype(v1.getSub() ->template get< p >(v1.getKey()))>::type
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto get (grid_dist_g_dx< device_grid > &v1) -> typename std::add_lvalue_reference< decltype(v1.getSub() ->template get< p >(v1.getKey()))>::type
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto get (const grid_dist_lin_dx &v1) const -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto get (const grid_dist_lin_dx &v1) -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto getProp (const grid_dist_key_dx< dim > &v1) const -> decltype(this->template get< p >(v1))
 Get the reference of the selected element. More...
 
template<unsigned int p = 0>
auto getProp (const grid_dist_key_dx< dim > &v1) -> decltype(this->template get< p >(v1))
 Get the reference of the selected element. More...
 
template<int... prp>
void ghost_get ()
 It synchronize the ghost parts. More...
 
template<template< typename, typename > class op, int... prp>
void ghost_put ()
 It synchronize the ghost parts. More...
 
grid_dist_id< dim, St, T,
Decomposition, Memory,
device_grid > & 
copy (grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > &g, bool use_memcpy=true)
 Copy the give grid into this grid. More...
 
Point< dim, St > getSpacing ()
 Get the spacing on each dimension. More...
 
grid_key_dx< dim > getGKey (const grid_dist_key_dx< dim > &k)
 Convert a g_dist_key_dx into a global key. More...
 
bool write (std::string output, size_t opt=VTK_WRITER|FORMAT_ASCII)
 Write the distributed grid information. More...
 
bool write_frame (std::string output, size_t i, size_t opt=VTK_WRITER|FORMAT_ASCII)
 Write the distributed grid information. More...
 
device_grid & get_loc_grid (size_t i)
 Get the i sub-domain grid. More...
 
grid_key_dx_iterator_sub< dim,
no_stencil
get_loc_grid_iterator (size_t i)
 Get the i sub-domain grid. More...
 
template<unsigned int Np>
grid_key_dx_iterator_sub< dim,
stencil_offset_compute< dim,
Np > > 
get_loc_grid_iterator_stencil (size_t i, const grid_key_dx< dim >(&stencil_pnt)[Np])
 Get the i sub-domain grid. More...
 
size_t getN_loc_grid ()
 Return the number of local grid. More...
 
long int who ()
 It return the id of structure in the allocation list. More...
 
void debugPrint ()
 It print the internal ghost boxes and external ghost boxes in global unit. More...
 
void setPropNames (const openfpm::vector< std::string > &names)
 Set the properties names. More...
 
void map ()
 It move all the grid parts that do not belong to the local processor to the respective processor. More...
 
void save (const std::string &filename) const
 
void load (const std::string &filename)
 
const openfpm::vector
< i_lbox_grid< dim > > & 
get_loc_ig_box ()
 Get the internal local ghost box. More...
 
const openfpm::vector
< i_lbox_grid< dim > > & 
get_ig_box ()
 Get the internal ghost box. More...
 
- Public Member Functions inherited from grid_dist_id_comm< dim, St, T, Decomposition, Memory, device_grid >
void grids_reconstruct (openfpm::vector< openfpm::vector< aggregate< device_grid, SpaceBox< dim, long int >>>> &m_oGrid_recv, openfpm::vector< device_grid > &loc_grid, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm)
 Reconstruct the local grids. More...
 
void labelIntersectionGridsProcessor (Decomposition &dec, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm, openfpm::vector< device_grid > &loc_grid_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_global, openfpm::vector< openfpm::vector< aggregate< device_grid, SpaceBox< dim, long int >>>> &lbl_b, openfpm::vector< size_t > &prc_sz)
 Label intersection grids for mappings. More...
 
void map_ (Decomposition &dec, CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm, openfpm::vector< device_grid > &loc_grid, openfpm::vector< device_grid > &loc_grid_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_old, openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext_global)
 Moves all the grids that does not belong to the local processor to the respective processor. More...
 
template<int... prp>
void ghost_get_ (const openfpm::vector< ip_box_grid< dim >> &ig_box, const openfpm::vector< ep_box_grid< dim >> &eg_box, const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< device_grid > &loc_grid, std::unordered_map< size_t, size_t > &g_id_to_external_ghost_box)
 It fill the ghost part of the grids. More...
 
template<template< typename, typename > class op, int... prp>
void ghost_put_ (const openfpm::vector< ip_box_grid< dim >> &ig_box, const openfpm::vector< ep_box_grid< dim >> &eg_box, const openfpm::vector< i_lbox_grid< dim >> &loc_ig_box, const openfpm::vector< e_lbox_grid< dim >> &loc_eg_box, const openfpm::vector< GBoxes< device_grid::dims >> &gdb_ext, openfpm::vector< device_grid > &loc_grid, openfpm::vector< std::unordered_map< size_t, size_t >> &g_id_to_internal_ghost_box)
 It merge the information in the ghost with the real information. More...
 
 grid_dist_id_comm ()
 Constructor. More...
 

Static Public Attributes

static const unsigned int dims = dim
 Number of dimensions.
 
- Static Public Attributes inherited from grid_dist_id< dim, St, T, Decomposition, Memory, device_grid >
static const unsigned int dims = dim
 Number of dimensions.
 

Private Attributes

openfpm::vector< comb< dim > > c_prp [T::max_prop_real]
 position of the properties in the grid cell
 

Friends

class stag_create_and_add_grid< dim, staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >, St >
 

Additional Inherited Members

- Data Fields inherited from grid_dist_id< dim, St, T, Decomposition, Memory, device_grid >
bool init_e_g_box = false
 Flag that indicate if the external ghost box has been initialized.
 
bool init_i_g_box = false
 Flag that indicate if the internal ghost box has been initialized.
 
bool init_fix_ie_g_box = false
 Flag that indicate if the internal and external ghost box has been fixed.
 
openfpm::vector< ip_box_grid
< dim > > 
ig_box
 Internal ghost boxes in grid units.
 
openfpm::vector< ep_box_grid
< dim > > 
eg_box
 External ghost boxes in grid units.
 
openfpm::vector< i_lbox_grid
< dim > > 
loc_ig_box
 Local internal ghost boxes in grid units.
 
openfpm::vector< e_lbox_grid
< dim > > 
loc_eg_box
 Local external ghost boxes in grid units.
 
- Protected Member Functions inherited from grid_dist_id< dim, St, T, Decomposition, Memory, device_grid >
Box< dim, size_t > getDomain (size_t i)
 Given a local sub-domain i with a local grid Domain + ghost return the part of the local grid that is domain. More...
 
- Static Protected Member Functions inherited from grid_dist_id< dim, St, T, Decomposition, Memory, device_grid >
static Ghost< dim, float > convert_ghost (const Ghost< dim, long int > &gd, const CellDecomposer_sm< dim, St, shift< dim, St >> &cd_sm)
 Convert a ghost from grid point units into continus space. More...
 

Constructor & Destructor Documentation

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
template<typename H >
staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::staggered_grid_dist ( const grid_dist_id< dim, St, H, typename Decomposition::base_type, Memory, grid_cpu< dim, H >> &  g,
const Ghost< dim, long int > &  gh,
Box< dim, size_t >  ext 
)
inline

This constructor is special, it construct an expanded grid that perfectly overlap with the previous.

The key-word here is "perfectly overlap". Using the default constructor you could create something similar, but because of rounding-off error it can happen that it is not perfectly overlapping

Parameters
gprevious grid
ghGhost part in grid units
extextension of the grid (must be positive on every direction)

Definition at line 86 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::staggered_grid_dist ( const size_t(&)  g_sz[dim],
const Box< dim, St > &  domain,
const Ghost< dim, St > &  ghost 
)
inline

Constructor.

Parameters
g_szsize of the staggered grid
domaindomain
ghostpart

Definition at line 101 of file staggered_dist_grid.hpp.

Member Function Documentation

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
bool staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::is_staggered ( )
inline

Return if the grid is staggered.

Returns
true

Definition at line 234 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
bool staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::is_staggered_prop ( size_t  prp)
inline

Return if the properties is a staggered property or not.

Parameters
prpproperty to check
Returns
true if the property is staggered

Definition at line 224 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
const staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::openfpm::vector ( getStagPositions())
inline

Get the staggered positions.

Returns
for each property it contain a vector that specify where in the cell grid the properties live

Definition at line 200 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
void staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::setDefaultStagPosition ( )
inline

It set all the properties defined to be staggered on the default location.

Definition at line 126 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
template<unsigned int p>
void staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::setStagPosition ( openfpm::vector< comb< dim >> &  cmb)
inline

set the staggered positions of the properties

Template Parameters
propertyp
Parameters
cmba vector containing for each component the position in the cell-grid

Definition at line 114 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
template<typename Grid_dst , unsigned int... pos>
bool staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::to_normal ( Grid_dst &  g_dst,
const Padding< dim > &  pd,
const long int(&)  start[dim],
const long int(&)  stop[dim] 
)
inline

Copy the staggered grid into a normal one.

Template Parameters
Grid_dsttype of the destination Grid
posdestination grid properties to fill
Parameters
g_dstdestination grid
pdpadding of the grid compared to the destination grid
startstarting point
stopstop point

Definition at line 147 of file staggered_dist_grid.hpp.

template<unsigned int dim, typename St, typename T, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, typename device_grid = grid_cpu<dim,T>>
void staggered_grid_dist< dim, St, T, Decomposition, Memory, device_grid >::write ( std::string  str)
inline

Write a vtk file with the information of the staggered grid.

Parameters
strvtk output file

Definition at line 210 of file staggered_dist_grid.hpp.


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