fvMesh: Split construction
This provides finer control as to when the changes get constructed and initial stitching is performed. These is needed by certain processes, notably decomposition and reconstruction. By default, the mesh still performs all these operations on a "normal" read-construction. A flag has to be passed explicitly to the constructor in order to prevent the post-construction steps.
This commit is contained in:
@ -113,10 +113,6 @@ Foam::regionSolvers::regionSolvers(const Time& runTime)
|
||||
forAll(regionSolverNames, i)
|
||||
{
|
||||
const word& regionName = regionSolverNames[i].first();
|
||||
const word& solverName = regionSolverNames[i].second();
|
||||
|
||||
// Load the solver library
|
||||
solver::load(solverName);
|
||||
|
||||
regions_.set
|
||||
(
|
||||
@ -129,9 +125,24 @@ Foam::regionSolvers::regionSolvers(const Time& runTime)
|
||||
runTime.name(),
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
),
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
forAll(regions_, i)
|
||||
{
|
||||
regions_[i].postConstruct(true, fvMesh::stitchType::geometric);
|
||||
}
|
||||
|
||||
forAll(regionSolverNames, i)
|
||||
{
|
||||
const word& regionName = regionSolverNames[i].first();
|
||||
const word& solverName = regionSolverNames[i].second();
|
||||
|
||||
// Load the solver library
|
||||
solver::load(solverName);
|
||||
|
||||
solvers_.set(i, solver::New(solverName, regions_[i]));
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -48,7 +48,8 @@ int main(int argc, char *argv[])
|
||||
runTime.name(),
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
Info<< mesh.C() << endl;
|
||||
|
||||
@ -477,10 +477,11 @@ void Foam::vtkPVFoam::updateFoamMesh()
|
||||
dbPtr_(),
|
||||
IOobject::MUST_READ
|
||||
),
|
||||
false,
|
||||
fvMesh::stitchType::nonGeometric
|
||||
false
|
||||
);
|
||||
|
||||
meshPtr_->postConstruct(false, fvMesh::stitchType::nonGeometric);
|
||||
|
||||
meshChanged_ = true;
|
||||
}
|
||||
else
|
||||
|
||||
@ -13,3 +13,5 @@ Foam::fvMesh mesh
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
mesh.postConstruct(false, fvMesh::stitchType::geometric);
|
||||
|
||||
@ -25,3 +25,5 @@ Foam::fvMesh mesh
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
mesh.postConstruct(false, fvMesh::stitchType::geometric);
|
||||
|
||||
@ -267,17 +267,12 @@ Foam::surfaceLabelField::Boundary& Foam::fvMesh::polyFacesBfRef()
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fvMesh::fvMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const bool changers,
|
||||
const stitchType stitch
|
||||
)
|
||||
Foam::fvMesh::fvMesh(const IOobject& io, const bool doPost)
|
||||
:
|
||||
polyMesh(io),
|
||||
surfaceInterpolation(*this),
|
||||
boundary_(*this, boundaryMesh()),
|
||||
stitcher_(fvMeshStitcher::New(*this, changers).ptr()),
|
||||
stitcher_(nullptr),
|
||||
topoChanger_(nullptr),
|
||||
distributor_(nullptr),
|
||||
mover_(nullptr),
|
||||
@ -307,54 +302,9 @@ Foam::fvMesh::fvMesh
|
||||
Pout<< FUNCTION_NAME << "Constructing fvMesh from IOobject" << endl;
|
||||
}
|
||||
|
||||
// Stitch or Re-stitch if necessary
|
||||
if (stitch != stitchType::none)
|
||||
if (doPost)
|
||||
{
|
||||
stitcher_->connect(false, stitch == stitchType::geometric, true);
|
||||
}
|
||||
|
||||
// Construct changers
|
||||
if (changers)
|
||||
{
|
||||
topoChanger_.set(fvMeshTopoChanger::New(*this).ptr());
|
||||
distributor_.set(fvMeshDistributor::New(*this).ptr());
|
||||
mover_.set(fvMeshMover::New(*this).ptr());
|
||||
|
||||
// Check the existence of the cell volumes and read if present
|
||||
if (fileHandler().isFile(time().timePath()/"Vc0"))
|
||||
{
|
||||
V0Ptr_ = new DimensionedField<scalar, volMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Vc0",
|
||||
time().name(),
|
||||
*this,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
true
|
||||
),
|
||||
*this
|
||||
);
|
||||
}
|
||||
|
||||
// Check the existence of the mesh fluxes and read if present
|
||||
if (fileHandler().isFile(time().timePath()/"meshPhi"))
|
||||
{
|
||||
phiPtr_ = new surfaceScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"meshPhi",
|
||||
time().name(),
|
||||
*this,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
true
|
||||
),
|
||||
*this
|
||||
);
|
||||
}
|
||||
postConstruct(true, stitchType::geometric);
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,6 +522,66 @@ Foam::fvMesh::~fvMesh()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fvMesh::postConstruct(const bool changers, const stitchType stitch)
|
||||
{
|
||||
// Construct the stitcher
|
||||
stitcher_.set(fvMeshStitcher::New(*this, changers).ptr());
|
||||
|
||||
// Stitch or Re-stitch if necessary
|
||||
if (stitch != stitchType::none)
|
||||
{
|
||||
stitcher_->connect(false, stitch == stitchType::geometric, true);
|
||||
}
|
||||
|
||||
// Construct changers
|
||||
if (changers)
|
||||
{
|
||||
topoChanger_.set(fvMeshTopoChanger::New(*this).ptr());
|
||||
distributor_.set(fvMeshDistributor::New(*this).ptr());
|
||||
mover_.set(fvMeshMover::New(*this).ptr());
|
||||
|
||||
// Check the existence of the cell volumes and read if present
|
||||
// and set the storage of V00
|
||||
if (fileHandler().isFile(time().timePath()/"Vc0"))
|
||||
{
|
||||
V0Ptr_ = new DimensionedField<scalar, volMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Vc0",
|
||||
time().name(),
|
||||
*this,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
true
|
||||
),
|
||||
*this
|
||||
);
|
||||
|
||||
V00();
|
||||
}
|
||||
|
||||
// Check the existence of the mesh fluxes and read if present
|
||||
if (fileHandler().isFile(time().timePath()/"meshPhi"))
|
||||
{
|
||||
phiPtr_ = new surfaceScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"meshPhi",
|
||||
time().name(),
|
||||
*this,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
true
|
||||
),
|
||||
*this
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::fvMesh::topoChanging() const
|
||||
{
|
||||
return topoChanger_.valid() && topoChanger_->dynamic();
|
||||
@ -649,7 +659,7 @@ bool Foam::fvMesh::move()
|
||||
|
||||
void Foam::fvMesh::addFvPatches
|
||||
(
|
||||
const List<polyPatch*> & p,
|
||||
const List<polyPatch*>& p,
|
||||
const bool validBoundary
|
||||
)
|
||||
{
|
||||
@ -748,11 +758,11 @@ Foam::fvMesh::readUpdateState Foam::fvMesh::readUpdate
|
||||
if
|
||||
(
|
||||
stitcher_.valid()
|
||||
&& stitch != stitchType::none
|
||||
&& stitcher_->stitches()
|
||||
&& state != polyMesh::UNCHANGED
|
||||
)
|
||||
{
|
||||
stitcher_->disconnect(false, stitch == stitchType::geometric);
|
||||
stitcher_->disconnect(false, false);
|
||||
}
|
||||
|
||||
if (state == polyMesh::TOPO_PATCH_CHANGE)
|
||||
@ -793,8 +803,9 @@ Foam::fvMesh::readUpdateState Foam::fvMesh::readUpdate
|
||||
if
|
||||
(
|
||||
stitcher_.valid()
|
||||
&& stitch != stitchType::none
|
||||
&& stitcher_->stitches()
|
||||
&& state != polyMesh::UNCHANGED
|
||||
&& stitch != stitchType::none
|
||||
)
|
||||
{
|
||||
stitcher_->connect(false, stitch == stitchType::geometric, true);
|
||||
@ -973,6 +984,12 @@ const Foam::fvMeshStitcher& Foam::fvMesh::stitcher() const
|
||||
}
|
||||
|
||||
|
||||
Foam::fvMeshStitcher& Foam::fvMesh::stitcher()
|
||||
{
|
||||
return stitcher_();
|
||||
}
|
||||
|
||||
|
||||
const Foam::fvMeshTopoChanger& Foam::fvMesh::topoChanger() const
|
||||
{
|
||||
return topoChanger_();
|
||||
|
||||
@ -327,15 +327,10 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
// with the option to not instantiate the mesh changers and the option
|
||||
// to prevent some or all of the stitching
|
||||
explicit fvMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
const bool changers = true,
|
||||
const stitchType stitch = stitchType::geometric
|
||||
);
|
||||
//- Construct from IOobject. Optionally prevent post-construction, so
|
||||
// that postConstruct may be called manually for finer control of
|
||||
// construction of mesh changes and the level of stitching.
|
||||
explicit fvMesh(const IOobject& io, const bool doPost = true);
|
||||
|
||||
//- Construct from cellShapes with boundary.
|
||||
fvMesh
|
||||
@ -364,7 +359,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct without boundary from cells rather than owner/neighbour.
|
||||
// Boundary is added using addPatches() member function
|
||||
// Boundary is added using addFvPatches() member function
|
||||
fvMesh
|
||||
(
|
||||
const IOobject& io,
|
||||
@ -389,6 +384,13 @@ public:
|
||||
|
||||
// Helpers
|
||||
|
||||
//- Complete construction of the mesh
|
||||
void postConstruct
|
||||
(
|
||||
const bool changers,
|
||||
const stitchType stitch
|
||||
);
|
||||
|
||||
//- Add boundary patches. Constructor helper
|
||||
void addFvPatches
|
||||
(
|
||||
@ -488,6 +490,9 @@ public:
|
||||
//- Return the stitcher function class
|
||||
const fvMeshStitcher& stitcher() const;
|
||||
|
||||
//- Return the stitcher function class
|
||||
fvMeshStitcher& stitcher();
|
||||
|
||||
//- Return the topo-changer function class
|
||||
const fvMeshTopoChanger& topoChanger() const;
|
||||
|
||||
|
||||
@ -245,8 +245,7 @@ bool Foam::fvMeshTopoChangers::meshToMesh::update()
|
||||
time,
|
||||
IOobject::MUST_READ
|
||||
),
|
||||
false,
|
||||
fvMesh::stitchType::none
|
||||
false
|
||||
);
|
||||
|
||||
mesh().swap(otherMesh);
|
||||
|
||||
@ -106,11 +106,16 @@ void Foam::domainDecomposition::readComplete(const bool stitch)
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
completeMesh_->init
|
||||
(
|
||||
false,
|
||||
stitch
|
||||
? fvMesh::stitchType::nonGeometric
|
||||
: fvMesh::stitchType::none
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -136,6 +141,12 @@ void Foam::domainDecomposition::readProcs()
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
procMeshes_[proci].init
|
||||
(
|
||||
false,
|
||||
fvMesh::stitchType::nonGeometric
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user