Class for reinitializing a levelset function into a signed distance function using Sussman redistancing. More...
Class for reinitializing a levelset function into a signed distance function using Sussman redistancing.
Firsttimeonly redistancing step (see: M. Sussman and E. Fatemi, “Efficient, interfacepreserving level set redistancing algorithm and its application to interfacial incompressible fluid flow” (1999) ). In the Sussmanredistancing, a levelsetfunction Phi_0, which can be a simple stepfunction having positive values inside the object and negative values outside, is reinitialized to a signed distance function Phi_SDF by finding the steadystate 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} \]
grid_in_type  Template type of input grid, which stores the initial levelset 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_temp >  g_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 Sussmanredistancing. 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 redistancing and compute Phi_n+1. More...  
void  go_one_redistancing_step_whole_grid (g_temp_type &grid) 
Go one redistancing timestep 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) 
Recomputes 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 userdefined 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 redistancing iteration. More...  
bool  steady_state_NB (g_temp_type &grid) 
Checks steadystate is reached in the narrow band. More...  
void  iterative_redistancing (g_temp_type &grid) 
Runs Sussman redistancing 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 halfbandwidth in no_of_grid_points into physical halfbandwidth 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).  
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.

inline 
Constructor initializing the redistancing options, the temporary internal grid and reference variable to the input grid.
grid_in  Input grid with min. 2 properties: 1.) Phi_0, 2.) Phi_SDF < will be overwritten with redistancing result 
redistOptions  User defined options for the Sussman redistancing process 
Definition at line 172 of file RedistancingSussman.hpp.

inlineprivate 
Run one timestep of redistancing and compute Phi_n+1.
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. 
Definition at line 325 of file RedistancingSussman.hpp.

inline 
Access the artificial timestep (private member) which will be used for the iterative redistancing.
This timestep is computed according to the grid spacing fulfilling the CFL condition.
Definition at line 241 of file RedistancingSussman.hpp.

inlineprivate 
Go one redistancing timestep on the whole grid.
grid  Internal temporary grid. 
Definition at line 335 of file RedistancingSussman.hpp.

inlineprivate 
Runs Sussman redistancing on the internal temporary grid.
The number of iterations is minimum redistOptions.min_iter iterations and finishes when either steadystate or redist_options.max_iter is reached. The steadystate convergence accuracy depends on the user defined redist_options.convTolChange.value and redist_options.convTolResidual.value, respectively.
grid  Internal temporary grid. 
Definition at line 474 of file RedistancingSussman.hpp.

inlineprivate 
Checks if a node lays within the narrow band around the interface.
Phi  Value of Phi at that specific node. 
Definition at line 358 of file RedistancingSussman.hpp.

inlineprivate 
Prints out the iteration number, max. change, max. residual and number of points in the narrow band of the current redistancing iteration.
grid  Internal temporary grid. 
iter  Current redistancing iteration. 
Definition at line 412 of file RedistancingSussman.hpp.

inline 
Runs the Sussmanredistancing.
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.

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).
dt  Artificial time step by which redistancing should be performed. 
Definition at line 234 of file RedistancingSussman.hpp.

inlineprivate 
Checks steadystate is reached in the narrow band.
Checks if change and/or residual between 2 iterations smaller than userdefined convolution tolerance.
grid  Internal temporary grid. 
Definition at line 439 of file RedistancingSussman.hpp.

inlineprivate 
Recomputes 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 userdefined convergence criteria.
grid  Internal temporary grid. 
Definition at line 368 of file RedistancingSussman.hpp.
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.

private 
Artificial timestep for the redistancing iterations.
Definition at line 286 of file RedistancingSussman.hpp.