OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
RedistancingSussman< grid_in_type, phi_type > Class Template Reference

Class for reinitializing a level-set function into a signed distance function using Sussman redistancing. More...

Detailed Description

template<typename grid_in_type, typename phi_type = double>
class RedistancingSussman< grid_in_type, phi_type >

Class for reinitializing a level-set function into a signed distance function using Sussman redistancing.

First-time-only redistancing step (see: M. Sussman and E. Fatemi, “Efficient, interface-preserving level set redistancing algorithm and its application to interfacial incompressible fluid flow” (1999) ). In the Sussman-redistancing, a level-set-function Phi_0, which can be a simple step-function having positive values inside the object and negative values outside, is reinitialized to a signed distance function Phi_SDF by finding the steady-state solution of the following PDE:

\[ \phi_{t} + sgn_{\epsilon}(\phi)(|\nabla\phi| - 1) = 0 \]

The signed distance function is defined as:

\[ \phi_{\text{SDF}} = \begin{cases} +d & \text{orthogonal distance to the closest surface of a point lying inside the object} \\ 0 & \text{object surface} \\ -d & \text{orthogonal distance to the closest surface of a point lying outside the object} \\ \end{cases} \]

Author
Justina Stark
Date
April 2020
Template Parameters
grid_in_typeTemplate type of input grid, which stores the initial level-set function Phi_0.

Definition at line 161 of file RedistancingSussman.hpp.

#include <RedistancingSussman.hpp>

Public Types

typedef aggregate< phi_type, phi_type[grid_in_type::dims], int > props_temp
 Aggregated properties for the temporary grid. More...
 
typedef grid_dist_id< grid_in_type::dims, typename grid_in_type::stype, props_tempg_temp_type
 Type definition for the temporary grid.
 

Public Member Functions

 RedistancingSussman (grid_in_type &grid_in, Redist_options< phi_type > &redistOptions)
 Constructor initializing the redistancing options, the temporary internal grid and reference variable to the input grid. More...
 
template<size_t Phi_0_in, size_t Phi_SDF_out>
void run_redistancing ()
 Runs the Sussman-redistancing. More...
 
template<typename T >
void set_user_time_step (T dt)
 Overwrite the time_step found via CFL condition with an individual time_step. More...
 
auto get_time_step ()
 Access the artificial timestep (private member) which will be used for the iterative redistancing. More...
 
int get_finalIteration ()
 
auto get_finalChange ()
 
auto get_finalResidual ()
 
int get_finalNumberNbPoints ()
 

Data Fields

g_temp_type g_temp
 Create temporary grid, which is only used inside the class for the redistancing. More...
 

Private Member Functions

template<size_t Phi_0_in>
void init_temp_grid ()
 Copies values from input grid to internal temporary grid and initializes ghost layer with minimum value of input grid.
 
phi_type get_phi_nplus1 (phi_type phi_n, phi_type phi_n_magnOfGrad, typename grid_in_type::stype dt, phi_type sgn_phi_n)
 Run one timestep of re-distancing and compute Phi_n+1. More...
 
void go_one_redistancing_step_whole_grid (g_temp_type &grid)
 Go one re-distancing time-step on the whole grid. More...
 
bool lays_inside_NB (phi_type Phi)
 Checks if a node lays within the narrow band around the interface. More...
 
void update_distFromSol (g_temp_type &grid)
 Re-computes the member variables distFromSol.change, distFromSol.residual, distFromSol.count for the Phi of the current iteration. Needed to check how far current solution is from fulfilling the user-defined convergence criteria. More...
 
void print_out_iteration_change_residual (g_temp_type &grid, size_t iter)
 Prints out the iteration number, max. change, max. residual and number of points in the narrow band of the current re-distancing iteration. More...
 
bool steady_state_NB (g_temp_type &grid)
 Checks steady-state is reached in the narrow band. More...
 
void iterative_redistancing (g_temp_type &grid)
 Runs Sussman re-distancing on the internal temporary grid. More...
 

Private Attributes

Redist_options< phi_type > redistOptions
 Instantiate redistancing options.
 
grid_in_type & r_grid_in
 Define reference to input grid.
 
DistFromSol< phi_type > distFromSol
 Instantiate distance from solution in terms of change, residual, numb.
 
int final_iter = 0
 Will be set to the final iteration when redistancing ends.
 
phi_type kappa = ceil(redistOptions.width_NB_in_grid_points / 2.0) * get_biggest_spacing(g_temp)
 Transform the half-bandwidth in no_of_grid_points into physical half-bandwidth kappa.
 
grid_in_type::stype time_step
 Artificial timestep for the redistancing iterations. More...
 
int order_upwind_gradient
 

Static Private Attributes

static constexpr size_t Phi_n_temp = 0
 Property index of Phi_0 on the temporary grid.
 
static constexpr size_t Phi_grad_temp = 1
 Property index of gradient of Phi_n on the temporary grid.
 
static constexpr size_t Phi_0_sign_temp = 2
 Property index of sign of initial (input) Phi_0 (temp. grid).
 

Member Typedef Documentation

◆ props_temp

template<typename grid_in_type, typename phi_type = double>
typedef aggregate<phi_type, phi_type[grid_in_type::dims], int> RedistancingSussman< grid_in_type, phi_type >::props_temp

Aggregated properties for the temporary grid.

The initial (input) Phi_0 (will be updated by Phi_{n+1} after each redistancing step), Phi_{n+1} (received from redistancing), gradient of Phi_{n+1}, sign of the original input Phi_0 (for the upwinding).

Definition at line 193 of file RedistancingSussman.hpp.

Constructor & Destructor Documentation

◆ RedistancingSussman()

template<typename grid_in_type, typename phi_type = double>
RedistancingSussman< grid_in_type, phi_type >::RedistancingSussman ( grid_in_type &  grid_in,
Redist_options< phi_type > &  redistOptions 
)
inline

Constructor initializing the redistancing options, the temporary internal grid and reference variable to the input grid.

Parameters
grid_inInput grid with min. 2 properties: 1.) Phi_0, 2.) Phi_SDF <- will be overwritten with re-distancing result
redistOptionsUser defined options for the Sussman redistancing process

Definition at line 172 of file RedistancingSussman.hpp.

Member Function Documentation

◆ get_phi_nplus1()

template<typename grid_in_type, typename phi_type = double>
phi_type RedistancingSussman< grid_in_type, phi_type >::get_phi_nplus1 ( phi_type  phi_n,
phi_type  phi_n_magnOfGrad,
typename grid_in_type::stype  dt,
phi_type  sgn_phi_n 
)
inlineprivate

Run one timestep of re-distancing and compute Phi_n+1.

Parameters
phi_nPhi value on current node and current time.
phi_n_magnOfGradGradient magnitude of current Phi from upwinding FD.
dtTime step.
sgn_phi_nSign of the current Phi, should be the smooth sign.
Returns
Phi_n+1 which is the Phi of the next time step on current node.

Definition at line 325 of file RedistancingSussman.hpp.

◆ get_time_step()

template<typename grid_in_type, typename phi_type = double>
auto RedistancingSussman< grid_in_type, phi_type >::get_time_step ( )
inline

Access the artificial timestep (private member) which will be used for the iterative redistancing.

See also
get_time_step_CFL(g_temp_type &grid), set_user_time_step()

This timestep is computed according to the grid spacing fulfilling the CFL condition.

Definition at line 241 of file RedistancingSussman.hpp.

◆ go_one_redistancing_step_whole_grid()

template<typename grid_in_type, typename phi_type = double>
void RedistancingSussman< grid_in_type, phi_type >::go_one_redistancing_step_whole_grid ( g_temp_type grid)
inlineprivate

Go one re-distancing time-step on the whole grid.

Parameters
gridInternal temporary grid.

Definition at line 335 of file RedistancingSussman.hpp.

◆ iterative_redistancing()

template<typename grid_in_type, typename phi_type = double>
void RedistancingSussman< grid_in_type, phi_type >::iterative_redistancing ( g_temp_type grid)
inlineprivate

Runs Sussman re-distancing on the internal temporary grid.

The number of iterations is minimum redistOptions.min_iter iterations and finishes when either steady-state or redist_options.max_iter is reached. The steady-state convergence accuracy depends on the user defined redist_options.convTolChange.value and redist_options.convTolResidual.value, respectively.

Parameters
gridInternal temporary grid.

Definition at line 474 of file RedistancingSussman.hpp.

◆ lays_inside_NB()

template<typename grid_in_type, typename phi_type = double>
bool RedistancingSussman< grid_in_type, phi_type >::lays_inside_NB ( phi_type  Phi)
inlineprivate

Checks if a node lays within the narrow band around the interface.

Parameters
PhiValue of Phi at that specific node.
Returns
True, if node lays within nb., false, if the distance to the interface is > kappa.

Definition at line 358 of file RedistancingSussman.hpp.

◆ print_out_iteration_change_residual()

template<typename grid_in_type, typename phi_type = double>
void RedistancingSussman< grid_in_type, phi_type >::print_out_iteration_change_residual ( g_temp_type grid,
size_t  iter 
)
inlineprivate

Prints out the iteration number, max. change, max. residual and number of points in the narrow band of the current re-distancing iteration.

Parameters
gridInternal temporary grid.
iterCurrent re-distancing iteration.

Definition at line 412 of file RedistancingSussman.hpp.

◆ run_redistancing()

template<typename grid_in_type, typename phi_type = double>
template<size_t Phi_0_in, size_t Phi_SDF_out>
void RedistancingSussman< grid_in_type, phi_type >::run_redistancing ( )
inline

Runs the Sussman-redistancing.

Copies Phi_0 from input grid to an internal temporary grid which allows having more properties. Computes the gradients. Runs the redistancing on the internal temporary grid. Copies resulting signed distance function to the Phi_SDF_out property of the input grid.

Definition at line 214 of file RedistancingSussman.hpp.

◆ set_user_time_step()

template<typename grid_in_type, typename phi_type = double>
template<typename T >
void RedistancingSussman< grid_in_type, phi_type >::set_user_time_step ( dt)
inline

Overwrite the time_step found via CFL condition with an individual time_step.

If the user wants to overwrite the time_step found via CFL condition with an individual time_step. Should be only used carefully, time_step must not be too large (jump over solution) nor too small (extremely slow).

Parameters
dtArtificial time step by which re-distancing should be performed.

Definition at line 234 of file RedistancingSussman.hpp.

◆ steady_state_NB()

template<typename grid_in_type, typename phi_type = double>
bool RedistancingSussman< grid_in_type, phi_type >::steady_state_NB ( g_temp_type grid)
inlineprivate

Checks steady-state is reached in the narrow band.

Checks if change and/or residual between 2 iterations smaller than user-defined convolution tolerance.

Parameters
gridInternal temporary grid.
Returns
True, if steady-state reached, else false.
See also
Conv_tol_change, Conv_tol_residual

Definition at line 439 of file RedistancingSussman.hpp.

◆ update_distFromSol()

template<typename grid_in_type, typename phi_type = double>
void RedistancingSussman< grid_in_type, phi_type >::update_distFromSol ( g_temp_type grid)
inlineprivate

Re-computes the member variables distFromSol.change, distFromSol.residual, distFromSol.count for the Phi of the current iteration. Needed to check how far current solution is from fulfilling the user-defined convergence criteria.

Parameters
gridInternal temporary grid.

Definition at line 368 of file RedistancingSussman.hpp.

Field Documentation

◆ g_temp

template<typename grid_in_type, typename phi_type = double>
g_temp_type RedistancingSussman< grid_in_type, phi_type >::g_temp

Create temporary grid, which is only used inside the class for the redistancing.

The temporary grid stores the following 3 properties: Phi_{n+1}(received from redistancing), gradient of Phi_{n+1}, sign of the original input Phi_0 (for the upwinding).

Definition at line 205 of file RedistancingSussman.hpp.

◆ time_step

template<typename grid_in_type, typename phi_type = double>
grid_in_type::stype RedistancingSussman< grid_in_type, phi_type >::time_step
private

Artificial timestep for the redistancing iterations.

See also
get_time_step_CFL(g_temp_type &grid), get_time_step(), set_user_time_step()

Definition at line 286 of file RedistancingSussman.hpp.


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