diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4309f6f00ef93503cbc92786b1c59b4d44db95aa..cf32a3227a98c11a005b97d2dc13f5a29c623727 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,10 +24,10 @@ centos_run: - ./run.sh $CI_PROJECT_DIR unused 4 pdata 0 $CI_COMMIT_REF_NAME - ./run.sh $CI_PROJECT_DIR unused 5 pdata 0 $CI_COMMIT_REF_NAME - cd openfpm_numerics - - ./run.sh $CI_PROJECT_DIR unused 1 0 0 numerics - - ./run.sh $CI_PROJECT_DIR unused 2 0 0 numerics - - ./run.sh $CI_PROJECT_DIR unused 3 0 0 numerics - - ./run.sh $CI_PROJECT_DIR unused 4 0 0 numerics + - ./run.sh $CI_PROJECT_DIR unused 1 0 0 numerics $CI_COMMIT_REF_NAME + - ./run.sh $CI_PROJECT_DIR unused 2 0 0 numerics $CI_COMMIT_REF_NAME + - ./run.sh $CI_PROJECT_DIR unused 3 0 0 numerics $CI_COMMIT_REF_NAME + - ./run.sh $CI_PROJECT_DIR unused 4 0 0 numerics $CI_COMMIT_REF_NAME mac_build: variables: @@ -53,7 +53,7 @@ mac_run: - ./run.sh $CI_PROJECT_DIR unused 1 0 0 $CI_COMMIT_REF_NAME - ./run.sh $CI_PROJECT_DIR unused 2 0 0 $CI_COMMIT_REF_NAME - cd openfpm_numerics - - ./run.sh $CI_PROJECT_DIR unused 2 0 0 numerics + - ./run.sh $CI_PROJECT_DIR unused 2 0 0 numerics $CI_COMMIT_REF_NAME ubuntu_build: stage: build @@ -78,8 +78,8 @@ ubuntu_run: - ./run.sh $CI_PROJECT_DIR unused 2 pdata 0 $CI_COMMIT_REF_NAME - ./run.sh $CI_PROJECT_DIR unused 3 pdata 0 $CI_COMMIT_REF_NAME - cd openfpm_numerics - - ./run.sh $CI_PROJECT_DIR unused 1 0 0 numerics - - ./run.sh $CI_PROJECT_DIR unused 2 0 0 numerics - - ./run.sh $CI_PROJECT_DIR unused 3 0 0 numerics - - ./run.sh $CI_PROJECT_DIR unused 4 0 0 numerics + - ./run.sh $CI_PROJECT_DIR unused 1 0 0 numerics $CI_COMMIT_REF_NAME + - ./run.sh $CI_PROJECT_DIR unused 2 0 0 numerics $CI_COMMIT_REF_NAME + - ./run.sh $CI_PROJECT_DIR unused 3 0 0 numerics $CI_COMMIT_REF_NAME + - ./run.sh $CI_PROJECT_DIR unused 4 0 0 numerics $CI_COMMIT_REF_NAME diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ed2e9d81077b8c78277cc4964c9ba659354d93..1c17bcb16955bef021402290af06bd44677e9799 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Change Log All notable changes to this project will be documented in this file. +## [4.0.0] September 2021 (Codename Heisenberg) + +- Adding DCPSE, Level-set based numerics (Closest-point) + +### Changes + +- Particles writer use now the new XML pvtp Paraview format +- Particles constructor does not accept discordance precision on space example: + If I create a Particle set with vector_dist<3,double,.......> + I MUST give in the constructor a domain Box<3,double> and a Ghost<3,double>, giving a Ghost<3,float> will produce + an error + ## [3.3.0] April 2021 (Codename Vega) - Adding support for HIP and AMD GPU. (Only particles) 1_gpu_first/7_sph_dlb_gpu/7_sph_dlb_gpu_opt are compatible with HIP diff --git a/CMakeLists.txt b/CMakeLists.txt index 176072c2cedc1ffa570d84ab143fc5a4fb4781ad..a5c6cc1ccb6b4a21f29798c7c984d3c68dd84656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ if (POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() -set(openfpm_VERSION 3.3.0) +set(openfpm_VERSION 4.0.0) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake_modules/) @@ -293,6 +293,12 @@ list(GET VERSION_LIST 2 OPENFPM_VERSION_PATCH) if (CPACK_RUN_INSTALL_DEPENDENCIES) + ###### Fix post inst script ###### + + + + ###### ###### + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenFPM distributed data-structures") set(CPACK_PACKAGE_VENDOR "IBirdSoft") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.txt") @@ -309,7 +315,7 @@ if (CPACK_RUN_INSTALL_DEPENDENCIES) set(CPACK_DEBIAN_PACKAGE_MAINTAINER Pietro Incardona) set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/scripts/postinst) set(CPACK_POSTFLIGHT_OPENFPM_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/src/scripts/postflight) - set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/src/script/postinst") + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_SOURCE_DIR}/src/scripts/postinst) set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.txt") install(FILES $ENV{DEP_PACKING}/openfpm_vars @@ -360,6 +366,14 @@ if (CPACK_RUN_INSTALL_DEPENDENCIES) DESTINATION dependencies/ COMPONENT OpenFPM) + install(DIRECTORY $ENV{DEP_PACKING}/BLITZ + DESTINATION dependencies/ + COMPONENT OpenFPM) + + install(DIRECTORY $ENV{DEP_PACKING}/ALGOIM + DESTINATION dependencies/ + COMPONENT OpenFPM) + endif() include(CPack) diff --git a/build.sh b/build.sh index 1cc35bf9cc7ac33927265ed16d726a006990e96b..1ded29927353de9bb87bf4073f7c7f5b034782d2 100755 --- a/build.sh +++ b/build.sh @@ -39,12 +39,10 @@ fi if [ x"$hostname" == x"cifarm-mac-node.mpi-cbg.de" ]; then echo "Mac node" export PATH="/usr/local/bin:$PATH" +# rm -rf /Users/admin/openfpm_dependencies/openfpm_pdata/$branch/ # rm -rf $HOME/openfpm_dependencies/openfpm_pdata/$branch/PETSC - ./install_CMAKE_on_CI.sh $HOME/openfpm_dependencies/openfpm_pdata/$branch/ - export PATH="$HOME/openfpm_dependencies/openfpm_pdata/$branch/CMAKE/bin:$PATH" - cd openfpm_vcluster - git stash - cd .. + #./install_CMAKE_on_CI.sh $HOME/openfpm_dependencies/openfpm_pdata/$branch/ +# export PATH="$HOME/openfpm_dependencies/openfpm_pdata/$branch/CMAKE/bin:$PATH" fi if [ x"$hostname" == x"falcon1" ]; then diff --git a/example/Numerics/OdeInt/Makefile b/example/Numerics/OdeInt/Makefile index 7bb01f1ab84fb758dcac072f7a91fa6ce79d3a2d..49784aa93f9eb62a4f0fa3fb77ccffb40999513e 100644 --- a/example/Numerics/OdeInt/Makefile +++ b/example/Numerics/OdeInt/Makefile @@ -19,7 +19,7 @@ example_odeint2: $(OBJ2) all: example_odeint example_odeint2 run: all - mpirun -np 2 ./example_odeint ./example_odeint + mpirun --oversubscribe -np 2 ./example_odeint && mpirun --oversubscribe -np 2 ./example_odeint2 .PHONY: clean all run diff --git a/example/Numerics/Sussman_redistancing/example_sussman_circle/Makefile b/example/Numerics/Sussman_redistancing/example_sussman_disk/Makefile similarity index 57% rename from example/Numerics/Sussman_redistancing/example_sussman_circle/Makefile rename to example/Numerics/Sussman_redistancing/example_sussman_disk/Makefile index 78f653991dbbe9895941ed52ff7dc9b1e87fcfb0..6e12dc3eac14fc873ab492e677a5bea4509efa0f 100644 --- a/example/Numerics/Sussman_redistancing/example_sussman_circle/Makefile +++ b/example/Numerics/Sussman_redistancing/example_sussman_disk/Makefile @@ -9,16 +9,16 @@ OBJ = main.o %.o: %.cpp $(CC) -O3 -c --std=c++14 -o $@ $< $(INCLUDE_PATH) -example_sussman_circle: $(OBJ) +example_sussman_disk: $(OBJ) $(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS) -all: example_sussman_circle +all: example_sussman_disk run: all - mpirun --oversubscribe -np 2 ./example_sussman_circle + mpirun --oversubscribe -np 2 ./example_sussman_disk .PHONY: clean all run clean: - rm -f *.o *~ core example_sussman_circle + rm -f *.o *~ core example_sussman_disk diff --git a/example/Numerics/Sussman_redistancing/example_sussman_circle/config.cfg b/example/Numerics/Sussman_redistancing/example_sussman_disk/config.cfg similarity index 100% rename from example/Numerics/Sussman_redistancing/example_sussman_circle/config.cfg rename to example/Numerics/Sussman_redistancing/example_sussman_disk/config.cfg diff --git a/example/Numerics/Sussman_redistancing/example_sussman_circle/main.cpp b/example/Numerics/Sussman_redistancing/example_sussman_disk/main.cpp similarity index 80% rename from example/Numerics/Sussman_redistancing/example_sussman_circle/main.cpp rename to example/Numerics/Sussman_redistancing/example_sussman_disk/main.cpp index f58ef59927e436be039bdf25232ab0cc96773f3c..3725674c4cb484200a33c24bdaea03c878735bee 100644 --- a/example/Numerics/Sussman_redistancing/example_sussman_circle/main.cpp +++ b/example/Numerics/Sussman_redistancing/example_sussman_disk/main.cpp @@ -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 Disk 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 Disk 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/DrawCircle.hpp" +#include "Draw/DrawDisk.hpp" //! @cond [Include] @endcond /** - * @page example_sussman_circle Circle 2D + * @page example_sussman_disk Disk 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 Disk 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 Disk 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 Disk 2D * - * ## Get filled circle on the grid ## {#e2d_c_getcircle} + * ## Get disk on the grid ## {#e2d_c_getdisk} * * - * 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 DrawDisk.hpp). Phi_0 will then be: * * @f[ \phi_{\text{indicator}} = \begin{cases} * +1 & \text{point lies inside the object} \\ @@ -206,71 +206,74 @@ 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: 100). + * * \p min_iter: Minimum number of iterations before steady state in narrow band will be checked (Default: 1e5). * * \p max_iter: Maximum number of iterations you want to run the redistancing, even if steady state might not yet - * have been reached (Default: 1e6). - * * \p convTolChange.value: Convolution tolerance for the normalized total 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 total change between two iterations as + * have been reached (Default: 1e12). + * * \p convTolChange.value: Convergence tolerance for the maximal change of Phi within the narrow band between + * two consecutive iterations (Default: 1e-15). + * * \p convTolChange.check: Set true, if you want to use the maximal 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: Convolution tolerance for the residual, that is abs(magnitude gradient of phi - 1) of - * Phi in the narrow band (Default 1e-1). + * * \p convTolResidual.value: Convergence 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). + * * \p save_temp_grid: If true, save the temporary grid as hdf5 that can be reloaded onto a grid (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 // Now we want to convert the initial Phi into a signed distance function (SDF) with magnitude of gradient = 1. // For the initial re-distancing we use the Sussman method. First of all, we can set some redistancing options. Redist_options redist_options; - redist_options.min_iter = 100; - redist_options.max_iter = 10000; + redist_options.min_iter = 1e3; + redist_options.max_iter = 1e4; - redist_options.convTolChange.value = 1e-6; + redist_options.convTolChange.value = 1e-7; redist_options.convTolChange.check = true; - redist_options.convTolResidual.value = 1e-6; + redist_options.convTolResidual.value = 1e-6; // is ignored if convTolResidual.check = false; redist_options.convTolResidual.check = false; - redist_options.interval_check_convergence = 1; - redist_options.width_NB_in_grid_points = 6; + redist_options.interval_check_convergence = 1e3; + redist_options.width_NB_in_grid_points = 10; redist_options.print_current_iterChangeResidual = true; redist_options.print_steadyState_iter = true; + redist_options.save_temp_grid = true; //! @cond [Redistancing options] @endcond /** - * @page example_sussman_circle Circle 2D + * @page example_sussman_disk Disk 2D * * ## Run the redistancing ## {#e2d_c_runredist} * @@ -281,13 +284,13 @@ int main(int argc, char* argv[]) * (T dt). However, be careful when setting your own timestep: if chosen too large, the CFL-condition may be no * longer fulfilled and the method can become unstable. For the #RedistancingSussman::run_redistancing we need to * provide two template parameters. These are the indices of the respective property that: 1.) contains the - * initial Phi, 2.) should - * contain the output of the redistancing. You can use the same index twice, if you want that your input will be - * overwritten by the output. This time, it makes sense, to save the output grid, since this is already our grid + * initial Phi, 2.) should contain the output of the redistancing. + * You can use the same index twice, if you want that your input will be overwritten by the output. This time, it + * makes sense, to save the output grid, since this is already our grid * 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 +299,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 +316,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 +325,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 +333,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 +348,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 +356,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 +375,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 +394,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 +406,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 +426,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 */ diff --git a/example/Numerics/Sussman_redistancing/example_sussman_images_2D/main.cpp b/example/Numerics/Sussman_redistancing/example_sussman_images_2D/main.cpp index 9a2b1507640e0f9f2e79768122c4673c8c85d46b..d17017f826bf433da5ece3fe3a3656c0611d0ec5 100644 --- a/example/Numerics/Sussman_redistancing/example_sussman_images_2D/main.cpp +++ b/example/Numerics/Sussman_redistancing/example_sussman_images_2D/main.cpp @@ -11,7 +11,7 @@ * * Build a 2D cartesian OpenFPM grid with same dimensions as the image (1 particle for each pixel in x and y) or * refined by arbitrary factor in dimension of choice (e.g. to get a isotropic grid) * * Assign pixel value to a grid node property - * * Run the Sussman Redistancing and get the narrow band around the interface (see also: @ref example_sussman_circle + * * Run the Sussman Redistancing and get the narrow band around the interface (see also: @ref example_sussman_disk * and example_sussman_sphere) * * Output: @@ -148,7 +148,7 @@ int main(int argc, char* argv[]) * */ //! @cond [Size] @endcond - std::vector<size_t> stack_size = get_size(path_to_size); + std::vector<int> stack_size = get_size(path_to_size); auto & v_cl = create_vcluster(); if (v_cl.rank() == 0) { @@ -160,7 +160,8 @@ int main(int argc, char* argv[]) } // Array with grid dimensions after refinement. This size-array will be used for the grid creation. - const size_t sz[grid_dim] = {(size_t)std::round(stack_size[x] * refinement[x]), (size_t)std::round(stack_size[y] * refinement[y])}; // 2D + const size_t sz[grid_dim] = {(size_t)std::round(stack_size[x] * refinement[x]), (size_t)std::round(stack_size[y] * + refinement[y])}; // 2D //! @cond [Size] @endcond // Here we create a 2D grid that stores 2 properties: // Prop1: store the initial Phi; @@ -172,7 +173,7 @@ int main(int argc, char* argv[]) * * Once we have loaded the geometrical object from the 2D image onto the grid, we can perform Sussman * redistancing and get the narrow band the same way as it is explained in detail here: @ref - * example_sussman_circle and here: @ref example_sussman_sphere. + * example_sussman_disk and here: @ref example_sussman_sphere. * * * @snippet example/Numerics/Sussman_redistancing/example_sussman_images_2D/main.cpp Redistancing @@ -195,22 +196,21 @@ int main(int argc, char* argv[]) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Now we want to convert the initial Phi into a signed distance function (SDF) with magnitude of gradient = 1 // For the initial re-distancing we use the Sussman method - // 1.) Set some redistancing options + // 1.) Set some redistancing options (for details see example sussman disk or sphere) Redist_options redist_options; - redist_options.min_iter = 100; // min. number of iterations before steady state in narrow band will be checked (default: 100) - redist_options.max_iter = 10000; // max. number of iterations you want to run the - // redistancing, even if steady state might not yet have been reached (default: 1e6) + redist_options.min_iter = 1e3; + redist_options.max_iter = 1e4; - redist_options.convTolChange.value = 1e-6; // convolution tolerance for the normalized total change of Phi in the narrow band between two consecutive iteratins (default: 1e-6) - redist_options.convTolChange.check = true; // define here which of the convergence criteria above should be used. If both are true, termination only occurs when both are fulfilled or when iter > max_iter - redist_options.convTolResidual.value = 1e-1; // convolution tolerance for the normalized total residual of Phi versus the SDF (aka the error). Don't choose too small to not run forever. (default: 1e-1) - redist_options.convTolResidual.check = false; // (default: false) + redist_options.convTolChange.value = 1e-7; + redist_options.convTolChange.check = true; + redist_options.convTolResidual.value = 1e-6; // is ignored if convTolResidual.check = false; + redist_options.convTolResidual.check = false; - redist_options.interval_check_convergence = 1; // interval of #iterations at which convergence is checked (default: 100) - redist_options.width_NB_in_grid_points = 6; // 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. (default: 4) - redist_options.print_current_iterChangeResidual = true; // if true, prints out every current iteration + corresponding change from the previous iteration + residual from SDF (default: false) - redist_options.print_steadyState_iter = true; // if true, prints out the final iteration number when steady state was reached + final change + residual (default: true) + redist_options.interval_check_convergence = 1e3; + redist_options.width_NB_in_grid_points = 10; + redist_options.print_current_iterChangeResidual = true; + redist_options.print_steadyState_iter = true; + redist_options.save_temp_grid = true; RedistancingSussman<grid_in_type> redist_obj(g_dist, redist_options); // Instantiation of Sussman-redistancing class // std::cout << "dt = " << redist_obj.get_time_step() << std::endl; diff --git a/example/Numerics/Sussman_redistancing/example_sussman_images_3D/main.cpp b/example/Numerics/Sussman_redistancing/example_sussman_images_3D/main.cpp index 6dcdb680f255474892a31f10a9b9aaa3053a6a7e..cbec16e6fb67a3e1a9a0496795fe25d48b24a9d2 100644 --- a/example/Numerics/Sussman_redistancing/example_sussman_images_3D/main.cpp +++ b/example/Numerics/Sussman_redistancing/example_sussman_images_3D/main.cpp @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) * */ //! @cond [Size] @endcond - std::vector<size_t> stack_size = get_size(path_to_size); + std::vector<int> stack_size = get_size(path_to_size); auto & v_cl = create_vcluster(); if (v_cl.rank() == 0) { @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) * * Once we have loaded the geometrical object from the 3D stack onto the grid, we can perform Sussman * redistancing and get the narrow band the same way as it is explained in detail here: @ref - * example_sussman_circle and here: @ref example_sussman_sphere. + * example_sussman_disk and here: @ref example_sussman_sphere. * * * @snippet example/Numerics/Sussman_redistancing/example_sussman_images_3D/main.cpp Redistancing @@ -189,25 +189,21 @@ int main(int argc, char* argv[]) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Now we want to convert the initial Phi into a signed distance function (SDF) with magnitude of gradient = 1 // For the initial re-distancing we use the Sussman method - // 1.) Set some redistancing options + // 1.) Set some redistancing options (for details see example sussman disk or sphere) Redist_options redist_options; - redist_options.min_iter = 100; // min. number of iterations before steady state in narrow band will be checked (default: 100) - redist_options.max_iter = 10000; // max. number of iterations you want to run the - // redistancing, even if steady state might not yet - // have been reached (default: 1e6) - redist_options.convTolChange.value = 1e-6; // convolution tolerance for the normalized total change of Phi in the narrow band between two consecutive iteratins (default: 1e-6) - redist_options.convTolChange.check = true; // define here which of the convergence criteria above should be used. If both are true, termination only occurs when both are fulfilled or when iter > max_iter - redist_options.convTolResidual.value = 1e-1; // convolution tolerance for the normalized total residual of Phi versus the SDF (aka the error). Don't choose too small to not run forever. (default: 1e-1) - redist_options.convTolResidual.check = false; // (default: false) + redist_options.min_iter = 1e3; + redist_options.max_iter = 1e4; - redist_options.interval_check_convergence = 1; // interval of #iterations at which convergence is checked (default: 100) - redist_options.width_NB_in_grid_points = 6; // 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. - // (default: 4) - redist_options.print_current_iterChangeResidual = true; // if true, prints out every current iteration + corresponding change from the previous iteration + residual from SDF (default: false) - redist_options.print_steadyState_iter = true; // if true, prints out the final iteration number when steady state was reached + final change + residual (default: true) + redist_options.convTolChange.value = 1e-7; + redist_options.convTolChange.check = true; + redist_options.convTolResidual.value = 1e-6; // is ignored if convTolResidual.check = false; + redist_options.convTolResidual.check = false; + redist_options.interval_check_convergence = 1e3; + redist_options.width_NB_in_grid_points = 10; + redist_options.print_current_iterChangeResidual = true; + redist_options.print_steadyState_iter = true; + redist_options.save_temp_grid = true; RedistancingSussman<grid_in_type> redist_obj(g_dist, redist_options); // Instantiation of Sussman-redistancing class // std::cout << "dt = " << redist_obj.get_time_step() << std::endl; // Run the redistancing. in the <> brackets provide property-index where 1.) your initial Phi is stored and 2.) where the resulting SDF should be written to. diff --git a/example/Numerics/Sussman_redistancing/example_sussman_sphere/main.cpp b/example/Numerics/Sussman_redistancing/example_sussman_sphere/main.cpp index 9be98523cddb14230ec731c5ee6817b043e30810..966094a693f1b01130c8fdd9a9a8303bcab4e1f2 100644 --- a/example/Numerics/Sussman_redistancing/example_sussman_sphere/main.cpp +++ b/example/Numerics/Sussman_redistancing/example_sussman_sphere/main.cpp @@ -183,51 +183,54 @@ int main(int argc, char* argv[]) * * ## Set the redistancing options ## {#e3d_s_redistoptions} * - * For the redistancing, we can choose some options. These options will then be passed bundled as a structure to + * 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: 100). + * * \p min_iter: Minimum number of iterations before steady state in narrow band will be checked (Default: 1e5). * * \p max_iter: Maximum number of iterations you want to run the redistancing, even if steady state might not yet - * have been reached (Default: 1e6). - * * \p convTolChange.value: Convolution tolerance for the normalized total 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 total change between two iterations as + * have been reached (Default: 1e12). + * * \p convTolChange.value: Convergence tolerance for the maximal change of Phi within the narrow band between + * two consecutive iterations (Default: 1e-15). + * * \p convTolChange.check: Set true, if you want to use the maximal 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: Convolution tolerance for the residual, that is abs(magnitude gradient of phi - 1) of - * Phi in the narrow band (Default 1e-1). + * * \p convTolResidual.value: Convergence 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). + * * \p save_temp_grid: If true, save the temporary grid as hdf5 that can be reloaded onto a grid (Default: false). * - * @snippet example/Numerics/Sussman_redistancing/example_sussman_sphere/main.cpp Redistancing options + * + * @snippet example/Numerics/Sussman_redistancing/example_sussman_disk/main.cpp Redistancing options */ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //! @cond [Redistancing options] @endcond // Now we want to convert the initial Phi into a signed distance function (SDF) with magnitude of gradient = 1. // For the initial re-distancing we use the Sussman method. First of all, we can set some redistancing options. Redist_options redist_options; - redist_options.min_iter = 100; - redist_options.max_iter = 1000; + redist_options.min_iter = 1e3; + redist_options.max_iter = 1e4; - redist_options.convTolChange.value = 1e-12; + redist_options.convTolChange.value = 1e-7; redist_options.convTolChange.check = true; - redist_options.convTolResidual.value = 1e-1; + redist_options.convTolResidual.value = 1e-6; // is ignored if convTolResidual.check = false; redist_options.convTolResidual.check = false; - redist_options.interval_check_convergence = 1; - redist_options.width_NB_in_grid_points = 6; + redist_options.interval_check_convergence = 1e3; + redist_options.width_NB_in_grid_points = 10; redist_options.print_current_iterChangeResidual = true; redist_options.print_steadyState_iter = true; + redist_options.save_temp_grid = true; //! @cond [Redistancing options] @endcond /** diff --git a/example/Vector/2_expressions/main.cpp b/example/Vector/2_expressions/main.cpp index f20b0a2828605a82c2299c3630b689ad5043b6a8..50f04ef53e14f56dd8d47c92bdc6230afd007749 100644 --- a/example/Vector/2_expressions/main.cpp +++ b/example/Vector/2_expressions/main.cpp @@ -115,13 +115,13 @@ int main(int argc, char* argv[]) openfpm_init(&argc,&argv); // Here we define our domain a 2D box with intervals from 0 to 1.0 - Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> domain({0.0,0.0,0.0},{1.0,1.0,1.0}); // Here we define the boundary conditions of our problem size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; // extended boundary around the domain, and the processor domain - Ghost<3,float> g(0.01); + Ghost<3,double> g(0.01); // Delta t double dt = 0.01; diff --git a/example/Vector/3_molecular_dynamic/main.cpp b/example/Vector/3_molecular_dynamic/main.cpp index 8df3ee93947c62e02728e304f82c999e0396347e..749047bb3593ccc28faea6b5669e47ce7311bad6 100644 --- a/example/Vector/3_molecular_dynamic/main.cpp +++ b/example/Vector/3_molecular_dynamic/main.cpp @@ -308,13 +308,13 @@ int main(int argc, char* argv[]) size_t sz[3] = {10,10,10}; // domain - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; // ghost, big enough to contain the interaction radius - Ghost<3,float> ghost(r_cut); + Ghost<3,double> ghost(r_cut); double dt = 0.0005; double sigma12 = pow(sigma,12); diff --git a/example/Vector/3_molecular_dynamic/main_expr.cpp b/example/Vector/3_molecular_dynamic/main_expr.cpp index 090631764a5da0af1e4ab4ae1d95532a7c11badc..352391e519e9ddd4a9bc7fa6b3e2ec478fcadfa6 100644 --- a/example/Vector/3_molecular_dynamic/main_expr.cpp +++ b/example/Vector/3_molecular_dynamic/main_expr.cpp @@ -56,9 +56,9 @@ int main(int argc, char* argv[]) Vcluster<> & vcl = create_vcluster(); size_t sz[3] = {10,10,10}; - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; - Ghost<3,float> ghost(r_cut); + Ghost<3,double> ghost(r_cut); ln_force lf(sigma12,sigma6,r_cut*r_cut); ln_potential lp(sigma12,sigma6,r_cut*r_cut,shift); diff --git a/example/Vector/3_molecular_dynamic/main_expr_paper.cpp b/example/Vector/3_molecular_dynamic/main_expr_paper.cpp index cfe7b19efa60b40997913e2e0dde9f359d288dac..e166299ae7e268f776e6221c8178160e077e66df 100644 --- a/example/Vector/3_molecular_dynamic/main_expr_paper.cpp +++ b/example/Vector/3_molecular_dynamic/main_expr_paper.cpp @@ -53,9 +53,9 @@ int main(int argc, char* argv[]) ///// Define initialization grid, simulation box, periodicity ///// and ghost size_t sz[3] = {10,10,10}; - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; - Ghost<3,float> ghost(r_cut); + Ghost<3,double> ghost(r_cut); ///// Lennard_jones potential object used in applyKernel_in ln_force lennard_jones; diff --git a/example/Vector/3_molecular_dynamic/main_vl.cpp b/example/Vector/3_molecular_dynamic/main_vl.cpp index 6063ea6cfd5a4603728d66972a7f2b0c94f9267a..1538033fe349173755440b01e9bc090e57fb29c8 100644 --- a/example/Vector/3_molecular_dynamic/main_vl.cpp +++ b/example/Vector/3_molecular_dynamic/main_vl.cpp @@ -278,13 +278,13 @@ int main(int argc, char* argv[]) size_t sz[3] = {10,10,10}; // domain - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; // ghost, big enough to contain the interaction radius - Ghost<3,float> ghost(r_gskin); + Ghost<3,double> ghost(r_gskin); vector_dist<3,double, aggregate<double[3],double[3]> > vd(0,box,bc,ghost); diff --git a/example/Vector/4_reorder/main_comp_ord.cpp b/example/Vector/4_reorder/main_comp_ord.cpp index e8d4c9f1d66426f358a564a24c4cf794d374d270..81f95d7e9435eb0d243c9f6c75bc3da27dc73ca7 100644 --- a/example/Vector/4_reorder/main_comp_ord.cpp +++ b/example/Vector/4_reorder/main_comp_ord.cpp @@ -226,7 +226,7 @@ int main(int argc, char* argv[]) //! \cond [vect create] \endcond double dt = 0.0001; - float r_cut = 0.03; + double r_cut = 0.03; double sigma = r_cut/3.0; double sigma12 = pow(sigma,12); double sigma6 = pow(sigma,6); @@ -241,13 +241,13 @@ int main(int argc, char* argv[]) size_t sz[3] = {40,40,40}; // domain - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; // ghost, big enough to contain the interaction radius - Ghost<3,float> ghost(r_cut); + Ghost<3,double> ghost(r_cut); vector_dist<3,double, aggregate<double[3],double[3]> > vd(0,box,bc,ghost); diff --git a/example/Vector/4_reorder/main_data_ord.cpp b/example/Vector/4_reorder/main_data_ord.cpp index d9b97b4797b0bc8abd0d2298f4ede8d7016d668f..4e5022ed6376761084c2f8d1595813a61c9a28b4 100644 --- a/example/Vector/4_reorder/main_data_ord.cpp +++ b/example/Vector/4_reorder/main_data_ord.cpp @@ -41,7 +41,7 @@ int main(int argc, char* argv[]) //! \cond [vect create] \endcond double dt = 0.0001; - float r_cut = 0.03; + double r_cut = 0.03; double sigma = r_cut/3.0; double sigma12 = pow(sigma,12); double sigma6 = pow(sigma,6); @@ -56,13 +56,13 @@ int main(int argc, char* argv[]) size_t sz[3] = {40,40,40}; // domain - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; // ghost, big enough to contain the interaction radius - Ghost<3,float> ghost(r_cut); + Ghost<3,double> ghost(r_cut); // Create vector vector_dist<3,double, aggregate<double[3],double[3]> > vd(0,box,bc,ghost); diff --git a/example/Vector/4_reorder/main_expr.cpp b/example/Vector/4_reorder/main_expr.cpp index 86c7e31bf41bbd94ef81c469fa90617ed261b0b1..82c0ca9508116928341acd754497cd46d17259c7 100644 --- a/example/Vector/4_reorder/main_expr.cpp +++ b/example/Vector/4_reorder/main_expr.cpp @@ -51,9 +51,9 @@ int main(int argc, char* argv[]) Vcluster & vcl = create_vcluster(); size_t sz[3] = {10,10,10}; - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; - Ghost<3,float> ghost(r_cut); + Ghost<3,double> ghost(r_cut); ln_force lf(sigma12,sigma6); ln_potential lp(sigma12,sigma6); diff --git a/example/Vector/5_molecular_dynamic_sym/main.cpp b/example/Vector/5_molecular_dynamic_sym/main.cpp index 1e1cfe2f844450568901f871970e07e58bdc4422..d44029d36c6776cf1a5c489d3ca22082e78a6fd8 100644 --- a/example/Vector/5_molecular_dynamic_sym/main.cpp +++ b/example/Vector/5_molecular_dynamic_sym/main.cpp @@ -290,13 +290,13 @@ int main(int argc, char* argv[]) size_t sz[3] = {10,10,10}; // domain - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; // ghost, big enough to contain the interaction radius - Ghost<3,float> ghost(r_gskin); + Ghost<3,double> ghost(r_gskin); vector_dist<3,double, aggregate<double[3],double[3]> > vd(0,box,bc,ghost); diff --git a/example/Vector/5_molecular_dynamic_sym_crs/main.cpp b/example/Vector/5_molecular_dynamic_sym_crs/main.cpp index 2985148412526fd4fcb845bc43e053a9b3f8c58a..5b45b06729b69f5d79f9460daa1ba0702c375f5c 100644 --- a/example/Vector/5_molecular_dynamic_sym_crs/main.cpp +++ b/example/Vector/5_molecular_dynamic_sym_crs/main.cpp @@ -363,7 +363,7 @@ int main(int argc, char* argv[]) size_t sz[3] = {10,10,10}; // domain - Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); + Box<3,double> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; @@ -371,7 +371,7 @@ int main(int argc, char* argv[]) //! \cond [remove_lower_part] \endcond // ghost, big enough to contain the interaction radius - Ghost<3,float> ghost(r_gskin); + Ghost<3,double> ghost(r_gskin); ghost.setLow(0,0.0); ghost.setLow(1,0.0); ghost.setLow(2,0.0); diff --git a/example/Vector/7_SPH_dlb_gpu/Makefile b/example/Vector/7_SPH_dlb_gpu/Makefile index 8813b2db0ecd3b2b8764579fea94295107af65ea..b4ebc34312ce5d2227f06fe1a196193e2be27469 100644 --- a/example/Vector/7_SPH_dlb_gpu/Makefile +++ b/example/Vector/7_SPH_dlb_gpu/Makefile @@ -8,7 +8,7 @@ CUDA_CC_LINK= CC=mpic++ ifdef HIP CUDA_CC=hipcc - CUDA_OPTIONS=-D__NVCC__ -D__HIP__ -DCUDART_VERSION=11000 -D__CUDACC__ -D__CUDACC_VER_MAJOR__=11 -D__CUDACC_VER_MINOR__=0 -D__CUDACC_VER_BUILD__=0 + CUDA_OPTIONS= -D__NVCC__ -D__HIP__ -DCUDART_VERSION=11000 -D__CUDACC__ -D__CUDACC_VER_MAJOR__=11 -D__CUDACC_VER_MINOR__=0 -D__CUDACC_VER_BUILD__=0 LIBS_SELECT=$(LIBS) CC=hipcc CUDA_CC_LINK=hipcc @@ -44,7 +44,7 @@ sph_dlb_test: OPT += -DTEST_RUN sph_dlb_test: sph_dlb %.o: %.cu - $(CUDA_CC) $(CUDA_OPTIONS) -O3 $(OPT) -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH_NVCC) + $(CUDA_CC) $(CUDA_OPTIONS) $(OPT) -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH_NVCC) %.o: %.cpp $(CC) -O3 $(OPT) -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH) diff --git a/install b/install index 4cd97bce9217305d4b6779409b0f8237d19e2ed5..abae1d1019f2e8a8f8fa9f6eea765248895b015f 100755 --- a/install +++ b/install @@ -220,11 +220,11 @@ echo -e "Installing requirements into: $i_dir " ## call the configure script -### Installing PETSC +### Installing PETSC and Extended numerics -if [ ! -d "$i_dir/PETSC" -o ! -f "$i_dir/PETSC/include/petsc.h" -o ! -d "$i_dir/EIGEN" ]; then +if [ ! -d "$i_dir/PETSC" -o ! -f "$i_dir/PETSC/include/petsc.h" -o ! -d "$i_dir/EIGEN" -o ! -d "$i_dir/BLITZ" -o ! -d "$i_dir/ALGOIM" ]; then echo -e "\033[1;34m Optional packages \033[0m" - echo -e "\033[1mDo you want to install linear algebra packages ?(y/n)\033[0m" + echo -e "\033[1mDo you want to install linear algebra packages and extended Level-set functionalities ?(y/n)\033[0m" if [ $sq -eq 0 ]; then read inst_lin_alg else @@ -409,6 +409,8 @@ else if [ x"$inst_lin_alg" == x"y" ]; then CXX="$CXX" CC="$CC" FC="$FC" F77="$F77" ./script/install_EIGEN.sh $i_dir $ncore CXX="$CXX" CC="$CC" FC="$FC" F77="$F77" ./script/install_PETSC.sh $i_dir $ncore $CC $CXX $F77 $FC + ./script/install_blitz_algoim.sh $i_dir $ncore + configure_options=" $configure_options --with-blitz=$i_dir/BLITZ --with-algoim=$i_dir/ALGOIM " fi ### collect PETSC configuration options diff --git a/openfpm_pdata.doc b/openfpm_pdata.doc index c29086dba9ff93b6146095ab3273bb9128d9b357..1d5143ba56bb56ef22c5d99c5b24121d75987a30 100644 --- a/openfpm_pdata.doc +++ b/openfpm_pdata.doc @@ -38,7 +38,7 @@ PROJECT_NAME = "OpenFPM_pdata" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.3.0 +PROJECT_NUMBER = 4.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/script/install_PETSC.sh b/script/install_PETSC.sh index 12079ff67f90b1f8e8299405ba9316b1d600f8b3..097435c1468b420089e0e9d74ef75a2dccd70e44 100755 --- a/script/install_PETSC.sh +++ b/script/install_PETSC.sh @@ -130,7 +130,7 @@ configure_options2="$configure_options --download-superlu_dist " test_configure_options if [ $error -eq 0 ]; then - echo "SUITESPARSE work with PETSC" + echo "SUPERLU work with PETSC" configure_options="$configure_options --download-superlu_dist " fi diff --git a/script/solve_gdbserver b/script/solve_gdbserver index a92893f127b4d5dac842896619333271b05fca70..cd7404c8ab5727c3694992efe4d95df81bd72bbb 100755 --- a/script/solve_gdbserver +++ b/script/solve_gdbserver @@ -19,7 +19,7 @@ elif [ x"$1" = x"linux" ]; then elif [ x"$pcman" = x"pacman" ]; then package_name=gdb elif [ x"$pcman" = x"apt-get" ]; then - package_name=gdbsever + package_name=gdbserver else package_name=gdb-gdbserver fi diff --git a/src/Amr/grid_dist_amr.hpp b/src/Amr/grid_dist_amr.hpp index 7c171bdc415092949eedc40c26fcd199d1bb1e17..8fd29645029de596b15563e1c0d9760dd4e77187 100644 --- a/src/Amr/grid_dist_amr.hpp +++ b/src/Amr/grid_dist_amr.hpp @@ -574,7 +574,7 @@ public: * \return the selected element * */ - template <unsigned int p>inline auto get(const grid_dist_amr_key<dim> & v1) const -> typename std::add_lvalue_reference<decltype(gd_array.get(v1.getLvl()).template get<p>(v1.getKey()))>::type + template <unsigned int p>inline auto get(const grid_dist_amr_key<dim> & v1) const -> decltype(gd_array.get(v1.getLvl()).template get<p>(v1.getKey())) { #ifdef SE_CLASS2 check_valid(this,8); @@ -590,7 +590,7 @@ public: * \return the selected element * */ - template <unsigned int p>inline auto get(const grid_dist_amr_key<dim> & v1) -> typename std::add_lvalue_reference<decltype(gd_array.get(v1.getLvl()).template get<p>(v1.getKey()))>::type + template <unsigned int p>inline auto get(const grid_dist_amr_key<dim> & v1) -> decltype(gd_array.get(v1.getLvl()).template get<p>(v1.getKey())) { #ifdef SE_CLASS2 check_valid(this,8); @@ -607,7 +607,7 @@ public: * \return the selected element * */ - template <unsigned int p>inline auto get(size_t lvl, const grid_dist_key_dx<dim> & v1) const -> typename std::add_lvalue_reference<decltype(gd_array.get(lvl).template get<p>(v1))>::type + template <unsigned int p>inline auto get(size_t lvl, const grid_dist_key_dx<dim> & v1) const -> decltype(gd_array.get(lvl).template get<p>(v1)) { #ifdef SE_CLASS2 check_valid(this,8); @@ -623,7 +623,7 @@ public: * \return the selected element * */ - template <unsigned int p>inline auto get(size_t lvl, const grid_dist_key_dx<dim> & v1) -> typename std::add_lvalue_reference<decltype(gd_array.get(lvl).template get<p>(v1))>::type + template <unsigned int p>inline auto get(size_t lvl, const grid_dist_key_dx<dim> & v1) -> decltype(gd_array.get(lvl).template get<p>(v1)) { #ifdef SE_CLASS2 check_valid(this,8); @@ -644,7 +644,7 @@ public: */ template <unsigned int p> inline auto insert(const grid_dist_amr_key<dim> & v1) - -> typename std::add_lvalue_reference<decltype(gd_array.get(v1.getLvl()).template insert<p>(v1.getKey()))>::type + -> decltype(gd_array.get(v1.getLvl()).template insert<p>(v1.getKey())) { #ifdef SE_CLASS2 check_valid(this,8); @@ -663,7 +663,7 @@ public: * */ template <unsigned int p>inline auto insert(size_t lvl, const grid_dist_key_dx<dim> & v1) - -> typename std::add_lvalue_reference<decltype(gd_array.get(lvl).template insert<p>(v1))>::type + -> decltype(gd_array.get(lvl).template insert<p>(v1)) { #ifdef SE_CLASS2 check_valid(this,8); diff --git a/src/Amr/grid_dist_amr_unit_tests.cpp b/src/Amr/grid_dist_amr_unit_tests.cpp index 96e07f01d595217d8d70ece9b32517a92139fa7a..b1241f9c0a6d90927a29859957c1946935fd5ddd 100644 --- a/src/Amr/grid_dist_amr_unit_tests.cpp +++ b/src/Amr/grid_dist_amr_unit_tests.cpp @@ -56,6 +56,14 @@ void Test3D_amr_create_levels(grid_amr & amr_g, Box<3,float> & domain, size_t co amr_g.template insert<0>(akey) = 3.0; + amr_g.template insert<1>(akey)[0] = 3.0; + amr_g.template insert<1>(akey)[1] = 3.0; + amr_g.template insert<1>(akey)[2] = 3.0; + + amr_g.template insert<2>(akey)[0] = 3; + amr_g.template insert<2>(akey)[1] = 3; + amr_g.template insert<2>(akey)[2] = 3; + count++; ++it; @@ -184,11 +192,15 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain amr_g.template insert<0>(key) = gkey.get(0); amr_g.template insert<1>(key) = gkey.get(1); amr_g.template insert<2>(key) = gkey.get(2); + amr_g.template insert<3>(key)[0] = gkey.get(0); + amr_g.template insert<3>(key)[1] = gkey.get(1); + amr_g.template insert<3>(key)[2] = gkey.get(2); + amr_g.template insert<3>(key)[3] = gkey.get(0); ++it; } - amr_g.template ghost_get<0,1,2>(); + amr_g.template ghost_get<0,1,2,3>(); // now we check that move space work @@ -224,12 +236,10 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain match &= amr_g.template get<1>(key_px) == gkey.get(1); match &= amr_g.template get<2>(key_px) == gkey.get(2); - - if (match == false) - { - int debug = 0; - debug++; - } + match &= amr_g.template get<3>(key_px)[0] == gkey.get(0) + 1; + match &= amr_g.template get<3>(key_px)[1] == gkey.get(1); + match &= amr_g.template get<3>(key_px)[2] == gkey.get(2); + match &= amr_g.template get<3>(key_px)[3] == gkey.get(0) + 1; } if (gr_is_inside(key_gmx,amr_g.getGridInfoVoid(it2.getLvl()).getSize()) == true) @@ -238,12 +248,10 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain match &= amr_g.template get<1>(key_mx) == gkey.get(1); match &= amr_g.template get<2>(key_mx) == gkey.get(2); - - if (match == false) - { - int debug = 0; - debug++; - } + match &= amr_g.template get<3>(key_mx)[0] == gkey.get(0) - 1; + match &= amr_g.template get<3>(key_mx)[1] == gkey.get(1); + match &= amr_g.template get<3>(key_mx)[2] == gkey.get(2); + match &= amr_g.template get<3>(key_mx)[3] == gkey.get(0) - 1; } if (gr_is_inside(key_gpy,amr_g.getGridInfoVoid(it2.getLvl()).getSize()) == true) @@ -252,12 +260,10 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain match &= amr_g.template get<1>(key_py) == gkey.get(1) + 1; match &= amr_g.template get<2>(key_py) == gkey.get(2); - - if (match == false) - { - int debug = 0; - debug++; - } + match &= amr_g.template get<3>(key_py)[0] == gkey.get(0); + match &= amr_g.template get<3>(key_py)[1] == gkey.get(1) + 1; + match &= amr_g.template get<3>(key_py)[2] == gkey.get(2); + match &= amr_g.template get<3>(key_py)[3] == gkey.get(0); } if (gr_is_inside(key_gmy,amr_g.getGridInfoVoid(it2.getLvl()).getSize()) == true) @@ -266,12 +272,10 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain match &= amr_g.template get<1>(key_my) == gkey.get(1) - 1; match &= amr_g.template get<2>(key_my) == gkey.get(2); - - if (match == false) - { - int debug = 0; - debug++; - } + match &= amr_g.template get<3>(key_my)[0] == gkey.get(0); + match &= amr_g.template get<3>(key_my)[1] == gkey.get(1) - 1; + match &= amr_g.template get<3>(key_my)[2] == gkey.get(2); + match &= amr_g.template get<3>(key_my)[3] == gkey.get(0); } if (gr_is_inside(key_gpz,amr_g.getGridInfoVoid(it2.getLvl()).getSize()) == true) @@ -280,12 +284,10 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain match &= amr_g.template get<1>(key_pz) == gkey.get(1); match &= amr_g.template get<2>(key_pz) == gkey.get(2) + 1; - - if (match == false) - { - int debug = 0; - debug++; - } + match &= amr_g.template get<3>(key_pz)[0] == gkey.get(0); + match &= amr_g.template get<3>(key_pz)[1] == gkey.get(1); + match &= amr_g.template get<3>(key_pz)[2] == gkey.get(2) + 1; + match &= amr_g.template get<3>(key_pz)[3] == gkey.get(0); } if (gr_is_inside(key_gmz,amr_g.getGridInfoVoid(it2.getLvl()).getSize()) == true) @@ -294,12 +296,10 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain match &= amr_g.template get<1>(key_mz) == gkey.get(1); match &= amr_g.template get<2>(key_mz) == gkey.get(2) - 1; - - if (match == false) - { - int debug = 0; - debug++; - } + match &= amr_g.template get<3>(key_mz)[0] == gkey.get(0); + match &= amr_g.template get<3>(key_mz)[1] == gkey.get(1); + match &= amr_g.template get<3>(key_mz)[2] == gkey.get(2) - 1; + match &= amr_g.template get<3>(key_mz)[3] == gkey.get(0); } @@ -338,12 +338,6 @@ void Test3D_amr_child_parent_get_no_periodic(grid & amr_g, Box<3,float> & domain } } - if (match == false) - { - int debug = 0; - debug++; - } - ++it2; } @@ -790,7 +784,8 @@ void Test3D_ghost_put(grid_amr & g_dist_amr, long int k) BOOST_REQUIRE_EQUAL(correct, true); } -template <typename> struct Debug; + + BOOST_AUTO_TEST_CASE( grid_dist_amr_get_child_test_nop ) { @@ -801,7 +796,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_amr_get_child_test_nop ) k = std::pow(k, 1/3.); Ghost<3,long int> g(1); - grid_dist_amr<3,float,aggregate<long int,long int,long int>> amr_g(domain3,g); + grid_dist_amr<3,float,aggregate<long int,long int,long int, long int[4]>> amr_g(domain3,g); Test3D_amr_child_parent_get_no_periodic(amr_g,domain3,k,4); } @@ -831,11 +826,11 @@ BOOST_AUTO_TEST_CASE( grid_dist_amr_test ) k = std::pow(k, 1/3.); Ghost<3,long int> g(0); - grid_dist_amr<3,float,aggregate<float>> amr_g(domain3,g); + grid_dist_amr<3,float,aggregate<float,float[3],int[3]>> amr_g(domain3,g); Test3D_amr_create_levels(amr_g,domain3,k,4); - sgrid_dist_amr<3,float,aggregate<float>> amr_g2(domain3,g); + sgrid_dist_amr<3,float,aggregate<float,float[3],int[3]>> amr_g2(domain3,g); Test3D_amr_create_levels(amr_g2,domain3,k,4); } @@ -900,11 +895,11 @@ BOOST_AUTO_TEST_CASE( grid_dist_amr_get_child_test_low_res ) long int k = 2; Ghost<3,long int> g(1); - grid_dist_amr<3,float,aggregate<long int,long int,long int>> amr_g(domain3,g); + grid_dist_amr<3,float,aggregate<long int,long int,long int,long int[4]>> amr_g(domain3,g); Test3D_amr_child_parent_get_no_periodic(amr_g,domain3,k,4); - sgrid_dist_amr<3,float,aggregate<long int,long int,long int>> amr_g2(domain3,g); + sgrid_dist_amr<3,float,aggregate<long int,long int,long int, long int [4]>> amr_g2(domain3,g); Test3D_amr_child_parent_get_no_periodic(amr_g2,domain3,k,4); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3148669a74322677e37a8342ffde69d6b35562d7..eee5aed20acdc3480b6526182051075b789c9e3e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,7 +13,8 @@ if(CUDA_FOUND OR CUDA_ON_CPU OR HIP_FOUND) Decomposition/cuda/decomposition_cuda_tests.cu Vector/cuda/vector_dist_gpu_unit_tests.cu Decomposition/cuda/Domain_icells_cart_unit_test.cu - Amr/tests/amr_base_gpu_unit_tests.cu) + Amr/tests/amr_base_gpu_unit_tests.cu + Grid/tests/grid_dist_id_unit_test.cu) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") @@ -61,8 +62,7 @@ if ( HIP_ENABLE AND HIP_FOUND ) Decomposition/tests/CartDecomposition_unit_test.cpp Decomposition/tests/shift_vect_converter_tests.cpp Vector/performance/vector_dist_performance_util.cpp - lib/pdata.cpp - test_multiple_o.cpp + lib/pdata.cpp ) @@ -89,9 +89,10 @@ else() Decomposition/tests/CartDecomposition_unit_test.cpp Decomposition/tests/shift_vect_converter_tests.cpp Vector/performance/vector_dist_performance_util.cpp - lib/pdata.cpp test_multiple_o.cpp) + lib/pdata.cpp) add_library(ofpm_pdata STATIC lib/pdata.cpp) + add_library(ofpm_pdata_python SHARED lib/pdata_python.cpp) endif() @@ -111,12 +112,14 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(pdata PRIVATE "-Wno-macro-redefined") endif() if ( CMAKE_COMPILER_IS_GNUCC ) - target_compile_options(pdata PRIVATE "-Wno-deprecated-declarations") - target_compile_options(pdata PRIVATE "-Wno-undefined-var-template") - target_compile_options(pdata PRIVATE "-Wno-macro-redefined") - #target_compile_options(pdata PRIVATE "-fsanitize=address") - # target_link_options(pdata PRIVATE "-fsanitize=address") +#target_compile_options(pdata PRIVATE "-Wno-deprecated-declarations") +#target_compile_options(pdata PRIVATE "-Wno-undefined-var-template") +#target_compile_options(pdata PRIVATE "-Wno-macro-redefined") +#target_compile_options(pdata PRIVATE "-fsanitize=address") +# target_link_options(pdata PRIVATE "-fsanitize=address") if (TEST_COVERAGE) +######################################## Add mem tests ############################ + target_compile_options(pdata PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -fprofile-arcs -ftest-coverage>) endif() endif() @@ -212,6 +215,51 @@ add_definitions(-DSCAN_WITH_CUB) if (TEST_COVERAGE) target_link_libraries(pdata -lgcov --coverage) + + get_target_property(PDATA_SOURCES pdata SOURCES) + get_target_property(MEM_SOURCES mem SOURCES) + get_target_property(DATA_SOURCES mem_map SOURCES) + get_target_property(VCLUSTER_SOURCES vcluster_test SOURCES) + get_target_property(IO_SOURCES io SOURCES) + get_target_property(NUMERIC_SOURCES numerics SOURCES) + get_target_property(PDATA_INCLUDES pdata INCLUDE_DIRECTORIES) + get_target_property(NUMERIC_INCLUDES numerics INCLUDE_DIRECTORIES) + get_target_property(PDATA_LIBS pdata LINK_LIBRARIES) + get_target_property(NUMERIC_LIBS numerics LINK_LIBRARIES) + + list(TRANSFORM MEM_SOURCES PREPEND "../openfpm_devices/src/") + list(TRANSFORM DATA_SOURCES PREPEND "../openfpm_data/src/") + list(TRANSFORM VCLUSTER_SOURCES PREPEND "../openfpm_vcluster/src/") + list(TRANSFORM IO_SOURCES PREPEND "../openfpm_io/src/") + list(TRANSFORM NUMERIC_SOURCES PREPEND "../openfpm_numerics/src/") + + set(PDATA_FULL_SOURCES ${PDATA_SOURCES} ${MEM_SOURCES} ${DATA_SOURCES} ${VCLUSTER_SOURCES} ${IO_SOURCES} ${NUMERIC_SOURCES}) + set(PDATA_FULL_SOURCES_CU ${PDATA_SOURCES} ${MEM_SOURCES} ${DATA_SOURCES} ${VCLUSTER_SOURCES} ${IO_SOURCES} ${NUMERIC_SOURCES}) + list(FILTER PDATA_FULL_SOURCES_CU INCLUDE REGEX ^.*\.cu) + set_source_files_properties(${PDATA_FULL_SOURCES_CU} PROPERTIES COMPILE_FLAGS "-D__NVCC__ -DCUDART_VERSION=11000") + + if (CUDA_ON_CPU) + set_source_files_properties(${PDATA_FULL_SOURCES_CU} PROPERTIES LANGUAGE CXX) + endif() + + add_executable(pdata_full ${PDATA_FULL_SOURCES}) + + target_compile_definitions(pdata_full PUBLIC NO_INIT_AND_MAIN) + target_compile_options(pdata_full PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -fprofile-arcs -ftest-coverage>) + target_link_options(pdata_full PUBLIC -fprofile-arcs -ftest-coverage) + + target_link_options(pdata_full PUBLIC -fprofile-arcs -ftest-coverage) + + if (ENABLE_ASAN) + target_compile_options(pdata_full PUBLIC $<$<COMPILE_LANGUAGE:CUDA>: -Xcompiler "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g" >) + target_compile_options(pdata_full PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g >) + endif() + + target_link_libraries(pdata_full -lgcov --coverage) + target_link_libraries(pdata_full ${PDATA_LIBS}) + target_link_libraries(pdata_full ${NUMERIC_LIBS}) + target_include_directories(pdata_full PUBLIC ${PDATA_INCLUDES}) + target_include_directories(pdata_full PUBLIC ${NUMERIC_INCLUDES}) endif() diff --git a/src/Decomposition/common.hpp b/src/Decomposition/common.hpp index b0994f259a1427c3924842380fd72634572c52ab..4ed7d3cdc6f7ed7ab2fe79e918fc32066f19e6bf 100755 --- a/src/Decomposition/common.hpp +++ b/src/Decomposition/common.hpp @@ -126,7 +126,7 @@ struct Box_sub_k //! Where this sub_domain live comb<dim> cmb; - //! k \see getLocalGhostIBoxE + //! k \see getLocalIGhostE long int k; Box_sub_k() @@ -138,21 +138,6 @@ struct Box_sub_k template<unsigned int dim,typename T> using Box_map = aggregate<Box<dim,T>,long int>; -/*template<unsigned int dim,typename T> -struct Box_map -{ - typedef boost::fusion::vector<Box<dim,T>,long int> type; - - type data; - - static bool noPointers() - { - return true; - } - - static const unsigned int max_prop = 2; -};*/ - //! Case for local ghost box template<unsigned int dim, typename T> struct lBox_dom diff --git a/src/Decomposition/ie_loc_ghost.hpp b/src/Decomposition/ie_loc_ghost.hpp index 231828e1e71503d525a371be2bb14760799f134e..207072bbd165aa88905a3b7ec52a94eeefa329ea 100755 --- a/src/Decomposition/ie_loc_ghost.hpp +++ b/src/Decomposition/ie_loc_ghost.hpp @@ -350,9 +350,9 @@ public: return loc_ghost_box; } - /*! \brief Get the number of local sub-domains + /*! \brief Get the number of local ghost boxes * - * \return the number of local sub-domains + * \return the number of local ghost boxes * * */ @@ -385,7 +385,7 @@ public: return loc_ghost_box.get(id).ibx.size(); } - /*! \brief For the sub-domain i intersected with a surrounding sub-domain enlarged. Produce a internal ghost box from + /*! \brief For the sub-domain i intersected with a surrounding sub-domain enlarged j. Produce a internal ghost box from * the prospecive of i and an associated external ghost box from the prospective of j. * In order to retrieve the information about the external ghost box we have to use getLocalEGhostBox(x,k). * where k is the value returned by getLocalIGhostE(i,j) and x is the value returned by diff --git a/src/Grid/Iterators/grid_dist_id_iterator.hpp b/src/Grid/Iterators/grid_dist_id_iterator.hpp index 308567b31fff370d39ac7627b29548b65b03c940..fd8dbfa2fa0346b1305cd20d1ebeba5f0b0008b3 100644 --- a/src/Grid/Iterators/grid_dist_id_iterator.hpp +++ b/src/Grid/Iterators/grid_dist_id_iterator.hpp @@ -20,6 +20,8 @@ #include "SparseGridGpu/encap_num.hpp" #endif +#include "Grid/cuda/grid_dist_id_kernels.cuh" + template<unsigned int dim> struct launch_insert_sparse_lambda_call { @@ -183,6 +185,56 @@ struct launch_insert_sparse } }; +template<unsigned int dim> +struct launch_set_dense +{ + template<typename grid_type, typename ite_type, typename lambda_f2> + __device__ void operator()(grid_type & grid, ite_type itg, lambda_f2 f2) + { +#ifdef __NVCC__ + + printf("grid on GPU Dimension %d not implemented, yet\n",(int)dim); + +#endif + } +}; + +template<> +struct launch_set_dense<2> +{ + template<typename grid_type, typename ite_type, typename lambda_f2> + __device__ void operator()(grid_type & grid, ite_type itg, lambda_f2 f2) + { +#ifdef __NVCC__ + + GRID_ID_2_GLOBAL(itg); + + auto obj = grid.get_o(key); + + f2(obj,keyg.get(0),keyg.get(1)); + +#endif + } +}; + +template<> +struct launch_set_dense<3> +{ + template<typename grid_type, typename ite_type, typename lambda_f2> + __device__ void operator()(grid_type & grid, ite_type itg, lambda_f2 f2) + { +#ifdef __NVCC__ + + GRID_ID_3_GLOBAL(itg); + + auto obj = grid.get_o(key); + + f2(obj,keyg.get(0),keyg.get(1),keyg.get(2)); + +#endif + } +}; + template<bool is_free> struct selvg { diff --git a/src/Grid/cuda/grid_dist_id_iterator_gpu.cuh b/src/Grid/cuda/grid_dist_id_iterator_gpu.cuh index 66d1cbbdad2e316c22a311009a110cd122907de5..b3a322a393767148197f6def300c7254dcaa417d 100644 --- a/src/Grid/cuda/grid_dist_id_iterator_gpu.cuh +++ b/src/Grid/cuda/grid_dist_id_iterator_gpu.cuh @@ -77,28 +77,28 @@ class grid_dist_id_iterator_gpu * \return itself * */ - grid_dist_id_iterator_gpu<Decomposition,deviceGrids> & operator=(const grid_dist_id_iterator_gpu<Decomposition,deviceGrids> & tmp) - { - g_c = tmp.g_c; - gdb_ext = tmp.gdb_ext; +// grid_dist_id_iterator_gpu<Decomposition,deviceGrids> & operator=(const grid_dist_id_iterator_gpu<Decomposition,deviceGrids> & tmp) +// { +// g_c = tmp.g_c; +// gdb_ext = tmp.gdb_ext; - start = tmp.start; - stop = tmp.stop; - loc_grids = tmp.loc_grids; +// start = tmp.start; +// stop = tmp.stop; +// loc_grids = tmp.loc_grids; - return *this; - } +// return *this; +// } /*! \brief Copy constructor * * \param tmp iterator to copy * */ - grid_dist_id_iterator_gpu(const grid_dist_id_iterator_gpu<Decomposition,deviceGrids> & tmp) - :loc_grids(tmp.loc_grids) - { - this->operator=(tmp); - } +// grid_dist_id_iterator_gpu(const grid_dist_id_iterator_gpu<Decomposition,deviceGrids> & tmp) +// :loc_grids(tmp.loc_grids) +// { +// this->operator=(tmp); +// } /*! \brief Constructor of the distributed grid iterator * @@ -269,6 +269,7 @@ class grid_dist_id_iterator_gpu } } + /*! \brief Get the starting point of the sub-grid we are iterating * * \return the starting point diff --git a/src/Grid/cuda/grid_dist_id_kernels.cuh b/src/Grid/cuda/grid_dist_id_kernels.cuh index e01fd5199584642bf9a5fa2d4c98a83647985efc..1095325a0cc6cd35151eb5d2d5aeea439bfb2646 100644 --- a/src/Grid/cuda/grid_dist_id_kernels.cuh +++ b/src/Grid/cuda/grid_dist_id_kernels.cuh @@ -8,6 +8,8 @@ #ifndef GRID_DIST_ID_KERNELS_CUH_ #define GRID_DIST_ID_KERNELS_CUH_ +#include "config.h" + #ifdef CUDA_GPU template<unsigned int dim> diff --git a/src/Grid/grid_dist_id.hpp b/src/Grid/grid_dist_id.hpp index 8d4965bd29b1626140afd1cae55cedc4bce99f64..141218883eb1badf7db3149c446d2573ea4f2ac2 100644 --- a/src/Grid/grid_dist_id.hpp +++ b/src/Grid/grid_dist_id.hpp @@ -1768,6 +1768,32 @@ public: #ifdef __NVCC__ + /*! \brief set existing points in the grid + * + * \param f2 lambda function to set points + */ + template<typename lambda_t2> + void setPoints(lambda_t2 f2) + { + auto it = getGridIteratorGPU(); + + it.template launch<1>(launch_set_dense<dim>(),f2); + } + + /*! \brief set point existing in the grid between start and stop + * + * \param start point + * \param stop point + * \param f2 lambda function to set points + */ + template<typename lambda_t2> + void setPoints(grid_key_dx<dim> k1, grid_key_dx<dim> k2, lambda_t2 f2) + { + auto it = getGridIteratorGPU(k1,k2); + + it.template launch<0>(launch_set_dense<dim>(),f2); + } + /*! \brief Insert point in the grid * * \param f1 lambda function to insert point @@ -2310,8 +2336,8 @@ public: * \return the selected element * */ - template <unsigned int p = 0> - inline auto getProp(const grid_dist_key_dx<dim> & v1) const -> decltype(this->template get<p>(v1)) + template <unsigned int p = 0, typename bgkey> + inline auto getProp(const grid_dist_key_dx<dim,bgkey> & v1) const -> decltype(this->template get<p>(v1)) { return this->template get<p>(v1); } @@ -2324,8 +2350,8 @@ public: * \return the selected element * */ - template <unsigned int p = 0> - inline auto getProp(const grid_dist_key_dx<dim> & v1) -> decltype(this->template get<p>(v1)) + template <unsigned int p = 0, typename bgkey> + inline auto getProp(const grid_dist_key_dx<dim,bgkey> & v1) -> decltype(this->template get<p>(v1)) { return this->template get<p>(v1); } @@ -2610,6 +2636,35 @@ public: } } + /*! \brief apply a convolution using the stencil N + * + * + */ + template<unsigned int prop_src, unsigned int prop_dst, unsigned int stencil_size, typename lambda_f, typename ... ArgsT > + void conv_cross_b(grid_key_dx<3> start, grid_key_dx<3> stop , lambda_f func, ArgsT ... args) + { + for (int i = 0 ; i < loc_grid.size() ; i++) + { + Box<dim,long int> inte; + + Box<dim,long int> base; + for (int j = 0 ; j < dim ; j++) + { + base.setLow(j,(long int)start.get(j) - (long int)gdb_ext.get(i).origin.get(j)); + base.setHigh(j,(long int)stop.get(j) - (long int)gdb_ext.get(i).origin.get(j)); + } + + Box<dim,long int> dom = gdb_ext.get(i).Dbox; + + bool overlap = dom.Intersect(base,inte); + + if (overlap == true) + { + loc_grid.get(i).template conv_cross_b<prop_src,prop_dst,stencil_size>(inte.getKP1(),inte.getKP2(),func,args...); + } + } + } + /*! \brief apply a convolution using the stencil N * * @@ -2668,7 +2723,7 @@ public: } } - /*! \brief apply a convolution using the stencil N + /*! \brief apply a convolution on 2 property on GPU * * */ @@ -2697,6 +2752,35 @@ public: } } + /*! \brief apply a convolution on 2 property on GPU + * + * + */ + template<unsigned int prop_src1, unsigned int prop_src2, unsigned int prop_dst1, unsigned int prop_dst2, unsigned int stencil_size, typename lambda_f, typename ... ArgsT > + void conv2_b(grid_key_dx<dim> start, grid_key_dx<dim> stop , lambda_f func, ArgsT ... args) + { + for (int i = 0 ; i < loc_grid.size() ; i++) + { + Box<dim,long int> inte; + + Box<dim,long int> base; + for (int j = 0 ; j < dim ; j++) + { + base.setLow(j,(long int)start.get(j) - (long int)gdb_ext.get(i).origin.get(j)); + base.setHigh(j,(long int)stop.get(j) - (long int)gdb_ext.get(i).origin.get(j)); + } + + Box<dim,long int> dom = gdb_ext.get(i).Dbox; + + bool overlap = dom.Intersect(base,inte); + + if (overlap == true) + { + loc_grid.get(i).template conv2_b<prop_src1,prop_src2,prop_dst1,prop_dst2,stencil_size>(inte.getKP1(),inte.getKP2(),func,args...); + } + } + } + template<typename NNtype> void findNeighbours() { @@ -3318,6 +3402,9 @@ using grid_dist_id_devg = grid_dist_id<dim,St,T,Decomposition,Memory,devg>; template<unsigned int dim, typename St, typename T, typename Memory = CudaMemory, typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_inte> > using sgrid_dist_id_gpu = grid_dist_id<dim,St,T,Decomposition,Memory,SparseGridGpu<dim,T>>; +template<unsigned int dim, typename St, typename T, typename Memory = CudaMemory, typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_inte> > +using grid_dist_id_gpu = grid_dist_id<dim,St,T,Decomposition,Memory,grid_gpu<dim,T>>; + template<unsigned int dim, typename St, typename T, typename Memory = CudaMemory, typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_inte> > using sgrid_dist_sid_gpu = grid_dist_id<dim,St,T,Decomposition,Memory,SparseGridGpu<dim,T,default_edge<dim>::type::value,default_edge<dim>::tb::value,int>>; #endif diff --git a/src/Grid/grid_dist_id_comm.hpp b/src/Grid/grid_dist_id_comm.hpp index 5508aa8f1d5fc4ad356f6a01b989f4d72a824a61..d9312ef5ea5bdeefb1c1c7b5a7df7731d9d8854b 100644 --- a/src/Grid/grid_dist_id_comm.hpp +++ b/src/Grid/grid_dist_id_comm.hpp @@ -1535,7 +1535,7 @@ public: std::vector<size_t> prp_recv; // Create an object of preallocated memory for properties - ExtPreAlloc<Memory> & prRecv_prp = *(new ExtPreAlloc<Memory>(tot_recv,g_recv_prp_mem)); + ExtPreAlloc<Memory> & prRecv_prp = *(new ExtPreAlloc<Memory>(0,g_recv_prp_mem)); prRecv_prp.incRef(); queue_recv_data_put<prp_object>(ig_box,prp_recv,prRecv_prp); diff --git a/src/Grid/performance/grid_dist_performance.hpp b/src/Grid/performance/grid_dist_performance.hpp index 368c2b9b21e0297ca58a166ed9d3972539f8af33..fedeca0a7827ce21e9146256533141c57b30ca7f 100644 --- a/src/Grid/performance/grid_dist_performance.hpp +++ b/src/Grid/performance/grid_dist_performance.hpp @@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE(grid_iterator_performance_write_report_final) if (create_vcluster().getProcessUnitID() == 0) { - addUpdtateTime(cg,create_vcluster().size()); + addUpdateTime(cg,create_vcluster().size(),"pdata","grid_performance"); cg.write("grid_performance.html"); } diff --git a/src/Grid/tests/grid_dist_id_unit_test.cpp b/src/Grid/tests/grid_dist_id_unit_test.cpp index a13d79a3494da2fc565349fc14c921441bbbf807..d34a1201ad0a8b31a235900edf9c3204933b124e 100644 --- a/src/Grid/tests/grid_dist_id_unit_test.cpp +++ b/src/Grid/tests/grid_dist_id_unit_test.cpp @@ -189,7 +189,8 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test) Box<2,size_t> g_box = g_dist.getCellDecomposer().convertDomainSpaceIntoGridUnits(sub,bc); - vol += g_box.getVolumeKey(); + if (g_box.isValid() == true) + {vol += g_box.getVolumeKey();} } v_cl.sum(vol); diff --git a/src/Grid/tests/grid_dist_id_unit_test.cu b/src/Grid/tests/grid_dist_id_unit_test.cu new file mode 100644 index 0000000000000000000000000000000000000000..01770490120f6cd8986b253533fb357a3898c35a --- /dev/null +++ b/src/Grid/tests/grid_dist_id_unit_test.cu @@ -0,0 +1,57 @@ +#define BOOST_TEST_DYN_LINK +#include <boost/test/unit_test.hpp> + +#include "Point_test.hpp" +#include "Grid/grid_dist_id.hpp" +#include "data_type/aggregate.hpp" + +extern void print_test_v(std::string test, size_t sz); + +BOOST_AUTO_TEST_SUITE( grid_dist_id_test ) + + +BOOST_AUTO_TEST_CASE( grid_dist_id_gpu_test ) +{ + // Test grid periodic + +/* Box<3,float> domain({-1.0,-1.0,-1.0},{1.0,1.0,1.0}); + + Vcluster<> & v_cl = create_vcluster(); + + if ( v_cl.getProcessingUnits() > 32 ) + {return;} + + // grid size + size_t sz[3]; + sz[0] = 32; + sz[1] = 32; + sz[2] = 32; + + // Ghost + Ghost<3,long int> g(1); + + // periodicity + periodicity<3> pr = {{PERIODIC,PERIODIC,PERIODIC}}; + + // Distributed grid with id decomposition + grid_dist_id_gpu<3, float, aggregate<float, float>> g_dist(sz,domain,g,pr); + + Box<3,size_t> box({1,1,1},{30,30,30}); + auto it = g_dist.getGridIterator(box.getKP1(),box.getKP2()); + + float c = 5.0; + + typedef typename GetSetBlockType<decltype(g_dist)>::type BlockT; + + g_dist.setPoints(box.getKP1(),box.getKP2(), + [c] __device__ (BlockT & data, int i, int j, int k) + { + data.template get<0>() = c + i*i + j*j + k*k; + } + ); + */ + +} + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/Grid/tests/sgrid_dist_id_gpu_unit_tests.cu b/src/Grid/tests/sgrid_dist_id_gpu_unit_tests.cu index e26743dfb8c54d8b0e91ae85fc3c4fe67d5fa636..4bc3e8841be21b95d2c4d911177e13074620889e 100644 --- a/src/Grid/tests/sgrid_dist_id_gpu_unit_tests.cu +++ b/src/Grid/tests/sgrid_dist_id_gpu_unit_tests.cu @@ -300,6 +300,69 @@ BOOST_AUTO_TEST_CASE( sgrid_gpu_test_ghost_get ) sgrid_ghost_get(sz2,sz4); } +BOOST_AUTO_TEST_CASE( sgrid_gpu_app_point_test_no_box ) +{ + size_t sz[3] = {75,75,75}; + periodicity<3> bc = {PERIODIC,PERIODIC,PERIODIC}; + + Ghost<3,long int> g(1); + + Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0}); + + sgrid_dist_id_gpu<3,float,aggregate<float,float,float,float>> gdist(sz,domain,g,bc); + + gdist.template setBackgroundValue<0>(666); + gdist.template setBackgroundValue<1>(666); + gdist.template setBackgroundValue<2>(666); + gdist.template setBackgroundValue<3>(666); + + /////// GPU insert + flush + + Box<3,size_t> box({1,1,1},{sz[0],sz[1],sz[2]}); + + /////// GPU Run kernel + + float c = 5.0; + + typedef typename GetAddBlockType<decltype(gdist)>::type InsertBlockT; + + CudaMemory cmem; + cmem.allocate(sizeof(int)); + + *(int *)cmem.getPointer() = 0.0; + + cmem.hostToDevice(); + + int * cnt = (int *)cmem.getDevicePointer(); + + gdist.addPoints([cnt] __device__ (int i, int j, int k) + { + atomicAdd(cnt,1); + + return true; + }, + [c] __device__ (InsertBlockT & data, int i, int j, int k) + { + data.template get<0>() = c + i + j; + data.template get<1>() = c + 1000 + i + j; + } + ); + + gdist.template flush<smax_<0>,smax_<1>>(flush_type::FLUSH_ON_DEVICE); + gdist.template ghost_get<0,1>(RUN_ON_DEVICE); + + cmem.deviceToHost(); + + int cnt_host = *(int *)cmem.getPointer(); + + auto & v_cl = create_vcluster(); + + v_cl.sum(cnt_host); + v_cl.execute(); + + BOOST_REQUIRE_EQUAL(cnt_host,75*75*75); +} + BOOST_AUTO_TEST_CASE( sgrid_gpu_app_point_test ) { @@ -352,7 +415,6 @@ BOOST_AUTO_TEST_CASE( sgrid_gpu_app_point_test ) {atomicAdd(cnt,1);} else { - printf("%d %d %d \n",i,j,k); atomicAdd(cnt_out,1); } @@ -569,6 +631,198 @@ BOOST_AUTO_TEST_CASE( sgrid_gpu_test_conv2_test_3d ) BOOST_REQUIRE_EQUAL(match,true); } +BOOST_AUTO_TEST_CASE( sgrid_gpu_test_conv_cross_block_test_3d ) +{ + #ifdef CUDA_ON_CPU + size_t sz[3] = {20,20,20}; + #else + size_t sz[3] = {60,60,60}; + #endif + periodicity<3> bc = {PERIODIC,PERIODIC,PERIODIC}; + + Ghost<3,long int> g(1); + + Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0}); + + sgrid_dist_id_gpu<3,float,aggregate<float,float,float,float>> gdist(sz,domain,g,bc); + + gdist.template setBackgroundValue<0>(666); + gdist.template setBackgroundValue<1>(666); + gdist.template setBackgroundValue<2>(666); + gdist.template setBackgroundValue<3>(666); + + /////// GPU insert + flush + + Box<3,size_t> box({1,1,1},{sz[0]-1,sz[1]-1,sz[2]-1}); + + /////// GPU Run kernel + + float c = 5.0; + + typedef typename GetAddBlockType<decltype(gdist)>::type InsertBlockT; + + gdist.addPoints(box.getKP1(),box.getKP2(), + [] __device__ (int i, int j, int k) + { + return true; + }, + [c] __device__ (InsertBlockT & data, int i, int j, int k) + { + data.template get<0>() = c + i + j + k; + data.template get<1>() = c + 1000 + i + j + k; + } + ); + + gdist.template flush<smax_<0>,smax_<1>>(flush_type::FLUSH_ON_DEVICE); + + gdist.template ghost_get<0,1>(RUN_ON_DEVICE); + + for (int i = 0 ; i < 10 ; i++) + { + gdist.template ghost_get<0,1>(RUN_ON_DEVICE); + } + + // Now run the convolution + + typedef typename GetCpBlockType<decltype(gdist),0,1>::type CpBlockType; + + gdist.template conv_cross_b<0,1,1>({2,2,2},{(int)sz[0]-2,(int)sz[1]-2,(int)sz[2]-2},[] __device__ (CpBlockType & u, auto & block, int offset,int i, int j, int k){ + return u(i+1,j,k) - u(i-1,j,k) + u(i,j+1,k) - u(i,j-1,k) + u(i,j,k+1) - u(i,j,k-1) + block.template get<0>()[offset]; + }); + + gdist.deviceToHost<0,1,2,3>(); + + // Now we check that ghost is correct + + auto it3 = gdist.getSubDomainIterator({2,2,2},{(int)sz[0]-2,(int)sz[1]-2,(int)sz[2]-2}); + + bool match = true; + + while (it3.isNext()) + { + auto p = it3.get(); + + auto p_xp1 = p.move(0,1); + auto p_xm1 = p.move(0,-1); + auto p_yp1 = p.move(1,1); + auto p_ym1 = p.move(1,-1); + auto p_zp1 = p.move(2,1); + auto p_zm1 = p.move(2,-1); + + float sub1 = gdist.template get<1>(p); + + if (sub1 != 6.0 + gdist.template get<0>(p)) + { + std::cout << sub1 << std::endl; + std::cout << gdist.template get<0>(p_xp1) << " " << gdist.template get<0>(p_xm1) << std::endl; + std::cout << gdist.template get<1>(p_xp1) << " " << gdist.template get<1>(p_xm1) << std::endl; + match = false; + break; + } + + ++it3; + } + + BOOST_REQUIRE_EQUAL(match,true); +} + +BOOST_AUTO_TEST_CASE( sgrid_gpu_test_conv2_b_test_3d ) +{ + #ifdef CUDA_ON_CPU + size_t sz[3] = {20,20,20}; + #else + size_t sz[3] = {60,60,60}; + #endif + periodicity<3> bc = {PERIODIC,PERIODIC,PERIODIC}; + + Ghost<3,long int> g(1); + + Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0}); + + sgrid_dist_id_gpu<3,float,aggregate<float,float,float,float>> gdist(sz,domain,g,bc); + + gdist.template setBackgroundValue<0>(666); + gdist.template setBackgroundValue<1>(666); + gdist.template setBackgroundValue<2>(666); + gdist.template setBackgroundValue<3>(666); + + /////// GPU insert + flush + + Box<3,size_t> box({1,1,1},{sz[0]-1,sz[1]-1,sz[2]-1}); + + /////// GPU Run kernel + + float c = 5.0; + + typedef typename GetAddBlockType<decltype(gdist)>::type InsertBlockT; + + gdist.addPoints(box.getKP1(),box.getKP2(), + [] __device__ (int i, int j, int k) + { + return true; + }, + [c] __device__ (InsertBlockT & data, int i, int j, int k) + { + data.template get<0>() = c + i + j + k; + data.template get<1>() = c + 1000 + i + j + k; + } + ); + + gdist.template flush<smax_<0>,smax_<1>>(flush_type::FLUSH_ON_DEVICE); + + gdist.template ghost_get<0,1>(RUN_ON_DEVICE); + + for (int i = 0 ; i < 10 ; i++) + { + gdist.template ghost_get<0,1>(RUN_ON_DEVICE); + } + + // Now run the convolution + + typedef typename GetCpBlockType<decltype(gdist),0,1>::type CpBlockType; + + gdist.template conv2_b<0,1,2,3,1>({2,2,2},{(int)sz[0]-2,(int)sz[1]-2,(int)sz[2]-2},[] __device__ (float & u_out, float & v_out, CpBlockType & u, CpBlockType & v, auto & block, int offset,int i, int j, int k){ + u_out = u(i+1,j,k) - u(i-1,j,k) + u(i,j+1,k) - u(i,j-1,k) + u(i,j,k+1) - u(i,j,k-1) + block.template get<0>()[offset]; + v_out = v(i+1,j,k) - v(i-1,j,k) + v(i,j+1,k) - v(i,j-1,k) + v(i,j,k+1) - v(i,j,k-1) + block.template get<1>()[offset]; + }); + + gdist.deviceToHost<0,1,2,3>(); + + // Now we check that ghost is correct + + auto it3 = gdist.getSubDomainIterator({2,2,2},{(int)sz[0]-2,(int)sz[1]-2,(int)sz[2]-2}); + + bool match = true; + + while (it3.isNext()) + { + auto p = it3.get(); + + auto p_xp1 = p.move(0,1); + auto p_xm1 = p.move(0,-1); + auto p_yp1 = p.move(1,1); + auto p_ym1 = p.move(1,-1); + auto p_zp1 = p.move(2,1); + auto p_zm1 = p.move(2,-1); + + float sub1 = gdist.template get<2>(p) ; + float sub2 = gdist.template get<3>(p); + + if (sub1 != 6.0 + gdist.template get<0>(p) || sub2 != 6.0 + gdist.template get<1>(p)) + { + std::cout << sub1 << " " << sub2 << std::endl; + std::cout << gdist.template get<0>(p_xp1) << " " << gdist.template get<0>(p_xm1) << std::endl; + std::cout << gdist.template get<1>(p_xp1) << " " << gdist.template get<1>(p_xm1) << std::endl; + match = false; + break; + } + + ++it3; + } + + BOOST_REQUIRE_EQUAL(match,true); +} + BOOST_AUTO_TEST_CASE( sgrid_gpu_test_ghost_point_remove ) { size_t sz[3] = {60,60,60}; diff --git a/src/Vector/cuda/vector_dist_gpu_unit_tests.cu b/src/Vector/cuda/vector_dist_gpu_unit_tests.cu index c8fcec4e295126ecc66e0f7c06a8fe537e68b3ca..9380e1e72cc5c1ca6b32525735cc374f0d623af7 100644 --- a/src/Vector/cuda/vector_dist_gpu_unit_tests.cu +++ b/src/Vector/cuda/vector_dist_gpu_unit_tests.cu @@ -1234,7 +1234,7 @@ void vector_dist_dlb_on_cuda_impl_async(size_t k,double r_cut) ++it; } - //Back to GPU + // Back to GPU vd.hostToDevicePos(); vd.map(RUN_ON_DEVICE); vd.template Ighost_get<0>(RUN_ON_DEVICE); diff --git a/src/Vector/performance/cell_list_comp_reorder.hpp b/src/Vector/performance/cell_list_comp_reorder.hpp index b0b01d3ff614fb7a8b5c0dcc14135a2d05bd4244..07aeee73f706a9282f643409fe94b59ccee95a0a 100644 --- a/src/Vector/performance/cell_list_comp_reorder.hpp +++ b/src/Vector/performance/cell_list_comp_reorder.hpp @@ -357,7 +357,9 @@ BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report) StandardXMLPerformanceGraph("celllist_performance.xml",file_xml_ref,cg); - addUpdtateTime(cg,create_vcluster().size()); + addUpdateTime(cg,create_vcluster().size(),"pdata","celllist_performance"); + + createCommitFile("pdata"); cg.write("celllist_performance.html"); } diff --git a/src/Vector/performance/cell_list_part_reorder.hpp b/src/Vector/performance/cell_list_part_reorder.hpp index c31c5c3f896582dcf6d56e72294f2c2104fe013f..a81bc6246864779d40269e77822e232dfcda0acb 100644 --- a/src/Vector/performance/cell_list_part_reorder.hpp +++ b/src/Vector/performance/cell_list_part_reorder.hpp @@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(vector_dist_cl_performance_write_report) StandardXMLPerformanceGraph("celllist_partreo_performance.xml",file_xml_ref,cg); - addUpdtateTime(cg,create_vcluster().size()); + addUpdateTime(cg,create_vcluster().size(),"pdata","celllist_part_ord"); if (create_vcluster().getProcessUnitID() == 0) {cg.write("celllist_part_ord.html");} diff --git a/src/Vector/performance/vector_dist_gg_map_performance.hpp b/src/Vector/performance/vector_dist_gg_map_performance.hpp index a75ba1b14c3ffb9feb880404dbea641e9317a1a4..e4d7f326a3453fd48bc1c5375ae6b96caff614ef 100644 --- a/src/Vector/performance/vector_dist_gg_map_performance.hpp +++ b/src/Vector/performance/vector_dist_gg_map_performance.hpp @@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(vector_dist_gg_map_performance_write_report) StandardXMLPerformanceGraph("particles_map_performance.xml",file_xml_ref,cg); - addUpdtateTime(cg,create_vcluster().size()); + addUpdateTime(cg,create_vcluster().size(),"pdata","particles_map_performance"); if (create_vcluster().getProcessUnitID() == 0) {cg.write("particles_map_performance.html");} diff --git a/src/Vector/performance/verlet_performance_tests.hpp b/src/Vector/performance/verlet_performance_tests.hpp index 97058e3418a41296498e09126104e5b2b42831f1..e88875af0791716cfd040e4ec2ac979a2c5936fd 100644 --- a/src/Vector/performance/verlet_performance_tests.hpp +++ b/src/Vector/performance/verlet_performance_tests.hpp @@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(vector_dist_verlet_performance_write_report) StandardXMLPerformanceGraph("verletlist_performance.xml",file_xml_ref,cg); - addUpdtateTime(cg,create_vcluster().size()); + addUpdateTime(cg,create_vcluster().size(),"pdata","verletlist_performance"); if (create_vcluster().getProcessUnitID() == 0) {cg.write("verletlist_performance.html");} diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp index a30f4b7c07cba3aece773bf2476d1daa794fd1a1..4cf572a70d4c996ec091c6c7cf735401c54b7b94 100644 --- a/src/Vector/vector_dist.hpp +++ b/src/Vector/vector_dist.hpp @@ -260,7 +260,9 @@ template<unsigned int dim, typename prop, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory, - template<typename> class layout_base = memory_traits_lin> + template<typename> class layout_base = memory_traits_lin, + typename vector_dist_pos = openfpm::vector<Point<dim, St>,Memory,layout_base>, + typename vector_dist_prop = openfpm::vector<prop,Memory,layout_base> > class vector_dist : public vector_dist_comm<dim,St,prop,Decomposition,Memory,layout_base>, #ifdef CUDA_GPU private vector_dist_ker_list<vector_dist_ker<dim,St,prop,layout_base>> @@ -281,17 +283,17 @@ private: //! Particle position vector, (It has 2 elements) the first has real particles assigned to a processor //! the second element contain unassigned particles - openfpm::vector<Point<dim, St>,Memory,layout_base> v_pos; + vector_dist_pos v_pos; //! Particle properties vector, (It has 2 elements) the first has real particles assigned to a processor //! the second element contain unassigned particles - openfpm::vector<prop,Memory,layout_base> v_prp; + vector_dist_prop v_prp; //! reordered v_pos buffer - openfpm::vector<prop,Memory,layout_base> v_prp_out; + vector_dist_prop v_prp_out; //! reordered v_prp buffer - openfpm::vector<Point<dim, St>,Memory,layout_base> v_pos_out; + vector_dist_pos v_pos_out; //! option used to create this vector size_t opt = 0; @@ -2529,6 +2531,22 @@ public: g_m -= keys.size(); } + /*! \brief Remove a set of elements from the distributed vector + * + * \warning keys must be sorted + * + * \param keys vector of elements to eliminate + * \param start from where to eliminate + * + */ + void remove(openfpm::vector<aggregate<int>> & keys, size_t start = 0) + { + v_pos.remove(keys, start); + v_prp.remove(keys, start); + + g_m -= keys.size(); + } + /*! \brief Remove one element from the distributed vector * * \param key remove one element from the vector @@ -2688,8 +2706,8 @@ public: if ((opt & 0x0FFF0000) == CSV_WRITER) { // CSVWriter test - CSVWriter<openfpm::vector<Point<dim, St>,Memory,layout_base>, - openfpm::vector<prop,Memory,layout_base> > csv_writer; + CSVWriter<vector_dist_pos, + vector_dist_prop > csv_writer; std::string output = std::to_string(out + "_" + std::to_string(v_cl.getProcessUnitID()) + std::to_string(".csv")); @@ -2704,8 +2722,8 @@ public: ft = file_type::BINARY; // VTKWriter for a set of points - VTKWriter<boost::mpl::pair<openfpm::vector<Point<dim, St>,Memory,layout_base>, - openfpm::vector<prop,Memory,layout_base>>, + VTKWriter<boost::mpl::pair<vector_dist_pos, + vector_dist_prop>, VECTOR_POINTS> vtk_writer; vtk_writer.add(v_pos,v_prp,g_m); @@ -2784,8 +2802,8 @@ public: if ((opt & 0x0FFF0000) == CSV_WRITER) { // CSVWriter test - CSVWriter<openfpm::vector<Point<dim, St>,Memory,layout_base>, - openfpm::vector<prop,Memory,layout_base> > csv_writer; + CSVWriter<vector_dist_pos, + vector_dist_prop > csv_writer; std::string output = std::to_string(out + "_" + std::to_string(v_cl.getProcessUnitID()) + "_" + std::to_string(iteration) + std::to_string(".csv")); @@ -2800,8 +2818,8 @@ public: ft = file_type::BINARY; // VTKWriter for a set of points - VTKWriter<boost::mpl::pair<openfpm::vector<Point<dim, St>,Memory,layout_base>, - openfpm::vector<prop,Memory,layout_base>>, VECTOR_POINTS> vtk_writer; + VTKWriter<boost::mpl::pair<vector_dist_pos, + vector_dist_prop>, VECTOR_POINTS> vtk_writer; vtk_writer.add(v_pos,v_prp,g_m); std::string output = std::to_string(out + "_" + std::to_string(v_cl.getProcessUnitID()) + "_" + std::to_string(iteration) + std::to_string(".vtp")); @@ -2873,7 +2891,7 @@ public: * \return the particle position vector * */ - const openfpm::vector<Point<dim, St>,Memory,layout_base> & getPosVector() const + const vector_dist_pos & getPosVector() const { return v_pos; } @@ -2883,7 +2901,7 @@ public: * \return the particle position vector * */ - openfpm::vector<Point<dim, St>,Memory,layout_base> & getPosVector() + vector_dist_pos & getPosVector() { return v_pos; } @@ -2893,7 +2911,7 @@ public: * \return the particle property vector * */ - const openfpm::vector<prop,Memory,layout_base> & getPropVector() const + const vector_dist_prop & getPropVector() const { return v_prp; } @@ -2903,7 +2921,7 @@ public: * \return the particle property vector * */ - openfpm::vector<prop,Memory,layout_base> & getPropVector() + vector_dist_prop & getPropVector() { return v_prp; } @@ -2913,7 +2931,7 @@ public: * \return the particle position vector * */ - const openfpm::vector<Point<dim, St>,Memory,layout_base> & getPosVectorSort() const + const vector_dist_pos & getPosVectorSort() const { return v_pos_out; } @@ -2923,7 +2941,7 @@ public: * \return the particle position vector * */ - openfpm::vector<Point<dim, St>,Memory,layout_base> & getPosVectorSort() + vector_dist_pos & getPosVectorSort() { return v_pos_out; } @@ -2933,7 +2951,7 @@ public: * \return the particle property vector * */ - const openfpm::vector<prop,Memory,layout_base> & getPropVectorSort() const + const vector_dist_prop & getPropVectorSort() const { return v_prp_out; } @@ -2943,7 +2961,7 @@ public: * \return the particle property vector * */ - openfpm::vector<prop,Memory,layout_base> & getPropVectorSort() + vector_dist_prop & getPropVectorSort() { return v_prp_out; } diff --git a/src/lib/pdata_python.cpp b/src/lib/pdata_python.cpp new file mode 100644 index 0000000000000000000000000000000000000000..03710408b3097419999e51ab75695a25218b24f6 --- /dev/null +++ b/src/lib/pdata_python.cpp @@ -0,0 +1,7 @@ + +void init_openfpm_python() +{ +} + + + diff --git a/src/scripts/postinst b/src/scripts/postinst index 763d3ed561a4529800f9222de37392223c86c1b1..f11b3ca9b487dc465991be39a7e9af67b48e813a 100644 --- a/src/scripts/postinst +++ b/src/scripts/postinst @@ -4,6 +4,5 @@ sed -i -e 's/projects\/ppm\/rundeck\/openfpm_super_bundles\/$1\/openfpm_dep_$1/usr\/local\/openfpm\/dependencies/g' /usr/local/openfpm/source/openfpm_vars sed -i -e 's/projects\/ppm\/rundeck\/openfpm_super_bundles\/$1\/openfpm_dep_$1/usr\/local\/openfpm\/dependencies/g' /usr/local/openfpm/openfpm_pdata/include/example.mk -echo "export OPAL_PREFIX=/usr/local/openfpm/dependencies/MPI" >> /usr/local/openfpm/source/openfpm_vars - +echo "export OPAL_PREFIX=/usr/local/openfpm/dependencies/MPI" >> /usr/local/openfpm/source/openfpm_vars diff --git a/src/test_multiple_o.cpp b/src/test_multiple_o.cpp deleted file mode 100644 index 5e45e1d284739bb0f6820b12744ba2de72cd08a2..0000000000000000000000000000000000000000 --- a/src/test_multiple_o.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * test_multiple_o.cpp - * - * Created on: Feb 5, 2016 - * Author: i-bird - * - * - * It just test that the compilation with multiple translation unit (*.o) does not - * produce error, if we have duplicated symbol in the translation unit we will get error - * - */ - -#include "Vector/vector_dist.hpp" -#include "Grid/grid_dist_id.hpp" -#include "data_type/aggregate.hpp" -#include "Decomposition/CartDecomposition.hpp" - -void f() -{ - // Ghost - Ghost<3,float> g(0.01); - - size_t bc[3]={PERIODIC,PERIODIC,PERIODIC}; - - Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0}); - size_t sz[3]; - sz[0] = 100; - sz[1] = 100; - sz[2] = 100; - - vector_dist<3,float, aggregate<float>, CartDecomposition<3,float> > vd(4096,domain,bc,g); - grid_dist_id<3, float, aggregate<float[3]>, CartDecomposition<3,float>> g_dist(sz,domain,g); -} - -