Files
openfoam/applications/utilities/postProcessing/dataConversion/foamToEnsight/createMeshAccounting.H
Mark Olesen 730ce92b68 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) ...
2022-03-12 21:16:30 +01:00

97 lines
2.7 KiB
C++

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Additional mesh accounting (Ensight)
\*---------------------------------------------------------------------------*/
PtrList<ensightCase> ensightCases(regionNames.size());
PtrList<ensightMesh> ensightMeshes(regionNames.size());
PtrList<faMesh> meshesFa(regionNames.size());
PtrList<ensightCase> ensightCasesFa(regionNames.size());
PtrList<ensightFaMesh> ensightMeshesFa(regionNames.size());
{
forAll(regionNames, regioni)
{
const fvMesh& mesh = meshes[regioni];
const word& regionName = regionNames[regioni];
const word& regionDir =
(
regionName != polyMesh::defaultRegion
? regionName
: word::null
);
fileName ensCasePath(outputDir);
word ensCaseName(args.globalCaseName());
if (!regionDir.empty())
{
ensCaseName = regionName;
ensCasePath /= regionName;
// Handle very rare naming collision with Ensight directories
if (regionName == "data")
{
ensCasePath += "-region";
}
}
ensightMeshes.set
(
regioni,
new ensightMesh(mesh, writeOpts)
);
// New ensight case file, initialize header etc.
ensightCases.set
(
regioni,
new ensightCase(ensCasePath, ensCaseName, caseOpts)
);
if (doFiniteArea)
{
autoPtr<faMesh> faMeshPtr(faMesh::TryNew(mesh));
if (faMeshPtr)
{
ensightCasesFa.set
(
regioni,
new ensightCase
(
ensCasePath/"finite-area",
"finite-area",
caseOpts
)
);
meshesFa.set(regioni, std::move(faMeshPtr));
ensightMeshesFa.set
(
regioni,
new ensightFaMesh(meshesFa[regioni])
);
}
}
}
}
// ************************************************************************* //