Commit 4e9909f5 by Pietro Incardona

parent 3b97c87c
 ... ... @@ -4,6 +4,9 @@ * \subpage Vector_1_celllist * \subpage Vector_2_expression * \subpage Vector_3_md * \subpage Vector_4_reo * \subpage Vector_4_comp_reo * \subpage Vector_4_complex_prop * */ ... ... @@ -179,10 +182,10 @@ int main(int argc, char* argv[]) auto key = it.get(); // we define x, assign a random position between 0.0 and 1.0 vd.getPos(key)[0] = rand() / RAND_MAX; vd.getPos(key)[0] = (float)rand() / RAND_MAX; // we define y, assign a random position between 0.0 and 1.0 vd.getPos(key)[1] = rand() / RAND_MAX; vd.getPos(key)[1] = (float)rand() / RAND_MAX; // next particle ++it; ... ...
 ... ... @@ -306,9 +306,6 @@ int main(int argc, char* argv[]) //! \cond [verletlist] \endcond openfpm::vector> verlet; // interaction radius float r_cut = 1.0/(128-2); vd.getVerlet(verlet,r_cut); // For each particle i verlet.size() == Number of particles ... ... @@ -324,8 +321,10 @@ int main(int argc, char* argv[]) // for each neighborhood j of particle to i for (size_t j = 0 ; j < NN.size() ; j++) { size_t p = NN.get(j); // Get the position of the particle neighborhood if i Point<3,float> xq = vd.getPos(NN.get(j)); Point<3,float> xq = vd.getPos(p); // Calculate the distance vector between p and q Point<3,float> f = (xp - xq); ... ...
 ... ... @@ -33,7 +33,7 @@ constexpr int force = 1; * * \page Vector_3_md Vector 3 molecular dynamic * * ## Calculate forces ## * ## Calculate forces ## {#e3_md_cf} * * In this function we calculate the forces between particles. It require the vector of particles * Cell list and scaling factor for the Lennard-Jhones potential. ... ... @@ -154,7 +154,7 @@ void calc_forces(vector_dist<3,double, aggregate > & vd, Ce /*! * \page Vector_3_md Vector 3 molecular dynamic * * ## Calculate energy ## * ## Calculate energy ## {#e3_md_ce} * * We also need a function to calculate energy, this function require the same parameter as calculate forces * ... ... @@ -272,7 +272,7 @@ int main(int argc, char* argv[]) /*! * \page Vector_3_md Vector 3 molecular dynamic * * ## Initialization ## * ## Initialization ## {#e3_md_init} * * After we defined the two main function calc forces and calc energy, we define * important parameters of the simulation, time step integration, ... ... @@ -347,7 +347,7 @@ int main(int argc, char* argv[]) /*! * \page Vector_3_md Vector 3 molecular dynamic * * ## Particles on a grid like position ## * ## Particles on a grid like position ## {#e3_md_gl} * * We define a grid iterator, to create particles on a grid like way. In the same cycle we also reset * force and velocity ... ... @@ -388,7 +388,7 @@ int main(int argc, char* argv[]) /*! * \page Vector_3_md Vector 3 molecular dynamic * * ## Molecular dynamic steps ## * ## Molecular dynamic steps ## {#e3_md_vi} * * Here we do 10000 MD steps using verlet integrator * ... ... @@ -509,7 +509,7 @@ int main(int argc, char* argv[]) /*! * \page Vector_3_md Vector 3 molecular dynamic * * ## Plotting graphs ## * ## Plotting graphs ## {#e3_md_pg} * * After we terminate the MD steps our vector x contains at which iteration we calculated the energy * while y contains the energy value at that time-step. We can produce a graph X Y ... ...
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
openfpm_data @ e2d9725f
 Subproject commit 24469b20034a8513d205e46db2aa058b824725be Subproject commit e2d9725f7101cf273213f69a6f91655c9112c17a
openfpm_devices @ 95ed584d
 Subproject commit 36227626f5a6020d8f4ecd7d26a9261b37e9101b Subproject commit 95ed584d33c976f3e13568ec8fd9c391de95db07
 ... ... @@ -455,7 +455,7 @@ public: proc_int_box = ie.proc_int_box; vb_ext = ie.vb_ext; vb_int = ie.vb_int; geo_cell = geo_cell; geo_cell = ie.geo_cell; shifts = ie.shifts; ids_p = ie.ids_p; ids = ie.ids; ... ...
 ... ... @@ -135,6 +135,8 @@ class grid_dist_id /*! \brief flip box just convert and internal ghost box into an external ghost box * * \param box to convert * \param cmb sector position of the box * */ Box flip_box(const Box & box, const comb & cmb) ... ...
 ... ... @@ -208,6 +208,18 @@ class grid_dist_iterator return start; } /*! \brief Get the boxes * * Get the boxes that define the local grids * * \return Vector of local boxes * */ inline const openfpm::vector> & getGBoxes() { return gdb_ext; } }; ... ... @@ -333,6 +345,18 @@ class grid_dist_iterator { return grid_dist_key_dx(g_c,a_it.get()); } /*! \brief Get the boxes * * Get the boxes that define the local grids * * \return Vector of local boxes * */ inline const openfpm::vector> & getGBoxes() { return gdb_ext; } }; #endif /* GRID_DIST_ID_ITERATOR_SUB_HPP_ */
 ... ... @@ -1451,6 +1451,9 @@ void Test3D_periodic(const Box<3,float> & domain, long int k) auto key = dom_gi.get(); auto key_g = g_dist.getGKey(key); // Return the external boxes auto & gb = dom_gi.getGBoxes(); // transform the key to be periodic for (size_t i = 0 ; i < 3 ; i++) { ... ... @@ -1463,8 +1466,25 @@ void Test3D_periodic(const Box<3,float> & domain, long int k) if (g_dist.template get<0>(key) != -1 && out_p == true) out_cnt++; if ( g_dist.template get<0>(key) != -1 && info.LinId(key_g) != g_dist.template get<0>(key) ) match &= false; // The last points can be invalid because of rounding off problems bool can_invalid = false; if (key.getKey().get(0) == 0 || key.getKey().get(1) == 0 || key.getKey().get(2) == 0) can_invalid = true; else if (key.getKey().get(0) == gb.get(key.getSub()).GDbox.getHigh(0) || key.getKey().get(1) == gb.get(key.getSub()).GDbox.getHigh(1) || key.getKey().get(2) == gb.get(key.getSub()).GDbox.getHigh(2)) can_invalid = true; if (can_invalid == true) { if ( g_dist.template get<0>(key) != -1 && info.LinId(key_g) != g_dist.template get<0>(key) ) match &= false; } else { if (info.LinId(key_g) != g_dist.template get<0>(key) ) match &= false; } ++dom_gi; } ... ...
 ... ... @@ -5,7 +5,7 @@ pdata_SOURCES = main.cpp Grid/grid_dist_id_unit_test.cpp lib/pdata.cpp test_mul pdata_CXXFLAGS = \$(LIBHILBERT_INCLUDE) \$(PETSC_INCLUDE) \$(HDF5_CPPFLAGS) \$(CUDA_CFLAGS) \$(INCLUDES_PATH) \$(PARMETIS_INCLUDE) \$(METIS_INCLUDE) \$(BOOST_CPPFLAGS) \$(H5PART_INCLUDE) -DPARALLEL_IO -Wno-unused-local-typedefs pdata_CFLAGS = \$(CUDA_CFLAGS) pdata_LDADD = \$(LINKLIBS) -lparmetis -lmetis nobase_include_HEADERS = Decomposition/CartDecomposition.hpp Decomposition/common.hpp Decomposition/Decomposition.hpp Decomposition/ie_ghost.hpp \ nobase_include_HEADERS = Decomposition/CartDecomposition.hpp Decomposition/CartDecomposition_ext.hpp Decomposition/common.hpp Decomposition/Decomposition.hpp Decomposition/ie_ghost.hpp \ Decomposition/nn_processor.hpp Decomposition/ie_loc_ghost.hpp Decomposition/ORB.hpp \ Graph/CartesianGraphFactory.hpp \ Grid/grid_dist_id.hpp Grid/grid_dist_id_iterator_dec.hpp Grid/grid_dist_util.hpp Grid/grid_dist_id_iterator_sub.hpp Grid/grid_dist_id_iterator.hpp Grid/grid_dist_key.hpp Grid/staggered_dist_grid.hpp Grid/staggered_dist_grid_util.hpp Grid/staggered_dist_grid_copy.hpp \ ... ...
 ... ... @@ -795,29 +795,13 @@ private: return pbox; } public: //! space type typedef St stype; //! dimensions of space static const unsigned int dims = dim; /*! \brief Constructor /*! \brief Initialize the structures * * \param np number of elements * \param box domain where the vector of elements live * \param boundary conditions * \param g Ghost margins * \param np number of particles * */ vector_dist(size_t np, Box box, const size_t (&bc)[dim], const Ghost & g) : dec(create_vcluster()), v_cl(create_vcluster()) void init_structures(size_t np) { #ifdef SE_CLASS2 check_new(this,8,VECTOR_DIST_EVENT,4); #endif // convert to a local number of elements size_t p_np = np / v_cl.getProcessingUnits(); ... ... @@ -835,7 +819,17 @@ public: v_prp.resize(p_np); g_m = p_np; } /*! \brief Initialize the decomposition * * \param box domain * \param bc boundary conditions * \param g ghost extension * */ void init_decomposition(Box & box, const size_t (& bc)[dim],const Ghost & g) { // Create a valid decomposition of the space // Get the number of processor and calculate the number of sub-domain // for decomposition ... ... @@ -855,6 +849,53 @@ public: dec.decompose(); } public: //! space type typedef St stype; //! dimensions of space static const unsigned int dims = dim; /*! \brief Constructor * * \param np number of elements * \param box domain where the vector of elements live * \param boundary conditions * \param g Ghost margins * */ vector_dist(const Decomposition & dec, size_t np) : dec(dec), v_cl(create_vcluster()) { #ifdef SE_CLASS2 check_new(this,8,VECTOR_DIST_EVENT,4); #endif init_structures(np); } /*! \brief Constructor * * \param np number of elements * \param box domain where the vector of elements live * \param boundary conditions * \param g Ghost margins * */ vector_dist(size_t np, Box box, const size_t (&bc)[dim], const Ghost & g) : dec(create_vcluster()), v_cl(create_vcluster()) { #ifdef SE_CLASS2 check_new(this,8,VECTOR_DIST_EVENT,4); #endif init_structures(np); init_decomposition(box,bc,g); } ~vector_dist() { #ifdef SE_CLASS2 ... ... @@ -1296,7 +1337,7 @@ public: { // Get ghost and anlarge by 1% Ghost g = dec.getGhost(); g.magnify(1.01); g.magnify(1.013); return getCellList_hilb(r_cut, g); } ... ... @@ -1325,6 +1366,8 @@ public: ++it; } cell_list.set_gm(g_m); } /*! \brief Construct a cell list starting from the stored particles ... ...
 ... ... @@ -155,6 +155,59 @@ template void calc_for } } /*! \brief For each particle of vd calculate the accumulation of the distances of the neighborhood * particles inside vd2 * * * \param NN Cell list vd * \param NN2 Cell list vd2 * \param vd Distributed vector * \param vd2 Distributed vector 2 * \param r_cut Cut-off radius * */ template void cross_calc(T & NN, T & NN2, V & vd, V & vd2) { auto it_v = vd.getDomainIterator(); float sum[dim]; for (size_t i = 0; i < dim; i++) sum[i] = 0; while (it_v.isNext()) { //key vect_dist_key_dx key = it_v.get(); // Get the position of the particles Point p = vd.getPos(key); // Get the neighborhood of the particle auto cell_it = NN2.template getNNIterator(NN2.getCell(p)); double sum = 0.0; while(cell_it.isNext()) { auto nnp = cell_it.get(); Point q = vd2.getPos(nnp); sum += norm(p - q); //Next particle in a cell ++cell_it; } vd.template getProp(key) = sum; //Next particle in cell list ++it_v; } } /*! \brief Benchmark particles' forces time * * \param NN Cell list ... ...
 ... ... @@ -431,6 +431,80 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_3d ) } } BOOST_AUTO_TEST_CASE( vector_dist_iterator_fixed_dec_3d ) { Vcluster & v_cl = create_vcluster(); // set the seed // create the random generator engine std::srand(v_cl.getProcessUnitID()); std::default_random_engine eg; std::uniform_real_distribution ud(0.0f, 1.0f); long int k = 52428 * v_cl.getProcessingUnits(); long int big_step = k / 4; big_step = (big_step == 0)?1:big_step; print_test_v( "Testing 3D vector copy decomposition k<=",k); // 3D test for ( ; k >= 2 ; k-= decrement(k,big_step) ) { BOOST_TEST_CHECKPOINT( "Testing 3D vector copy decomposition k=" << k ); Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0}); // Boundary conditions size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC}; vector_dist<3,float, aggregate > vd(k,box,bc,Ghost<3,float>(0.05)); vector_dist<3,float, aggregate > vd2(vd.getDecomposition(),k); auto it = vd.getIterator(); while (it.isNext()) { auto key = it.get(); vd.getPos(key)[0] = ud(eg); vd.getPos(key)[1] = ud(eg); vd.getPos(key)[2] = ud(eg); vd2.getPos(key)[0] = vd.getPos(key)[0]; vd2.getPos(key)[1] = vd.getPos(key)[1]; vd2.getPos(key)[2] = vd.getPos(key)[2]; ++it; } vd.map(); vd2.map(); vd.ghost_get(); vd2.ghost_get(); auto NN = vd.getCellList(0.05); auto NN2 = vd2.getCellList(0.05); cross_calc<3,0>(NN,NN2,vd,vd2); cross_calc<3,1>(NN,NN,vd,vd); auto it3 = vd.getIterator(); while (it3.isNext()) { auto key = it3.get(); BOOST_REQUIRE_EQUAL(vd.getProp<0>(key),vd.getProp<1>(key)); ++it3; } } } BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_use_2d ) { Vcluster & v_cl = create_vcluster(); ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!