Skip to content

Commit

Permalink
postProcess: Stitch non-conformal couples on first time
Browse files Browse the repository at this point in the history
This has required implementation of finer control of stitching in the
fvMesh read constructor and readUpdate methods. Stitching is now
controlled independently of the mesh changers. Full-geometric stitching
is now always the default unless explicitly overridden in the calls to
fvMesh's read methods.
  • Loading branch information
Will Bainbridge committed Jul 28, 2022
1 parent d675aab commit fbd6702
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ int Foam::vtkPVFoam::setTime(int nRequest, const double requestTimes[])

if (meshPtr_)
{
if (meshPtr_->readUpdate(false) != polyMesh::UNCHANGED)
if
(
meshPtr_->readUpdate(fvMesh::stitchType::nonGeometric)
!= polyMesh::UNCHANGED
)
{
meshChanged_ = true;
}
Expand Down Expand Up @@ -474,7 +478,8 @@ void Foam::vtkPVFoam::updateFoamMesh()
dbPtr_(),
IOobject::MUST_READ
),
false
false,
fvMesh::stitchType::nonGeometric
);

meshChanged_ = true;
Expand Down
32 changes: 22 additions & 10 deletions src/finiteVolume/fvMesh/fvMesh.C
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@ Foam::fvMesh::fvMesh
(
const IOobject& io,
const bool changers,
const bool stitcher
const stitchType stitch
)
:
polyMesh(io),
surfaceInterpolation(*this),
data(static_cast<const objectRegistry&>(*this)),
boundary_(*this, boundaryMesh()),
stitcher_(nullptr),
stitcher_(fvMeshStitcher::New(*this, changers).ptr()),
topoChanger_(nullptr),
distributor_(nullptr),
mover_(nullptr),
Expand Down Expand Up @@ -345,10 +345,9 @@ Foam::fvMesh::fvMesh
}

// Stitch or Re-stitch if necessary
if (stitcher)
if (stitch != stitchType::none)
{
stitcher_.set(fvMeshStitcher::New(*this, changers).ptr());
stitcher_->connect(false, changers, true);
stitcher_->connect(false, stitch == stitchType::geometric, true);
}

// Construct changers
Expand Down Expand Up @@ -710,7 +709,10 @@ void Foam::fvMesh::reset(const fvMesh& newMesh)
}


Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate(const bool changers)
Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate
(
const stitchType stitch
)
{
if (debug)
{
Expand All @@ -719,9 +721,14 @@ Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate(const bool changers)

polyMesh::readUpdateState state = polyMesh::readUpdate();

if (stitcher_.valid() && state != polyMesh::UNCHANGED)
if
(
stitcher_.valid()
&& stitch != stitchType::none
&& state != polyMesh::UNCHANGED
)
{
stitcher_->disconnect(false, changers);
stitcher_->disconnect(false, stitch == stitchType::geometric);
}

if (state == polyMesh::TOPO_PATCH_CHANGE)
Expand Down Expand Up @@ -761,9 +768,14 @@ Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate(const bool changers)
}
}

if (stitcher_.valid() && state != polyMesh::UNCHANGED)
if
(
stitcher_.valid()
&& stitch != stitchType::none
&& state != polyMesh::UNCHANGED
)
{
stitcher_->connect(false, changers, true);
stitcher_->connect(false, stitch == stitchType::geometric, true);
}

// If the mesh has been re-stitched with different geometry, then the
Expand Down
30 changes: 27 additions & 3 deletions src/finiteVolume/fvMesh/fvMesh.H
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ class fvMesh
public surfaceInterpolation,
public data
{
public:

// Public data types

//- Extent to which to stitch on read and readUpdate. By default, a
// full geometric stitch is performed. A non-geometric stitch can be
// done as an optimisation in situations when finite volume geometry
// is not needed (e.g., decomposition). Stitching can also be
// prevented altogether if that is appropriate (e.g., if the mesh is
// loaded for mapping in an un-stitched state).
enum class stitchType
{
none,
nonGeometric,
geometric
};


private:

// Private Data

//- Boundary mesh
Expand Down Expand Up @@ -274,12 +294,13 @@ public:
// Constructors

//- Construct from IOobject
// with the option to not instantiate the mesh changers or stitcher
// 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 bool stitcher = true
const stitchType stitch = stitchType::geometric
);

//- Construct from cellShapes with boundary.
Expand Down Expand Up @@ -340,7 +361,10 @@ public:

//- Update the mesh based on the mesh files saved in time
// directories
readUpdateState readUpdate(const bool changers = true);
readUpdateState readUpdate
(
const stitchType stitch = stitchType::geometric
);


// Access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool Foam::fvMeshTopoChangers::meshToMesh::update()
IOobject::MUST_READ
),
false,
false
fvMesh::stitchType::none
);

autoPtr<Foam::meshToMesh> mapper;
Expand Down
6 changes: 4 additions & 2 deletions src/parallel/parallel/domainDecomposition.C
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,12 @@ Foam::fvMesh::readUpdateState Foam::domainDecomposition::readUpdate()
validateProcs();

// Do read-update on all meshes
fvMesh::readUpdateState stat = completeMesh_->readUpdate(false);
fvMesh::readUpdateState stat =
completeMesh_->readUpdate(fvMesh::stitchType::nonGeometric);
forAll(runTimes_.procTimes(), proci)
{
fvMesh::readUpdateState procStat = procMeshes_[proci].readUpdate(false);
fvMesh::readUpdateState procStat =
procMeshes_[proci].readUpdate(fvMesh::stitchType::nonGeometric);
if (procStat > stat)
{
stat = procStat;
Expand Down

0 comments on commit fbd6702

Please sign in to comment.