Merge pull request #823 from atgeirr/parallel-nldd-fixes

Avoid collective operations in single-domain calls.
This commit is contained in:
Bård Skaflestad 2023-08-25 16:17:00 +02:00 committed by GitHub
commit 19bde5f5ec
2 changed files with 33 additions and 49 deletions

View File

@ -239,33 +239,17 @@ public:
const GlobalEqVector& currentResidual,
const DofIndices& dofIndices)
{
const auto& comm = this->simulator_.gridView().comm();
int succeeded;
try {
auto zero = solutionUpdate[0];
zero = 0.0;
for (auto dofIdx : dofIndices) {
if (solutionUpdate[dofIdx] == zero) {
continue;
}
updatePrimaryVariables_(dofIdx,
nextSolution[dofIdx],
currentSolution[dofIdx],
solutionUpdate[dofIdx],
currentResidual[dofIdx]);
const auto zero = 0.0 * solutionUpdate[0];
for (auto dofIdx : dofIndices) {
if (solutionUpdate[dofIdx] == zero) {
continue;
}
succeeded = 1;
updatePrimaryVariables_(dofIdx,
nextSolution[dofIdx],
currentSolution[dofIdx],
solutionUpdate[dofIdx],
currentResidual[dofIdx]);
}
catch (...) {
succeeded = 0;
}
succeeded = comm.min(succeeded);
if (!succeeded)
throw NumericalProblem("A process did not succeed in adapting the primary variables");
numPriVarsSwitched_ = comm.sum(numPriVarsSwitched_);
}
protected:

View File

@ -191,7 +191,29 @@ public:
*/
void linearizeDomain()
{
linearizeDomain(fullDomain_);
int succeeded;
try {
linearizeDomain(fullDomain_);
succeeded = 1;
}
catch (const std::exception& e)
{
std::cout << "rank " << simulator_().gridView().comm().rank()
<< " caught an exception while linearizing:" << e.what()
<< "\n" << std::flush;
succeeded = 0;
}
catch (...)
{
std::cout << "rank " << simulator_().gridView().comm().rank()
<< " caught an exception while linearizing"
<< "\n" << std::flush;
succeeded = 0;
}
succeeded = simulator_().gridView().comm().min(succeeded);
if (!succeeded)
throw NumericalProblem("A process did not succeed in linearizing the system");
}
/*!
@ -222,29 +244,7 @@ public:
resetSystem_(domain);
}
int succeeded;
try {
linearize_(domain);
succeeded = 1;
}
catch (const std::exception& e)
{
std::cout << "rank " << simulator_().gridView().comm().rank()
<< " caught an exception while linearizing:" << e.what()
<< "\n" << std::flush;
succeeded = 0;
}
catch (...)
{
std::cout << "rank " << simulator_().gridView().comm().rank()
<< " caught an exception while linearizing"
<< "\n" << std::flush;
succeeded = 0;
}
succeeded = simulator_().gridView().comm().min(succeeded);
if (!succeeded)
throw NumericalProblem("A process did not succeed in linearizing the system");
linearize_(domain);
}
void finalize()