OpenFPM_pdata  4.1.0 Project that contain the implementation of distributed structures
Searching...
No Matches
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}$

Date
April 2020
Template Parameters
 grid_in_type Template 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.

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.

template<size_t Phi_0_in, size_t Phi_SDF_out>
void run_redistancing ()
Runs the Sussman-redistancing.

template<typename T >
void set_user_time_step (T dt)
Overwrite the time_step found via CFL condition with an individual time_step.

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

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.

## 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.

void go_one_redistancing_step_whole_grid (g_temp_type &grid)
Go one re-distancing time-step on the whole grid.

bool lays_inside_NB (phi_type Phi)
Checks if a node lays within the narrow band around the interface.

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.

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.

bool steady_state_NB (g_temp_type &grid)
Checks steady-state is reached in the narrow band.

void iterative_redistancing (g_temp_type &grid)
Runs Sussman re-distancing on the internal temporary grid.

## 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.

## 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).

## ◆ g_temp_type

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

Type definition for the temporary grid.

Definition at line 197 of file RedistancingSussman.hpp.

## ◆ props_temp

template<typename grid_in_type , typename phi_type = double>
 typedef aggregate 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 194 of file RedistancingSussman.hpp.

## ◆ 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_in Input grid with min. 2 properties: 1.) Phi_0, 2.) Phi_SDF <- will be overwritten with re-distancing result redistOptions User defined options for the Sussman redistancing process

Definition at line 172 of file RedistancingSussman.hpp.

## ◆ get_finalChange()

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

Definition at line 253 of file RedistancingSussman.hpp.

## ◆ get_finalIteration()

template<typename grid_in_type , typename phi_type = double>
 int RedistancingSussman< grid_in_type, phi_type >::get_finalIteration ( )
inline

Definition at line 248 of file RedistancingSussman.hpp.

## ◆ get_finalNumberNbPoints()

template<typename grid_in_type , typename phi_type = double>
 int RedistancingSussman< grid_in_type, phi_type >::get_finalNumberNbPoints ( )
inline

Definition at line 263 of file RedistancingSussman.hpp.

## ◆ get_finalResidual()

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

Definition at line 258 of file RedistancingSussman.hpp.

## ◆ 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_n Phi value on current node and current time. phi_n_magnOfGrad Gradient magnitude of current Phi from upwinding FD. dt Time step. sgn_phi_n Sign 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 326 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.

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 242 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
 grid Internal temporary grid.

Definition at line 336 of file RedistancingSussman.hpp.

## ◆ init_temp_grid()

template<typename grid_in_type , typename phi_type = double>
template<size_t Phi_0_in>
 void RedistancingSussman< grid_in_type, phi_type >::init_temp_grid ( )
inlineprivate

Copies values from input grid to internal temporary grid and initializes ghost layer with minimum value of input grid.

Definition at line 309 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
 grid Internal temporary grid.

Definition at line 475 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
 Phi Value 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 359 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
 grid Internal temporary grid. iter Current re-distancing iteration.

Definition at line 413 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 215 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 ( T 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
 dt Artificial time step by which re-distancing should be performed.

Definition at line 235 of file RedistancingSussman.hpp.

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
 grid Internal temporary grid.
Returns
True, if steady-state reached, else false.
Conv_tol_change, Conv_tol_residual

Definition at line 440 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
 grid Internal temporary grid.

Definition at line 369 of file RedistancingSussman.hpp.

## ◆ distFromSol

template<typename grid_in_type , typename phi_type = double>
 DistFromSol RedistancingSussman< grid_in_type, phi_type >::distFromSol
private

Instantiate distance from solution in terms of change, residual, numb.

Definition at line 278 of file RedistancingSussman.hpp.

## ◆ final_iter

template<typename grid_in_type , typename phi_type = double>
 int RedistancingSussman< grid_in_type, phi_type >::final_iter = 0
private

Will be set to the final iteration when redistancing ends.

Definition at line 280 of file RedistancingSussman.hpp.

## ◆ 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 206 of file RedistancingSussman.hpp.

## ◆ kappa

template<typename grid_in_type , typename phi_type = double>
 phi_type RedistancingSussman< grid_in_type, phi_type >::kappa = ceil(redistOptions.width_NB_in_grid_points / 2.0) * get_biggest_spacing(g_temp)
private

Transform the half-bandwidth in no_of_grid_points into physical half-bandwidth kappa.

Definition at line 283 of file RedistancingSussman.hpp.

template<typename grid_in_type , typename phi_type = double>
 int RedistancingSussman< grid_in_type, phi_type >::order_upwind_gradient
private

Definition at line 288 of file RedistancingSussman.hpp.

## ◆ Phi_0_sign_temp

template<typename grid_in_type , typename phi_type = double>
 constexpr size_t RedistancingSussman< grid_in_type, phi_type >::Phi_0_sign_temp = 2
staticconstexprprivate

Property index of sign of initial (input) Phi_0 (temp. grid).

Definition at line 272 of file RedistancingSussman.hpp.

template<typename grid_in_type , typename phi_type = double>
 constexpr size_t RedistancingSussman< grid_in_type, phi_type >::Phi_grad_temp = 1
staticconstexprprivate

Property index of gradient of Phi_n on the temporary grid.

Definition at line 271 of file RedistancingSussman.hpp.

## ◆ Phi_n_temp

template<typename grid_in_type , typename phi_type = double>
 constexpr size_t RedistancingSussman< grid_in_type, phi_type >::Phi_n_temp = 0
staticconstexprprivate

Property index of Phi_0 on the temporary grid.

Definition at line 270 of file RedistancingSussman.hpp.

## ◆ r_grid_in

template<typename grid_in_type , typename phi_type = double>
 grid_in_type& RedistancingSussman< grid_in_type, phi_type >::r_grid_in
private

Define reference to input grid.

Definition at line 276 of file RedistancingSussman.hpp.

## ◆ redistOptions

template<typename grid_in_type , typename phi_type = double>
 Redist_options RedistancingSussman< grid_in_type, phi_type >::redistOptions
private

Instantiate redistancing options.

Definition at line 275 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.