BUG: redistributePar: cell/face/pointProcAddressing written to incorrect dir

This commit is contained in:
mattijs
2023-10-25 15:05:53 +01:00
committed by Andrew Heather
parent 910713398e
commit 31825dd981
4 changed files with 48 additions and 17 deletions

View File

@ -1040,7 +1040,8 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
mesh, mesh,
distMap(), distMap(),
decompose, decompose,
writeHandler mesh.facesInstance(), //oldFacesInstance,
writeHandler // to write *ProcAddressing
); );
} }
else if (reconstruct) else if (reconstruct)
@ -1054,6 +1055,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
mesh, mesh,
distMap(), distMap(),
decompose, decompose,
volMeshInstance, //oldFacesInstance,
readHandler //writeHandler readHandler //writeHandler
); );
} }

View File

@ -760,12 +760,19 @@ Foam::fvMeshTools::loadOrCreateMeshImpl
const label oldNumProcs = fileHandler().nProcs(); const label oldNumProcs = fileHandler().nProcs();
const int oldCache = fileOperation::cacheLevel(0); const int oldCache = fileOperation::cacheLevel(0);
const fileName facesInstance = io.time().findInstance
(
meshSubDir,
"faces",
IOobject::MUST_READ
);
patchEntries = polyBoundaryMeshEntries patchEntries = polyBoundaryMeshEntries
( (
IOobject IOobject
( (
"boundary", "boundary",
io.instance(), facesInstance,
meshSubDir, meshSubDir,
io.db(), io.db(),
IOobject::MUST_READ, IOobject::MUST_READ,

View File

@ -220,6 +220,7 @@ public:
const fvMesh& procMesh, const fvMesh& procMesh,
const mapDistributePolyMesh& map, const mapDistributePolyMesh& map,
const bool decompose, const bool decompose,
const fileName& writeHandlerInstance,
refPtr<fileOperation>& writeHandler refPtr<fileOperation>& writeHandler
); );
}; };

View File

@ -303,6 +303,7 @@ void Foam::fvMeshTools::writeProcAddressing
const fvMesh& mesh, const fvMesh& mesh,
const mapDistributePolyMesh& map, const mapDistributePolyMesh& map,
const bool decompose, const bool decompose,
const fileName& writeHandlerInstance,
refPtr<fileOperation>& writeHandler refPtr<fileOperation>& writeHandler
) )
{ {
@ -317,7 +318,7 @@ void Foam::fvMeshTools::writeProcAddressing
// been done independently (as a registered object) // been done independently (as a registered object)
IOobject ioAddr IOobject ioAddr
( (
"procAddressing", "proc-addressing",
mesh.facesInstance(), mesh.facesInstance(),
polyMesh::meshSubDir, polyMesh::meshSubDir,
mesh.thisDb(), mesh.thisDb(),
@ -421,23 +422,43 @@ void Foam::fvMeshTools::writeProcAddressing
); );
} }
auto oldHandler = fileOperation::fileHandler(writeHandler);
const bool cellOk = cellMap.write(); // Switch to using the correct
const bool faceOk = faceMap.write(); // - fileHandler
const bool pointOk = pointMap.write(); // - instance
const bool patchOk = patchMap.write(); // to write to the original mesh/time in the original format. Clunky!
// Bypass regIOobject writing to avoid taking over the current time
// as instance so instead of e.g. 'celllMap.write()' directly call
// the chosen file-handler.
writeHandler = fileOperation::fileHandler(oldHandler); const auto& tm = cellMap.time();
const IOstreamOption opt(tm.writeFormat(), tm.writeCompression());
if (!cellOk || !faceOk || !pointOk || !patchOk)
{ {
WarningInFunction auto oldHandler = fileOperation::fileHandler(writeHandler);
<< "Failed to write some of "
<< cellMap.objectRelPath() << ", " cellMap.instance() = writeHandlerInstance;
<< faceMap.objectRelPath() << ", " const bool cellOk = fileHandler().writeObject(cellMap, opt, true);
<< pointMap.objectRelPath() << ", "
<< patchMap.objectRelPath() << endl; faceMap.instance() = writeHandlerInstance;
const bool faceOk = fileHandler().writeObject(faceMap, opt, true);
pointMap.instance() = writeHandlerInstance;
const bool pointOk = fileHandler().writeObject(pointMap, opt, true);
patchMap.instance() = writeHandlerInstance;
const bool patchOk = fileHandler().writeObject(patchMap, opt, true);
writeHandler = fileOperation::fileHandler(oldHandler);
if (!cellOk || !faceOk || !pointOk || !patchOk)
{
WarningInFunction
<< "Failed to write some of "
<< cellMap.objectRelPath() << ", "
<< faceMap.objectRelPath() << ", "
<< pointMap.objectRelPath() << ", "
<< patchMap.objectRelPath() << endl;
}
} }
} }