ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Parallel::ParaCollection Class Reference

Container for all parallel communication domains. More...

#include <para_collection.h>

Collaboration diagram for Parallel::ParaCollection:

Public Member Functions

 ParaCollection ()=default
void add (std::unique_ptr< ParaWorld > world)
 Append a domain to the collection.
const ParaWorld & find (const std::string &tag) const
 Look up a domain by tag.
template<typename T>
const T * find_as (const std::string &tag) const
 Look up a domain by tag and cast to the requested subclass.
size_t size () const
 Number of domains in the collection.

Private Attributes

std::vector< std::unique_ptr< ParaWorld > > worlds_
 owned domains

Detailed Description

Container for all parallel communication domains.

A ParaCollection owns a set of ParaWorld objects (base class pointers), each describing one communication domain (see ParaTag). Callers look up domains by tag via find(); a missing tag yields a static empty (invalid) domain as a safe degradation, never an exception.

The collection is passed explicitly to functions that need communicator access, replacing reads of loose globals such as GlobalV::POOL_WORLD.

Constructor & Destructor Documentation

◆ ParaCollection()

Parallel::ParaCollection::ParaCollection ( )
default

Member Function Documentation

◆ add()

void Parallel::ParaCollection::add ( std::unique_ptr< ParaWorld > world)

Append a domain to the collection.

Duplicate tags are rejected (the existing entry is kept).

Parameters
[in]worlddomain to add (ownership transferred)
Here is the caller graph for this function:

◆ find()

const ParaWorld & Parallel::ParaCollection::find ( const std::string & tag) const

Look up a domain by tag.

Parameters
[in]tagdomain tag string
Returns
the matching ParaWorld, or a static empty domain if not found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_as()

template<typename T>
const T * Parallel::ParaCollection::find_as ( const std::string & tag) const

Look up a domain by tag and cast to the requested subclass.

Template Parameters
Texpected subclass (e.g. ParaKmeshWorld)
Parameters
[in]tagdomain tag string
Returns
pointer to the domain if found and type matches, nullptr otherwise
Here is the caller graph for this function:

◆ size()

size_t Parallel::ParaCollection::size ( ) const
inline

Number of domains in the collection.

Here is the caller graph for this function:

Member Data Documentation

◆ worlds_

std::vector<std::unique_ptr<ParaWorld> > Parallel::ParaCollection::worlds_
private

owned domains


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