Commit 820d3462 authored by Alexander Kissinger's avatar Alexander Kissinger
Browse files

This commit is related to FS#221 concerning freezes during parallel computations.

The error occurs in the compositional multi-phase models 2p2c, 3p3c and co2 during the update of the static data
- The problem has been fixed for the three models
- Additionally another check in the implicitmodel.hh update() function was added to make sure that no process converges if all the other processes have not converged as well.
Reviewed by Bernd.

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@14431 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent c8b13c30
......@@ -507,45 +507,66 @@ public:
const SolutionVector &oldGlobalSol)
{
bool wasSwitched = false;
for (unsigned i = 0; i < staticDat_.size(); ++i)
staticDat_[i].visited = false;
FVElementGeometry fvGeometry;
static VolumeVariables volVars;
ElementIterator eIt = this->gridView_().template begin<0> ();
const ElementIterator &eEndIt = this->gridView_().template end<0> ();
for (; eIt != eEndIt; ++eIt)
{
fvGeometry.update(this->gridView_(), *eIt);
for (int scvIdx = 0; scvIdx < fvGeometry.numScv; ++scvIdx)
int succeeded;
try {
for (unsigned i = 0; i < staticDat_.size(); ++i)
staticDat_[i].visited = false;
FVElementGeometry fvGeometry;
static VolumeVariables volVars;
ElementIterator eIt = this->gridView_().template begin<0> ();
const ElementIterator &eEndIt = this->gridView_().template end<0> ();
for (; eIt != eEndIt; ++eIt)
{
fvGeometry.update(this->gridView_(), *eIt);
for (int scvIdx = 0; scvIdx < fvGeometry.numScv; ++scvIdx)
{
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
int dofIdxGlobal = this->dofMapper().subIndex(*eIt, scvIdx, dofCodim);
int dofIdxGlobal = this->dofMapper().subIndex(*eIt, scvIdx, dofCodim);
#else
int dofIdxGlobal = this->dofMapper().map(*eIt, scvIdx, dofCodim);
int dofIdxGlobal = this->dofMapper().map(*eIt, scvIdx, dofCodim);
#endif
if (staticDat_[dofIdxGlobal].visited)
continue;
staticDat_[dofIdxGlobal].visited = true;
volVars.update(curGlobalSol[dofIdxGlobal],
this->problem_(),
*eIt,
fvGeometry,
scvIdx,
false);
const GlobalPosition &globalPos = fvGeometry.subContVol[scvIdx].global;
if (primaryVarSwitch_(curGlobalSol,
volVars,
dofIdxGlobal,
globalPos))
{
this->jacobianAssembler().markDofRed(dofIdxGlobal);
wasSwitched = true;
if (staticDat_[dofIdxGlobal].visited)
continue;
staticDat_[dofIdxGlobal].visited = true;
volVars.update(curGlobalSol[dofIdxGlobal],
this->problem_(),
*eIt,
fvGeometry,
scvIdx,
false);
const GlobalPosition &globalPos = fvGeometry.subContVol[scvIdx].global;
if (primaryVarSwitch_(curGlobalSol,
volVars,
dofIdxGlobal,
globalPos))
{
this->jacobianAssembler().markDofRed(dofIdxGlobal);
wasSwitched = true;
}
}
}
succeeded = 1;
}
catch (Dumux::NumericalProblem &e)
{
std::cout << "\n"
<< "Rank " << this->problem_().gridView().comm().rank()
<< " caught an exception while updating the static data." << e.what()
<< "\n";
succeeded = 0;
}
//make sure that all processes succeeded. If not throw a NumericalProblem to decrease the time step size.
if (this->gridView_().comm().size() > 1)
succeeded = this->gridView_().comm().min(succeeded);
if (!succeeded) {
if(this->problem_().gridView().comm().rank() == 0)
DUNE_THROW(NumericalProblem,
"A process did not succeed in updating the static data.");
return;
}
// make sure that if there was a variable switch in an
......
......@@ -495,45 +495,67 @@ public:
const SolutionVector &oldGlobalSol)
{
bool wasSwitched = false;
int succeeded;
try {
for (unsigned i = 0; i < staticDat_.size(); ++i)
staticDat_[i].visited = false;
for (unsigned i = 0; i < staticDat_.size(); ++i)
staticDat_[i].visited = false;
FVElementGeometry fvGeometry;
static VolumeVariables volVars;
ElementIterator eIt = this->gridView_().template begin<0> ();
const ElementIterator &eEndIt = this->gridView_().template end<0> ();
for (; eIt != eEndIt; ++eIt)
{
fvGeometry.update(this->gridView_(), *eIt);
for (int scvIdx = 0; scvIdx < fvGeometry.numScv; ++scvIdx)
FVElementGeometry fvGeometry;
static VolumeVariables volVars;
ElementIterator eIt = this->gridView_().template begin<0> ();
const ElementIterator &eEndIt = this->gridView_().template end<0> ();
for (; eIt != eEndIt; ++eIt)
{
fvGeometry.update(this->gridView_(), *eIt);
for (int scvIdx = 0; scvIdx < fvGeometry.numScv; ++scvIdx)
{
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 4)
int dofIdxGlobal = this->dofMapper().subIndex(*eIt, scvIdx, dofCodim);
int dofIdxGlobal = this->dofMapper().subIndex(*eIt, scvIdx, dofCodim);
#else
int dofIdxGlobal = this->dofMapper().map(*eIt, scvIdx, dofCodim);
int dofIdxGlobal = this->dofMapper().map(*eIt, scvIdx, dofCodim);
#endif
if (staticDat_[dofIdxGlobal].visited)
continue;
staticDat_[dofIdxGlobal].visited = true;
volVars.update(curGlobalSol[dofIdxGlobal],
this->problem_(),
*eIt,
fvGeometry,
scvIdx,
false);
const GlobalPosition &globalPos = fvGeometry.subContVol[scvIdx].global;
if (primaryVarSwitch_(curGlobalSol,
volVars,
dofIdxGlobal,
globalPos))
{
this->jacobianAssembler().markDofRed(dofIdxGlobal);
wasSwitched = true;
if (staticDat_[dofIdxGlobal].visited)
continue;
staticDat_[dofIdxGlobal].visited = true;
volVars.update(curGlobalSol[dofIdxGlobal],
this->problem_(),
*eIt,
fvGeometry,
scvIdx,
false);
const GlobalPosition &globalPos = fvGeometry.subContVol[scvIdx].global;
if (primaryVarSwitch_(curGlobalSol,
volVars,
dofIdxGlobal,
globalPos))
{
this->jacobianAssembler().markDofRed(dofIdxGlobal);
wasSwitched = true;
}
}
}
succeeded = 1;
}
catch (Dumux::NumericalProblem &e)
{
std::cout << "\n"
<< "Rank " << this->problem_().gridView().comm().rank()
<< " caught an exception while updating the static data." << e.what()
<< "\n";
succeeded = 0;
}
//make sure that all processes succeeded. If not throw a NumericalProblem to decrease the time step size.
if (this->gridView_().comm().size() > 1)
succeeded = this->gridView_().comm().min(succeeded);
if (!succeeded) {
if(this->problem_().gridView().comm().rank() == 0)
DUNE_THROW(NumericalProblem,
"A process did not succeed in updating the static data.");
return;
}
// make sure that if there was a variable switch in an
......
......@@ -100,41 +100,64 @@ public:
const SolutionVector &oldGlobalSol)
{
bool wasSwitched = false;
int succeeded;
try {
for (unsigned i = 0; i < ParentType::staticDat_.size(); ++i)
ParentType::staticDat_[i].visited = false;
for (unsigned i = 0; i < ParentType::staticDat_.size(); ++i)
ParentType::staticDat_[i].visited = false;
FVElementGeometry fvGeometry;
static VolumeVariables volVars;
ElementIterator eIt = this->gridView_().template begin<0> ();
const ElementIterator &eEndIt = this->gridView_().template end<0> ();
for (; eIt != eEndIt; ++eIt)
{
fvGeometry.update(this->gridView_(), *eIt);
for (int scvIdx = 0; scvIdx < fvGeometry.numScv; ++scvIdx)
FVElementGeometry fvGeometry;
static VolumeVariables volVars;
ElementIterator eIt = this->gridView_().template begin<0> ();
const ElementIterator &eEndIt = this->gridView_().template end<0> ();
for (; eIt != eEndIt; ++eIt)
{
int dofIdxGlobal = this->dofMapper().map(*eIt, scvIdx, dofCodim);
if (ParentType::staticDat_[dofIdxGlobal].visited)
continue;
ParentType::staticDat_[dofIdxGlobal].visited = true;
volVars.update(curGlobalSol[dofIdxGlobal],
this->problem_(),
*eIt,
fvGeometry,
scvIdx,
false);
const GlobalPosition &globalPos = eIt->geometry().corner(scvIdx);
if (primaryVarSwitch_(curGlobalSol,
volVars,
dofIdxGlobal,
globalPos))
fvGeometry.update(this->gridView_(), *eIt);
for (int scvIdx = 0; scvIdx < fvGeometry.numScv; ++scvIdx)
{
this->jacobianAssembler().markDofRed(dofIdxGlobal);
wasSwitched = true;
int dofIdxGlobal = this->dofMapper().map(*eIt, scvIdx, dofCodim);
if (ParentType::staticDat_[dofIdxGlobal].visited)
continue;
ParentType::staticDat_[dofIdxGlobal].visited = true;
volVars.update(curGlobalSol[dofIdxGlobal],
this->problem_(),
*eIt,
fvGeometry,
scvIdx,
false);
const GlobalPosition &globalPos = eIt->geometry().corner(scvIdx);
if (primaryVarSwitch_(curGlobalSol,
volVars,
dofIdxGlobal,
globalPos))
{
this->jacobianAssembler().markDofRed(dofIdxGlobal);
wasSwitched = true;
}
}
}
succeeded = 1;
}
catch (Dumux::NumericalProblem &e)
{
std::cout << "\n"
<< "Rank " << this->problem_().gridView().comm().rank()
<< " caught an exception while updating the static data." << e.what()
<< "\n";
succeeded = 0;
}
//make sure that all processes succeeded. If not throw a NumericalProblem to decrease the time step size.
if (this->gridView_().comm().size() > 1)
succeeded = this->gridView_().comm().min(succeeded);
if (!succeeded) {
if(this->problem_().gridView().comm().rank() == 0)
DUNE_THROW(NumericalProblem,
"A process did not succeed in updating the static data.");
return;
}
// make sure that if there was a variable switch in an
......
......@@ -459,7 +459,12 @@ public:
asImp_().updateBegin();
bool converged = solver.execute(controller);
int converged = solver.execute(controller);
if (this->gridView_().comm().size() > 1)
{
converged = this->gridView_().comm().min(converged);
}
if (converged) {
asImp_().updateSuccessful();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment