OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
HelpFunctionsForGrid.hpp File Reference

Header file containing help-functions that perform on OpenFPM-grids. More...

#include <iostream>
#include <limits>
#include "HelpFunctions.hpp"
#include "VCluster/VCluster.hpp"
#include "Grid/grid_dist_id.hpp"

Go to the source code of this file.

Functions

template<typename grid_type >
grid_type::stype get_time_step_CFL (grid_type &grid, typename grid_type::stype u[grid_type::dims], typename grid_type::stype C)
 Computes the time step size fulfilling CFL condition according to https://www.cfd-online .com/Wiki/Courant–Friedrichs–Lewy_condition for arbitrary dimensionality.
 
template<typename grid_type >
grid_type::stype get_time_step_CFL (grid_type &grid, typename grid_type::stype u, typename grid_type::stype C)
 Computes the time step size fulfilling CFL condition according to https://www.cfd-online .com/Wiki/Courant–Friedrichs–Lewy_condition for arbitrary dimensionality.
 
template<size_t Prop, typename grid_type , typename T >
void init_grid_and_ghost (grid_type &grid, T init_value)
 Initializes given property Prop of an OpenFPM grid including ghost layer with a given value from init_value.
 
template<size_t attr_sc, size_t attr_ds, typename grid_source_type , typename grid_dest_type >
void copy_gridTogrid (const grid_source_type &grid_sc, grid_dest_type &grid_ds, bool include_ghost=false)
 Copies the value stored in a given property from a given source grid to a given destination grid.
 
template<typename grid_type >
grid_type::stype get_biggest_spacing (grid_type &grid)
 Determines the biggest spacing of a grid which is potentially anisotropic when comparing x, y (and z) coordinate axis.
 
template<typename grid_type >
grid_type::stype get_smallest_spacing (grid_type &grid)
 Determines the smallest spacing of a grid which is potentially anisotropic when comparing x, y (and z) coordinate axis.
 
template<size_t Prop1, size_t Prop2, typename grid_type >
auto average_difference (grid_type &grid)
 Computes the average difference between the values stored at two different properties of the same grid, that is, the total difference of these values summed over all the grid nodes divided by the gridsize.
 
template<size_t Prop, typename grid_type >
auto get_max_val (grid_type &grid)
 Determines the maximum value stored on a given grid at a given property.
 
template<size_t Prop, typename grid_type >
auto get_min_val (grid_type &grid)
 Determines the minimum value stored on a given grid at a given property.
 
template<size_t Prop_in, size_t Prop_out, typename grid_type >
void init_sign_prop (grid_type &grid)
 Determines the sign of a value stored at a given property and stores it in another property.
 
template<size_t Vector_in, size_t Magnitude_out, typename magnitude_type , typename gridtype >
void get_vector_magnitude (gridtype &grid)
 Computes the magnitude of the gradient (L2-norm of gradient vector).
 
template<size_t Vector_in, typename key_type , typename gridtype >
auto get_vector_magnitude (gridtype &grid, key_type &key)
 Computes the magnitude of the gradient (L2-norm of gradient vector).
 

Detailed Description

Header file containing help-functions that perform on OpenFPM-grids.

Author
Justina Stark
Date
May 2020

Definition in file HelpFunctionsForGrid.hpp.

Function Documentation

◆ average_difference()

template<size_t Prop1, size_t Prop2, typename grid_type >
auto average_difference ( grid_type grid)

Computes the average difference between the values stored at two different properties of the same grid, that is, the total difference of these values summed over all the grid nodes divided by the gridsize.

Template Parameters
Prop1Index of the first property.
Prop2Index of the second property.
grid_typeTemplate type of the input grid.
Parameters
gridInput OpenFPM grid.
Returns
Sum over all grid nodes of the difference between the value stored at Prop1 and the value stored at Prop2.

Definition at line 175 of file HelpFunctionsForGrid.hpp.

◆ copy_gridTogrid()

template<size_t attr_sc, size_t attr_ds, typename grid_source_type , typename grid_dest_type >
void copy_gridTogrid ( const grid_source_type &  grid_sc,
grid_dest_type &  grid_ds,
bool  include_ghost = false 
)

Copies the value stored in a given property from a given source grid to a given destination grid.

Template Parameters
attr_scIndex of property that contains the value that should be copied.
attr_dsIndex of property to which the value should be copied to.
grid_source_typeTemplate type of the source grid grid_sc.
grid_dest_typeTemplate type of the destination grid grid_ds.
Parameters
grid_scOpenFPM grid from which value is copied (source).
grid_dsOpenFPM grid to which value is copied to (destination).
include_ghostBool variable that defines if the copying should include the ghost layer. False, if not; true, if yes. Default: false.

Definition at line 95 of file HelpFunctionsForGrid.hpp.

◆ get_biggest_spacing()

template<typename grid_type >
grid_type::stype get_biggest_spacing ( grid_type grid)

Determines the biggest spacing of a grid which is potentially anisotropic when comparing x, y (and z) coordinate axis.

Template Parameters
grid_typeTemplate type of input grid.
Parameters
gridInput OpenFPM grid.
Returns
Biggest spacing of same type as grid-space.

Definition at line 135 of file HelpFunctionsForGrid.hpp.

◆ get_max_val()

template<size_t Prop, typename grid_type >
auto get_max_val ( grid_type grid)

Determines the maximum value stored on a given grid at a given property.

Template Parameters
PropIndex of property for which maximum should be found.
grid_typeTemplate type of the input grid.
Parameters
gridInput OpenFPM grid.
Returns
Maximum value of property Prop in grid.

Definition at line 197 of file HelpFunctionsForGrid.hpp.

◆ get_min_val()

template<size_t Prop, typename grid_type >
auto get_min_val ( grid_type grid)

Determines the minimum value stored on a given grid at a given property.

Template Parameters
PropIndex of property for which minimum should be found.
grid_typeTemplate type of the input grid.
Parameters
gridInput OpenFPM grid.
Returns
Minimum value of property Prop in grid.

Definition at line 222 of file HelpFunctionsForGrid.hpp.

◆ get_smallest_spacing()

template<typename grid_type >
grid_type::stype get_smallest_spacing ( grid_type grid)

Determines the smallest spacing of a grid which is potentially anisotropic when comparing x, y (and z) coordinate axis.

Template Parameters
grid_typeTemplate type of input grid.
Parameters
gridInput OpenFPM grid.
Returns
Smallest spacing of same type as grid-space.

Definition at line 153 of file HelpFunctionsForGrid.hpp.

◆ get_time_step_CFL() [1/2]

template<typename grid_type >
grid_type::stype get_time_step_CFL ( grid_type grid,
typename grid_type::stype  u,
typename grid_type::stype  C 
)

Computes the time step size fulfilling CFL condition according to https://www.cfd-online .com/Wiki/Courant–Friedrichs–Lewy_condition for arbitrary dimensionality.

Template Parameters
grid_typeTemplate type of the input grid.
Parameters
gridInput OpenFPM grid.
uVelocity of propagating wave if isotropic for each direction.
CCourant number.
Returns
Time step.

Definition at line 52 of file HelpFunctionsForGrid.hpp.

◆ get_time_step_CFL() [2/2]

template<typename grid_type >
grid_type::stype get_time_step_CFL ( grid_type grid,
typename grid_type::stype  u[grid_type::dims],
typename grid_type::stype  C 
)

Computes the time step size fulfilling CFL condition according to https://www.cfd-online .com/Wiki/Courant–Friedrichs–Lewy_condition for arbitrary dimensionality.

Template Parameters
grid_typeTemplate type of the input grid.
Parameters
gridInput OpenFPM grid.
uArray of size grid_type::dims containing the velocity in each dimension.
CCourant number.
Returns
Time step.

Definition at line 33 of file HelpFunctionsForGrid.hpp.

◆ get_vector_magnitude() [1/2]

template<size_t Vector_in, size_t Magnitude_out, typename magnitude_type , typename gridtype >
void get_vector_magnitude ( gridtype &  grid)

Computes the magnitude of the gradient (L2-norm of gradient vector).

Template Parameters
Phi_grad_inSize_t index of property that contains the gradient.
Phi_magnOfGrad_outSize_t index of property where the magnitude of gradient should be stored.
gridtypeType of input grid.
Parameters
gridGrid, on which the magnitude of gradient should be computed.

Definition at line 267 of file HelpFunctionsForGrid.hpp.

◆ get_vector_magnitude() [2/2]

template<size_t Vector_in, typename key_type , typename gridtype >
auto get_vector_magnitude ( gridtype &  grid,
key_type &  key 
)

Computes the magnitude of the gradient (L2-norm of gradient vector).

Template Parameters
Phi_grad_inSize_t index of property that contains the gradient.
gridtypeType of input grid.
Parameters
gridGrid, on which the magnitude of gradient should be computed.

Definition at line 291 of file HelpFunctionsForGrid.hpp.

◆ init_grid_and_ghost()

template<size_t Prop, typename grid_type , typename T >
void init_grid_and_ghost ( grid_type grid,
init_value 
)

Initializes given property Prop of an OpenFPM grid including ghost layer with a given value from init_value.

Template Parameters
PropIndex of property that should be initialized with the value from init_value.
grid_typeTemplate type of input OpenFPM grid.
TTemplate type of the variable containing the initialization value init_value.
Parameters
gridOpenFPM grid whose property Prop should be initialized, including its ghost layer.
init_valueVariable that contains the value that should be copied to Prop.

Definition at line 72 of file HelpFunctionsForGrid.hpp.

◆ init_sign_prop()

template<size_t Prop_in, size_t Prop_out, typename grid_type >
void init_sign_prop ( grid_type grid)

Determines the sign of a value stored at a given property and stores it in another property.

Template Parameters
Prop_inIndex of property that contains the value whose sign should be determined.
Prop_outIndex of property where the sign should be written to.
grid_typeTemplate type of the input grid.
Parameters
gridInput OpenFPM grid.

Definition at line 247 of file HelpFunctionsForGrid.hpp.