74 int main(
int argc,
char* argv[])
79 std::string image_name =
"dolphin";
81 typedef double phi_type;
83 openfpm_init(&argc, &argv);
87 const std::string path_output = cwd +
"/output_" + image_name;
95 const std::string path_input =
"input/";
96 const std::string path_to_image = path_input + image_name +
".bin";
97 const std::string path_to_size = path_input +
"size_" + image_name +
".csv";
102 const unsigned int grid_dim = 2;
107 const size_t Phi_0_grid = 0;
108 const size_t Phi_SDF_grid = 1;
110 const size_t Phi_SDF_vd = 0;
111 const size_t Phi_grad_vd = 1;
112 const size_t Phi_magnOfGrad_vd = 2;
129 const phi_type refinement [] = {0.5, 0.5};
150 std::vector<int> stack_size =
get_size(path_to_size);
152 auto & v_cl = create_vcluster();
153 if (v_cl.rank() == 0)
155 for(std::vector<int>::size_type i = 0; i != stack_size.size(); i++)
157 std::cout <<
"#Pixel in dimension " << i <<
" = " << stack_size[i] << std::endl;
158 std::cout <<
"original refinement in dimension " << i <<
" = " << refinement[i] << std::endl;
163 const size_t sz[grid_dim] = {(size_t)std::round(stack_size[x] * refinement[x]), (size_t)std::round(stack_size[y] *
188 grid_in_type g_dist(sz, box, ghost);
189 g_dist.setPropNames({
"Phi_0",
"Phi_SDF"});
192 init_grid_and_ghost<Phi_0_grid>(g_dist, -1.0);
195 load_pixel_onto_grid<Phi_0_grid>(g_dist, path_to_image, stack_size);
196 g_dist.write(path_output +
"/grid_from_images_initial", FORMAT_BINARY);
204 redist_options.min_iter = 1e3;
205 redist_options.max_iter = 1e4;
207 redist_options.convTolChange.value = 1e-7;
208 redist_options.convTolChange.check =
true;
209 redist_options.convTolResidual.value = 1e-6;
210 redist_options.convTolResidual.check =
false;
212 redist_options.interval_check_convergence = 1e3;
213 redist_options.width_NB_in_grid_points = 10;
214 redist_options.print_current_iterChangeResidual =
true;
215 redist_options.print_steadyState_iter =
true;
216 redist_options.save_temp_grid =
true;
222 redist_obj.run_redistancing<Phi_0_grid, Phi_SDF_grid>();
224 g_dist.write(path_output +
"/grid_images_post_redistancing", FORMAT_BINARY);
228 size_t bc[grid_dim] = {NON_PERIODIC, NON_PERIODIC};
236 vd_type vd_narrow_band(0, box, bc, ghost_vd);
237 vd_narrow_band.setPropNames({
"Phi_SDF",
"Phi_grad",
"Phi_magnOfGrad"});
249 narrowBand.get_narrow_band<Phi_SDF_grid, Phi_SDF_vd, Phi_grad_vd, Phi_magnOfGrad_vd>(g_dist, vd_narrow_band);
251 vd_narrow_band.write(path_output +
"/vd_narrow_band_images", FORMAT_BINARY);
static void create_directory_if_not_exist(std::string path)
Creates a directory if not already existent.
Class for getting the narrow band around the interface.
Class for reinitializing a level-set function into a signed distance function using Sussman redistanc...
std::vector< int > get_size(const std::string &path_to_file)
Read the number of pixels per dimension from a csv-file in order to create a grid with the same size.
Structure to bundle options for redistancing.
static std::string get_cwd()
Gets the current working directory and returns path as string.
Class for reinitializing a level-set function into a signed distance function using Sussman redistanc...
This is a distributed grid.
This class represent an N-dimensional box.
Header file containing functions for loading pixel values from 2D image or 3D image stack (volume) st...
Header file containing functions for creating files and folders.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Class for getting the narrow band around the interface.