8 #ifndef SRC_DECOMPOSITION_NN_PROCESSOR_HPP_
9 #define SRC_DECOMPOSITION_NN_PROCESSOR_HPP_
12 #include <unordered_map>
22 template<
unsigned int dim,
typename T>
95 for (
size_t k = 0 ; k < dim ; k++)
139 static void *
message_alloc(
size_t msg_i ,
size_t total_msg,
size_t total_p,
size_t i,
size_t ri,
void * ptr)
163 nnpst.
r_sub.add(r_sub);
179 for (
long int i = dim-1 ; i >= 0 ; i--)
183 for (
size_t j = 0 ; j < cmbs.size() ; j++)
192 for (
size_t k = 0 ; k < dim ; k++)
222 for (
size_t l = 0 ; l < nn_sub.
size(); l++)
257 for (
size_t i = 0 ; i < nnp_bx.
bx.
size() ; i++)
262 nnps.
bx.add(nnps_tmp.
bx.get(i));
263 nnps.
pos.add(nnps_tmp.
pos.get(i));
306 if (cmb.n_zero() == dim)
309 for (
size_t i = 0 ; i < dim ; i++)
311 if (bc[i] == NON_PERIODIC && cmb.
getComb()[i] != 0)
360 for (
size_t i = 0 ; i < box_nn_processor.size() ; i++)
362 for (
size_t j = 0 ; j < box_nn_processor.get(i).size() ; j++)
376 for (
size_t i = 0 ; i < box_nn_processor.size() ; i++)
378 for (
size_t j = 0 ; j < box_nn_processor.get(i).size() ; j++)
381 size_t proc_id = box_nn_processor.get(i).get(j);
397 for (
size_t b = 0 ; b < box_nn_processor.size() ; b++)
399 for (
size_t p = 0 ; p < box_nn_processor.get(b).size() ; p++)
401 size_t prc = box_nn_processor.get(b).get(p);
407 boxes.get(
id).add(sub_domains.get(b));
422 for (
size_t i = 0 ; i < nnp_bx.
bx.
size() ; i++)
471 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" error this process rank is not adjacent to the local processor";
475 return key->second.r_sub;
491 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" error this process rank is not adjacent to the local processor";
495 return key->second.bx;
513 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" error this process rank is not adjacent to the local processor";
517 return key->second.n_real_sub;
533 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" error this process rank is not adjacent to the local processor";
536 return key->second.pos;
552 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" error this process rank is not adjacent to the local processor";
555 return key->second.id;
585 std::cerr <<
"Error " << __FILE__ <<
":" << __LINE__ <<
" error this process rank is not adjacent to the local processor";
589 return key->second.id;
605 bool write(std::string output)
const
616 vtk_box2.write(output + std::string(
"subdomains_adjacent_") + std::to_string(
v_cl.
getProcessUnitID()) + std::string(
".vtk"));
632 std::cerr <<
"Warning " << __FILE__ <<
":" << __LINE__ <<
" apply BC is suppose to be called only one time\n";
size_t ProctoID(size_t p) const
Convert the processor rank to the id in the list.
nn_prcs(nn_prcs< dim, T > &&ilg)
Constructor from temporal ie_loc_ghost.
std::unordered_map< size_t, N_box< dim, T > > & get_nn_processor_subdomains()
Used for testing porpose do not use.
bool aBC
applyBC function is suppose to be called only one time
This class represent an N-dimensional box.
size_t IDtoProc(size_t id) const
Return the processor id of the near processor list at place id.
bool is_equal(nn_prcs< dim, T > &np)
Check if the nn_prcs contain the same information.
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Position of the element of dimension d in the hyper-cube of dimension dim.
size_t getProcessUnitID()
Get the process unit id.
size_t getNNProcessors() const
Get the number of Near processors.
openfpm::vector< openfpm::vector< size_t > > proc_adj_box
Vcluster & v_cl
Virtual cluster.
T getHigh(int i) const
get the high interval of the box
void setHigh(int i, T val)
set the high interval of the box
This class implement the point shape in an N-dimensional space.
static bool check_valid(comb< dim > cmb, const size_t(&bc)[dim])
static std::vector< comb< dim > > getCombinations_R_bc(size_t d, const size_t(&bc)[dim])
openfpm::vector< size_t > r_sub
nn_prcs(const nn_prcs< dim, T > &ilg)
Constructor from another nn_prcs.
void sendrecvMultipleMessagesNBX(openfpm::vector< size_t > &prc, openfpm::vector< T > &data, openfpm::vector< size_t > prc_recv, openfpm::vector< size_t > &recv_sz, void *(*msg_alloc)(size_t, size_t, size_t, size_t, size_t, void *), void *ptr_arg, long int opt=NONE)
Send and receive multiple messages.
bool write(std::string output) const
Write the decomposition as VTK file.
Implementation of VCluster class.
std::unordered_map< size_t, N_box< dim, T > > nn_processor_subdomains_tmp
when we add new boxes, are added here
void add_box_periodic(const Box< dim, T > &domain, const Ghost< dim, T > &ghost, const size_t(&bc)[dim])
In case of periodic boundary conditions we replicate the sub-domains at the border.
bool Intersect(const Box< dim, T > &b, Box< dim, T > &b_out) const
Intersect.
const openfpm::vector< size_t > & getNearSubdomainsRealId(size_t p_id) const
Get the real-id of the sub-domains of a near processor.
char * getComb()
get the combination array pointer
size_t recv_cnt
Receive counter.
void consistent_shift(Box< dim, T > &box, const Box< dim, T > &domain, const Point< dim, T > &shift)
It shift a box but it does consistently.
const T & get(size_t i) const
Get coordinate.
openfpm::vector< size_t > nn_processors
List of adjacent processors.
void setLow(int i, T val)
set the low interval of the box
nn_prcs(Vcluster &v_cl)
Constructor require Vcluster.
void zero()
Set all the elements to zero.
openfpm::vector< openfpm::vector< ::SpaceBox< dim, T > > > boxes
contain the set of sub-domains sent to the other processors
This class represent an N-dimensional box.
nn_prcs< dim, T > & operator=(nn_prcs< dim, T > &&nnp)
Copy the object.
This class is a trick to indicate the compiler a specific specialization pattern. ...
size_t getNearProcessor(size_t p_id) const
Get the near processor id.
static void * message_alloc(size_t msg_i, size_t total_msg, size_t total_p, size_t i, size_t ri, void *ptr)
Message allocation.
void flush()
Flush the temporal added sub-domain to the processor sub-domain.
nn_prcs< dim, T > & operator=(const nn_prcs< dim, T > &nnp)
Copy the object.
openfpm::vector< comb< dim > > pos
near processor sector position (or where they live outside the domain)
const openfpm::vector< comb< dim > > & getNearSubdomainsPos(size_t p_id) const
Get the sub-domains sector position of a near processor.
openfpm::vector< size_t > & get_nn_processors()
Used for testing porpose do not use.
This class calculate elements of the hyper-cube.
void applyBC(const Box< dim, T > &domain, const Ghost< dim, T > &ghost, const size_t(&bc)[dim])
Apply boundary conditions.
const openfpm::vector< size_t > & getSentSubdomains(size_t p_id) const
For each near processor it give a vector with the id of the local sub-domain sent to that processor...
openfpm::vector<::Box< dim, T > > bx
near processor sub-domains
size_t n_real_sub
Number of real sub-domains or sub-domain in the central sector.
void reset()
Reset the nn_prcs structure.
const openfpm::vector< ::Box< dim, T > > & getNearSubdomains(size_t p_id) const
Get the sub-domains of a near processor.
void add_nn_subdomain(size_t i, size_t r_sub, const Box< dim, T > &bx, const comb< dim > &c)
add sub-domains to processor for a near processor i
std::unordered_map< size_t, N_box< dim, T > > nn_processor_subdomains
for each near processor store the sub-domains of the near processors
size_t getNRealSubdomains(size_t p_id) const
Get the number of real sub-domains of a near processor.
void create(const openfpm::vector< openfpm::vector< long unsigned int > > &box_nn_processor, const openfpm::vector< SpaceBox< dim, T >> &sub_domains)
Create the list of adjacent processors and the list of adjacent sub-domains.
This class store the adjacent processors and the adjacent sub_domains.