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++)
279 for (
size_t i = 0; i < dim; i++)
284 if (sub_dc.
getLow(i) == 0)
323 void initialize_fine_s(const ::Box<dim,T> &
domain)
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++)
400 ghe.setLow(i,static_cast<long int>(
ghost.getLow(i)/
spacing[i]) - 1);
401 ghe.setHigh(i,static_cast<long int>(
ghost.getHigh(i)/
spacing[i]) + 1);
417 for (
size_t i = 0 ; i < dim ; i++)
428 for (
size_t s = 1; s <
loc_box.size(); s++)
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 << ::SpaceBox<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);}
size_t getNSubDomain()
Get the number of local sub-domains.
size_t get_ndec()
Get the decomposition counter.
openfpm::vector< SpaceBox< dim, T >, Memory, memory_traits_lin, openfpm::vector_grow_policy_default, openfpm::vect_isel< SpaceBox< dim, T > >::value >::access_key acc_key
openfpm::vector< Box_map< dim, T >, Memory, layout_base > & private_get_sub_domains_global()
Return the internal data structure sub_domains_global.
openfpm::vector< openfpm::vector< long unsigned int > > & private_get_box_nn_processor()
Return the internal data structure box_nn_processor.
This class represent an N-dimensional box.
size_t & private_get_bc(int i)
Return the internal data structure bc.
void addCell(size_t cell_id, typename Mem_type::local_index_type ele)
Add to the cell.
static size_t id(const encap_type &p, size_t b_id)
Return the near processor id.
openfpm::vector< openfpm::vector< long unsigned int > > box_nn_processor
for each sub-domain, contain the list of the neighborhood processors
Ghost< dim, T > ghost
ghost info
CartDecomposition_ext< dim, T, Memory, layout_base, Distribution > extended_type
This class admit a class defined on an extended 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.
const bool & private_get_commCostSet() const
Return the internal data structure commCostSet.
Transform the boost::fusion::vector into memory specification (memory_traits)
openfpm::vector< size_t > & getCRSDomainCells()
Get the CRS domain Cells with normal neighborhood.
SpaceBox< dim, T > convertDecBoxIntoSubDomain(encapc< 1,::Box< dim, size_t >, Memory_bx > loc_box)
It convert the box from the domain decomposition into sub-domain.
long int ref_cnt
reference counter of the object in case is shared between object
void getSubSubDomainPosition(size_t id, T(&pos)[dim])
function that return the position of the cell in the space
bool check_consistency()
function to check the consistency of the information of the decomposition
Heuristic getHeurisitc()
Get the heuristic.
size_t getProcessUnitID()
Get the process unit id.
bool write(std::string output) const
Write the decomposition as VTK file.
openfpm::vector< size_t > & getDomainCells()
Get the domain Cells.
size_t processorID(const encapc< 1, Point< dim, T >, Mem > &p) const
Given a point return in which processor the particle should go.
This class decompose a space into sub-sub-domains and distribute them across processors.
::Box< dim, T > & private_get_domain()
Return the internal data structure domain.
openfpm::vector< subsub_lin< dim > > & getCRSAnomDomainCells()
Get the domain anomalous cells.
void setParameters(const Box< dim, long int > &proc_box)
Set parameters to calculate the cell neighborhood.
Distribution & getDistribution()
Return the distribution object.
size_t getProcessorEGhostId(size_t id, size_t j) const
Get the j External ghost box id.
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...
void create_box_nn_processor_int(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< SpaceBox< 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.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_get_fine_s()
Return the internal data structure fine_s.
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.
__device__ __host__ size_t size() const
Return the size of the grid.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Distribution & private_get_dist()
Return the internal data structure dist.
::Box< dim, T > bbox
Processor bounding box.
CartDecomposition< dim, T, Memory, layout_base, Distribution > & operator=(const CartDecomposition &cart)
Copy the element.
void mul(T(&sp)[dim])
multiply the space box with the coefficient defined in sp
void Initialize_geo_cell_lists()
Initialize geo_cell lists.
T spacing[dim]
Box Spacing.
const CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > & private_get_fine_s() const
Return the internal data structure fine_s.
Ghost< dim, T > & private_get_ghost()
Return the internal data structure ghost.
void CreateSubspaces()
Create the sub-domain that decompose your domain.
void clear()
Clear the cell list.
bool write(std::string output, size_t p_id) const
Write the decomposition as VTK file.
Vcluster & v_cl
Runtime virtual cluster machine.
friend extended_type
friend classes
const Ghost< dim, T > & private_get_ghost() const
Return the internal data structure ghost.
void computeCommunicationAndMigrationCosts(size_t ts)
Calculate communication and migration costs.
void reset()
Reset the nn_prcs structure.
void reset()
Delete the decomposition and reset the data-structure.
::Box< dim, T > domain
rectangular domain to decompose
size_t processorID(const Point< dim, T > &p) const
Given a point return in which processor the particle should go.
void create(openfpm::vector< SpaceBox< 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 destroy()
Litterary destroy the memory of the cell list, including the retained one.
openfpm::vector< SpaceBox< dim, T > > & private_get_sub_domains()
Return the internal data structure sub_domains.
grid_key_dx< dim > one
key with all coordinates set to one
bool write(std::string output) const
Write the decomposition as VTK file.
__device__ __host__ index_type get(index_type i) const
Get the i index.
SpaceBox< dim, T > getSubDomainWithGhost(size_t lc)
Get the local sub-domain enlarged with ghost extension.
This class implement the point shape in an N-dimensional space.
const grid_sm< dim, void > & private_get_gr_dist() const
Return the internal data structure gr_dist.
grow_policy_double vector_grow_policy_default
default grow policy
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
size_t getSubSubDomainComputationCost(size_t id)
function that return the computation cost of the sub-sub-domain id
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...
bool rebalanceNeeded()
check if a re-balance is needed using the selected heuristic
grid_sm< dim, void > & private_get_gr()
Return the internal data structure gr.
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.
const grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
grid_sm< dim, void > & private_get_gr_dist()
Return the internal data structure gr_dist.
CellList< dim, T, Mem_fast< Memory, int >, shift< dim, T > > fine_s
bool isLocal(const T(&pos)[dim]) const
Check if the particle is local.
const ::Box< dim, T > & getDomain() const
Return the box of the physical 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 openfpm::vector< openfpm::vector< long unsigned int > > & private_get_box_nn_processor() const
Return the internal data structure box_nn_processor.
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.
void expand(T(&exp)[dim])
expand the box by a vector
class to select the returned id by ghost_processorID
grid_sm< dim, void > gr
Structure that store the cartesian grid information.
void decRef()
Decrement the reference counter.
void setSubSubDomainComputationCost(size_t id, size_t weight)
Function that set the computational cost for a of a sub-sub domain.
Implementation of VCluster class.
SpaceBox< dim, T > Box
It simplify to access the SpaceBox element.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
CartDecomposition(const CartDecomposition< dim, T, Memory, layout_base, Distribution > &cart)
Cartesian decomposition copy constructor.
void Initialize_geo_cell(const Box< dim, T > &domain, const size_t(&div)[dim])
Initialize the geo cell list structure.
void execute()
Execute all the requests.
const CellDecomposer_sm< dim, T, shift< dim, T > > & getCellDecomposer()
Get the cell decomposer of the decomposition.
Distribution dist
Create distribution.
void setNNParameters(grid_key_dx< dim > &shift, grid_sm< dim, void > &gs)
set NN parameters to calculate cell-list neighborhood
void free_geo_cell()
Deallocate structures that identify a point to which internal ghost is located.
CellDecomposer_sm< dim, T, shift< dim, T > > cd
openfpm::vector< size_t > & getCRSDomainCells()
Get the domain Cells.
void generateShiftVectors(const Box< dim, T > &domain, size_t(&bc)[dim])
Here we generare the shift vectors.
void reset()
Reset the ie_loc_ghost.
::Box< dim, T > & getProcessorBounds()
Return the bounding box containing union of all the sub-domains for the local processor.
void applyBC(const Box< dim, T > &domain, const Ghost< dim, T > &ghost, const size_t(&bc)[dim])
Apply boundary conditions.
static size_t id(const encap_type &p, size_t b_id)
Return the shift id.
size_t getNTimeStepSinceDLB()
Get how many time-steps have passed since the last re-balancing.
const size_t & private_get_bc(int i) const
Return the internal data structure bc.
grid_sm< dim, void > gs
Processor cells-grid.
size_t getProcessorLoad()
Compute the processor load counting the total weights of its vertices.
bool write(std::string output, size_t p_id) const
write the information about the ghost in vtk format
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
T & private_get_spacing(int i)
Return the internal data structure spacing.
void calculate_magn(const grid_sm< dim, void > &gm)
Calculate magnification.
This class decompose a space into sub-sub-domains and distribute them across processors.
void enclose(const Box< dim, T > &en)
Refine the box to enclose the given box and itself.
size_t processorID(const T(&p)[dim]) const
Given a point return in which processor the particle should go.
size_t getNSubSubDomains()
Get the number of sub-sub-domains in this sub-graph.
~CartDecomposition()
Cartesian decomposition destructor.
bool host_dev_transfer
bool that indicate whenever the buffer has been already transfer to device
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
void addComputationCost(size_t gid, size_t i)
Add computation cost i to the subsubdomain with global id gid.
sub-domain edge graph node
CartDecomposition< dim, T, Memory, layout_base, Distribution > base_type
This class is base of itself.
It analyze the type given and it select correctly the implementation for vector.
const grid_key_dx< dim > & get() const
Get the actual key.
size_t bc[dim]
Boundary condition info.
structure that store and compute the internal and external local ghost box
const size_t(& periodicity() const)[dim]
Get the periodicity.
size_t rank()
Get the process unit id.
openfpm::vector< SpaceBox< dim, T >, Memory, layout_base > sub_domains
the set of all local sub-domain as vector
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
const openfpm::vector< SpaceBox< dim, T > > & private_get_sub_domains() const
Return the internal data structure sub_domains.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
const size_t(& getSize() const)[N]
Return the size of the grid as an array.
void CalculateInternalCells(VCluster_type &v_cl, openfpm::vector< Box< dim, T >, Memory, layout_base > &ig_box, openfpm::vector< SpaceBox< 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.
void reset()
In case you have to recompute the indexes.
void reset_host_dev_transfer()
Notify that the next toKernel() data-structures must be re-offloaded.
class to select the returned id by ghost_processorID
size_t processorIDBC(const T(&p)[dim]) const
Given a point return in which processor the particle should go.
::Box< dim, size_t > proc_box
Processor domain bounding box.
void applyPointBC(encapc< 1, Point< dim, T >, Mem > &&pt) const
Apply boundary condition to the point.
void debugPrint()
Print subdomains, external and internal ghost boxes.
bool isLocal(const encapc< 1, Point< dim, T >, Mem > p) const
Check if the particle is local.
size_t getProcessingUnits()
Get the total number of processors.
void redecompose(size_t ts)
Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call.
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)
size_t IDtoProc(size_t id) const
Return the processor id of the near processor list at place id.
openfpm::vector< size_t > & getDomainCells()
Get the domain Cells.
void decompose(dec_options opt=dec_options::DEC_NONE)
Start decomposition.
void calculateGhostBoxes()
It calculate the internal ghost boxes.
T & private_get_magn(int i)
Return the internal data structure magn.
Vcluster & getVC() const
Get the Virtual Cluster machine.
void free_fines()
Deallocate structures that identify a point to which internal ghost is located.
const T & private_get_spacing(int i) const
Return the internal data structure spacing.
const T & private_get_magn(int i) const
Return the internal data structure magn.
bool is_equal(CartDecomposition< dim, T, Memory > &cart)
Check if the CartDecomposition contain the same information.
size_t getProcessorIGhostId(size_t id, size_t j) const
Get the j Internal ghost box id.
void create(const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const openfpm::vector< SpaceBox< dim, T >, Memory, layout_base > &sub_domains)
Create the list of adjacent processors and the list of adjacent sub-domains.
bool commCostSet
Indicate the communication weight has been set.
bool isLocalBC(const T(&p)[dim], const size_t(&bc)[dim]) const
Check if the particle is local considering boundary conditions.
size_t periodicity(size_t i) const
Get the periodicity on i dimension.
static constexpr int dims
Space dimensions.
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
This class take a graph representing the space decomposition and produce a simplified version.
T domain_type
Type of the domain we are going to decompose.
structure that store and compute the internal and external local ghost box
void incRef()
Increment the reference counter.
bool & private_get_commCostSet()
Return the internal data structure commCostSet.
class to select the returned id by ghost_processorID
CartDecomposition< dim, T, Memory, layout_base, Distribution > & operator=(const CartDecomposition2 &cart)
Copy the element.
static size_t id(p_box< dim, T > &p, size_t b_id)
Return the box id.
size_t processorIDBC(const Point< dim, T > &p) const
Given a point return in which processor the particle should go.
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
bool refine(DLB &dlb)
Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call.
grid_sm< dim, void > gr_dist
Structure that store the cartesian grid information.
CartDecomposition(Vcluster<> &v_cl)
Cartesian decomposition constructor.
bool Bcast(openfpm::vector< T, Mem, layout_base > &v, size_t root)
Broadcast the data to all processors.
const ::Box< dim, T > & private_get_domain() const
Return the internal data structure domain.
static size_t id(const encap_type &p, size_t b_id)
Return the processor id.
static bool check_valid(comb< dim > cmb, const size_t(&bc)[dim])
void applyPointBC(Point< dim, T > &pt) const
Apply boundary condition to the point.
This class calculate processor domains and neighborhood of each processor domain.
void create_box_nn_processor_ext(Vcluster<> &v_cl, Ghost< dim, T > &ghost, openfpm::vector< SpaceBox< 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.
const grid_sm< dim, void > getGrid()
Decomposition grid.
const grid_sm< dim, void > getDistGrid()
Distribution grid.
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.
const CellDecomposer_sm< dim, T, shift< dim, T > > & private_get_cd() const
Return the internal data structure cd.
void refine(size_t ts)
Refine the decomposition, available only for ParMetis distribution, for Metis it is a null call.
openfpm::vector< subsub_lin< dim > > & getCRSAnomDomainCells()
Get the CRS anomalous cells.
void max(T &num)
Get the maximum number across all processors (or reduction with infinity norm)
CellDecomposer_sm< dim, T, shift< dim, T > > & private_get_cd()
Return the internal data structure cd.
size_t processorIDBC(encapc< 1, Point< dim, T >, Mem > p)
Given a point return in which processor the point/particle should go.
const ::Box< dim, T > & private_get_bbox() const
Return the internal data structure bbox.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
class to select the returned id by ghost_processorID
void getParameters(size_t(&div_)[dim])
return the parameters of the decomposition
float getUnbalance()
Get the current un-balance value.
It store all the boxes of the near processors in a linear array.
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.
SpaceBox< dim, T > getSubDomain(size_t lc)
Get the local sub-domain.
CartDecomposition< dim, T, Memory, layout_base, Distribution > & operator=(CartDecomposition &&cart)
Copy the element, move semantic.
CartDecomposition(CartDecomposition< dim, T, Memory, layout_base, Distribution > &&cart)
Cartesian decomposition copy constructor.
bool isLocal(const Point< dim, T > &pos) const
Check if the particle is local.
bool isValidN() const
Check if the Box is a valid box P2 > P1.
CartDecomposition_gpu< dim, T, Memory, layout_base > toKernel()
convert to a structure usable in a device kernel
Implementation of 1-D std::vector like structure.
size_t subSize()
Operator to access the size of the sub-graph.
long int ref()
Return the reference counter.
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.
Class for FAST cell list implementation.
const grid_sm< dim, void > & private_get_gr() const
Return the internal data structure gr.
__device__ __host__ T getHigh(int i) const
get the high interval of the box
bool isNext()
Check if there is the next element.
::Box< dim, T > & private_get_bbox()
Return the internal data structure bbox.
const Ghost< dim, T > & getGhost() const
Return the ghost.
void setDimensions(const size_t(&dims)[N])
Reset the dimension of the grid.
void applyPointBC(float(&pt)[dim]) const
Apply boundary condition to the point.
const Distribution & private_get_dist() const
Return the internal data structure dist.
ie_ghost_gpu< dim, T, Memory, layout_base > toKernel()
toKernel() Convert this data-structure into a kernel usable data-structure
bool isLocalBC(const Point< dim, T > &p, const size_t(&bc)[dim]) const
Check if the particle is local considering boundary conditions.
static size_t getDefaultGrid(size_t n_sub)
The default grid size.
void setUnbalance(float u)
Set un-balance value.
void reset()
Reset the nn_prcs structure.
openfpm::vector<::Box< dim, size_t > > loc_box
set of Boxes produced by the decomposition optimizer
This class store the adjacent processors and the adjacent sub_domains.