BUG: copy construct of faSchemes/faSolution ignored (see !605)

- the faMesh/fvMesh copy constructors were using the readOption from
  the base-mesh schemes/solution instead of copying their contents.

  This would not really affect fvMesh (since it has its own IOobject
  for the constructor), but did affect faMesh. However, the problem
  only shows up with collated + redistribute, since that is where
  the ranks can be doing uncoordinated IO.

  Only consider as a bug for recent develop since previous versions
  had other problems with collated+redistribute with finite-area
  anyhow.
This commit is contained in:
Mark Olesen
2023-12-11 19:24:18 +01:00
parent 5b177b44f3
commit 56a0f80863
9 changed files with 225 additions and 29 deletions

View File

@ -344,13 +344,18 @@ bool Foam::faMesh::init(const bool doInit)
Foam::faMesh::faMesh(const polyMesh& pMesh, const Foam::zero)
:
faMesh(pMesh, labelList(), static_cast<const IOobject&>(pMesh))
faMesh(pMesh, labelList(), static_cast<IOobjectOption>(pMesh))
{}
Foam::faMesh::faMesh(const faMesh& baseMesh, const Foam::zero)
:
faMesh(baseMesh, labelList())
faMesh
(
baseMesh,
labelList(),
IOobjectOption(IOobjectOption::NO_READ, IOobjectOption::NO_WRITE)
)
{}
@ -471,7 +476,12 @@ Foam::faMesh::faMesh
labelList&& faceLabels
)
:
faMesh(pMesh, std::move(faceLabels), static_cast<const IOobject&>(pMesh))
faMesh
(
pMesh,
std::move(faceLabels),
static_cast<IOobjectOption>(pMesh)
)
{}
@ -479,13 +489,13 @@ Foam::faMesh::faMesh
(
const polyMesh& pMesh,
labelList&& faceLabels,
const IOobject& io
IOobjectOption ioOpt
)
:
MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>(pMesh),
faSchemes(mesh(), io.readOpt()),
faSchemes(mesh(), ioOpt.readOpt()),
edgeInterpolation(*this),
faSolution(mesh(), io.readOpt()),
faSolution(mesh(), ioOpt.readOpt()),
faceLabels_
(
IOobject
@ -553,20 +563,23 @@ Foam::faMesh::faMesh
Foam::faMesh::faMesh
(
const faMesh& baseMesh,
labelList&& faceLabels
labelList&& faceLabels,
IOobjectOption ioOpt
)
:
MeshObject<polyMesh, Foam::UpdateableMeshObject, faMesh>(baseMesh.mesh()),
faSchemes
(
mesh(),
static_cast<const faSchemes&>(baseMesh)
faMesh::thisDb(),
ioOpt.readOpt(),
static_cast<const dictionary*>(baseMesh.hasSchemes())
),
edgeInterpolation(*this),
faSolution
(
mesh(),
static_cast<const faSolution&>(baseMesh)
faMesh::thisDb(),
ioOpt.readOpt(),
static_cast<const dictionary*>(baseMesh.hasSolution())
),
faceLabels_
(
@ -740,6 +753,42 @@ Foam::faMesh::~faMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::faSchemes* Foam::faMesh::hasSchemes() const
{
return static_cast<const faSchemes*>(this);
}
const Foam::faSolution* Foam::faMesh::hasSolution() const
{
return static_cast<const faSolution*>(this);
}
const Foam::faSchemes& Foam::faMesh::schemes() const
{
return static_cast<const faSchemes&>(*this);
}
Foam::faSchemes& Foam::faMesh::schemes()
{
return static_cast<faSchemes&>(*this);
}
const Foam::faSolution& Foam::faMesh::solution() const
{
return static_cast<const faSolution&>(*this);
}
Foam::faSolution& Foam::faMesh::solution()
{
return static_cast<faSolution&>(*this);
}
Foam::fileName Foam::faMesh::meshDir() const
{
return mesh().dbDir()/faMesh::meshSubDir;

View File

@ -534,29 +534,38 @@ public:
faMesh(const polyMesh& pMesh, const Foam::zero);
//- Construct as copy (for dictionaries) and zero-sized
//- without boundary, using IOobject properties from polyMesh.
//- without boundary.
// 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.
//- without boundary, using read properties from baseMesh.
// Boundary is added using addFaPatches() member function
faMesh(const faMesh& baseMesh, labelList&& faceLabels);
//- Construct as copy (for dictionaries) and faceLabels
//- without boundary, using specified read properties.
// Boundary is added using addFaPatches() member function.
faMesh
(
const faMesh& baseMesh,
labelList&& faceLabels,
IOobjectOption ioOpt
);
//- Construct from components (face labels) without boundary,
//- using IOobject properties from polyMesh.
// Boundary is added using addFaPatches() member function.
faMesh(const polyMesh& pMesh, labelList&& faceLabels);
//- Construct from components (face labels) without boundary,
//- using alternative IOobject properties
//- (primarily the readOption).
//- using specified read properties.
// Boundary is added using addFaPatches() member function.
faMesh
(
const polyMesh& pMesh,
labelList&& faceLabels,
const IOobject& io
IOobjectOption ioOpt
);
//- Construct from single polyPatch
@ -672,6 +681,27 @@ public:
const faGlobalMeshData& globalData() const;
// Solution Control
//- Non-null if faSchemes exists (can test as bool).
const faSchemes* hasSchemes() const;
//- Non-null if faSolution exists (can test as bool).
const faSolution* hasSolution() const;
//- Read-access to the faSchemes controls
const faSchemes& schemes() const;
//- Read/write-access to the faSchemes controls
faSchemes& schemes();
//- Read-access to the faSolution controls
const faSolution& solution() const;
//- Read/write-access to the faSolution controls
faSolution& solution();
// Access: Mesh size parameters
//- Number of local mesh points

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,6 +106,19 @@ public:
schemesLookup(obr, rOpt, "faSchemes", fallback)
{}
//- Construct for objectRegistry, readOption with the
//- default dictionary name ("faSchemes") and
//- fallback dictionary content.
faSchemes
(
const objectRegistry& obr,
IOobjectOption::readOption rOpt,
const dictionary& dict
)
:
schemesLookup(obr, rOpt, "faSchemes", &dict)
{}
//- Construct for objectRegistry with the
//- default dictionary name ("faSchemes").
// Uses the readOption from the registry.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,6 +106,19 @@ public:
schemesLookup(obr, rOpt, "fvSchemes", fallback)
{}
//- Construct for objectRegistry, readOption with the
//- default dictionary name ("fvSchemes") and
//- fallback dictionary content.
fvSchemes
(
const objectRegistry& obr,
IOobjectOption::readOption rOpt,
const dictionary& dict
)
:
schemesLookup(obr, rOpt, "fvSchemes", &dict)
{}
//- Construct for objectRegistry with the
//- default dictionary name ("fvSchemes").
// Uses the readOption from the registry.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -107,6 +107,19 @@ public:
solution(obr, rOpt, "fvSolution", fallback)
{}
//- Construct for objectRegistry, readOption with the
//- default dictionary name ("fvSolution") and
//- fallback dictionary content.
fvSolution
(
const objectRegistry& obr,
IOobjectOption::readOption rOpt,
const dictionary& dict
)
:
solution(obr, rOpt, "fvSolution", &dict)
{}
//- Construct for objectRegistry with the
//- default dictionary name ("fvSolution").
// Uses the readOption from the registry.

View File

@ -485,13 +485,15 @@ Foam::fvMesh::fvMesh
fvSchemes
(
static_cast<const objectRegistry&>(*this),
static_cast<const fvSchemes&>(baseMesh)
io.readOpt(),
static_cast<const dictionary*>(baseMesh.hasSchemes())
),
surfaceInterpolation(*this),
fvSolution
(
static_cast<const objectRegistry&>(*this),
static_cast<const fvSolution&>(baseMesh)
io.readOpt(),
static_cast<const dictionary*>(baseMesh.hasSolution())
),
boundary_(*this),
lduPtr_(nullptr),
@ -533,13 +535,15 @@ Foam::fvMesh::fvMesh
fvSchemes
(
static_cast<const objectRegistry&>(*this),
static_cast<const fvSchemes&>(baseMesh)
io.readOpt(),
static_cast<const dictionary*>(baseMesh.hasSchemes())
),
surfaceInterpolation(*this),
fvSolution
(
static_cast<const objectRegistry&>(*this),
static_cast<const fvSolution&>(baseMesh)
io.readOpt(),
static_cast<const dictionary*>(baseMesh.hasSolution())
),
boundary_(*this),
lduPtr_(nullptr),
@ -570,6 +574,42 @@ Foam::fvMesh::~fvMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::fvSchemes* Foam::fvMesh::hasSchemes() const
{
return static_cast<const fvSchemes*>(this);
}
const Foam::fvSolution* Foam::fvMesh::hasSolution() const
{
return static_cast<const fvSolution*>(this);
}
const Foam::fvSchemes& Foam::fvMesh::schemes() const
{
return static_cast<const fvSchemes&>(*this);
}
Foam::fvSchemes& Foam::fvMesh::schemes()
{
return static_cast<fvSchemes&>(*this);
}
const Foam::fvSolution& Foam::fvMesh::solution() const
{
return static_cast<const fvSolution&>(*this);
}
Foam::fvSolution& Foam::fvMesh::solution()
{
return static_cast<fvSolution&>(*this);
}
Foam::SolverPerformance<Foam::scalar> Foam::fvMesh::solve
(
fvMatrix<scalar>& m,

View File

@ -332,6 +332,27 @@ public:
}
// Solution Control
//- Non-null if fvSchemes exists (can test as bool).
const fvSchemes* hasSchemes() const;
//- Non-null if fvSolution exists (can test as bool).
const fvSolution* hasSolution() const;
//- Read-access to the fvSchemes controls
const fvSchemes& schemes() const;
//- Read/write-access to the fvSchemes controls
fvSchemes& schemes();
//- Read-access to the fvSolution controls
const fvSolution& solution() const;
//- Read/write-access to the fvSolution controls
fvSolution& solution();
// Overlap
//- Interpolate interpolationCells only

View File

@ -3,6 +3,9 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
unset fileHandler
fileHandler="-fileHandler collated"
restore0Dir
runApplication blockMesh
@ -15,19 +18,20 @@ then
runApplication makeFaMesh
runApplication decomposePar
runApplication decomposePar $fileHandler
else
# Additional steps (to exercise some functionality)
runParallel $decompDict -s decompose redistributePar -decompose
runParallel $decompDict -s decompose redistributePar -decompose \
-no-finite-area $fileHandler
runParallel $decompDict makeFaMesh
runParallel $decompDict makeFaMesh $fileHandler
runParallel -s redistribute redistributePar -overwrite
runParallel -s redistribute redistributePar -overwrite $fileHandler
fi
runParallel $(getApplication)
runParallel $(getApplication) $fileHandler
#------------------------------------------------------------------------------