OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
nn_prcs< dim, T, layout_base, Memory > Class Template Reference

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

Detailed Description

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

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, layout_base, Memory >:

Public Member Functions

 nn_prcs (Vcluster<> &v_cl)
 Constructor require Vcluster.
 
 nn_prcs (const nn_prcs< dim, T, layout_base, Memory > &ilg)
 Constructor from another nn_prcs.
 
 nn_prcs (nn_prcs< dim, T, layout_base, Memory > &&ilg)
 Constructor from temporal ie_loc_ghost.
 
nn_prcs< dim, T, layout_base, Memory > & operator= (const nn_prcs< dim, T, layout_base, Memory > &nnp)
 Copy the object.
 
nn_prcs< dim, T, layout_base, Memory > & operator= (nn_prcs< dim, T, layout_base, Memory > &&nnp)
 Copy the object.
 
template<typename Memory2 , template< typename > class layout_base2>
nn_prcs< dim, T, layout_base, Memory > & operator= (const nn_prcs< dim, T, layout_base2, Memory2 > &nnp)
 Copy the object.
 
openfpm::vector< size_t > & private_get_nn_processors ()
 Return the internal nn_processor struct.
 
std::unordered_map< size_t, N_box< dim, T > > & private_get_nn_processor_subdomains ()
 Return the internal nn_processor_subdomains.
 
openfpm::vector< openfpm::vector< size_t > > & private_get_proc_adj_box ()
 Return the internal proc_adj_box.
 
openfpm::vector< openfpm::vector< ::SpaceBox< dim, T > > > & private_get_boxes ()
 Return the internal boxes structure.
 
template<typename Memory2 , template< typename > class layout_base2>
nn_prcs< dim, T, layout_base, Memory > & operator= (nn_prcs< dim, T, layout_base2, Memory2 > &&nnp)
 Copy the object.
 
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.
 
size_t getNNProcessors () const
 Get the number of Near processors.
 
size_t IDtoProc (size_t id) const
 Return the processor id of the near processor list at place id.
 
const openfpm::vector< size_t > & getNearSubdomainsRealId (size_t p_id) const
 Get the real-id of the sub-domains of a near processor.
 
const openfpm::vector< ::Box< dim, T > > & getNearSubdomains (size_t p_id) const
 Get the sub-domains of a near processor.
 
size_t getNRealSubdomains (size_t p_id) const
 Get the number of real sub-domains of a near processor.
 
const openfpm::vector< comb< dim > > & getNearSubdomainsPos (size_t p_id) const
 Get the sub-domains sector position of a near processor.
 
size_t getNearProcessor (size_t p_id) const
 Get the near processor id.
 
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.
 
size_t ProctoID (size_t p) const
 Convert the processor rank to the id in the list.
 
bool write (std::string output) const
 Write the decomposition as VTK file.
 
void applyBC (const Box< dim, T > &domain, const Ghost< dim, T > &ghost, const size_t(&bc)[dim])
 Apply boundary conditions.
 
bool is_equal (nn_prcs< dim, T, layout_base, Memory > &np)
 Check if the nn_prcs contain the same information.
 
void reset ()
 Reset the nn_prcs structure.
 
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.
 
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
 
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.
 
void flush ()
 Flush the temporal added sub-domain to the processor sub-domain.
 

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, size_t tag, void *ptr)
 Message allocation.
 

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
 

Constructor & Destructor Documentation

◆ nn_prcs() [1/3]

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
nn_prcs< dim, T, layout_base, Memory >::nn_prcs ( Vcluster<> &  v_cl)
inline

Constructor require Vcluster.

Definition at line 274 of file nn_processor.hpp.

◆ nn_prcs() [2/3]

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
nn_prcs< dim, T, layout_base, Memory >::nn_prcs ( const nn_prcs< dim, T, layout_base, Memory > &  ilg)
inline

Constructor from another nn_prcs.

Definition at line 279 of file nn_processor.hpp.

◆ nn_prcs() [3/3]

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
nn_prcs< dim, T, layout_base, Memory >::nn_prcs ( nn_prcs< dim, T, layout_base, Memory > &&  ilg)
inline

Constructor from temporal ie_loc_ghost.

Definition at line 286 of file nn_processor.hpp.

Member Function Documentation

◆ add_box_periodic()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
void nn_prcs< dim, T, layout_base, Memory >::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.

◆ add_nn_subdomain()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
void nn_prcs< dim, T, layout_base, Memory >::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.

◆ applyBC()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
void nn_prcs< dim, T, layout_base, Memory >::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 705 of file nn_processor.hpp.

◆ check_valid()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
static bool nn_prcs< dim, T, layout_base, Memory >::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.

◆ consistent_shift()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
void nn_prcs< dim, T, layout_base, Memory >::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

Parameters
boxto shift
domain
shift

Definition at line 93 of file nn_processor.hpp.

◆ create()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
void nn_prcs< dim, T, layout_base, Memory >::create ( const openfpm::vector< openfpm::vector< long unsigned int > > &  box_nn_processor,
const openfpm::vector< SpaceBox< dim, T >, Memory, layout_base > &  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 433 of file nn_processor.hpp.

◆ flush()

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

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

Definition at line 251 of file nn_processor.hpp.

◆ get_nn_processor_subdomains()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
std::unordered_map< size_t, N_box< dim, T > > & nn_prcs< dim, T, layout_base, Memory >::get_nn_processor_subdomains ( )
inline

Used for testing porpose do not use.

Definition at line 758 of file nn_processor.hpp.

◆ get_nn_processors()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector< size_t > & nn_prcs< dim, T, layout_base, Memory >::get_nn_processors ( )
inline

Used for testing porpose do not use.

Definition at line 764 of file nn_processor.hpp.

◆ getNearProcessor()

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

Get the near processor id.

Parameters
p_idadjacent processor rank
Returns
the processor rank

Definition at line 623 of file nn_processor.hpp.

◆ getNearSubdomains()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
const openfpm::vector< ::Box< dim, T > > & nn_prcs< dim, T, layout_base, Memory >::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 562 of file nn_processor.hpp.

◆ getNearSubdomainsPos()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
const openfpm::vector< comb< dim > > & nn_prcs< dim, T, layout_base, Memory >::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 604 of file nn_processor.hpp.

◆ getNearSubdomainsRealId()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
const openfpm::vector< size_t > & nn_prcs< dim, T, layout_base, Memory >::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 542 of file nn_processor.hpp.

◆ getNNProcessors()

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

Get the number of Near processors.

Returns
the number of near processors

Definition at line 518 of file nn_processor.hpp.

◆ getNRealSubdomains()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
size_t nn_prcs< dim, T, layout_base, Memory >::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 584 of file nn_processor.hpp.

◆ getSentSubdomains()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
const openfpm::vector< size_t > & nn_prcs< dim, T, layout_base, Memory >::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 644 of file nn_processor.hpp.

◆ IDtoProc()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
size_t nn_prcs< dim, T, layout_base, Memory >::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 530 of file nn_processor.hpp.

◆ is_equal()

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

Check if the nn_prcs contain the same information.

Parameters
npElement to check
Returns
true if they are equal

Definition at line 725 of file nn_processor.hpp.

◆ message_alloc()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
static void * nn_prcs< dim, T, layout_base, Memory >::message_alloc ( size_t  msg_i,
size_t  total_msg,
size_t  total_p,
size_t  i,
size_t  ri,
size_t  tag,
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.

◆ operator=() [1/4]

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

Copy the object.

Parameters
nnpobject to copy
Returns
itself

Definition at line 324 of file nn_processor.hpp.

◆ operator=() [2/4]

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
template<typename Memory2 , template< typename > class layout_base2>
nn_prcs< dim, T, layout_base, Memory > & nn_prcs< dim, T, layout_base, Memory >::operator= ( const nn_prcs< dim, T, layout_base2, Memory2 > &  nnp)
inline

Copy the object.

Parameters
nnpobject to copy
Returns
itself

Definition at line 359 of file nn_processor.hpp.

◆ operator=() [3/4]

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

Copy the object.

Parameters
nnpobject to copy
Returns
itself

Definition at line 341 of file nn_processor.hpp.

◆ operator=() [4/4]

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
template<typename Memory2 , template< typename > class layout_base2>
nn_prcs< dim, T, layout_base, Memory > & nn_prcs< dim, T, layout_base, Memory >::operator= ( nn_prcs< dim, T, layout_base2, Memory2 > &&  nnp)
inline

Copy the object.

Parameters
nnpobject to copy
Returns
itself

Definition at line 417 of file nn_processor.hpp.

◆ private_get_boxes()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector< openfpm::vector< ::SpaceBox< dim, T > > > & nn_prcs< dim, T, layout_base, Memory >::private_get_boxes ( )
inline

Return the internal boxes structure.

Returns
the internal boxes structure

Definition at line 404 of file nn_processor.hpp.

◆ private_get_nn_processor_subdomains()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
std::unordered_map< size_t, N_box< dim, T > > & nn_prcs< dim, T, layout_base, Memory >::private_get_nn_processor_subdomains ( )
inline

Return the internal nn_processor_subdomains.

Returns
the internal nn_processor_subdomains

Definition at line 384 of file nn_processor.hpp.

◆ private_get_nn_processors()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector< size_t > & nn_prcs< dim, T, layout_base, Memory >::private_get_nn_processors ( )
inline

Return the internal nn_processor struct.

Returns
the internal nn_processor struct

Definition at line 374 of file nn_processor.hpp.

◆ private_get_proc_adj_box()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector< openfpm::vector< size_t > > & nn_prcs< dim, T, layout_base, Memory >::private_get_proc_adj_box ( )
inline

Return the internal proc_adj_box.

Returns
the internal proc_adj_box

Definition at line 394 of file nn_processor.hpp.

◆ ProctoID()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
size_t nn_prcs< dim, T, layout_base, Memory >::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 656 of file nn_processor.hpp.

◆ reset()

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

Reset the nn_prcs structure.

Definition at line 746 of file nn_processor.hpp.

◆ write()

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
bool nn_prcs< dim, T, layout_base, Memory >::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 682 of file nn_processor.hpp.

Field Documentation

◆ aBC

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
bool nn_prcs< dim, T, layout_base, Memory >::aBC
private

applyBC function is suppose to be called only one time

Definition at line 49 of file nn_processor.hpp.

◆ boxes

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector< openfpm::vector< ::SpaceBox<dim,T> > > nn_prcs< dim, T, layout_base, Memory >::boxes
private

contain the set of sub-domains sent to the other processors

Definition at line 43 of file nn_processor.hpp.

◆ nn_processor_subdomains

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
std::unordered_map<size_t, N_box<dim,T> > nn_prcs< dim, T, layout_base, Memory >::nn_processor_subdomains
private

for each near processor store the sub-domains of the near processors

Definition at line 32 of file nn_processor.hpp.

◆ nn_processor_subdomains_tmp

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
std::unordered_map<size_t, N_box<dim,T> > nn_prcs< dim, T, layout_base, Memory >::nn_processor_subdomains_tmp
private

when we add new boxes, are added here

Definition at line 35 of file nn_processor.hpp.

◆ nn_processors

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector<size_t> nn_prcs< dim, T, layout_base, Memory >::nn_processors
private

List of adjacent processors.

Definition at line 29 of file nn_processor.hpp.

◆ proc_adj_box

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
openfpm::vector<openfpm::vector<size_t> > nn_prcs< dim, T, layout_base, Memory >::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.

◆ recv_cnt

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
size_t nn_prcs< dim, T, layout_base, Memory >::recv_cnt
private

Receive counter.

Definition at line 46 of file nn_processor.hpp.

◆ v_cl

template<unsigned int dim, typename T , template< typename > class layout_base, typename Memory >
Vcluster& nn_prcs< dim, T, layout_base, Memory >::v_cl
private

Virtual cluster.

Definition at line 26 of file nn_processor.hpp.


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