Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_pdata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_pdata
Commits
05dc7fbe
Commit
05dc7fbe
authored
3 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' of git.mpi-cbg.de:openfpm/openfpm_pdata into develop
parents
e1d9a0ca
ed2d8bd7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#3431
failed
3 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
example/Numerics/Sussman_redistancing/example_sussman_circle/main.cpp
+60
-60
60 additions, 60 deletions
...rics/Sussman_redistancing/example_sussman_circle/main.cpp
openfpm_io
+1
-1
1 addition, 1 deletion
openfpm_io
with
61 additions
and
61 deletions
example/Numerics/Sussman_redistancing/example_sussman_circle/main.cpp
+
60
−
60
View file @
05dc7fbe
...
...
@@ -2,10 +2,10 @@
// Created by jstark on 2020-05-18.
//
/**
* @file example_sussman_
circle
/main.cpp
* @file example_sussman_
disk
/main.cpp
* @page Examples_SussmanRedistancing Examples Sussman Redistancing
*
* @subpage example_sussman_
circle
* @subpage example_sussman_
disk
* @subpage example_sussman_sphere
* @subpage example_sussman_images_2D
* @subpage example_sussman_images_3D
...
...
@@ -44,19 +44,19 @@
/**
* @page example_sussman_
circle
Circle 2D
* @page example_sussman_
disk
Circle 2D
*
* # Get the signed distance function for a 2D
circle
via Sussman Redistancing #
* # Get the signed distance function for a 2D
disk
via Sussman Redistancing #
*
* In this example, we perform Sussman redistancing on a
filled 2D circle
. Here, the
circle
is constructed via
* In this example, we perform Sussman redistancing on a
2D disk
. Here, the
disk
is constructed via
* equation. For image based reconstruction and redistancing see @ref example_sussman_images_2D.
*
* A
filled circle
with center a, b can be constructed by the following equation:
* A
disk
with center a, b can be constructed by the following equation:
*
*
* @f[ (x-a)^2 + (y-b)^2 <= r^2 @f]
*
* We will create a
filled circle
on a 2D grid, where the
circle
is represented by a -1/+1 step function
* We will create a
disk
on a 2D grid, where the
disk
is represented by a -1/+1 step function
* (indicator function) as:
*
* @f[ \phi_{\text{indicator}} = \begin{cases}
...
...
@@ -75,14 +75,14 @@
*
* Once we have received the Phi_SDF from the redistancing, particles can be placed on narrow band around the interface.
*
* * Creates
filled 2D circle
with -1/+1 indicator function
* * Creates
2D disk
with -1/+1 indicator function
* * Runs Sussman redistancing (see @ref RedistancingSussman.hpp)
* * Places particles on narrow band around interface
*
* Output:
* print on promt : Iteration, Change, Residual (see: #DistFromSol::change, #DistFromSol::residual)
* writes vtk and hdf5 files of:
* 1.) 2D grid with
circle
pre-redistancing and post-redistancing (Phi_0 and Phi_SDF, respectively)
* 1.) 2D grid with
disk
pre-redistancing and post-redistancing (Phi_0 and Phi_SDF, respectively)
* 2.) particles on narrow band around interface
*
* ## Visualization of example output in Paraview ##
...
...
@@ -92,13 +92,13 @@
*/
/**
* @page example_sussman_
circle
Circle 2D
* @page example_sussman_
disk
Circle 2D
*
* ## Include ## {#e2d_c_include}
*
* These are the header files that we need to include:
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Include
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Include
*
*/
//! @cond [Include] @endcond
...
...
@@ -107,11 +107,11 @@
#include
"util/PathsAndFiles.hpp"
#include
"level_set/redistancing_Sussman/RedistancingSussman.hpp"
#include
"level_set/redistancing_Sussman/NarrowBand.hpp"
#include
"Draw/Draw
Circle
.hpp"
#include
"Draw/Draw
Disk
.hpp"
//! @cond [Include] @endcond
/**
* @page example_sussman_
circle
Circle 2D
* @page example_sussman_
disk
Circle 2D
*
* ## Initialization and output folder ## {#e2d_c_init}
*
...
...
@@ -119,7 +119,7 @@
* * Initializing OpenFPM
* * Setting the output path and creating an output folder
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Initialization and output folder
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Initialization and output folder
*
*/
//! @cond [Initialization and output folder] @endcond
...
...
@@ -130,13 +130,13 @@ int main(int argc, char* argv[])
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Set current working directory, define output paths and create folders where output will be saved
std
::
string
cwd
=
get_cwd
();
const
std
::
string
path_output
=
cwd
+
"/output_
circle
"
;
const
std
::
string
path_output
=
cwd
+
"/output_
disk
"
;
create_directory_if_not_exist
(
path_output
);
//! @cond [Initialization and output folder] @endcond
/**
* @page example_sussman_
circle
Circle 2D
* @page example_sussman_
disk
Circle 2D
*
* ## Indices for the grid ## {#e2d_c_indices}
*
...
...
@@ -145,7 +145,7 @@ int main(int argc, char* argv[])
* * \p y: Second dimension
* * \p Phi_0_grid: Index of property that stores the initial level-set-function
* * \p Phi_SDF_grid: Index of property where the redistancing result should be written to
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Indices grid
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Indices grid
*
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -161,7 +161,7 @@ int main(int argc, char* argv[])
//! @cond [Indices grid] @endcond
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @page example_sussman_
circle
Circle 2D
* @page example_sussman_
disk
Circle 2D
*
* ## Create the grid ## {#e2d_c_grid}
*
...
...
@@ -173,7 +173,7 @@ int main(int argc, char* argv[])
* the post-redistancing Phi_SDF should be written to.
* * Set some property names (optionally. These names show up when opening the grid vtk in Paraview.)
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Grid creation
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Grid creation
*
*/
//! @cond [Grid creation] @endcond
...
...
@@ -191,13 +191,13 @@ int main(int argc, char* argv[])
/**
* @page example_sussman_
circle
Circle 2D
* @page example_sussman_
disk
Circle 2D
*
* ## Get
filled circle
on the grid ## {#e2d_c_get
circle
}
* ## Get
disk
on the grid ## {#e2d_c_get
disk
}
*
*
* On the grid that we have just created, we can now initialize Phi_0 as a
filled circle
of defined radius.
* The center of the
circle
is passed as x_center and y_center (see @ref Circle.hpp). Phi_0 will then be:
* On the grid that we have just created, we can now initialize Phi_0 as a
disk
of defined radius.
* The center of the
disk
is passed as x_center and y_center (see @ref Circle.hpp). Phi_0 will then be:
*
* @f[ \phi_{\text{indicator}} = \begin{cases}
* +1 & \text{point lies inside the object} \\
...
...
@@ -206,49 +206,49 @@ int main(int argc, char* argv[])
* \end{cases} @f]
*
* Optionally, we can save this initial grid as a vtk file, if we want to visualize and check it in Paraview.
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Get
circle
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Get
disk
*/
//! @cond [Get
circle
] @endcond
// Now we initialize the grid with a
filled circle
. Outside the
circle
, the value of Phi_0 will be -1, inside +1.
double
radius
=
1.0
;
// Radius of the
circle
init_grid_with_
circle
<
Phi_0_grid
>
(
g_dist
,
radius
,
2.5
,
2.5
);
// Initialize
circle
onto grid, centered at (2.5, 2.5)
//! @cond [Get
disk
] @endcond
// Now we initialize the grid with a
disk
. Outside the
disk
, the value of Phi_0 will be -1, inside +1.
double
radius
=
1.0
;
// Radius of the
disk
init_grid_with_
disk
<
Phi_0_grid
>
(
g_dist
,
radius
,
2.5
,
2.5
);
// Initialize
disk
onto grid, centered at (2.5, 2.5)
g_dist
.
write
(
path_output
+
"/grid_
circle
_preRedistancing_radius"
+
std
::
to_string
((
int
)
radius
)
,
FORMAT_BINARY
);
// Save the
circle
as vtk file
//! @cond [Get
circle
] @endcond
g_dist
.
write
(
path_output
+
"/grid_
disk
_preRedistancing_radius"
+
std
::
to_string
((
int
)
radius
)
,
FORMAT_BINARY
);
// Save the
disk
as vtk file
//! @cond [Get
disk
] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Set the redistancing options ## {#e2d_c_redistoptions}
*
* For the redistancing, we can choose some options. These options will then be passed bundled as a structure to
* the redistancing function. Setting these options is optional, since they all have a Default value as well. In
* particular the following options can be set by the user:
* * \p min_iter: Minimum number of iterations before steady state in narrow band will be checked (Default: 1
00
).
* * \p min_iter: Minimum number of iterations before steady state in narrow band will be checked (Default: 1
e5
).
* * \p max_iter: Maximum number of iterations you want to run the redistancing, even if steady state might not yet
* have been reached (Default: 1e
6
).
* * \p convTolChange.value: Conv
olution
tolerance for the
normalized tot
al change of Phi in the narrow band between
* two consecutive iterations (Default: 1e-
6
).
* * \p convTolChange.check: Set true, if you want to use the
normalized tot
al change between two iterations as
* have been reached (Default: 1e
12
).
* * \p convTolChange.value: Conv
ergence
tolerance for the
maxim
al change of Phi
with
in the narrow band between
* two consecutive iterations (Default: 1e-
15
).
* * \p convTolChange.check: Set true, if you want to use the
maxim
al change
of Phi
between two iterations as
* measure of how close you are to the steady state solution. Redistancing will then stop
* if convTolChange.value is reached or if the current iteration is bigger than max_iter.
* * \p convTolResidual.value: Conv
olution
tolerance for the residual, that is abs(magnitude gradient of phi -
1) of
* Phi in the narrow band (Default 1e-
1
).
* * \p convTolResidual.value: Conv
ergence
tolerance for the residual, that is
max{
abs(magnitude gradient of phi -
*
1)} of
Phi in the narrow band (Default 1e-
3
).
* * \p convTolResidual.check: Set true, if you want to use the residual of the current iteration as measure of how
* close you are to the steady state solution. Redistancing will then stop if
* convTolResidual.value is reached or if the current iteration is bigger than max_iter.
* * \p interval_check_convergence: Interval of #iterations at which convergence to steady state is checked
* (Default: 100).
* * \p width_NB_in_grid_points: Width of narrow band in number of grid points. Must be at least 4, in order to
* have at least 2 grid points on each side of the interface. Is automatically set
* * \p width_NB_in_grid_points: Width of narrow band in number of grid points. Must be at least 4, in order to
* have at least 2 grid points on each side of the interface. Is automatically set
* to 4, if a value smaller than 4 is chosen (Default: 4).
* * \p print_current_iterChangeResidual: If true, the number of the current iteration, the corresponding change
* w.r.t the previous iteration and the residual is printed (Default: false).
* * \p print_steadyState_iter: If true, the number of the steady-state-iteration, the corresponding change
* w.r.t the previous iteration and the residual is printed (Default: false).
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Redistancing options
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Redistancing options
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//! @cond [Redistancing options] @endcond
...
...
@@ -270,7 +270,7 @@ int main(int argc, char* argv[])
//! @cond [Redistancing options] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Run the redistancing ## {#e2d_c_runredist}
*
...
...
@@ -287,7 +287,7 @@ int main(int argc, char* argv[])
* containing the signed distance function in Prop. 2. The vtk-file can be opened in Paraview. If we want, we can
* further save the result as hdf5 file that can be reloaded onto an openFPM grid.
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Run redistancing
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Run redistancing
*/
//! @cond [Run redistancing] @endcond
RedistancingSussman
<
grid_in_type
>
redist_obj
(
g_dist
,
redist_options
);
// Instantiation of Sussman-redistancing class
...
...
@@ -296,13 +296,13 @@ int main(int argc, char* argv[])
// where the resulting SDF should be written to.
redist_obj
.
run_redistancing
<
Phi_0_grid
,
Phi_SDF_grid
>
();
g_dist
.
write
(
path_output
+
"/grid_
circle
_postRedistancing"
,
FORMAT_BINARY
);
// Save the result as vtk file
g_dist
.
save
(
path_output
+
"/grid_
circle
_postRedistancing"
+
".bin"
);
// Save the result as hdf5 file that can be
g_dist
.
write
(
path_output
+
"/grid_
disk
_postRedistancing"
,
FORMAT_BINARY
);
// Save the result as vtk file
g_dist
.
save
(
path_output
+
"/grid_
disk
_postRedistancing"
+
".bin"
);
// Save the result as hdf5 file that can be
// reloaded onto an openFPM grid
//! @cond [Run redistancing] @endcond
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Initialize empty vector for narrow band particles ## {#e2d_c_initnbvector}
*
...
...
@@ -313,7 +313,7 @@ int main(int argc, char* argv[])
* one, but you can have particles with arbitrary many properties, depending on what you want to use them for
* later on. Here, we exemplarily define 3 properties.
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Initialize narrow band
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Initialize narrow band
*/
//! @cond [Initialize narrow band] @endcond
// Get narrow band: Place particles on interface (narrow band width e.g. 2 grid points on each side of the interface)
...
...
@@ -322,7 +322,7 @@ int main(int argc, char* argv[])
// Minimum is 1 property, to which the Phi_SDF can be written
// In this example we chose 3 properties. The 1st for the Phi_SDF, the 2nd for the gradient of phi and the 3rd for
// the magnitude of the gradient
typedef
aggregate
<
double
,
Point
<
grid_dim
,
double
>
,
double
>
props_nb
;
typedef
aggregate
<
double
,
double
[
grid_dim
]
,
double
>
props_nb
;
typedef
vector_dist
<
grid_dim
,
double
,
props_nb
>
vd_type
;
Ghost
<
grid_dim
,
double
>
ghost_vd
(
0
);
vd_type
vd_narrow_band
(
0
,
box
,
bc
,
ghost_vd
);
...
...
@@ -330,7 +330,7 @@ int main(int argc, char* argv[])
//! @cond [Initialize narrow band] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Instantiate narrow band ## {#e2d_c_instnarrowband}
*
...
...
@@ -345,7 +345,7 @@ int main(int argc, char* argv[])
* grid points (size_t), physical width (double) or extension of narrow band as physical width inside of object
* and outside the object (double, double).
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Instantiate narrow band
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Instantiate narrow band
*/
//! @cond [Instantiate narrow band] @endcond
size_t
thickness_of_narrowBand_in_grid_points
=
6
;
...
...
@@ -353,14 +353,14 @@ int main(int argc, char* argv[])
//! @cond [Instantiate narrow band] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Indices for the narrow band vector ## {#e2d_c_indices}
*
* Again, we can define some indices for better code readability. This is just an example, you may want to choose
* different names and have a different number of properties thus different number of indices.
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Indices narrow band
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Indices narrow band
*
*/
//////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -372,7 +372,7 @@ int main(int argc, char* argv[])
//! @cond [Indices narrow band] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Fill the vector with particles placed within a narrow band around the interface ## {#e2d_c_getnarrowband}
*
...
...
@@ -391,7 +391,7 @@ int main(int argc, char* argv[])
*
* We save the particles in a vtk file (open in Paraview) and as hdf5 file (can be loaded back on particles).
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Get narrow band
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Get narrow band
*/
// Get the narrow band. You can decide, if you only want the Phi_SDF saved to your particles or
// if you also want the gradients or gradients and magnitude of gradient.
...
...
@@ -403,18 +403,18 @@ int main(int argc, char* argv[])
//! @cond [Get narrow band] @endcond
narrowBand
.
get_narrow_band
<
Phi_SDF_grid
,
Phi_SDF_vd
,
Phi_grad_vd
,
Phi_magnOfGrad_vd
>
(
g_dist
,
vd_narrow_band
);
vd_narrow_band
.
write
(
path_output
+
"/vd_narrow_band_
circle
"
,
FORMAT_BINARY
);
// Save particles as vtk file
vd_narrow_band
.
save
(
path_output
+
"/vd_narrow_band_
circle
.bin"
);
// Save particles as hdf5 file -> can be reloaded as particles
vd_narrow_band
.
write
(
path_output
+
"/vd_narrow_band_
disk
"
,
FORMAT_BINARY
);
// Save particles as vtk file
vd_narrow_band
.
save
(
path_output
+
"/vd_narrow_band_
disk
.bin"
);
// Save particles as hdf5 file -> can be reloaded as particles
//! @cond [Get narrow band] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Terminate ## {#e2d_c_terminate}
*
* We end with terminating OpenFPM
*
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp Terminate
* @snippet example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp Terminate
*/
//! @cond [Terminate] @endcond
openfpm_finalize
();
// Finalize openFPM library
...
...
@@ -423,11 +423,11 @@ int main(int argc, char* argv[])
//! @cond [Terminate] @endcond
/**
* @page example_sussman_
circle Circle
2D
* @page example_sussman_
disk Disk
2D
*
* ## Full code ## {#e2d_c_full}
*
* @include example/Numerics/Sussman_redistancing/example_sussman_
circle
/main.cpp
* @include example/Numerics/Sussman_redistancing/example_sussman_
disk
/main.cpp
*/
...
...
This diff is collapsed.
Click to expand it.
openfpm_io
@
41fcad3e
Subproject commit 4
8e5e8912314b9eff58711cea88ce5c3d78fe5f6
Subproject commit 4
1fcad3e6ca84084663fbf2898c2af2b84643c98
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment