ENH: handle try-construct faMesh (#2399)

- a try/catch approach is not really robust enough (or even possible)
  since read failures likely do not occur on all ranks simultaneously.
  This leads to situations where the master has thrown an exception
  (and thus exiting the current routine) while other ranks are still
  waiting to receive data and the program blocks completely.

  Since this primarily affects data conversion routines such as
  foamToEnsight etc, treat similarly to lagrangian: check for the
  existence of essential files before proceeding or not. This is
  wrapped into a TryNew factory method:

      autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh));
      if (faMeshPtr) ...
This commit is contained in:
Mark Olesen
2022-03-09 15:58:14 +01:00
parent 62fc3bbc33
commit 730ce92b68
5 changed files with 180 additions and 27 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -46,16 +46,7 @@ if (doFiniteArea)
if (nAreaFields)
{
const bool oldThrowingError = FatalError.throwing(true);
try
{
faMeshPtr.reset(new faMesh(meshProxy.baseMesh()));
}
catch (const Foam::error& err)
{
faMeshPtr.clear();
}
FatalError.throwing(oldThrowingError);
faMeshPtr = faMesh::TryNew(meshProxy.baseMesh());
}
if (faMeshPtr && nAreaFields)