Commit 528ec206 authored by incardon's avatar incardon

examples SPH update

parent 065f9a27
......@@ -11,6 +11,7 @@
* \subpage Vector_5_md_vl_sym
* \subpage Vector_5_md_vl_sym_crs
* \subpage Vector_6_complex_usage
* \subpage Vector_7_sph_dlb
*
*/
......
......@@ -317,7 +317,7 @@ int main(int argc, char* argv[])
CL_phase1 = phases.get(1).getCellListSym(r_cut);
// This function create a Verlet-list between phases 0 and 1
NN_ver01 = createVerletSym(phases.get(0),CL_phase1,r_cut);
NN_ver01 = createVerletSym(phases.get(0),phases.get(1),CL_phase1,r_cut);
// Get an iterator over the real and ghost particles
it = phases.get(0).getDomainAndGhostIterator();
......@@ -419,7 +419,7 @@ int main(int argc, char* argv[])
CL_all = createCellListSymM<2>(phases,r_cut);
// Type of the multiphase Verlet-list
typedef decltype(createVerletSymM<2>(phases.get(0),CL_all,r_cut)) verlet_type;
typedef decltype(createVerletSymM<2>(phases.get(0),phases,CL_all,r_cut)) verlet_type;
// for each phase we create one Verlet-list that contain the neighborhood
// from all the phases
......
This diff is collapsed.
openfpm_numerics @ 9e49bd95
Subproject commit 2a805e31cd0bc1e5fe89c8f6a03ba22b1691ad2d
Subproject commit 9e49bd9594b1b1c0d9cdd19e609aaba7a163d907
......@@ -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.7.0
PROJECT_NUMBER = 0.8.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
......
......@@ -351,11 +351,11 @@ public:
for (size_t i = 0; i < dist.getNSubSubDomains(); i++)
{
dist.setMigrationCost(i, norm * migration * dist.getSubSubDomainComputationCost(i));
dist.setMigrationCost(i, norm * migration /* * dist.getSubSubDomainComputationCost(i) */);
for (size_t s = 0; s < dist.getNSubSubDomainNeighbors(i); s++)
{
dist.setCommunicationCost(i, s, 1 * dist.getSubSubDomainComputationCost(i) * ts);
dist.setCommunicationCost(i, s, 1 * /* dist.getSubSubDomainComputationCost(i) * */ ts);
}
prev += dist.getNSubSubDomainNeighbors(i);
}
......@@ -994,6 +994,7 @@ public:
sub_domains.clear();
box_nn_processor.clear();
fine_s.clear();
loc_box.clear();
nn_prcs<dim, T>::reset();
ie_ghost<dim, T>::reset();
ie_loc_ghost<dim, T>::reset();
......@@ -1122,7 +1123,7 @@ public:
*/
inline size_t getSubSubDomainComputationCost(size_t id)
{
return dist.getComputationCost(id);
return dist.getSubSubDomainComputationCost(id);
}
/*! \brief Operator to access the size of the sub-graph
......
......@@ -118,28 +118,33 @@ class ParMetisDistribution
for (size_t i = 0; i <= Np; i++)
vtxdist.get(i) = n_vtxdist.get(i);
openfpm::vector<size_t> cnt;
cnt.resize(Np);
// Renumber the main graph and re-create the map
for (size_t p = 0; p < (size_t)Np; p++)
/* for (size_t p = 0; p < (size_t)Np; p++)
{
size_t i = 0;
for (rid j = vtxdist.get(p); j < vtxdist.get(p + 1); ++j, i++)
{
setMapId(j, v_per_proc.get(p).get(i));
gp.vertex(v_per_proc.get(p).get(i).id).template get<nm_v::id>() = j.id;
gp.vertex(v_per_proc.get(p).get(i).id).template get<nm_v::id>() = cnt.get(p) + vtxdist.get(p).id;
cnt.get(p)++;
}
}
}
void createMapsFromGlobalGraph(openfpm::vector<size_t> & vtxdist)
{
/* openfpm::vector<size_t> cnt_np;
}*/
for (size_t i = 0 ; i < gp.getNVertex() ; i++)
for (size_t i = 0 ; i < gp.getNVertex(); ++i)
{
cnt_np(gp.template vertex<nm_v::proc_id>)++;
size_t pid = gp.template vertex_p<nm_v::proc_id>(i);
gp.setMapId()
}*/
rid j = rid(vtxdist.get(pid).id + cnt.get(pid));
gid gi = gid(i);
gp.template vertex_p<nm_v::id>(i) = j.id;
cnt.get(pid)++;
setMapId(j,gi);
}
}
/*! \brief operator to access the vertex by mapped position
......
......@@ -76,6 +76,9 @@ struct fill_id<dim, G_v, NO_VERTEX_ID>
template<unsigned int dim, int lin_id, typename dT, typename G_v, typename v, int impl>
class fill_prop
{
//! Domain
const Box<dim,dT> & domain;
//! Reference to an array containing the spacing
const dT (&szd)[dim];
......@@ -91,8 +94,8 @@ class fill_prop
public:
//! Fill the object from where to take the properties
fill_prop(G_v & g_v, const dT (&szd)[dim], grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs) :
szd(szd), gk(gk), g_v(g_v), gs(gs)
fill_prop(G_v & g_v, const dT (&szd)[dim], grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs, const Box<dim,dT> & domain)
:domain(domain), szd(szd), gk(gk), g_v(g_v), gs(gs)
{
}
......@@ -102,7 +105,7 @@ public:
{
typedef typename boost::fusion::result_of::at<v, boost::mpl::int_<T::value>>::type t_val;
g_v.template get<t_val::value>() = gk.get(T::value) * szd[T::value];
g_v.template get<t_val::value>() = gk.get(T::value) * szd[T::value] + domain.getLow(T::value);
fill_id<dim, G_v, lin_id>::fill(g_v, gk, gs);
}
};
......@@ -140,7 +143,7 @@ class fill_prop<dim, lin_id, dT, G_v, v, 0>
public:
//! Fill the object from where to take the properties
fill_prop(G_v & g_v, const dT (&szd)[dim], grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs)
fill_prop(G_v & g_v, const dT (&szd)[dim], grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs, const Box<dim,dT> & domain)
{
}
......@@ -180,6 +183,8 @@ public:
template<unsigned int dim, int lin_id, typename dT, typename G_v, typename v>
class fill_prop<dim, lin_id, dT, G_v, v, 2>
{
//! Domain
const Box<dim,dT> & domain;
//! Reference to an array containing the spacing
const dT (&szd)[dim];
......@@ -196,8 +201,8 @@ class fill_prop<dim, lin_id, dT, G_v, v, 2>
public:
//! Fill the object from where to take the properties
fill_prop(G_v & g_v, const dT (&szd)[dim], grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs) :
szd(szd), gk(gk), g_v(g_v), gs(gs)
fill_prop(G_v & g_v, const dT (&szd)[dim], grid_key_dx<dim> & gk, const grid_sm<dim, void> & gs, const Box<dim,dT> & domain)
:domain(domain), szd(szd), gk(gk), g_v(g_v), gs(gs)
{
}
......@@ -212,7 +217,7 @@ public:
g_v.template get<t_val::value>()[i] = 0.0;
for (size_t i = 0 ; i < dim ; i++)
g_v.template get<t_val::value>()[i] = gk.get(i) * static_cast<float>(szd[i]);
g_v.template get<t_val::value>()[i] = gk.get(i) * static_cast<float>(szd[i]) + domain.getLow(i);
fill_id<dim, G_v, lin_id>::fill(g_v, gk, gs);
}
......@@ -330,7 +335,7 @@ public:
// vertex spatial properties functor
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
// fill properties
......@@ -451,7 +456,7 @@ public:
// vertex spatial properties functor
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g);
fill_prop<dim, lin_id, T, decltype(gp.vertex(g.LinId(key))), typename to_boost_vmpl<pos...>::type, fill_prop_by_type<sizeof...(pos), p, Graph, pos...>::value> flp(obj, szd, key, g, dom);
// fill properties
......
......@@ -17,8 +17,17 @@
*/
struct rid
{
//! id
idx_t id;
//! Cosntructor
rid(size_t id)
:id(id)
{}
//! Constructor
rid() {}
inline bool operator<=(const rid & r) const
{
return id <= r.id;
......@@ -79,6 +88,14 @@ struct rid
struct gid
{
size_t id;
//! Constructor
gid(){};
//! Constructor
gid(size_t id)
:id(id)
{}
};
/*! Here we define different the remapped-id
......
......@@ -14,7 +14,7 @@ nobase_include_HEADERS = Decomposition/CartDecomposition.hpp Decomposition/CartD
example.mk \
Decomposition/Distribution/metis_util.hpp Decomposition/Distribution/SpaceDistribution.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 \
Graph/ids.hpp Graph/dist_map_graph.hpp Graph/DistGraphFactory.hpp \
DLB/DLB.hpp
DLB/DLB.hpp DLB/LB_Model.hpp
lib_LIBRARIES = libofpm_pdata.a
libofpm_pdata_a_SOURCES = lib/pdata.cpp
......
......@@ -30,10 +30,13 @@
#include "data_type/aggregate.hpp"
#include "NN/VerletList/VerletList.hpp"
#include "vector_dist_comm.hpp"
#include "DLB/LB_Model.hpp"
#define NO_ID false
#define ID true
#define DEC_GRAN(gr) ((size_t)gr << 32)
// Perform a ghost get or a ghost put
#define GET 1
#define PUT 2
......@@ -236,6 +239,9 @@ public:
check_new(this,8,VECTOR_DIST_EVENT,4);
#endif
if (opt >> 32 != 0)
this->setDecompositionGranularity(opt >> 32);
check_parameters(box);
init_structures(np);
......@@ -1022,21 +1028,19 @@ public:
g_m--;
}
/*! \brief Add the computation cost on the decomposition comming from the particles
/*! \brief Add the computation cost on the decomposition coming from the particles
*
*/
inline void addComputationCosts()
template <typename Model=ModelLin>inline void addComputationCosts(Model md=Model())
{
CellDecomposer_sm<dim, St> cdsm;
CellDecomposer_sm<dim, St, shift<dim,St>> cdsm;
Decomposition & dec = getDecomposition();
cdsm.setDimensions(dec.getDomain(), dec.getGrid().getSize(), 0);
for (size_t i = 0; i < getDecomposition().getNSubSubDomains(); i++)
{
dec.setSubSubDomainComputationCost(i, 1);
}
auto it = getDomainIterator();
......@@ -1044,11 +1048,15 @@ public:
{
size_t v = cdsm.getCell(this->getPos(it.get()));
dec.addComputationCost(v, 1);
md.addComputation(dec,*this,v,it.get().getKey());
++it;
}
// Go throught all the sub-sub-domains and apply the model
for (size_t i = 0 ; i < dec.getDistribution().getNSubSubDomains(); i++)
md.applyModel(dec,i);
}
/*! \brief Output particle position and properties
......
......@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_test )
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);
auto NN_ver01 = createVerlet(phases.get(0),phases.get(1),CL_phase1,r_cut);
// Check NNver0_1
......@@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_test )
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);
auto NNver0_all = createVerletM<2>(phases.get(0),phases,CL_all,r_cut);
it = phases.get(0).getDomainIterator();
......@@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_sym_test )
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);
auto NN_ver01 = createVerletSym(phases.get(0),phases.get(1),CL_phase1,r_cut);
// Check NNver0_1
......@@ -305,15 +305,15 @@ BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_sym_test )
// 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;
typedef decltype(createVerletSymM<2>(phases.get(0),phases,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);
NNver_all[0] = createVerletSymM<2>(phases.get(0),phases,CL_all,r_cut);
NNver_all[1] = createVerletSymM<2>(phases.get(1),phases,CL_all,r_cut);
NNver_all[2] = createVerletSymM<2>(phases.get(2),phases,CL_all,r_cut);
NNver_all[3] = createVerletSymM<2>(phases.get(3),phases,CL_all,r_cut);
// all phases to all phases
......
......@@ -8,8 +8,6 @@
#ifndef SRC_VECTOR_VECTOR_DIST_COMM_HPP_
#define SRC_VECTOR_VECTOR_DIST_COMM_HPP_
#define V_SUB_UNIT_FACTOR 64
#define SKIP_LABELLING 512
#define KEEP_PROPERTIES 512
......@@ -47,6 +45,9 @@ inline static size_t compute_options(size_t opt)
template<unsigned int dim, typename St, typename prop, typename Decomposition = CartDecomposition<dim,St>, typename Memory = HeapMemory>
class vector_dist_comm
{
//! Number of units for each sub-domain
size_t v_sub_unit_factor = 64;
//! definition of the send vector for position
typedef openfpm::vector<Point<dim, St>, Memory> send_pos_vector;
......@@ -784,14 +785,24 @@ public:
{
}
/*! \brief Get the number of minimum sub-domain
/*! \brief Get the number of minimum sub-domain per processor
*
* \return minimum number
*
*/
static size_t getDefaultNsubsub()
size_t getDecompositionGranularity()
{
return v_sub_unit_factor;
}
/*! \brief Set the minimum number of sub-domain per processor
*
* \param n_sub
*
*/
void setDecompositionGranularity(size_t n_sub)
{
return V_SUB_UNIT_FACTOR;
this->v_sub_unit_factor = n_sub;
}
/*! \brief Initialize the decomposition
......@@ -826,7 +837,7 @@ public:
// Get the number of processor and calculate the number of sub-domain
// for decomposition
size_t n_proc = v_cl.getProcessingUnits();
size_t n_sub = n_proc * getDefaultNsubsub();
size_t n_sub = n_proc * getDecompositionGranularity();
// Calculate the maximum number (before merging) of sub-domain on
// each dimension
......
......@@ -11,20 +11,25 @@
#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)
template<typename Vector, typename CL, typename T> VerletList<Vector::dims,typename Vector::stype,FAST,shift<Vector::dims,typename Vector::stype>> createVerlet(Vector & v, Vector & v1, 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());
ver.Initialize(cl,r_cut,v.getPosVector(),v1.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)
template<unsigned int sh_byte, typename Vector , typename Vector1,typename CL, typename T> VerletListM<Vector::dims,typename Vector::stype,sh_byte,CL,shift<Vector::dims,typename Vector::stype>> createVerletM(Vector & v, Vector1 & phases, CL & cl, T r_cut)
{
VerletListM<Vector::dims,typename Vector::stype,sh_byte,shift<Vector::dims,typename Vector::stype>> ver;
VerletListM<Vector::dims,typename Vector::stype,sh_byte,CL,shift<Vector::dims,typename Vector::stype>> ver;
ver.Initialize(cl,r_cut,v.getPosVector(),v.size_local());
openfpm::vector<pos_v<Vector::dims,typename Vector::stype>> v_phases;
for (size_t i = 0 ; i < phases.size() ; i++)
v_phases.add(pos_v<Vector::dims,typename Vector::stype>(phases.get(i).getPosVector()));
ver.Initialize(cl,r_cut,v.getPosVector(),v_phases,v.size_local());
return ver;
}
......@@ -65,20 +70,25 @@ template<unsigned int nbit, typename Vector, typename T> CellListM<Vector::dims,
/////// 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)
template<typename Vector,typename CL, typename T> VerletList<Vector::dims,typename Vector::stype,FAST,shift<Vector::dims,typename Vector::stype>> createVerletSym(Vector & v, Vector & v1, 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());
ver.Initialize(cl,r_cut,v.getPosVector(),v1.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)
template<unsigned int sh_byte, typename Vector, typename Vector1 ,typename CL, typename T> VerletListM<Vector::dims,typename Vector::stype,sh_byte,CL,shift<Vector::dims,typename Vector::stype>> createVerletSymM(Vector & v, Vector1 & phases, CL & cl, T r_cut)
{
VerletListM<Vector::dims,typename Vector::stype,sh_byte,shift<Vector::dims,typename Vector::stype>> ver;
VerletListM<Vector::dims,typename Vector::stype,sh_byte,CL,shift<Vector::dims,typename Vector::stype>> ver;
openfpm::vector<pos_v<Vector::dims,typename Vector::stype>> v_phases;
for (size_t i = 0 ; i < phases.size() ; i++)
v_phases.add(pos_v<Vector::dims,typename Vector::stype>(phases.get(i).getPosVector()));
ver.Initialize(cl,r_cut,v.getPosVector(),v.size_local(),VL_SYMMETRIC);
ver.Initialize(cl,r_cut,v.getPosVector(),v_phases,v.size_local(),VL_SYMMETRIC);
return ver;
}
......
......@@ -105,7 +105,7 @@ void Test2D_ghost(Box<2,float> & box)
typedef Point_test<float> p;
// Get the default minimum number of sub-sub-domain per processor (granularity of the decomposition)
size_t n_sub = vector_dist<2,float, Point_test<float>, CartDecomposition<2,float> >::getDefaultNsubsub() * v_cl.getProcessingUnits();
size_t n_sub = 64 * v_cl.getProcessingUnits();
// Convert the request of having a minimum n_sub number of sub-sub domain into grid decompsition of the space
size_t sz = CartDecomposition<2,float>::getDefaultGrid(n_sub);
......
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