mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -65,18 +65,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
|
||||
|
||||
if (doFiniteArea)
|
||||
{
|
||||
autoPtr<faMesh> faMeshPtr;
|
||||
|
||||
const bool oldThrowingError = FatalError.throwing(true);
|
||||
try
|
||||
{
|
||||
faMeshPtr.reset(new faMesh(mesh));
|
||||
}
|
||||
catch (const Foam::error& err)
|
||||
{
|
||||
faMeshPtr.reset(nullptr);
|
||||
}
|
||||
FatalError.throwing(oldThrowingError);
|
||||
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh));
|
||||
|
||||
if (faMeshPtr)
|
||||
{
|
||||
@ -91,7 +80,7 @@ PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
|
||||
)
|
||||
);
|
||||
|
||||
meshesFa.set(regioni, faMeshPtr);
|
||||
meshesFa.set(regioni, std::move(faMeshPtr));
|
||||
|
||||
ensightMeshesFa.set
|
||||
(
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user