Commit 5fdb12a6 authored by incardon's avatar incardon

Adding missing files

parent 0985040d
# Change Log
All notable changes to this project will be documented in this file.
## [0.6.0] - End October 2016
### Added
- Symmetric cell-list/verlet list
- Multi-phase cell-list and Multi-phase cell-list
- Added ghost_get that keep properties
- Examples: 1_ghost_get_put it show how to use ghost_get and put with the new options
4_multiphase_celllist_verlet completely rewritten for new Cell-list and multiphase verlet
5_molecular_dynamic use case of symmetric cell-list and verlet list with ghost put
6_complex_usage It show how the flexibility of openfpm can be used to debug your program
### Fixed
- Option NO_POSITION was untested
### Changes
## [0.5.1] - 27 September 2016
### Added
- ghost_put support for particles
- Full-Support for complex property on vector_dist (Serialization)
- Added examples for serialization of complex properties 4_Vector
- improved speed of the iterators
### Fixed
- Installation PETSC installation fail in case of preinstalled MPI
......@@ -131,17 +149,14 @@ All notable changes to this project will be documented in this file.
- Algebraic Multigrid solver
- Parallel VTK, improved visualization
- Asynchronous communication
## [0.6.0] - Middle of October
## [0.7.0] - December of October
### Added
- Asynchronous communication
- Symmetric Cell list and Verlet (15 days)
- Semantic communication (??)
- Improved Finite difference interface (15 days)
## [0.6.0] - Beginning of September
- Complex properties and serialization interface (15 days)
......@@ -348,7 +348,7 @@ int main(int argc, char* argv[])
*
* ## Finalize ## {#finalize_e0_sim}
*
* At the very end of the program we have always to de-initialize the library
* At the very end of the program we have always de-initialize the library
*
* \snippet Vector/0_simple/main.cpp finalize
*
......
......@@ -9,16 +9,16 @@ OBJ = main.o
%.o: %.cpp
$(CC) -fext-numeric-literals -O3 -g -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
cell: $(OBJ)
multip: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: cell
all: multip
run: all
source $$HOME/openfpm_vars; mpirun -np 2 ./cell
source $$HOME/openfpm_vars; mpirun -np 2 ./multip
.PHONY: clean all run
clean:
rm -f *.o *~ core cell
rm -f *.o *~ core multip
......@@ -66,11 +66,13 @@ struct vtk_write<ele,vtk,false>
template<typename T>
struct extends
{
//! number of elements
static inline size_t mul()
{
return 1;
}
//! number of indexes
static inline size_t dim()
{
return 0;
......@@ -81,11 +83,13 @@ struct extends
template<typename T,size_t N1>
struct extends<T[N1]>
{
//! number of elements
static inline size_t mul()
{
return N1;
}
//! number of indexes
static inline size_t dim()
{
return 1;
......@@ -96,11 +100,13 @@ struct extends<T[N1]>
template<typename T,size_t N1,size_t N2>
struct extends<T[N1][N2]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2;
}
//! number of indexes
static inline size_t dim()
{
return 2;
......@@ -111,11 +117,13 @@ struct extends<T[N1][N2]>
template<typename T,size_t N1,size_t N2,size_t N3>
struct extends<T[N1][N2][N3]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3;
}
//! number of indexes
static inline size_t dim()
{
return 3;
......@@ -126,11 +134,13 @@ struct extends<T[N1][N2][N3]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4>
struct extends<T[N1][N2][N3][N4]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4;
}
//! number of indexes
static inline size_t dim()
{
return 4;
......@@ -141,11 +151,13 @@ struct extends<T[N1][N2][N3][N4]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4,size_t N5>
struct extends<T[N1][N2][N3][N4][N5]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4 * N5;
}
//! number of indexes
static inline size_t dim()
{
return 5;
......@@ -156,11 +168,13 @@ struct extends<T[N1][N2][N3][N4][N5]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4,size_t N5, size_t N6>
struct extends<T[N1][N2][N3][N4][N5][N6]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4 * N5 * N6;
}
//! number of indexes
static inline size_t dim()
{
return 6;
......@@ -171,11 +185,13 @@ struct extends<T[N1][N2][N3][N4][N5][N6]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4,size_t N5, size_t N6, size_t N7>
struct extends<T[N1][N2][N3][N4][N5][N6][N7]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4 * N5 * N6 * N7;
}
//! number of indexes
static inline size_t dim()
{
return 7;
......@@ -186,11 +202,13 @@ struct extends<T[N1][N2][N3][N4][N5][N6][N7]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4,size_t N5, size_t N6, size_t N7, size_t N8>
struct extends<T[N1][N2][N3][N4][N5][N6][N7][N8]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4 * N5 * N6 * N7 * N8;
}
//! number of indexes
static inline size_t dim()
{
return 8;
......@@ -201,11 +219,13 @@ struct extends<T[N1][N2][N3][N4][N5][N6][N7][N8]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4,size_t N5, size_t N6, size_t N7, size_t N8, size_t N9>
struct extends<T[N1][N2][N3][N4][N5][N6][N7][N8][N9]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4 * N5 * N6 * N7 * N8 * N9;
}
//! number of indexes
static inline size_t dim()
{
return 9;
......@@ -216,11 +236,13 @@ struct extends<T[N1][N2][N3][N4][N5][N6][N7][N8][N9]>
template<typename T,size_t N1,size_t N2,size_t N3,size_t N4,size_t N5, size_t N6, size_t N7, size_t N8, size_t N9, size_t N10>
struct extends<T[N1][N2][N3][N4][N5][N6][N7][N8][N9][N10]>
{
//! number of elements
static inline size_t mul()
{
return N1 * N2 * N3 * N4 * N5 * N6 * N7 * N8 * N9 * N10;
}
//! number of indexes
static inline size_t dim()
{
return 10;
......
......@@ -9,7 +9,7 @@ nobase_include_HEADERS = Decomposition/CartDecomposition.hpp Decomposition/CartD
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 \
Vector/vector_dist_comm.hpp Vector/vector_dist.hpp Vector/vector_dist_ofb.hpp Vector/vector_dist_iterator.hpp Vector/vector_dist_key.hpp \
Vector/vector_dist_multiphase_functions.hpp Vector/vector_dist_comm.hpp Vector/vector_dist.hpp Vector/vector_dist_ofb.hpp Vector/vector_dist_iterator.hpp Vector/vector_dist_key.hpp \
config/config.h \
example.mk \
Decomposition/Distribution/metis_util.hpp Decomposition/Distribution/parmetis_dist_util.hpp Decomposition/Distribution/parmetis_util.hpp Decomposition/Distribution/MetisDistribution.hpp Decomposition/Distribution/ParMetisDistribution.hpp Decomposition/Distribution/DistParMetisDistribution.hpp dec_optimizer.hpp SubdomainGraphNodes.hpp \
......
/*
* vector_dist_MP_unit_tests.hpp
*
* Created on: Oct 14, 2016
* Author: i-bird
*/
#ifndef SRC_VECTOR_VECTOR_DIST_MP_UNIT_TESTS_HPP_
#define SRC_VECTOR_VECTOR_DIST_MP_UNIT_TESTS_HPP_
#include "Vector/vector_dist_multiphase_functions.hpp"
BOOST_AUTO_TEST_SUITE( vector_dist_multiphase_test )
BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_test )
{
if (create_vcluster().getProcessingUnits() > 24)
return;
size_t sz[3] = {60,60,40};
// The domain
Box<3,float> box({-1000.0,-1000.0,-1000.0},{2000.0,2000.0,1000.0});
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
float r_cut = 51.0;
// ghost, big enough to contain the interaction radius
Ghost<3,float> ghost(r_cut);
openfpm::vector< vector_dist<3,float, aggregate<double,double>> > phases;
// first phase
phases.add( vector_dist<3,float, aggregate<double,double>>(0,box,bc,ghost) );
// The other 3 phases
phases.add( vector_dist<3,float, aggregate<double,double>>(phases.get(0).getDecomposition(),0) );
phases.add( vector_dist<3,float, aggregate<double,double>>(phases.get(0).getDecomposition(),0) );
phases.add( vector_dist<3,float, aggregate<double,double>>(phases.get(0).getDecomposition(),0) );
// Fill the phases with particles
auto g_it = phases.get(0).getGridIterator(sz);
while (g_it.isNext())
{
auto key = g_it.get();
// Add a particle to all the phases
phases.get(0).add();
phases.get(1).add();
phases.get(2).add();
phases.get(3).add();
phases.get(0).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(0).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(0).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
phases.get(1).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(1).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(1).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
phases.get(2).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(2).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(2).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
phases.get(3).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(3).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(3).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
++g_it;
}
// Sync all phases
for (size_t i = 0 ; i < 4 ; i++)
{
phases.get(i).map();
phases.get(i).ghost_get<>();
}
// Get the cell list of the phase 0 and 1
auto CL_phase0 = phases.get(0).getCellList(r_cut);
auto CL_phase1 = phases.get(1).getCellList(r_cut);
// This function create a Verlet-list between phases 0 and 1
auto NN_ver01 = createVerlet(phases.get(0),CL_phase1,r_cut);
// Check NNver0_1
bool ret = true;
auto it = phases.get(0).getDomainIterator();
while (it.isNext())
{
auto p = it.get();
auto Np = NN_ver01.template getNNIterator<NO_CHECK>(p.getKey());
size_t nn_count = 0;
// For each neighborhood of the particle p
while (Np.isNext())
{
// Neighborhood particle q
auto q = Np.get();
// Count the number of particles
nn_count++;
++Np;
}
ret &= nn_count == 7ul;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
// Sync all phases
for (size_t i = 0 ; i < 4 ; i++)
{
phases.get(i).map();
phases.get(i).ghost_get<>();
}
// NN_ver0_all
// This function create an "Empty" Multiphase Cell List
auto CL_all = createCellListM<2>(phases,r_cut);
// This create a Verlet-list between phase 0 and all the other phases
auto NNver0_all = createVerletM<2>(phases.get(0),CL_all,r_cut);
it = phases.get(0).getDomainIterator();
while (it.isNext())
{
auto p = it.get();
auto Np = NNver0_all.template getNNIterator<NO_CHECK>(p.getKey());
size_t nn_cout[4] = {0,0,0,0};
// For each neighborhood of the particle p
while (Np.isNext())
{
// Get the particle q near to p
auto q = Np.getP();
// Get from which phase it come from
auto ph_q = Np.getV();
nn_cout[ph_q]++;
++Np;
}
ret &= nn_cout[0] == 7;
ret &= nn_cout[1] == 7;
ret &= nn_cout[2] == 7;
ret &= nn_cout[3] == 7;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
}
BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_sym_test )
{
if (create_vcluster().getProcessingUnits() > 24)
return;
size_t sz[3] = {60,60,40};
// The domain
Box<3,float> box({-1000.0,-1000.0,-1000.0},{2000.0,2000.0,1000.0});
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
float r_cut = 51.0;
// ghost, big enough to contain the interaction radius
Ghost<3,float> ghost(r_cut);
openfpm::vector< vector_dist<3,float, aggregate<size_t>> > phases;
// first phase
phases.add( vector_dist<3,float, aggregate<size_t>>(0,box,bc,ghost) );
// The other 3 phases
phases.add( vector_dist<3,float, aggregate<size_t>>(phases.get(0).getDecomposition(),0) );
phases.add( vector_dist<3,float, aggregate<size_t>>(phases.get(0).getDecomposition(),0) );
phases.add( vector_dist<3,float, aggregate<size_t>>(phases.get(0).getDecomposition(),0) );
// Fill the phases with particles
auto g_it = phases.get(0).getGridIterator(sz);
while (g_it.isNext())
{
auto key = g_it.get();
// Add a particle to all the phases
phases.get(0).add();
phases.get(1).add();
phases.get(2).add();
phases.get(3).add();
phases.get(0).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(0).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(0).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
phases.get(1).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(1).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(1).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
phases.get(2).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(2).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(2).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
phases.get(3).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
phases.get(3).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
phases.get(3).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
++g_it;
}
// Sync all phases
for (size_t i = 0 ; i < 4 ; i++)
{
phases.get(i).map();
phases.get(i).ghost_get<>();
}
// Get the cell list of the phase 0 and 1
auto CL_phase0 = phases.get(0).getCellListSym(r_cut);
auto CL_phase1 = phases.get(1).getCellListSym(r_cut);
// This function create a Verlet-list between phases 0 and 1
auto NN_ver01 = createVerletSym(phases.get(0),CL_phase1,r_cut);
// Check NNver0_1
bool ret = true;
auto it = phases.get(0).getDomainIterator();
while (it.isNext())
{
auto p = it.get();
auto Np = NN_ver01.template getNNIterator<NO_CHECK>(p.getKey());
// For each neighborhood of the particle p
while (Np.isNext())
{
// Neighborhood particle q
auto q = Np.get();
phases.get(0).getProp<0>(p)++;
phases.get(1).getProp<0>(q)++;
++Np;
}
++it;
}
phases.get(0).ghost_put<add_,0>();
phases.get(1).ghost_put<add_,0>();
it = phases.get(0).getDomainIterator();
while (it.isNext())
{
auto p = it.get();
ret &= phases.get(0).getProp<0>(p) == 7;
ret &= phases.get(1).getProp<0>(p) == 7;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
// Sync all phases
for (size_t i = 0 ; i < 4 ; i++)
{
phases.get(i).map();
phases.get(i).ghost_get<>();
}
// Reset counter on all phases
for (size_t i = 0 ; i < phases.size() ; i++)
{
it = phases.get(i).getDomainAndGhostIterator();
while (it.isNext())
{
auto p = it.get();
phases.get(i).getProp<0>(p) = 0;
++it;
}
}
// NN_ver0_all
// This function create an "Empty" Multiphase Cell List
auto CL_all = createCellListSymM<2>(phases,r_cut);
typedef decltype(createVerletSymM<2>(phases.get(0),CL_all,r_cut)) verlet_type;
verlet_type NNver_all[4];
// This create a Verlet-list between phase all phases to all the other phases
NNver_all[0] = createVerletSymM<2>(phases.get(0),CL_all,r_cut);
NNver_all[1] = createVerletSymM<2>(phases.get(1),CL_all,r_cut);
NNver_all[2] = createVerletSymM<2>(phases.get(2),CL_all,r_cut);
NNver_all[3] = createVerletSymM<2>(phases.get(3),CL_all,r_cut);
// all phases to all phases
for (size_t i = 0 ; i < phases.size() ; i++)
{
it = phases.get(i).getDomainIterator();
while (it.isNext())
{
auto p = it.get();
auto Np = NNver_all[i].template getNNIterator<NO_CHECK>(p.getKey());
// For each neighborhood of the particle p
while (Np.isNext())
{
// Get the particle q near to p
auto q = Np.getP();
// Get from which phase it come from
auto ph_q = Np.getV();
phases.get(i).getProp<0>(p)++;
phases.get(ph_q).getProp<0>(q)++;
++Np;
}
++it;
}
}
phases.get(0).ghost_put<add_,0>();
phases.get(1).ghost_put<add_,0>();
phases.get(2).ghost_put<add_,0>();
phases.get(3).ghost_put<add_,0>();
it = phases.get(0).getDomainIterator();
while (it.isNext())
{
auto p = it.get();
ret &= phases.get(0).getProp<0>(p) == 32;
ret &= phases.get(1).getProp<0>(p) == 32;
ret &= phases.get(2).getProp<0>(p) == 32;
ret &= phases.get(3).getProp<0>(p) == 32;
++it;
}
BOOST_REQUIRE_EQUAL(ret,true);
}
BOOST_AUTO_TEST_SUITE_END()
#endif /* SRC_VECTOR_VECTOR_DIST_MP_UNIT_TESTS_HPP_ */
/*
* vector_dist_multiphase_functions.hpp
*
* Created on: Oct 14, 2016
* Author: i-bird
*/
#ifndef SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_
#define SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_
#include "NN/CellList/CellListM.hpp"
#include "NN/VerletList/VerletListM.hpp"
template<typename Vector,typename CL, typename T> VerletList<Vector::dims,typename Vector::stype,FAST,shift<Vector::dims,typename Vector::stype>> createVerlet(Vector & v, CL & cl, T r_cut)
{
VerletList<Vector::dims,typename Vector::stype,FAST,shift<Vector::dims,typename Vector::stype>> ver;
ver.Initialize(cl,r_cut,v.getPosVector(),v.size_local());
return ver;
}
template<unsigned int sh_byte, typename Vector,typename CL, typename T> VerletListM<Vector::dims,typename Vector::stype,sh_byte,shift<Vector::dims,typename Vector::stype>> createVerletM(Vector & v, CL & cl, T r_cut)
{
VerletListM<Vector::dims,typename Vector::stype,sh_byte,shift<Vector::dims,typename Vector::stype>> ver;
ver.Initialize(cl,r_cut,v.getPosVector(),v.size_local());
return ver;
}
template<unsigned int nbit, typename Vector, typename T> CellListM<Vector::dims,typename Vector::stype,nbit> createCellListM(openfpm::vector<Vector> & phases, T r_cut)
{
size_t div[3];
Box<Vector::dims,typename Vector::stype> box_cl;
CellListM<Vector::dims,typename Vector::stype,nbit> NN;
if (phases.size() == 0)
return NN;
box_cl = phases.get(0).getDecomposition().getProcessorBounds();
phases.get(0).getCellListParams(r_cut,div,box_cl);
NN.Initialize(box_cl,div);
// for all the phases i
for (size_t i = 0; i < phases.size() ; i++)
{
// iterate across all the particle of the phase i
auto it = phases.get(i).getDomainAndGhostIterator();
while (it.isNext())
{
auto key = it.get();
// Add the particle of the phase i to the cell list
NN.add(phases.get(i).getPos(key), key.getKey(), i);
++it;
}
}
return NN;
}
/////// Symmetric version
template<typename Vector,typename CL, typename T> VerletList<Vector::dims,typename Vector::stype,FAST,shift<Vector::dims,typename Vector::stype>> createVerletSym(Vector & v, CL & cl, T r_cut)
{
VerletList<Vector::dims,typename Vector::stype,FAST,shift<Vector::dims,typename Vector::stype>> ver;
ver.Initialize(cl,r_cut,v.getPosVector(),v.size_local());
return ver;
}
template<unsigned int sh_byte, typename Vector,typename CL, typename T> VerletListM<Vector::dims,typename Vector::stype,sh_byte,shift<Vector::dims,typename Vector::stype>> createVerletSymM(Vector & v, CL & cl, T r_cut)
{
VerletListM<Vector::dims,typename Vector::stype,sh_byte,shift<Vector::dims,typename Vector::stype>> ver;
ver.Initialize(cl,r_cut,v.getPosVector(),v.size_local(),VL_SYMMETRIC);
return ver;
}
template<unsigned int nbit, typename Vector, typename T> CellListM<Vector::dims,typename Vector::stype,nbit> createCellListSymM(openfpm::vector<Vector> & phases, T r_cut)