Class for reinitializing a level-set function into a signed distance function using Sussman redistancing. More...
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} \]
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_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. | |
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. | |
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 grid_dist_id<grid_in_type::dims, typename grid_in_type::stype, props_temp> RedistancingSussman< grid_in_type, phi_type >::g_temp_type |
Type definition for the temporary grid.
Definition at line 197 of file RedistancingSussman.hpp.
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 194 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 re-distancing result |
redistOptions | User defined options for the Sussman redistancing process |
Definition at line 172 of file RedistancingSussman.hpp.
|
inline |
Definition at line 253 of file RedistancingSussman.hpp.
|
inline |
Definition at line 248 of file RedistancingSussman.hpp.
|
inline |
Definition at line 263 of file RedistancingSussman.hpp.
|
inline |
Definition at line 258 of file RedistancingSussman.hpp.
|
inlineprivate |
Run one timestep of re-distancing 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 326 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 242 of file RedistancingSussman.hpp.
|
inlineprivate |
Go one re-distancing time-step on the whole grid.
grid | Internal temporary grid. |
Definition at line 336 of file RedistancingSussman.hpp.
|
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.
|
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.
grid | Internal temporary grid. |
Definition at line 475 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 359 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 re-distancing iteration.
grid | Internal temporary grid. |
iter | Current re-distancing iteration. |
Definition at line 413 of file RedistancingSussman.hpp.
|
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.
|
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 re-distancing should be performed. |
Definition at line 235 of file RedistancingSussman.hpp.
|
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.
grid | Internal temporary grid. |
Definition at line 440 of file RedistancingSussman.hpp.
|
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.
grid | Internal temporary grid. |
Definition at line 369 of file RedistancingSussman.hpp.
|
private |
Instantiate distance from solution in terms of change, residual, numb.
Definition at line 278 of file RedistancingSussman.hpp.
|
private |
Will be set to the final iteration when redistancing ends.
Definition at line 280 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 206 of file RedistancingSussman.hpp.
|
private |
Transform the half-bandwidth in no_of_grid_points into physical half-bandwidth kappa.
Definition at line 283 of file RedistancingSussman.hpp.
|
private |
Definition at line 288 of file RedistancingSussman.hpp.
|
staticconstexprprivate |
Property index of sign of initial (input) Phi_0 (temp. grid).
Definition at line 272 of file RedistancingSussman.hpp.
|
staticconstexprprivate |
Property index of gradient of Phi_n on the temporary grid.
Definition at line 271 of file RedistancingSussman.hpp.
|
staticconstexprprivate |
Property index of Phi_0 on the temporary grid.
Definition at line 270 of file RedistancingSussman.hpp.
|
private |
Define reference to input grid.
Definition at line 276 of file RedistancingSussman.hpp.
|
private |
Instantiate redistancing options.
Definition at line 275 of file RedistancingSussman.hpp.
|
private |
Artificial timestep for the redistancing iterations.
Definition at line 287 of file RedistancingSussman.hpp.