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

Approximating upwind gradients on a grid with the following options for the order of accuracy: 1, 3 or 5. More...

#include <cmath>
#include "Grid/grid_dist_id.hpp"
#include "FD_simple.hpp"
#include "Eno_Weno.hpp"
#include "level_set/redistancing_Sussman/HelpFunctions.hpp"

Go to the source code of this file.

Functions

template<typename field_type >
static field_type upwinding (field_type dplus, field_type dminus, int sign)
 Upwinding: For a specific dimension, from the forward and backward gradient find the upwind side.
 
template<typename velocity_type >
int get_sign_velocity (velocity_type v, size_t d)
 Returns the sign of a scalar velocity field.
 
template<typename velocity_type >
int get_sign_velocity (velocity_type v[], size_t d)
 Returns the sign of one component in a vector velocity field.
 
template<size_t Field, size_t Velocity, typename gridtype , typename keytype >
auto FD_upwind (gridtype &grid, keytype &key, size_t d, size_t order)
 Get the upwind finite difference of a scalar property on the current grid node.
 
template<size_t Field, size_t Velocity, size_t Gradient, typename gridtype >
void upwind_gradient (gridtype &grid, const bool one_sided_BC, size_t order)
 Computes upwind gradient with order of accuracy 1, 3 or 5.
 
template<typename gridtype >
static bool ghost_width_is_sufficient (gridtype &grid, size_t required_width)
 Checks if ghost layer is thick enough for a given stencil-width.
 
template<size_t Field_in, size_t Velocity, size_t Gradient_out, typename gridtype >
void get_upwind_gradient (gridtype &grid, const size_t order=5, const bool one_sided_BC=true)
 Calls upwind_gradient. Computes upwind gradient of desired order {1, 3, 5} for the whole n-dim grid.
 

Detailed Description

Approximating upwind gradients on a grid with the following options for the order of accuracy: 1, 3 or 5.

For solving hyperbolic PDEs using differencing that is biased by the direction of the wave front. Upwinding is done according to M. Sussman and E. Fatemi, “Efficient, interface-preserving level set redistancing algorithm and its application to interfacial incompressible fluid flow” (1999) ), paragraph 4.1, 2 b). Order 1 is achieved by upwinding of forward and backward finite difference, order 3 and 5 by upwinding the ENO and WENO scheme, respectively.

Author
Justina Stark
Date
May 2021

Definition in file Upwind_gradient.hpp.

Function Documentation

◆ FD_upwind()

template<size_t Field, size_t Velocity, typename gridtype , typename keytype >
auto FD_upwind ( gridtype &  grid,
keytype &  key,
size_t  d,
size_t  order 
)

Get the upwind finite difference of a scalar property on the current grid node.

Order of accuracy can be 1, 3 or 5.

Template Parameters
FieldSize_t index of property for which the gradient should be computed.
VelocitySize_t index of property that contains the velocity field. Can be scalar or vector field.
gridtypeType of input grid.
keytypeType of key variable.
Parameters
gridGrid, on which the gradient should be computed.
keyKey that contains the index of the current grid node.
dVariable (size_t) that contains the dimension.
orderOrder of accuracy of the difference scheme. Can be 1, 3 or 5.
Returns
Upwind finite difference in one dimension of the property under index Field on the current node with index key.

Definition at line 95 of file Upwind_gradient.hpp.

◆ get_sign_velocity() [1/2]

template<typename velocity_type >
int get_sign_velocity ( velocity_type  v,
size_t  d 
)
inline

Returns the sign of a scalar velocity field.

Template Parameters
velocity_typeTemplate type of velocity (scalar).
Parameters
vVelocity of type velocity_type.
dDimension. This is a dummy to simplify call in module FD_upwind.
Returns
Sign of velocity v.

Definition at line 62 of file Upwind_gradient.hpp.

◆ get_sign_velocity() [2/2]

template<typename velocity_type >
int get_sign_velocity ( velocity_type  v[],
size_t  d 
)
inline

Returns the sign of one component in a vector velocity field.

Template Parameters
velocity_typeTemplate type of velocity (vector).
Parameters
vVelocity of type velocity_type.
dComponent of velocity vector for which sign should be returned.
Returns
Sign of component d from velocity v.

Definition at line 75 of file Upwind_gradient.hpp.

◆ get_upwind_gradient()

template<size_t Field_in, size_t Velocity, size_t Gradient_out, typename gridtype >
void get_upwind_gradient ( gridtype &  grid,
const size_t  order = 5,
const bool  one_sided_BC = true 
)

Calls upwind_gradient. Computes upwind gradient of desired order {1, 3, 5} for the whole n-dim grid.

Template Parameters
FieldSize_t index of property for which the gradient should be computed.
VelocitySize_t index of property that contains the velocity field. Can be scalar or vector field.
GradientSize_t index of property where the upwind gradient result should be stored.
gridtypeType of input grid.
Parameters
gridGrid, on which the gradient should be computed.

Definition at line 242 of file Upwind_gradient.hpp.

◆ ghost_width_is_sufficient()

template<typename gridtype >
static bool ghost_width_is_sufficient ( gridtype &  grid,
size_t  required_width 
)
static

Checks if ghost layer is thick enough for a given stencil-width.

Template Parameters
gridtypeType of input grid.
Parameters
gridGrid, for which ghost layer width should be checked.
required_widthSize_t variable, number of ghost nodes that are required in one direction.
Returns
Bool, true if ghost layer sufficiently large, false otherwise.

Definition at line 214 of file Upwind_gradient.hpp.

◆ upwind_gradient()

template<size_t Field, size_t Velocity, size_t Gradient, typename gridtype >
void upwind_gradient ( gridtype &  grid,
const bool  one_sided_BC,
size_t  order 
)

Computes upwind gradient with order of accuracy 1, 3 or 5.

Checks if a point lays within the grid or at the boundary. For the internal grid points, it calls upwind finite difference FD_upwind(). For the border points, simply FD_forward() and FD_backward() is used, respectively, depending on the side of the border.

Template Parameters
FieldSize_t index of property for which the gradient should be computed.
VelocitySize_t index of property that contains the velocity field. Can be scalar or vector field.
GradientSize_t index of property where the gradient result should be stored.
gridtypeType of input grid.
Parameters
gridGrid, on which the gradient should be computed.
one_sided_BCBool variable, if true, use one-sided kernel for boundary-nodes. If false, extend stencil onto ghost nodes.
orderSize_t variable, order of accuracy the upwind FD scheme should have. Can be 1, 3 or 5.

Definition at line 149 of file Upwind_gradient.hpp.

◆ upwinding()

template<typename field_type >
static field_type upwinding ( field_type  dplus,
field_type  dminus,
int  sign 
)
static

Upwinding: For a specific dimension, from the forward and backward gradient find the upwind side.

Parameters
dplusGradient approximated using RHS neighbors.
dminusGradient approximated using LHS neighbors.
signSign of current component of the wave front velocity.
Returns
Scalar upwind gradient approximation in the dimension given.

Definition at line 40 of file Upwind_gradient.hpp.