BUG: distributed roots cause redistributePar failure (fixes #2523)

- zero-sized faMeshSubset and fvMeshSubset had READ_IF_PRESENT instead
  of simply copying the schemes/solution setting from the baseMesh
This commit is contained in:
Mark Olesen
2022-06-23 18:20:06 +02:00
parent 7b94573add
commit 39d8964851
14 changed files with 219 additions and 43 deletions

View File

@ -76,14 +76,10 @@ void Foam::parFaFieldDistributorCache::read
// Missing an area mesh somewhere?
if (areaMeshOnProc.found(false))
{
const bool oldParRun = Pstream::parRun(false);
// A zero-sized mesh with boundaries.
// This is used to create zero-sized fields.
subsetterPtr.reset(new faMeshSubset(mesh, zero{}));
Pstream::parRun(oldParRun);
// Deregister from polyMesh ...
auto& obr = const_cast<objectRegistry&>
(

View File

@ -631,13 +631,9 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
// Missing a volume mesh somewhere?
if (volMeshOnProc.found(false))
{
const bool oldParRun = Pstream::parRun(false);
// A zero-sized mesh with boundaries.
// This is used to create zero-sized fields.
subsetterPtr.reset(new fvMeshSubset(mesh, zero{}));
Pstream::parRun(oldParRun);
}

View File

@ -105,11 +105,11 @@ bool Foam::dynamicFvMesh::init(const bool doInit)
Foam::dynamicFvMesh::dynamicFvMesh
(
const IOobject& io,
const zero,
const bool syncPar
const Foam::zero,
bool syncPar
)
:
fvMesh(io, Zero, syncPar),
fvMesh(io, Foam::zero{}, syncPar),
timeControl_(io.time(), "update")
{
readDict();

View File

@ -115,12 +115,12 @@ public:
// Constructors
//- Construct from an IOobject
//- Construct from IOobject
explicit dynamicFvMesh(const IOobject& io, const bool doInit=true);
//- Construct from components without boundary.
//- Construct from IOobject or as zero-sized mesh
// Boundary is added using addFvPatches() member function
dynamicFvMesh(const IOobject& io, const zero, const bool syncPar=true);
dynamicFvMesh(const IOobject& io, const Foam::zero, bool syncPar=true);
//- Construct from components without boundary.
// Boundary is added using addFvPatches() member function

View File

@ -307,6 +307,12 @@ Foam::faMesh::faMesh(const polyMesh& pMesh, const Foam::zero)
{}
Foam::faMesh::faMesh(const faMesh& baseMesh, const Foam::zero)
:
faMesh(baseMesh, labelList())
{}
Foam::faMesh::faMesh
(
const polyMesh& pMesh,
@ -483,6 +489,85 @@ Foam::faMesh::faMesh
{}
Foam::faMesh::faMesh
(
const faMesh& baseMesh,
labelList&& faceLabels
)
:
MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>(baseMesh.mesh()),
faSchemes
(
mesh(),
static_cast<const faSchemes&>(baseMesh)
),
edgeInterpolation(*this),
faSolution
(
mesh(),
static_cast<const faSolution&>(baseMesh)
),
data
(
mesh(),
static_cast<const data&>(baseMesh)
),
faceLabels_
(
IOobject
(
"faceLabels",
mesh().facesInstance(),
faMesh::meshSubDir,
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
std::move(faceLabels)
),
boundary_
(
IOobject
(
"faBoundary",
mesh().facesInstance(),
faMesh::meshSubDir,
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
label(0)
),
comm_(Pstream::worldComm),
curTimeIndex_(time().timeIndex()),
patchPtr_(nullptr),
bndConnectPtr_(nullptr),
lduPtr_(nullptr),
SPtr_(nullptr),
S0Ptr_(nullptr),
S00Ptr_(nullptr),
patchStartsPtr_(nullptr),
LePtr_(nullptr),
magLePtr_(nullptr),
centresPtr_(nullptr),
edgeCentresPtr_(nullptr),
faceAreaNormalsPtr_(nullptr),
edgeAreaNormalsPtr_(nullptr),
pointAreaNormalsPtr_(nullptr),
faceCurvaturesPtr_(nullptr),
edgeTransformTensorsPtr_(nullptr),
correctPatchPointNormalsPtr_(nullptr),
globalMeshDataPtr_(nullptr),
haloMapPtr_(nullptr),
haloFaceCentresPtr_(nullptr),
haloFaceNormalsPtr_(nullptr)
{}
Foam::faMesh::faMesh(const polyPatch& pp, const bool doInit)
:
faMesh

View File

@ -514,6 +514,16 @@ public:
// Boundary is added using addFaPatches() member function
faMesh(const polyMesh& pMesh, const Foam::zero);
//- Construct as copy (for dictionaries) and zero-sized
//- without boundary, using IOobject properties from polyMesh.
// Boundary is added using addFaPatches() member function
faMesh(const faMesh& baseMesh, const Foam::zero);
//- Construct as copy (for dictionaries) and faceLabels
//- without boundary, using IOobject properties from polyMesh.
// Boundary is added using addFaPatches() member function
faMesh(const faMesh& baseMesh, labelList&& faceLabels);
//- Construct from components (face labels) without boundary,
//- using IOobject properties from polyMesh.
// Boundary is added using addFaPatches() member function.

View File

@ -103,19 +103,7 @@ void Foam::faMeshSubset::reset(const Foam::zero)
// Create zero-sized subMesh
subMeshPtr_.reset
(
new faMesh
(
baseMesh_.mesh(), // The polyMesh
// IOobject
// (
// baseMesh_.name(),
// baseMesh_.time().timeName(),
// baseMesh_.time(),
// IOobject::READ_IF_PRESENT, // Read fa* if present
// IOobject::NO_WRITE
// ),
Foam::zero{} // zero-sized
)
new faMesh(baseMesh_, Foam::zero{})
);
auto& newSubMesh = subMeshPtr_();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -117,6 +117,14 @@ public:
:
solution(obr, "faSolution", fallback)
{}
//- Construct for objectRegistry with the
//- default dictionary name ("faSolution") and optional contents.
// Uses the readOption from the registry.
faSolution(const objectRegistry& obr, const dictionary& dict)
:
solution(obr, "faSolution", &dict)
{}
};

View File

@ -434,12 +434,33 @@ Foam::fvMesh::fvMesh
}
Foam::fvMesh::fvMesh(const IOobject& io, const zero, const bool syncPar)
Foam::fvMesh::fvMesh(const IOobject& io, const Foam::zero, const bool syncPar)
:
fvMesh(io, pointField(), faceList(), labelList(), labelList(), syncPar)
{}
Foam::fvMesh::fvMesh
(
const IOobject& io,
const fvMesh& baseMesh,
const Foam::zero,
const bool syncPar
)
:
fvMesh
(
io,
baseMesh,
pointField(),
faceList(),
labelList(), // owner
labelList(), // neighbour
syncPar
)
{}
Foam::fvMesh::fvMesh
(
const IOobject& io,

View File

@ -194,7 +194,17 @@ public:
//- Construct from IOobject or as zero-sized mesh
// Boundary is added using addFvPatches() member function
fvMesh(const IOobject& io, const zero, bool syncPar=true);
fvMesh(const IOobject& io, const Foam::zero, bool syncPar=true);
//- Construct as copy (for dictionaries) and zero-sized components.
// Boundary is added using addFvPatches() member function
fvMesh
(
const IOobject& io,
const fvMesh& baseMesh,
const Foam::zero,
const bool syncPar = true
);
//- Construct from components without boundary.
// Boundary is added using addFvPatches() member function
@ -219,8 +229,8 @@ public:
const bool syncPar = true
);
//- Construct as copy (for dictionaries) and components without
// boundary. Boundary is added using addFvPatches() member function
//- Copy construct (for dictionaries) with components, without boundary.
// Boundary is added using addFvPatches() member function
fvMesh
(
const IOobject& io,
@ -232,9 +242,8 @@ public:
const bool syncPar = true
);
//- Construct as copy (for dictionaries) without boundary from cells
// rather than owner/neighbour. Boundary is added using addFvPatches()
// member function
//- Copy construct (for dictionaries) with cells, without boundary.
// Boundary is added using addFvPatches() member function
fvMesh
(
const IOobject& io,

View File

@ -535,10 +535,11 @@ void Foam::fvMeshSubset::reset(const Foam::zero)
baseMesh_.name(),
baseMesh_.time().timeName(),
baseMesh_.time(),
IOobject::READ_IF_PRESENT, // Read fv* if present
IOobject::NO_READ, // Do not read any dictionaries
IOobject::NO_WRITE
),
Foam::zero{} // zero-sized
baseMesh_, // Get dictionaries from base mesh
Foam::zero{} // zero-sized
// Uses syncPar (bounds) - should generally be OK
)
);
@ -1001,13 +1002,13 @@ void Foam::fvMeshSubset::reset
(
IOobject
(
baseMesh().name(),
baseMesh().time().timeName(),
baseMesh().time(),
IOobject::NO_READ, // do not read any dictionaries
baseMesh_.name(),
baseMesh_.time().timeName(),
baseMesh_.time(),
IOobject::NO_READ, // Do not read any dictionaries
IOobject::NO_WRITE
),
baseMesh(), // get dictionaries from base mesh
baseMesh_, // Get dictionaries from base mesh
std::move(newPoints),
std::move(newFaces),
std::move(newCells),

View File

@ -3,6 +3,8 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
# ./Allclean
if isTest "$@"
then
# Reset the controlDict
@ -44,7 +46,7 @@ CASE_ROOTS
#export FOAM_ABORT=true
runParallel redistributePar -decompose -case test-distribute/machineA/testcase
runParallel -s decompose redistributePar -decompose -case test-distribute/machineA/testcase
runParallel checkMesh -case test-distribute/machineA/testcase

View File

@ -5,4 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
rm -rf test-*
#------------------------------------------------------------------------------

View File

@ -0,0 +1,58 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
## ./Allclean
restore0Dir
runApplication blockMesh
rm -rf test-distribute
masterDecompParDict="test-distribute/machineA/testcase/system/decomposeParDict"
for subdir in machineA machineB machineC machineD
do
mkdir -p test-distribute/"$subdir"/testcase
done
# master
cp -R 0 constant system test-distribute/machineA/testcase
# others (nothing to copy)
cat<< CASE_ROOTS >> "$masterDecompParDict"
distributed true;
roots
(
//master: "$PWD/test-distribute/machineA"
"$PWD/test-distribute/machineA"
"$PWD/test-distribute/machineA"
"$PWD/test-distribute/machineB"
"$PWD/test-distribute/machineB"
"$PWD/test-distribute/machineB"
"$PWD/test-distribute/machineC"
"$PWD/test-distribute/machineC"
"$PWD/test-distribute/machineC"
"$PWD/test-distribute/machineD"
"$PWD/test-distribute/machineD"
"$PWD/test-distribute/machineD"
);
CASE_ROOTS
#export FOAM_ABORT=true
runParallel -s decompose redistributePar -decompose -case test-distribute/machineA/testcase
# Currently fails (OpenFOAM-v2206)
runParallel checkFaMesh -case test-distribute/machineA/testcase
exit 0
#------------------------------------------------------------------------------