# PhasicFlow: src/phasicFlow/processors/localProcessors.hpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

localProcessors.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __pFlowProcessors_hpp__
#define __pFlowProcessors_hpp__
#include "processors.hpp"
#include "types.hpp"
#ifdef pFlow_Build_MPI
#include "mpi.h"
#endif
namespace pFlow
{
class localProcessors
:
public processors
{
private:
#ifdef pFlow_Build_MPI
MPI_Comm parrentCommunicator_;
MPI_Comm localCommunicator_;
#endif
int localSize_ = 1 ;
int localRank_ = 0;
bool isPartOfLocal_ = true;
word name_;
public:
localProcessors(const word& name);
localProcessors(
const word& name,
const std::vector<int>& ranks);
#ifdef pFlow_Build_MPI
localProcessors(
MPI_Comm parrentComm,
const word& name,
const std::vector<int>& ranks);
#endif
// - Access
inline
const auto& name()const
{
return name_;
}
inline
auto localRank()const
{
return localRank_;
}
inline
auto localSize()const
{
return localSize_;
}
// - Methods
inline
bool localMaster()const
{
return localRank_ == localMasterNo();
}
inline
int localMasterNo()const
{
return 0;
}
inline
bool localParallel()const
{
return localSize_>1;
}
inline
const char* localRunTypeName()
{
if(localParallel())
return "MPI";
else
return "regular";
}
inline
bool isThisActive()const
{
return isPartOfLocal_;
}
#ifdef pFlow_Build_MPI
inline
auto parrentCommunicator()const
{
return parrentCommunicator_;
}
inline
auto localCommunicator()const
{
return localCommunicator_;
}
#endif
static
bool builtForMPI()
{
#ifdef pFlow_Build_MPI
return true;
#else
return false;
#endif
}
};
}
#endif
pFlow::localProcessors::builtForMPI
static bool builtForMPI()
Definition: localProcessors.hpp:149
pFlow::localProcessors::name
const auto & name() const
return name of the local communicator
Definition: localProcessors.hpp:82
pFlow::localProcessors::localMasterNo
int localMasterNo() const
Definition: localProcessors.hpp:108
pFlow::localProcessors::localRank
auto localRank() const
Definition: localProcessors.hpp:88
processors.hpp
pFlow::localProcessors::localParallel
bool localParallel() const
Definition: localProcessors.hpp:114
pFlow::localProcessors::localRank_
int localRank_
Definition: localProcessors.hpp:49
types.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::processors
This class holds the information about the global execution world and number of processors in communi...
Definition: processors.hpp:51
pFlow::localProcessors::localMaster
bool localMaster() const
Definition: localProcessors.hpp:102
pFlow
Definition: demGeometry.hpp:27
pFlow::localProcessors::localRunTypeName
const char * localRunTypeName()
Definition: localProcessors.hpp:120
pFlow::localProcessors::localProcessors
localProcessors(const word &name)
Construct a local processor communication similar to global with specified name.
Definition: localProcessors.cpp:22
pFlow::localProcessors::localSize
auto localSize() const
Definition: localProcessors.hpp:94
pFlow::localProcessors::name_
word name_
Definition: localProcessors.hpp:53
pFlow::localProcessors
Definition: localProcessors.hpp:35
pFlow::localProcessors::isThisActive
bool isThisActive() const
Definition: localProcessors.hpp:129
pFlow::localProcessors::localSize_
int localSize_
Definition: localProcessors.hpp:47
pFlow::localProcessors::isPartOfLocal_
bool isPartOfLocal_
Definition: localProcessors.hpp:51