mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: more fault-tolerance in makeFaMesh decomposition
- if the volume faceProcAddressing is missing, it is not readily possible to determine equivalent area procAddressing. Instead of throwing an error, be more fault-tolerant by having it create with READ_IF_PRESENT and then detect and warn if there are problems.
This commit is contained in:
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -15,9 +15,21 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// Embed do-while to support early termination
|
||||||
if (doDecompose && Pstream::parRun())
|
if (doDecompose && Pstream::parRun())
|
||||||
|
do
|
||||||
{
|
{
|
||||||
faMeshReconstructor reconstructor(aMesh);
|
faMeshReconstructor reconstructor(aMesh, IOobjectOption::READ_IF_PRESENT);
|
||||||
|
|
||||||
|
if (!reconstructor.good())
|
||||||
|
{
|
||||||
|
Info<< "Missing volume proc-addressing, "
|
||||||
|
"cannot generate area proc-addressing." << nl
|
||||||
|
<< "Also skip decomposing area fields...."
|
||||||
|
<< endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
reconstructor.writeAddressing();
|
reconstructor.writeAddressing();
|
||||||
|
|
||||||
Info<< "Wrote proc-addressing" << nl << endl;
|
Info<< "Wrote proc-addressing" << nl << endl;
|
||||||
@ -77,7 +89,7 @@ if (doDecompose && Pstream::parRun())
|
|||||||
areaFieldsCache.decomposeAllFields(fieldDecomposer, true);
|
areaFieldsCache.decomposeAllFields(fieldDecomposer, true);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
}
|
} while (false);
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -402,7 +402,7 @@ class faFieldDecomposer::fieldsCache
|
|||||||
|
|
||||||
class privateCache;
|
class privateCache;
|
||||||
|
|
||||||
//- All field and field-field types for lagrangian
|
//- All field and field-field types for finiteArea
|
||||||
std::unique_ptr<privateCache> cache_;
|
std::unique_ptr<privateCache> cache_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -466,7 +466,7 @@ void Foam::faMeshReconstructor::createMesh()
|
|||||||
|
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false // not registered
|
IOobject::NO_REGISTER
|
||||||
),
|
),
|
||||||
pointField(singlePatchPoints_), // copy
|
pointField(singlePatchPoints_), // copy
|
||||||
faceList(singlePatchFaces_), // copy
|
faceList(singlePatchFaces_), // copy
|
||||||
@ -525,10 +525,12 @@ void Foam::faMeshReconstructor::createMesh()
|
|||||||
|
|
||||||
Foam::faMeshReconstructor::faMeshReconstructor
|
Foam::faMeshReconstructor::faMeshReconstructor
|
||||||
(
|
(
|
||||||
const faMesh& procMesh
|
const faMesh& procMesh,
|
||||||
|
IOobjectOption::readOption readVolAddressing
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
procMesh_(procMesh)
|
procMesh_(procMesh),
|
||||||
|
errors_(0)
|
||||||
{
|
{
|
||||||
if (!Pstream::parRun())
|
if (!Pstream::parRun())
|
||||||
{
|
{
|
||||||
@ -537,32 +539,49 @@ Foam::faMeshReconstructor::faMeshReconstructor
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require faceProcAddressing from finiteVolume decomposition
|
IOobject ioAddr
|
||||||
labelIOList fvFaceProcAddressing
|
|
||||||
(
|
(
|
||||||
IOobject
|
"faceProcAddressing",
|
||||||
(
|
procMesh_.mesh().facesInstance(),
|
||||||
"faceProcAddressing",
|
|
||||||
procMesh_.mesh().facesInstance(),
|
|
||||||
|
|
||||||
// Or search?
|
// Or search?
|
||||||
// procMesh_.time().findInstance
|
// procMesh_.time().findInstance
|
||||||
// (
|
// (
|
||||||
// // Search for polyMesh face instance
|
// // Search for polyMesh face instance
|
||||||
// // mesh.facesInstance()
|
// // mesh.facesInstance()
|
||||||
// procMesh_.mesh().meshDir(),
|
// procMesh_.mesh().meshDir(),
|
||||||
// "faceProcAddressing"
|
// "faceProcAddressing"
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
polyMesh::meshSubDir,
|
polyMesh::meshSubDir,
|
||||||
procMesh_.mesh(), // The polyMesh db
|
procMesh_.mesh(), // The polyMesh db
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE,
|
readVolAddressing, // Read option
|
||||||
false // not registered
|
IOobject::NO_WRITE,
|
||||||
)
|
IOobject::NO_REGISTER
|
||||||
);
|
);
|
||||||
|
|
||||||
calcAddressing(fvFaceProcAddressing);
|
// Require faceProcAddressing from finiteVolume decomposition
|
||||||
|
labelIOList fvFaceProcAddr(ioAddr);
|
||||||
|
|
||||||
|
// Check if any/all where read.
|
||||||
|
// Use 'headerClassName' for checking
|
||||||
|
bool fileOk
|
||||||
|
(
|
||||||
|
(fvFaceProcAddr.readOpt() != IOobjectOption::NO_READ)
|
||||||
|
&& fvFaceProcAddr.isHeaderClass<labelIOList>()
|
||||||
|
);
|
||||||
|
|
||||||
|
Pstream::reduceAnd(fileOk);
|
||||||
|
|
||||||
|
if (fileOk)
|
||||||
|
{
|
||||||
|
calcAddressing(fvFaceProcAddr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errors_ = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -572,7 +591,8 @@ Foam::faMeshReconstructor::faMeshReconstructor
|
|||||||
const labelUList& fvFaceProcAddressing
|
const labelUList& fvFaceProcAddressing
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
procMesh_(procMesh)
|
procMesh_(procMesh),
|
||||||
|
errors_(0)
|
||||||
{
|
{
|
||||||
if (!Pstream::parRun())
|
if (!Pstream::parRun())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -44,8 +44,8 @@ SourceFiles
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef faMeshReconstructor_H
|
#ifndef Foam_faMeshReconstructor_H
|
||||||
#define faMeshReconstructor_H
|
#define Foam_faMeshReconstructor_H
|
||||||
|
|
||||||
#include "faMesh.H"
|
#include "faMesh.H"
|
||||||
#include "primitivePatch.H"
|
#include "primitivePatch.H"
|
||||||
@ -69,6 +69,11 @@ class faMeshReconstructor
|
|||||||
//- The processor-specific faMesh
|
//- The processor-specific faMesh
|
||||||
const faMesh& procMesh_;
|
const faMesh& procMesh_;
|
||||||
|
|
||||||
|
// Flags
|
||||||
|
|
||||||
|
//- Problems encountered during construction?
|
||||||
|
int errors_;
|
||||||
|
|
||||||
|
|
||||||
// Addressing
|
// Addressing
|
||||||
|
|
||||||
@ -142,7 +147,12 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
explicit faMeshReconstructor(const faMesh& procMesh);
|
explicit faMeshReconstructor
|
||||||
|
(
|
||||||
|
const faMesh& procMesh,
|
||||||
|
IOobjectOption::readOption readVolProcAddr =
|
||||||
|
IOobjectOption::MUST_READ
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
faMeshReconstructor
|
faMeshReconstructor
|
||||||
@ -160,6 +170,9 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- True if no construct errors encountered
|
||||||
|
bool good() const noexcept { return !errors_; }
|
||||||
|
|
||||||
//- Processor point addressing
|
//- Processor point addressing
|
||||||
const labelList& pointProcAddressing() const noexcept
|
const labelList& pointProcAddressing() const noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user