OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
nn_prcs< dim, T > Class Template Reference

This class store the adjacent processors and the adjacent sub_domains. More...

Detailed Description

template<unsigned int dim, typename T>
class nn_prcs< dim, T >

This class store the adjacent processors and the adjacent sub_domains.

Template Parameters
dimis the dimensionality of the physical domain we are going to decompose.
Ttype of the space we decompose, Real, Integer, Complex ...
See Also
CartDecomposition

Definition at line 23 of file nn_processor.hpp.

#include <nn_processor.hpp>

+ Inheritance diagram for nn_prcs< dim, T >:

Public Member Functions

 nn_prcs (Vcluster &v_cl)
 Constructor require Vcluster.
 
 nn_prcs (const nn_prcs< dim, T > &ilg)
 Constructor from another nn_prcs.
 
 nn_prcs (nn_prcs< dim, T > &&ilg)
 Constructor from temporal ie_loc_ghost.
 
nn_prcs< dim, T > & operator= (const nn_prcs< dim, T > &nnp)
 Copy the object. More...
 
nn_prcs< dim, T > & operator= (nn_prcs< dim, T > &&nnp)
 Copy the object. More...
 
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. More...
 
size_t getNNProcessors () const
 Get the number of Near processors. More...
 
size_t IDtoProc (size_t id) const
 Return the processor id of the near processor list at place id. More...
 
const openfpm::vector< size_t > & getNearSubdomainsRealId (size_t p_id) const
 Get the real-id of the sub-domains of a near processor. More...
 
const openfpm::vector< ::Box
< dim, T > > & 
getNearSubdomains (size_t p_id) const
 Get the sub-domains of a near processor. More...
 
size_t getNRealSubdomains (size_t p_id) const
 Get the number of real sub-domains of a near processor. More...
 
const openfpm::vector< comb
< dim > > & 
getNearSubdomainsPos (size_t p_id) const
 Get the sub-domains sector position of a near processor. More...
 
size_t getNearProcessor (size_t p_id) const
 Get the near processor id. More...
 
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. More...
 
size_t ProctoID (size_t p) const
 Convert the processor rank to the id in the list. More...
 
bool write (std::string output) const
 Write the decomposition as VTK file. More...
 
void applyBC (const Box< dim, T > &domain, const Ghost< dim, T > &ghost, const size_t(&bc)[dim])
 Apply boundary conditions. More...
 
bool is_equal (nn_prcs< dim, T > &np)
 Check if the nn_prcs contain the same information. More...
 
void reset ()
 Reset the nn_prcs structure. More...
 
std::unordered_map< size_t,
N_box< dim, T > > & 
get_nn_processor_subdomains ()
 Used for testing porpose do not use.
 
openfpm::vector< size_t > & get_nn_processors ()
 Used for testing porpose do not use.
 

Static Public Member Functions

static bool check_valid (comb< dim > cmb, const size_t(&bc)[dim])
 

Private Member Functions

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. More...
 
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 More...
 
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. More...
 
void flush ()
 Flush the temporal added sub-domain to the processor sub-domain. More...
 

Static Private Member Functions

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. More...
 

Private Attributes

Vclusterv_cl
 Virtual cluster.
 
openfpm::vector< size_t > nn_processors
 List of adjacent processors.
 
std::unordered_map< size_t,
N_box< dim, T > > 
nn_processor_subdomains
 for each near processor store the sub-domains of the near processors
 
std::unordered_map< size_t,
N_box< dim, T > > 
nn_processor_subdomains_tmp
 when we add new boxes, are added here
 
openfpm::vector
< openfpm::vector< size_t > > 
proc_adj_box
 
openfpm::vector
< openfpm::vector< ::SpaceBox
< dim, T > > > 
boxes
 contain the set of sub-domains sent to the other processors
 
size_t recv_cnt
 Receive counter.
 
bool aBC
 applyBC function is suppose to be called only one time
 

Member Function Documentation

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::add_box_periodic ( const Box< dim, T > &  domain,
const Ghost< dim, T > &  ghost,
const size_t(&)  bc[dim] 
)
inlineprivate

In case of periodic boundary conditions we replicate the sub-domains at the border.

Parameters
domainDomain
ghostghost part
bcboundary boundary conditions

Definition at line 173 of file nn_processor.hpp.

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::add_nn_subdomain ( size_t  i,
size_t  r_sub,
const Box< dim, T > &  bx,
const comb< dim > &  c 
)
inlineprivate

add sub-domains to processor for a near processor i

Parameters
inear processor
r_subreal sub-domain id
bxBox to add
cfrom which sector the sub-domain come from

Definition at line 158 of file nn_processor.hpp.

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::applyBC ( const Box< dim, T > &  domain,
const Ghost< dim, T > &  ghost,
const size_t(&)  bc[dim] 
)
inline

Apply boundary conditions.

Parameters
domainThe simulation domain
ghostghost part
bcBoundary conditions

Definition at line 628 of file nn_processor.hpp.

template<unsigned int dim, typename T>
static bool nn_prcs< dim, T >::check_valid ( comb< dim >  cmb,
const size_t(&)  bc[dim] 
)
inlinestatic

Check that the combination is valid

Is a function that is used in otder to understand if a sub-domain must be mirrored because of boundary conditions

Parameters
cmbcombination
bcboundary conditions
Returns
true if the combination is valid

Definition at line 303 of file nn_processor.hpp.

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::consistent_shift ( Box< dim, T > &  box,
const Box< dim, T > &  domain,
const Point< dim, T > &  shift 
)
inlineprivate

It shift a box but it does consistently.

In calculating internal and external ghost boxes, domains are shifted by periodicity. In particular, consider a box touching with the left bolder the left border of the domain

 before shift                              after shift

+--------------------------—+ +---------------------------—+ | | | |

domain domain
+------—+ +------—+
box box
+------—+ +------—+

+--------------------------—+ +---------------------------—+

   shifting the box on the right by the size of the domain, we expect to have a box touching with
   the left side the right side of the domain. Because of rounding off problem this is not possible
   with a simple shift. This function ensure consistency like ensuring the previous condition, with
   the assumption that the shift is +/- the domain size

   \param box to shift
   \param domain
   \param shift

Definition at line 93 of file nn_processor.hpp.

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::create ( const openfpm::vector< openfpm::vector< long unsigned int > > &  box_nn_processor,
const openfpm::vector< SpaceBox< dim, T >> &  sub_domains 
)
inline

Create the list of adjacent processors and the list of adjacent sub-domains.

Parameters
box_nn_processorlist of adjacent processors for each sub-domain
sub_domainslist of local sub-domains

Definition at line 357 of file nn_processor.hpp.

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::flush ( )
inlineprivate

Flush the temporal added sub-domain to the processor sub-domain.

Definition at line 251 of file nn_processor.hpp.

template<unsigned int dim, typename T>
size_t nn_prcs< dim, T >::getNearProcessor ( size_t  p_id) const
inline

Get the near processor id.

Parameters
p_idadjacent processor rank
Returns
the processor rank

Definition at line 546 of file nn_processor.hpp.

template<unsigned int dim, typename T>
const openfpm::vector< ::Box<dim,T> >& nn_prcs< dim, T >::getNearSubdomains ( size_t  p_id) const
inline

Get the sub-domains of a near processor.

Parameters
p_idnear processor rank
Returns
the sub-domains

Definition at line 485 of file nn_processor.hpp.

template<unsigned int dim, typename T>
const openfpm::vector< comb<dim> >& nn_prcs< dim, T >::getNearSubdomainsPos ( size_t  p_id) const
inline

Get the sub-domains sector position of a near processor.

Parameters
p_idnear processor rank
Returns
the sub-domains positions

Definition at line 527 of file nn_processor.hpp.

template<unsigned int dim, typename T>
const openfpm::vector< size_t >& nn_prcs< dim, T >::getNearSubdomainsRealId ( size_t  p_id) const
inline

Get the real-id of the sub-domains of a near processor.

Parameters
p_idnear processor rank
Returns
the sub-domains real id

Definition at line 465 of file nn_processor.hpp.

template<unsigned int dim, typename T>
size_t nn_prcs< dim, T >::getNNProcessors ( ) const
inline

Get the number of Near processors.

Returns
the number of near processors

Definition at line 441 of file nn_processor.hpp.

template<unsigned int dim, typename T>
size_t nn_prcs< dim, T >::getNRealSubdomains ( size_t  p_id) const
inline

Get the number of real sub-domains of a near processor.

Note
the real sub-domain are the subdomain in the central sector, or any sub-domain that has not been create because of boundary conditions
Parameters
p_idnear processor rank
Returns
the number of real sub-domains

Definition at line 507 of file nn_processor.hpp.

template<unsigned int dim, typename T>
const openfpm::vector<size_t>& nn_prcs< dim, T >::getSentSubdomains ( size_t  p_id) const
inline

For each near processor it give a vector with the id of the local sub-domain sent to that processor.

Parameters
p_idadjacent processor (id from 0 to getNNProcessors())
Returns
a vector of sub-domains id

Definition at line 567 of file nn_processor.hpp.

template<unsigned int dim, typename T>
size_t nn_prcs< dim, T >::IDtoProc ( size_t  id) const
inline

Return the processor id of the near processor list at place id.

Parameters
id
Returns
return the processor rank

Definition at line 453 of file nn_processor.hpp.

template<unsigned int dim, typename T>
bool nn_prcs< dim, T >::is_equal ( nn_prcs< dim, T > &  np)
inline

Check if the nn_prcs contain the same information.

Parameters
npElement to check
Returns
true if they are equal

Definition at line 648 of file nn_processor.hpp.

template<unsigned int dim, typename T>
static void* nn_prcs< dim, T >::message_alloc ( size_t  msg_i,
size_t  total_msg,
size_t  total_p,
size_t  i,
size_t  ri,
void *  ptr 
)
inlinestaticprivate

Message allocation.

Parameters
msg_imessage size required to receive from i
total_msgtotal message size to receive from all the processors
total_pthe total number of processor want to communicate with you
iprocessor id from which we receive
rirequest id (it is an id that goes from 0 to total_p, and is unique every time message_alloc is called)
ptra pointer to the vector_dist structure
Returns
the pointer where to store the message

Definition at line 139 of file nn_processor.hpp.

template<unsigned int dim, typename T>
nn_prcs<dim,T>& nn_prcs< dim, T >::operator= ( const nn_prcs< dim, T > &  nnp)
inline

Copy the object.

Parameters
nnpobject to copy
Returns
itself

Definition at line 324 of file nn_processor.hpp.

template<unsigned int dim, typename T>
nn_prcs<dim,T>& nn_prcs< dim, T >::operator= ( nn_prcs< dim, T > &&  nnp)
inline

Copy the object.

Parameters
nnpobject to copy
Returns
itself

Definition at line 341 of file nn_processor.hpp.

template<unsigned int dim, typename T>
size_t nn_prcs< dim, T >::ProctoID ( size_t  p) const
inline

Convert the processor rank to the id in the list.

Parameters
pprocessor rank
Returns
the id

Definition at line 579 of file nn_processor.hpp.

template<unsigned int dim, typename T>
void nn_prcs< dim, T >::reset ( )
inline

Reset the nn_prcs structure.

Definition at line 669 of file nn_processor.hpp.

template<unsigned int dim, typename T>
bool nn_prcs< dim, T >::write ( std::string  output) const
inline

Write the decomposition as VTK file.

The function generate several files

1) subdomains_adjacent_X.vtk sub-domains adjacent to the local processor (X)

where X is the local processor rank

Parameters
outputdirectory where to write the files
Returns
true if the write procedure succeed

subdomains_adjacent_X.vtk sub-domains adjacent to the local processor (X)

Definition at line 605 of file nn_processor.hpp.

Field Documentation

template<unsigned int dim, typename T>
openfpm::vector<openfpm::vector<size_t> > nn_prcs< dim, T >::proc_adj_box
private

contain the same information as the member boxes with the difference that instead of the Box itself, it contain the sub-domain id in the list of the local sub-domains

Definition at line 40 of file nn_processor.hpp.


The documentation for this class was generated from the following file: