8 #ifndef CARTDECOMPOSITION_HPP
9 #define CARTDECOMPOSITION_HPP
13 #include "VCluster/VCluster.hpp"
14 #include "Graph/CartesianGraphFactory.hpp"
15 #include "Decomposition.hpp"
16 #include "Vector/map_vector.hpp"
18 #include <initializer_list>
19 #include "SubdomainGraphNodes.hpp"
20 #include "dec_optimizer.hpp"
21 #include "Space/Shape/Box.hpp"
22 #include "Space/Shape/Point.hpp"
23 #include "NN/CellList/CellDecomposer.hpp"
24 #include <unordered_map>
25 #include "NN/CellList/CellList.hpp"
26 #include "Space/Ghost.hpp"
28 #include "ie_loc_ghost.hpp"
29 #include "ie_ghost.hpp"
30 #include "nn_processor.hpp"
31 #include "GraphMLWriter/GraphMLWriter.hpp"
32 #include "Distribution/ParMetisDistribution.hpp"
33 #include "Distribution/DistParMetisDistribution.hpp"
34 #include "Distribution/MetisDistribution.hpp"
35 #include "DLB/DLB.hpp"
36 #include "util/se_util.hpp"
37 #include "util/mathutil.hpp"
38 #include "CartDecomposition_ext.hpp"
39 #include "data_type/aggregate.hpp"
40 #include "Domain_NN_calculator_cart.hpp"
41 #include "cuda/CartDecomposition_gpu.cuh"
42 #include "Domain_icells_cart.hpp"
44 #define CARTDEC_ERROR 2000lu
63 template<
unsigned int dim>
static void nsub_to_div2(
size_t (& div)[dim],
size_t n_sub,
size_t dim_r)
65 for (
size_t i = 0; i < dim; i++)
68 {div[i] = openfpm::math::round_big_2(pow(n_sub, 1.0 / dim_r));}
85 template<
unsigned int dim>
static void nsub_to_div(
size_t (& div)[dim],
size_t n_sub,
size_t dim_r)
87 for (
size_t i = 0; i < dim; i++)
90 {div[i] = std::floor(pow(n_sub, 1.0 / dim_r));}
96 #define COMPUTE_SKIN_SUB 1
139 template<
unsigned int dim,
typename T,
typename Memory,
template <
typename>
class layout_base,
typename Distribution>
141 public nn_prcs<dim, T,layout_base,Memory>,
142 public ie_ghost<dim,T,Memory,layout_base>,
203 CellDecomposer_sm<dim, T, shift<dim,T>>
cd;
254 for (
size_t i = 0 ; i < dim ; i++) {
one[i] = 1;}
262 for (
size_t i = 0 ; i < dim ; i++)
264 loc_box.template get<Box<dim,T>::p1>()[i] = sub_dce.
getLow(i);
265 loc_box.template get<Box<dim,T>::p2>()[i] = sub_dce.
getHigh(i) - 1;
279 for (
size_t i = 0; i < dim; i++)
284 if (sub_dc.
getLow(i) == 0)
329 for (
size_t i = 0 ; i < dim ; i++)
335 void construct_fine_s()
353 while (g_sub.isNext())
355 auto key = g_sub.get();
381 for (
unsigned int i = 0; i < dim; i++)
388 initialize_fine_s(
domain);
398 for (
size_t i = 0 ; i < dim ; i++)
417 for (
size_t i = 0 ; i < dim ; i++)
470 for (
size_t i = 0; i < dim; i++)
471 {div[i] = (size_t) ((bound.
getHigh(i) - bound.
getLow(i)) /
cd.getCellBox().getP2()[i]);}
490 float b_s =
static_cast<float>(cellBox.
getHigh(0));
491 float gh_s =
static_cast<float>(
ghost.getHigh(0));
494 float gh_v = (gh_s * b_s);
497 for (
size_t i = 2; i < dim; i++)
503 size_t norm = (size_t) (1.0 / gh_v);
505 migration = pow(b_s, dim);
509 for (
size_t i = 0; i <
dist.getNSubSubDomains(); i++)
511 dist.setMigrationCost(i, norm * migration );
513 for (
size_t s = 0; s <
dist.getNSubSubDomainNeighbors(i); s++)
517 dist.setCommunicationCost(i, s, 1 * ts);
519 prev +=
dist.getNSubSubDomainNeighbors(i);
546 for (
int i = 0; i < dim; i++)
673 static constexpr
int dims = dim;
765 template<
typename encap_type>
inline static size_t id(
const encap_type & p,
size_t b_id)
767 return p.template get<proc_>();
785 template<
typename encap_type>
inline static size_t id(
const encap_type & p,
size_t b_id)
787 return p.template get<lc_proc_>();
805 template<
typename encap_type>
inline static size_t id(
const encap_type & p,
size_t b_id)
807 return p.template get<shift_id_>();
822 for (
size_t i = 0 ; i < dim ; i++)
824 if (
bc[i] == PERIODIC)
825 {pt[i] = openfpm::math::periodic_l(pt[i],
domain.getHigh(i),
domain.getLow(i));}
840 for (
size_t i = 0 ; i < dim ; i++)
842 if (
bc[i] == PERIODIC)
843 {pt.
get(i) = openfpm::math::periodic_l(pt.
get(i),
domain.getHigh(i),
domain.getLow(i));}
858 for (
size_t i = 0 ; i < dim ; i++)
860 if (
bc[i] == PERIODIC)
861 {pt.template get<0>()[i] = openfpm::math::periodic_l(pt.template get<0>()[i],
domain.getHigh(i),
domain.getLow(i));}
883 for (
size_t i = 0 ; i < dim ; i++)
894 for (
size_t i = 0 ; i < dim ; i++)
931 for (
size_t i = 0 ; i < dim ; i++)
941 for (
size_t i = 0 ; i < dim ; i++)
942 {cart.
bc[i] = this->bc[i];}
952 template<
typename Memory2,
template <
typename>
class layout_base2>
959 ie_ghost<dim,T,Memory,layout_base> * ptr =
static_cast<ie_ghost<dim,T,Memory,layout_base> *
>((
CartDecomposition<dim,T,Memory,layout_base,Distribution> *)
this);
972 for (
size_t i = 0 ; i < dim ; i++)
979 for (
size_t i = 0 ; i < dim ; i++)
1009 for (
size_t i = 0 ; i < dim ; i++)
1019 for (
size_t i = 0 ; i < dim ; i++)
1032 template<
typename CartDecomposition2>
1041 fine_s = cart.private_get_fine_s();
1042 gr = cart.private_get_gr();
1043 gr_dist = cart.private_get_gr_dist();
1044 dist = cart.private_get_dist();
1046 cd = cart.private_get_cd();
1047 domain = cart.private_get_domain();
1050 for (
size_t i = 0 ; i < dim ; i++)
1052 spacing[i] = cart.private_get_spacing(i);
1053 magn[i] = cart.private_get_magn(i);
1056 ghost = cart.private_get_ghost();
1058 bbox = cart.private_get_bbox();
1060 for (
size_t i = 0 ; i < dim ; i++)
1061 {
bc[i] = cart.private_get_bc(i);}
1093 for (
size_t i = 0 ; i < dim ; i++)
1096 magn[i] = cart.magn[i];
1103 for (
size_t i = 0 ; i < dim ; i++)
1124 return openfpm::math::round_big_2(pow(n_sub, 1.0 / dim));
1249 for (
size_t i = 0 ; i < dim ; i++)
1254 for (
size_t i = 0 ; i < dim ; i++)
1257 std::cerr << __FILE__ <<
":" << __LINE__ <<
".Error the decomposition grid specified as gr.size(" << i <<
")=" <<
gr.
size(i) <<
" is not multiple of the distribution grid gm.size(" << i <<
")=" << gm.
size(i) << std::endl;
1279 const size_t (&
bc)[dim],
1290 size_t n_sub = n_proc * dec_gran;
1295 nsub_to_div2(div,n_sub,dim);
1304 long int dim_r = dim-1;
1308 size_t tot_size = 1;
1309 for (
size_t i = 0 ; i < dim ; i++)
1310 {tot_size *= div[i];}
1313 if (tot_size / n_proc > (
unsigned int long)(0.75*dec_gran) )
1316 nsub_to_div(div,n_sub,dim_r);
1332 for (
size_t i = 0 ; i < dim ; i++)
1333 {div_[i] = this->gr.
size(i);}
1349 const size_t (&
bc)[dim],
1354 for (
size_t i = 0 ; i < dim ; i++)
1355 this->bc[i] =
bc[i];
1358 this->ghost =
ghost;
1366 if (sec_dist.size(0) != 0)
1416 if (opt != dec_options::DEC_SKIP_ICELL)
1482 if (dlb.
getHeurisitc() == DLB::Heuristic::UNBALANCE_THRLD)
1484 float unbalance =
dist.getUnbalance();
1488 std::cout << std::setprecision(3) << unbalance <<
"\n";
1509 return dist.getUnbalance();
1518 return dist.getProcessorLoad();
1529 dist.getSubSubDomainPosition(
id, pos);
1539 return dist.getNSubSubDomains();
1550 dist.setComputationCost(
id, weight);
1562 return dist.getSubSubDomainComputationCost(
id);
1571 return dist.subSize();
1598 for (
size_t k = 0; k < dim; k++)
1637 getSubDomains()
const
1700 for (
size_t i = 0 ; i < dim ; i++)
1702 if (
bc[i] == PERIODIC)
1703 pt.
get(i) = openfpm::math::periodic_l(p.template get<0>()[i],
domain.getHigh(i),
domain.getLow(i));
1725 for (
size_t i = 0 ; i < dim ; i++)
1727 if (
bc[i] == PERIODIC)
1728 pt.
get(i) = openfpm::math::periodic_l(p[i],
domain.getHigh(i),
domain.getLow(i));
1812 for (
size_t i = 0 ; i < dim ; i++)
1814 if (
bc[i] == PERIODIC)
1815 pt.
get(i) = openfpm::math::periodic_l(p[i],
domain.getHigh(i),
domain.getLow(i));
1887 vtk_box1.write(output + std::string(
"subdomains_") + std::to_string(
v_cl.
getProcessUnitID()) + std::string(
".vtk"));
1944 std::cout <<
"Subdomains\n";
1947 std::cout << Box<dim, T>(
sub_domains.get(p)).toString() <<
"\n";
1950 std::cout <<
"Subdomains global\n";
1956 std::cout <<
"External ghost box\n";
1958 for (
size_t p = 0; p<nn_prcs < dim, T, layout_base, Memory>::getNNProcessors(); p++)
1960 for (
size_t i = 0; i<ie_ghost <dim,T,Memory,layout_base>::getProcessorNEGhost(p); i++)
1962 std::cout << ie_ghost<dim,T,Memory,layout_base>::getProcessorEGhostBox(p, i).toString() <<
" prc=" <<
nn_prcs<dim, T, layout_base,Memory>::IDtoProc(p) <<
" id=" <<
ie_ghost<dim,T,Memory,layout_base>::getProcessorEGhostId(p, i) <<
"\n";
1966 std::cout <<
"Internal ghost box\n";
1968 for (
size_t p = 0; p<nn_prcs < dim, T, layout_base, Memory>::getNNProcessors(); p++)
1970 for (
size_t i = 0; i<ie_ghost<dim,T,Memory,layout_base>::getProcessorNIGhost(p); i++)
1972 std::cout << ie_ghost<dim,T,Memory,layout_base>::getProcessorIGhostBox(p, i).toString() <<
" prc=" <<
nn_prcs<dim, T, layout_base, Memory>::IDtoProc(p) <<
" id=" <<
ie_ghost<dim,T,Memory,layout_base>::getProcessorIGhostId(p, i) <<
"\n";
2083 size_t c =
dist.getSubSubDomainComputationCost(
gid);
2085 dist.setComputationCost(
gid, c + i);
2095 return dist.get_ndec();
2125 for (
int i = 0 ; i < dim ; i++) {bc_[i] = this->
periodicity(i);}
This class represent an N-dimensional box.
void expand(T(&exp)[dim])
expand the box by a vector
void mul(T(&sp)[dim])
multiply box p1,p2 points with the coefficients defined in sp
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
void enclose(const Box< dim, T > &en)
Refine the box to enclose the given box and itself.
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
bool isValidN() const
Check if the Box is a valid box P2 > P1.
class to select the returned id by ghost_processorID
static size_t id(p_box< dim, T > &p, size_t b_id)
Return the box id.
class to select the returned id by ghost_processorID
static size_t id(const encap_type &p, size_t b_id)
Return the near processor id.
class to select the returned id by ghost_processorID
static size_t id(const encap_type &p, size_t b_id)
Return the processor id.
class to select the returned id by ghost_processorID
static size_t id(const encap_type &p, size_t b_id)
Return the shift id.
This class decompose a space into sub-sub-domains and distribute them across processors.
This class decompose a space into sub-sub-domains and distribute them across processors.
size_t processorID(const Point< dim, T > &p) const
Given a point return in which processor the particle should go.
void setNNParameters(grid_key_dx< dim > &shift, grid_sm< dim, void > &gs)
set NN parameters to calculate cell-list neighborhood
Distribution & getDistribution()
Return the distribution object.
void calculateGhostBoxes()
It calculate the internal ghost boxes.
grid_sm< dim, void > gr_dist
Structure that store the cartesian grid information.
static size_t getDefaultGrid(size_t n_sub)
The default grid size.
T domain_type
Type of the domain we are going to decompose.
openfpm::vector< size_t > & getDomainCells()
Get the domain Cells.
bool check_consistency()
function to check the consistency of the information of the decomposition
size_t processorID(const T(&p)[dim]) const
Given a point return in which processor the particle should go.
Vcluster & v_cl
Runtime virtual cluster machine.
Ghost< dim, T > ghost
ghost info
bool isLocal(const encapc< 1, Point< dim, T >, Mem > p) const
Check if the particle is local.
void setParameters(const size_t(&div_)[dim], Box< dim, T > &domain_, const size_t(&bc)[dim], const Ghost< dim, T > &ghost, const grid_sm< dim, void > &sec_dist=grid_sm< dim, void >())
Set the parameter of the decomposition.
openfpm::vector< openfpm::vector< long unsigned int > > & private_get_box_nn_processor()
Return the internal data structure box_nn_processor.
T & private_get_magn(int i)
Return the internal data structure magn.
grid_sm< dim, void > & private_get_gr_dist()
Return the internal data structure gr_dist.
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
CartDecomposition_gpu< dim, T, Memory, layout_base > toKernel()
convert to a structure usable in a device kernel
void applyPointBC(float(&pt)[dim]) const
Apply boundary condition to the point.
CartDecomposition< dim, T, Memory, layout_base, Distribution > duplicate(const Ghost< dim, T > &g) const
It create another object that contain the same decomposition information but with different ghost box...
openfpm::vector< openfpm::vector< long unsigned int > > box_nn_processor
for each sub-domain, contain the list of the neighborhood processors
T & private_get_spacing(int i)
Return the internal data structure spacing.
CartDecomposition(Vcluster<> &v_cl)
Cartesian decomposition constructor.
size_t processorIDBC(encapc< 1, Point< dim, T >, Mem > p)
Given a point return in which processor the point/particle should go.
size_t processorID(const encapc< 1, Point< dim, T >, Mem > &p) const
Given a point return in which processor the particle should go.
long int ref_cnt
reference counter of the object in case is shared between object
const grid_sm< dim, void > getDistGrid()
Distribution grid.
size_t getProcessorLoad()
Compute the processor load counting the total weights of its vertices.
CellDecomposer_sm< dim, T, shift< dim, T > > cd
const Box< dim, T > & getDomain() const
Return the box of the physical domain.
void decompose(dec_options opt=dec_options::DEC_NONE)
Start decomposition.
bool is_equal(CartDecomposition< dim, T, Memory > &cart)
Check if the CartDecomposition contain the same information.
grid_sm< dim, void > & private_get_gr()
Return the internal data structure gr.
const grid_sm< dim, void > getGrid()
Decomposition grid.
CartDecomposition(CartDecomposition< dim, T, Memory, layout_base, Distribution > &&cart)
Cartesian decomposition copy constructor.
const Ghost< dim, T > & private_get_ghost() const
Return the internal data structure ghost.
size_t getNSubSubDomains()
Get the number of sub-sub-domains in this sub-graph.
void addComputationCost(size_t gid, size_t i)
Add computation cost i to the subsubdomain with global id gid.
Box< dim, T > bbox
Processor bounding box.
Box< dim, T > getSubDomainWithGhost(size_t lc)
Get the local sub-domain enlarged with ghost extension.
CartDecomposition< dim, T, Memory, layout_base, Distribution > base_type
It simplify to access the Box element.
void computeCommunicationAndMigrationCosts(size_t ts)
Calculate communication and migration costs.
long int ref()
Return the reference counter.
Box< dim, T > & getProcessorBounds()
Return the bounding box containing union of all the sub-domains for the local processor.
openfpm::vector< Box< dim, size_t > > loc_boxes
set of Boxes produced by the decomposition optimizer
CartDecomposition< dim, T, Memory, layout_base, Distribution > & operator=(CartDecomposition &&cart)
Copy the element, move semantic.
const Ghost< dim, T > & getGhost() const
Return the ghost.
bool & private_get_commCostSet()
Return the internal data structure commCostSet.
Vcluster & getVC() const
Get the Virtual Cluster machine.
bool write(std::string output) const
Write the decomposition as VTK file.
Box< dim, T > & private_get_domain()
Return the internal data structure domain.
size_t periodicity(size_t i) const
Get the periodicity on i dimension.
void getParameters(size_t(&div_)[dim])
return the parameters of the decomposition
Distribution & private_get_dist()
Return the internal data structure dist.
T spacing[dim]
Box Spacing.
CartDecomposition(const CartDecomposition< dim, T, Memory, layout_base, Distribution > &cart)
Cartesian decomposition copy constructor.
CartDecomposition< dim, T, Memory2, layout_base2, Distribution > duplicate_convert() const
It create another object that contain the same information and act in the same way.
Box< dim, T > & private_get_bbox()
Return the internal data structure bbox.
const grid_sm< dim, void > & private_get_gr() const
Return the internal data structure gr.
Ghost< dim, T > & private_get_ghost()
Return the internal data structure ghost.
openfpm::vector< Box< dim, T >, Memory, memory_traits_lin, openfpm::vector_grow_policy_default, openfpm::vect_isel< Box< dim, T > >::value >::access_key acc_key
void getSubSubDomainPosition(size_t id, T(&pos)[dim])
function that return the position of the cell in the space
CellDecomposer_sm< dim, T, shift< dim, T > > & private_get_cd()
Return the internal data structure cd.
void calculate_magn(const grid_sm< dim, void > &gm)
Calculate magnification.
const bool & private_get_commCostSet() const
Return the internal data structure commCostSet.
void setSubSubDomainComputationCost(size_t id, size_t weight)
Function that set the computational cost for a of a sub-sub domain.
CartDecomposition< dim, T, Memory, layout_base, Distribution > duplicate() const
It create another object that contain the same information and act in the same way.
const T & private_get_spacing(int i) const
Return the internal data structure spacing.
bool commCostSet
Indicate the communication weight has been set.
bool host_dev_transfer
bool that indicate whenever the buffer has been already transfer to device
size_t getNSubDomain()
Get the number of local sub-domains.
bool refine(DLB &dlb)
Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call.
openfpm::vector< Box_map< dim, T >, Memory, layout_base > & private_get_sub_domains_global()
Return the internal data structure sub_domains_global.
const openfpm::vector< openfpm::vector< long unsigned int > > & private_get_box_nn_processor() const
Return the internal data structure box_nn_processor.
const Distribution & private_get_dist() const
Return the internal data structure dist.
grid_sm< dim, void > gr
Structure that store the cartesian grid information.
bool isLocalBC(const encapc< 1, Point< dim, T >, Mem > p, const size_t(&bc)[dim]) const
Check if the particle is local considering boundary conditions.
bool isLocal(const T(&pos)[dim]) const
Check if the particle is local.
openfpm::vector< Box< dim, T > > & private_get_sub_domains()
Return the internal data structure sub_domains.
const grid_sm< dim, void > & private_get_gr_dist() const
Return the internal data structure gr_dist.
void setGoodParameters(Box< dim, T > &domain_, const size_t(&bc)[dim], const Ghost< dim, T > &ghost, size_t dec_gran, const grid_sm< dim, void > &sec_dist=grid_sm< dim, void >())
Set the best parameters for the decomposition.
const size_t & private_get_bc(int i) const
Return the internal data structure bc.
const size_t(& periodicity() const)[dim]
Get the periodicity.
bool isLocalBC(const Point< dim, T > &p, const size_t(&bc)[dim]) const
Check if the particle is local considering boundary conditions.
void createSubdomains(Vcluster<> &v_cl, const size_t(&bc)[dim], size_t opt=0)
Constructor, it decompose and distribute the sub-domains across the processors.
Box< dim, size_t > proc_box
Processor domain bounding box.
Box< dim, T > convertDecBoxIntoSubDomain(encapc< 1, Box< dim, size_t >, Memory_bx > loc_box)
It convert the box from the domain decomposition into sub-domain.
friend extended_type
friend classes
openfpm::vector< subsub_lin< dim > > & getCRSAnomDomainCells()
Get the CRS anomalous cells.
void incRef()
Increment the reference counter.
Distribution dist
Create distribution.
size_t subSize()
Operator to access the size of the sub-graph.
CartDecomposition< dim, T, Memory, layout_base, Distribution > & operator=(const CartDecomposition2 &cart)
Copy the element.
void free_fines()
Deallocate structures that identify a point to which internal ghost is located.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_get_fine_s()
Return the internal data structure fine_s.
size_t & private_get_bc(int i)
Return the internal data structure bc.
const Box< dim, T > & private_get_bbox() const
Return the internal data structure bbox.
const T & private_get_magn(int i) const
Return the internal data structure magn.
CartDecomposition_ext< dim, T, Memory, layout_base, Distribution > extended_type
This class admit a class defined on an extended domain.
size_t bc[dim]
Boundary condition info.
const CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_get_fine_s() const
Return the internal data structure fine_s.
void CreateSubspaces()
Create the sub-domain that decompose your domain.
const Box< dim, T > & private_get_domain() const
Return the internal data structure domain.
float getUnbalance()
Get the current un-balance value.
void applyPointBC(Point< dim, T > &pt) const
Apply boundary condition to the point.
size_t processorIDBC(const T(&p)[dim]) const
Given a point return in which processor the particle should go.
void debugPrint()
Print subdomains, external and internal ghost boxes.
bool isLocal(const Point< dim, T > &pos) const
Check if the particle is local.
static constexpr int dims
Space dimensions.
const openfpm::vector< Box< dim, T > > & private_get_sub_domains() const
Return the internal data structure sub_domains.
void decRef()
Decrement the reference counter.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > fine_s
const CellDecomposer_sm< dim, T, shift< dim, T > > & getCellDecomposer()
Get the cell decomposer of the decomposition.
const CellDecomposer_sm< dim, T, shift< dim, T > > & private_get_cd() const
Return the internal data structure cd.
void reset()
Delete the decomposition and reset the data-structure.
Box< dim, T > getSubDomain(size_t lc)
Get the local sub-domain.
const openfpm::vector< Box_map< dim, T >, Memory, layout_base > & private_get_sub_domains_global() const
Return the internal data structure sub_domains_global.
bool isLocalBC(const T(&p)[dim], const size_t(&bc)[dim]) const
Check if the particle is local considering boundary conditions.
openfpm::vector< Box< dim, T >, Memory, layout_base > sub_domains
the set of all local sub-domain as vector
size_t processorIDBC(const Point< dim, T > &p) const
Given a point return in which processor the particle should go.
bool is_equal_ng(CartDecomposition< dim, T, Memory > &cart)
Check if the CartDecomposition contain the same information with the exception of the ghost part It i...
~CartDecomposition()
Cartesian decomposition destructor.
size_t getSubSubDomainComputationCost(size_t id)
function that return the computation cost of the sub-sub-domain id
openfpm::vector< Box_map< dim, T >, Memory, layout_base > sub_domains_global
the remote set of all sub-domains as vector of 'sub_domains' vectors
Box< dim, T > domain
rectangular domain to decompose
void redecompose(size_t ts)
Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call.
size_t get_ndec()
Get the decomposition counter.
void refine(size_t ts)
Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call.
void applyPointBC(encapc< 1, Point< dim, T >, Mem > &&pt) const
Apply boundary condition to the point.
CartDecomposition< dim, T, Memory, layout_base, Distribution > & operator=(const CartDecomposition &cart)
Copy the element.
void Initialize_geo_cell_lists()
Initialize geo_cell lists.
openfpm::vector< size_t > & getCRSDomainCells()
Get the CRS domain Cells with normal neighborhood.
Class for FAST cell list implementation.
const grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
void clear()
Clear the cell list.
void destroy()
Litterary destroy the memory of the cell list, including the retained one.
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
void Initialize(CellDecomposer_sm< dim, T, transform > &cd_sm, const Box< dim, T > &dom_box, const size_t pad=1, size_t slot=STARTING_NSLOT)
bool rebalanceNeeded()
check if a re-balance is needed using the selected heuristic
void setUnbalance(float u)
Set un-balance value.
size_t getNTimeStepSinceDLB()
Get how many time-steps have passed since the last re-balancing.
Heuristic getHeurisitc()
Get the heuristic.
void addCell(local_index cell_id, local_index ele)
Add an element to the cell.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
void execute()
Execute all the requests.
size_t rank()
Get the process unit id.
bool Bcast(openfpm::vector< T, Mem, layout_base > &v, size_t root)
Broadcast the data to all processors.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
void max(T &num)
Get the maximum number across all processors (or reduction with infinity norm)
Implementation of VCluster class.
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
This class take a graph representing the space decomposition and produce a simplified version.
void CalculateInternalCells(VCluster_type &v_cl, openfpm::vector< Box< dim, T >, Memory, layout_base > &ig_box, openfpm::vector< Box< dim, T >, Memory, layout_base > &domain, Box< dim, T > &pbox, T r_cut, const Ghost< dim, T > &enlarge)
Calculate the subdomain that are in the skin part of the domain.
This class calculate processor domains and neighborhood of each processor domain.
openfpm::vector< subsub_lin< dim > > & getCRSAnomDomainCells()
Get the domain anomalous cells.
grid_sm< dim, void > gs
Processor cells-grid.
void setParameters(const Box< dim, long int > &proc_box)
Set parameters to calculate the cell neighborhood.
void reset()
In case you have to recompute the indexes.
void setNNParameters(openfpm::vector<::Box< dim, size_t >> &loc_box, const grid_key_dx< dim > &shift, const grid_sm< dim, void > &gs)
Set parameters to calculate the cell neighborhood.
openfpm::vector< size_t > & getDomainCells()
Get the domain Cells.
openfpm::vector< size_t > & getCRSDomainCells()
Get the domain Cells.
grid_key_dx< dim > one
key with all coordinates set to one
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
__device__ __host__ index_type get(index_type i) const
Get the i index.
void setDimensions(const size_t(&dims)[N])
Reset the dimension of the grid.
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
__device__ __host__ size_t size() const
Return the size of the grid.
structure that store and compute the internal and external local ghost box
void reset_host_dev_transfer()
Notify that the next toKernel() data-structures must be re-offloaded.
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
void reset()
Reset the nn_prcs structure.
bool write(std::string output, size_t p_id) const
write the information about the ghost in vtk format
void create_box_nn_processor_int(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< Box< dim, T >, Memory, layout_base > &sub_domains, const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const nn_prcs< dim, T, layout_base, Memory > &nn_p)
Create the box_nn_processor_int (nbx part) structure, the geo_cell list and proc_int_box.
size_t getProcessorEGhostId(size_t id, size_t j) const
Get the j External ghost box id.
void generateShiftVectors(const Box< dim, T > &domain, size_t(&bc)[dim])
Here we generare the shift vectors.
void Initialize_geo_cell(const Box< dim, T > &domain, const size_t(&div)[dim])
Initialize the geo cell list structure.
void create_box_nn_processor_ext(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< Box< dim, T >, Memory, layout_base > &sub_domains, const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const nn_prcs< dim, T, layout_base, Memory > &nn_p)
Create the box_nn_processor_int (bx part) structure.
size_t getProcessorIGhostId(size_t id, size_t j) const
Get the j Internal ghost box id.
structure that store and compute the internal and external local ghost box
bool write(std::string output, size_t p_id) const
Write the decomposition as VTK file.
void create(openfpm::vector< Box< dim, T >, Memory, layout_base > &sub_domains, Box< dim, T > &domain, Ghost< dim, T > &ghost, const size_t(&bc)[dim])
Create external and internal local ghosts.
void reset()
Reset the ie_loc_ghost.
This class store the adjacent processors and the adjacent sub_domains.
static bool check_valid(comb< dim > cmb, const size_t(&bc)[dim])
void applyBC(const Box< dim, T > &domain, const Ghost< dim, T > &ghost, const size_t(&bc)[dim])
Apply boundary conditions.
void create(const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const openfpm::vector< Box< dim, T >, Memory, layout_base > &sub_domains)
Create the list of adjacent processors and the list of adjacent sub-domains.
bool write(std::string output) const
Write the decomposition as VTK file.
size_t IDtoProc(size_t id) const
Return the processor id of the near processor list at place id.
void reset()
Reset the nn_prcs structure.
Implementation of 1-D std::vector like structure.
grow_policy_double vector_grow_policy_default
default grow policy
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Transform the boost::fusion::vector into memory specification (memory_traits)
sub-domain edge graph node
It analyze the type given and it select correctly the implementation for vector.
It store all the boxes of the near processors in a linear array.