Commit 882cf3b6 authored by incardon's avatar incardon

small fixes

parent 36080771
......@@ -7,6 +7,8 @@
* \subpage Vector_4_reo_root
* \subpage Vector_4_cp
* \subpage Vector_4_mp_cl
* \subpage Vector_5_md_vl_sym
* \subpage Vector_6_complex_usage
*
*/
......
......@@ -7,9 +7,8 @@ LDIR =
OBJ = main.o
OBJ_EXPR = main_expr.o
OBJ_VL = main_vl.o
OBJ_VL_SYM = main_vl_sym.o
all: md_dyn md_dyn_expr md_dyn_vl md_dyn_vl_sym
all: md_dyn md_dyn_expr md_dyn_vl
%.o: %.cpp
$(CC) -fext-numeric-literals -O3 -g -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
......@@ -23,14 +22,11 @@ md_dyn_expr: $(OBJ_EXPR)
md_dyn_vl: $(OBJ_VL)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
md_dyn_vl_sym: $(OBJ_VL_SYM)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
run: all
source $$HOME/openfpm_vars; mpirun -np 3 ./md_dyn; mpirun -np 3 ./md_dyn_expr; mpirun -np 3 ./md_dyn_vl; mpirun -np 3 ./md_dyn_vl_sym;
source $$HOME/openfpm_vars; mpirun -np 3 ./md_dyn; mpirun -np 3 ./md_dyn_expr; mpirun -np 3 ./md_dyn_vl;
.PHONY: clean all run
clean:
rm -f *.o *~ core md_dyn md_dyn_expr md_dyn_vl md_dyn_vl_sym
rm -f *.o *~ core md_dyn md_dyn_expr md_dyn_vl
This diff is collapsed.
include ../../example.mk
CC=mpic++
LDIR =
OBJ_DORD = main.o
all: complex_use
%.o: %.cpp
$(CC) -fext-numeric-literals -O3 -g -c --std=c++11 $(OPT) -o $@ $< $(INCLUDE_PATH)
complex_use: $(OBJ_DORD)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
run: all_test
source $$HOME/openfpm_vars; mpirun -np 3 ./complex_use
.PHONY: clean all run all_test on_test
clean:
rm -f *.o *~ core complex_use
This diff is collapsed.
openfpm_data @ 1a4dc990
Subproject commit 21a5f6ee7bf426ad13106a26f581b788b8c7c95d
Subproject commit 1a4dc99034168bd02982055185682b3c3a9c2ff4
openfpm_io @ 5cf76966
Subproject commit 62b8316404bf98c5cc5ad299563425656cfd3003
Subproject commit 5cf769662d6e57a7a2fd12d1cfc835fd2793bc7b
......@@ -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 = 0.5.1
PROJECT_NUMBER = 0.6.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
......
......@@ -181,6 +181,9 @@ if [ ! -d "$1/MUMPS" ]; then
$sed_command -i "/LIBBLAS\s=\s-lblas/c\LIBBLAS = -lopenblas" Makefile.inc
$sed_command -i "/INCPAR\s\+=\s\-I\/usr\/include/c\INCPAR =" Makefile.inc
$sed_command -i "/LIBPAR\s\+=\s\$(SCALAP)\s\-L\/usr\/lib\s\-lmpi/c\LIBPAR = \$(SCALAP)" Makefile.inc
make -j $2
if [ $? -eq 0 ]; then
......
......@@ -526,15 +526,29 @@ public:
return cell_list;
}
/*! \brief for each particle get the symmetric verlet list
*
* \param r_cut cut-off radius
*
*/
VerletList<dim,St,FAST,shift<dim,St> > getVerletSym(St r_cut)
{
VerletList<dim,St,FAST,shift<dim,St>> ver;
// Processor bounding box
Box<dim, St> pbox = getDecomposition().getProcessorBounds();
ver.InitializeSym(getDecomposition().getDomain(),pbox,getDecomposition().getGhost(),r_cut,v_pos,g_m);
return ver;
}
/*! \brief for each particle get the verlet list
*
* \param r_cut cut-off radius
* \param opt option like VL_SYMMETRIC and VL_NON_SYMMETRIC
*
*/
VerletList<dim,St,FAST,shift<dim,St> > getVerlet(St r_cut, size_t opt = VL_NON_SYMMETRIC)
VerletList<dim,St,FAST,shift<dim,St> > getVerlet(St r_cut)
{
VerletList<dim,St,FAST,shift<dim,St>> ver;
......@@ -548,7 +562,7 @@ public:
// enlarge the box where the Verlet is defined
bt.enlarge(g);
ver.Initialize(bt,getDecomposition().getProcessorBounds(),r_cut,v_pos,g_m,opt);
ver.Initialize(bt,getDecomposition().getProcessorBounds(),r_cut,v_pos,g_m,VL_NON_SYMMETRIC);
return ver;
}
......@@ -1126,6 +1140,28 @@ public:
{
return v_pos;
}
/*! \brief It return the sum of the particles in the previous processors
*
* \return the particles number
*
*/
size_t accum()
{
openfpm::vector<size_t> accu;
size_t sz = size_local();
v_cl.allGather(sz,accu);
v_cl.execute();
sz = 0;
for (size_t i = 0 ; i < v_cl.getProcessUnitID() ; i++)
sz += accu.get(i);
return sz;
}
};
......
......@@ -530,173 +530,206 @@ BOOST_AUTO_TEST_CASE( vector_dist_symmetric_cell_list )
BOOST_REQUIRE_EQUAL(ret,true);
}
BOOST_AUTO_TEST_CASE( vector_dist_sym_verlet_list_test )
BOOST_AUTO_TEST_CASE( vector_dist_symmetric_verlet_list )
{
if (create_vcluster().getProcessingUnits() > 48)
Vcluster & v_cl = create_vcluster();
if (v_cl.getProcessingUnits() > 24)
return;
long int k = 4096*create_vcluster().getProcessingUnits();
float L = 1000.0;
long int big_step = k / 30;
// set the seed
// create the random generator engine
std::srand(0);
std::default_random_engine eg;
std::uniform_real_distribution<float> ud(-L,L);
long int k = 4096 * v_cl.getProcessingUnits();
long int big_step = k / 4;
big_step = (big_step == 0)?1:big_step;
long int small_step = 21;
print_test( "Testing vector symmetric verlet-list k<=",k);
print_test("Testing 3D periodic vector symmetric cell-list k=",k);
BOOST_TEST_CHECKPOINT( "Testing 3D periodic vector symmetric cell-list k=" << k );
// 3D test
for ( ; k > 8*big_step ; k-= (k > 2*big_step)?big_step:small_step )
{
double r_cut = 0.1;
Box<3,float> box({-L,-L,-L},{L,L,L});
// domain
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};
// Boundary conditions
size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
float r_cut = 100.0;
// ghost, big enough to contain the interaction radius
Ghost<3,float> ghost(r_cut);
// ghost
Ghost<3,float> ghost(r_cut);
vector_dist<3,double, aggregate<double> > vd(k,box,bc,ghost);
// Point and global id
struct point_and_gid
{
size_t id;
Point<3,float> xq;
bool operator<(const struct point_and_gid & pag)
{
auto it = vd.getDomainIterator();
return (id < pag.id);
}
};
while (it.isNext())
{
auto p = it.get();
typedef aggregate<size_t,size_t,size_t,openfpm::vector<point_and_gid>,openfpm::vector<point_and_gid>> part_prop;
vd.getPos(p)[0] = (double)rand()/RAND_MAX;
vd.getPos(p)[1] = (double)rand()/RAND_MAX;
vd.getPos(p)[2] = (double)rand()/RAND_MAX;
// Distributed vector
vector_dist<3,float, part_prop > vd(k,box,bc,ghost);
size_t start = vd.init_size_accum(k);
++it;
}
}
auto it = vd.getIterator();
vd.map();
vd.ghost_get<>();
while (it.isNext())
{
auto key = it.get();
// Get the Cell list structure
auto NN = vd.getVerlet(r_cut,VL_SYMMETRIC);
auto NNc = vd.getVerlet(r_cut);
vd.getPos(key)[0] = ud(eg);
vd.getPos(key)[1] = ud(eg);
vd.getPos(key)[2] = ud(eg);
// Get an iterator over particles
auto it2 = vd.getDomainAndGhostIterator();
// Fill some properties randomly
openfpm::vector<openfpm::vector<size_t>> idx;
idx.resize(vd.size_local_with_ghost());
vd.getProp<0>(key) = 0;
vd.getProp<1>(key) = 0;
vd.getProp<2>(key) = key.getKey() + start;
/////////// SYMMETRIC CASE VERLET-LIST ////////
++it;
}
// For each particle ...
while (it2.isNext())
{
// ... p
auto p = it2.get();
vd.map();
// Get the position of the particle p
Point<3,double> xp = vd.getPos(p);
// sync the ghost
vd.ghost_get<0,2>();
// Get an iterator over the neighborhood of the particle p symmetric
auto NpSym = NN.template getNNIterator<NO_CHECK>(p.getKey());
auto NN = vd.getVerlet(r_cut);
auto p_it = vd.getDomainIterator();
// For each neighborhood of the particle p
while (NpSym.isNext())
{
// Neighborhood particle q
auto q = NpSym.get();
while (p_it.isNext())
{
auto p = p_it.get();
// if p == q skip this particle
if (q == p.getKey()) {++NpSym; continue;};
Point<3,float> xp = vd.getPos(p);
// Get position of the particle q
Point<3,double> xq = vd.getPos(q);
auto Np = NN.getNNIterator(p.getKey());
// take the normalized direction
double rn = norm2(xp - xq);
while (Np.isNext())
{
auto q = Np.get();
// potential energy (using pow is slower)
vd.getProp<0>(p) += rn;
vd.getProp<0>(q) += rn;
if (p.getKey() == q)
{
++Np;
continue;
}
idx.get(p.getKey()).add(q);
idx.get(q).add(p.getKey());
// repulsive
Point<3,float> xq = vd.getPos(q);
Point<3,float> f = (xp - xq);
float distance = f.norm();
// Particle should be inside 2 * r_cut range
// Next neighborhood
++NpSym;
if (distance < r_cut )
{
vd.getProp<0>(p)++;
vd.getProp<3>(p).add();
vd.getProp<3>(p).last().xq = xq;
vd.getProp<3>(p).last().id = vd.getProp<2>(q);
}
// Next Particle
++it2;
++Np;
}
/////////////// NON SYMMETRIC CASE VERLET-LIST ////////////////////////
++p_it;
}
openfpm::vector<openfpm::vector<size_t>> idx2;
idx2.resize(vd.size_local());
// We now try symmetric Cell-list
auto it = vd.getDomainIterator();
auto NN2 = vd.getVerletSym(r_cut);
// For each particle ...
while (it.isNext())
{
// ... p
auto p = it.get();
auto p_it2 = vd.getDomainIterator();
while (p_it2.isNext())
{
auto p = p_it2.get();
// Get the position of the particle p
Point<3,double> xp = vd.getPos(p);
Point<3,float> xp = vd.getPos(p);
// Get an iterator over the neighborhood of the particle p
auto Np = NNc.template getNNIterator<NO_CHECK>(p.getKey());
auto Np = NN2.template getNNIterator<NO_CHECK>(p.getKey());
double Ep = 0.0;
while (Np.isNext())
{
auto q = Np.get();
// For each neighborhood of the particle p
while (Np.isNext())
if (p.getKey() == q)
{
// Neighborhood particle q
auto q = Np.get();
++Np;
continue;
}
// if p == q skip this particle
if (q == p.getKey()) {++Np; continue;};
// repulsive
// Get position of the particle q
Point<3,double> xq = vd.getPos(q);
Point<3,float> xq = vd.getPos(q);
Point<3,float> f = (xp - xq);
// take the normalized direction
double rn = norm2(xp - xq);
float distance = f.norm();
idx2.get(p.getKey()).add(q);
// Particle should be inside r_cut range
// potential energy (using pow is slower)
Ep += rn;
if (distance < r_cut )
{
vd.getProp<1>(p)++;
vd.getProp<1>(q)++;
// Next neighborhood
++Np;
vd.getProp<4>(p).add();
vd.getProp<4>(q).add();
vd.getProp<4>(p).last().xq = xq;
vd.getProp<4>(q).last().xq = xp;
vd.getProp<4>(p).last().id = vd.getProp<2>(q);
vd.getProp<4>(q).last().id = vd.getProp<2>(p);
}
idx.get(p.getKey()).sort();
idx2.get(p.getKey()).sort();
++Np;
}
bool ret = true;
++p_it2;
}
BOOST_REQUIRE_EQUAL(idx.get(p.getKey()).size(),idx2.get(p.getKey()).size());
vd.ghost_put<add_,1>();
vd.ghost_put<merge_,4>();
for (size_t i = 0 ; i < idx.get(p.getKey()).size() ; i++)
{
ret &= idx.get(p.getKey()).get(i) == idx2.get(p.getKey()).get(i);
}
auto p_it3 = vd.getDomainIterator();
BOOST_REQUIRE_EQUAL(ret,true);
bool ret = true;
while (p_it3.isNext())
{
auto p = p_it3.get();
BOOST_REQUIRE_CLOSE(Ep,vd.getProp<0>(p),0.01);
ret &= vd.getProp<1>(p) == vd.getProp<0>(p);
// Next Particle
++it;
}
vd.getProp<3>(p).sort();
vd.getProp<4>(p).sort();
ret &= vd.getProp<3>(p).size() == vd.getProp<4>(p).size();
for (size_t i = 0 ; i < vd.getProp<3>(p).size() ; i++)
ret &= vd.getProp<3>(p).get(i).id == vd.getProp<4>(p).get(i).id;
if (ret == false)
break;
++p_it3;
}
BOOST_REQUIRE_EQUAL(ret,true);
}
......
......@@ -1052,12 +1052,13 @@ public:
size_t i2 = 0;
#ifdef SE_CLASS1
if (v_prp.size() - lg_m != o_part_loc.size())
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " v_prp.size() - lg_m = " << v_prp.size() - lg_m << " != " << o_part_loc.size() << std::endl;
{
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " Local ghost particles = " << v_prp.size() - lg_m << " != " << o_part_loc.size() << std::endl;
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << "Check that you did a ghost_get before a ghost_put" << std::endl;
}
#endif
for (size_t i = lg_m ; i < v_prp.size() ; i++)
{
......
......@@ -22,6 +22,7 @@ int main(int argc, char* argv[])
return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
}
#include "debug.hpp"
#include "Grid/grid_dist_id.hpp"
#include "Point_test.hpp"
#include "Decomposition/CartDecomposition.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment