mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add isRankZero() utility.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <opm/autodiff/NewtonIterationUtilities.hpp>
|
||||
#include <opm/autodiff/AutoDiffHelpers.hpp>
|
||||
#include <opm/core/linalg/ParallelIstlInformation.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||
@@ -288,5 +289,24 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
|
||||
/// Return true if this is a serial run, or rank zero on an MPI run.
|
||||
bool isRankZero(const boost::any& parallel_info)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
if (parallel_info.type() == typeid(ParallelISTLInformation)) {
|
||||
const ParallelISTLInformation& info =
|
||||
boost::any_cast<const ParallelISTLInformation&>(parallel_info);
|
||||
return info.communicator().rank() == 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static_cast<void>(parallel_info); // Suppress unused argument warning.
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define OPM_NEWTONITERATIONUTILITIES_HEADER_INCLUDED
|
||||
|
||||
#include <opm/autodiff/AutoDiffBlock.hpp>
|
||||
#include <boost/any.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
@@ -58,6 +59,8 @@ namespace Opm
|
||||
Eigen::SparseMatrix<double, Eigen::RowMajor>& A,
|
||||
AutoDiffBlock<double>::V& b);
|
||||
|
||||
/// Return true if this is a serial run, or rank zero on an MPI run.
|
||||
bool isRankZero(const boost::any& parallel_info);
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user