mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: (un)refinement: combine topochange+motion. Fixes #2492
This is on - incompressible/pimpleFoam/laminar/mixerVesselAMI2D/mixerVesselAMI2D-topologyChange - redistributePar -reconstruct where the fvMesh::updateMesh does an early trigger of mesh.phi() calculation
This commit is contained in:
@ -639,9 +639,14 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::repatch
|
||||
// shared points (see mergeSharedPoints below). So temporarily points
|
||||
// and edges do not match!
|
||||
|
||||
// TBD: temporarily unset mesh moving to avoid problems in meshflux
|
||||
// mapping. To be investigated.
|
||||
const bool oldMoving = mesh_.moving(false);
|
||||
autoPtr<mapPolyMesh> mapPtr = meshMod.changeMesh(mesh_, false, true);
|
||||
mesh_.moving(oldMoving);
|
||||
mapPolyMesh& map = *mapPtr;
|
||||
|
||||
|
||||
// Update fields. No inflation, parallel sync.
|
||||
mesh_.updateMesh(map);
|
||||
|
||||
@ -766,7 +771,12 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::mergeSharedPoints
|
||||
fvMeshAdder::mergePoints(mesh_, pointToMaster, meshMod);
|
||||
|
||||
// Change the mesh (no inflation). Note: parallel comms allowed.
|
||||
|
||||
// TBD: temporarily unset mesh moving to avoid problems in meshflux
|
||||
// mapping. To be investigated.
|
||||
const bool oldMoving = mesh_.moving(false);
|
||||
autoPtr<mapPolyMesh> mapPtr = meshMod.changeMesh(mesh_, false, true);
|
||||
mesh_.moving(oldMoving);
|
||||
mapPolyMesh& map = *mapPtr;
|
||||
|
||||
// Update fields. No inflation, parallel sync.
|
||||
@ -1402,7 +1412,12 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::doRemoveCells
|
||||
saveInternalFields(tFlds);
|
||||
|
||||
// Change the mesh. No inflation. Note: no parallel comms allowed.
|
||||
|
||||
// TBD: temporarily unset mesh moving to avoid problems in meshflux
|
||||
// mapping. To be investigated.
|
||||
const bool oldMoving = mesh_.moving(false);
|
||||
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, false);
|
||||
mesh_.moving(oldMoving);
|
||||
|
||||
// Update fields
|
||||
mesh_.updateMesh(map());
|
||||
@ -2825,6 +2840,10 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
||||
const label nOldInternalFaces = mesh_.nInternalFaces();
|
||||
const labelList oldFaceOwner(mesh_.faceOwner());
|
||||
|
||||
// TBD: temporarily unset mesh moving to avoid problems in meshflux
|
||||
// mapping. To be investigated.
|
||||
const bool oldMoving = mesh_.moving(false);
|
||||
|
||||
fvMeshAdder::add
|
||||
(
|
||||
Pstream::myProcNo(), // index of mesh to modify (== mesh_)
|
||||
@ -2842,6 +2861,9 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
||||
constructPointMap
|
||||
);
|
||||
|
||||
mesh_.moving(oldMoving);
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< nl << "ADDED REMOTE MESHES:" << endl;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -63,29 +63,33 @@ bool Foam::fvGeometryScheme::setMeshPhi() const
|
||||
const faceList& faces = mesh_.faces();
|
||||
const scalar rdt = 1.0/mesh_.time().deltaTValue();
|
||||
|
||||
auto& meshPhi = const_cast<fvMesh&>(mesh_).setPhi();
|
||||
auto& meshPhii = meshPhi.primitiveFieldRef();
|
||||
forAll(meshPhii, facei)
|
||||
auto tmeshPhi(const_cast<fvMesh&>(mesh_).setPhi());
|
||||
if (tmeshPhi)
|
||||
{
|
||||
const face& f = faces[facei];
|
||||
meshPhii[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
}
|
||||
|
||||
auto& meshPhiBf = meshPhi.boundaryFieldRef();
|
||||
for (auto& meshPhip : meshPhiBf)
|
||||
{
|
||||
if (!meshPhip.size())
|
||||
auto& meshPhi = tmeshPhi.ref();
|
||||
auto& meshPhii = meshPhi.primitiveFieldRef();
|
||||
forAll(meshPhii, facei)
|
||||
{
|
||||
// Empty patches
|
||||
continue;
|
||||
const face& f = faces[facei];
|
||||
meshPhii[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
}
|
||||
|
||||
const auto& pp = meshPhip.patch().patch();
|
||||
|
||||
forAll(pp, facei)
|
||||
auto& meshPhiBf = meshPhi.boundaryFieldRef();
|
||||
for (auto& meshPhip : meshPhiBf)
|
||||
{
|
||||
const face& f = pp[facei];
|
||||
meshPhip[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
if (!meshPhip.size())
|
||||
{
|
||||
// Empty patches
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& pp = meshPhip.patch().patch();
|
||||
|
||||
forAll(pp, facei)
|
||||
{
|
||||
const face& f = pp[facei];
|
||||
meshPhip[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -220,40 +220,45 @@ void Foam::solidBodyFvGeometryScheme::movePoints()
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
const faceList& faces = mesh_.faces();
|
||||
const scalar rdt = 1.0/mesh_.time().deltaTValue();
|
||||
|
||||
// Set the mesh flux
|
||||
auto& meshPhi = const_cast<fvMesh&>(mesh_).setPhi();
|
||||
auto& meshPhii = meshPhi.primitiveFieldRef();
|
||||
auto& meshPhiBf = meshPhi.boundaryFieldRef();
|
||||
|
||||
//meshPhi == dimensionedScalar(dimVolume/dimTime, Zero);
|
||||
meshPhii = Zero;
|
||||
meshPhiBf == Zero;
|
||||
|
||||
forAll(changedFaceIDs_, i)
|
||||
auto tmeshPhi(const_cast<fvMesh&>(mesh_).setPhi());
|
||||
if (tmeshPhi)
|
||||
{
|
||||
const face& f = faces[changedFaceIDs_[i]];
|
||||
const scalar rdt = 1.0/mesh_.time().deltaTValue();
|
||||
|
||||
if (changedPatchIDs_[i] == -1)
|
||||
{
|
||||
const label facei = changedFaceIDs_[i];
|
||||
meshPhii[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
}
|
||||
else
|
||||
{
|
||||
const label patchi = changedPatchIDs_[i];
|
||||
const polyPatch& pp = pbm[patchi];
|
||||
// Set the mesh flux
|
||||
auto& meshPhi = tmeshPhi.ref();
|
||||
auto& meshPhii = meshPhi.primitiveFieldRef();
|
||||
auto& meshPhiBf = meshPhi.boundaryFieldRef();
|
||||
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
//meshPhi == dimensionedScalar(dimVolume/dimTime, Zero);
|
||||
meshPhii = Zero;
|
||||
meshPhiBf == Zero;
|
||||
|
||||
forAll(changedFaceIDs_, i)
|
||||
{
|
||||
const face& f = faces[changedFaceIDs_[i]];
|
||||
|
||||
if (changedPatchIDs_[i] == -1)
|
||||
{
|
||||
continue;
|
||||
const label facei = changedFaceIDs_[i];
|
||||
meshPhii[facei] = f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
}
|
||||
else
|
||||
{
|
||||
const label patchi = changedPatchIDs_[i];
|
||||
const polyPatch& pp = pbm[patchi];
|
||||
|
||||
const label patchFacei = changedFaceIDs_[i] - pp.start();
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
meshPhiBf[patchi][patchFacei] =
|
||||
f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
const label patchFacei = changedFaceIDs_[i] - pp.start();
|
||||
|
||||
meshPhiBf[patchi][patchFacei] =
|
||||
f.sweptVol(oldPoints, currPoints)*rdt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -482,8 +482,8 @@ public:
|
||||
//- these fvPatches.
|
||||
void removeFvBoundary();
|
||||
|
||||
//- Return cell face motion fluxes
|
||||
surfaceScalarField& setPhi();
|
||||
//- Return cell face motion fluxes (or null)
|
||||
refPtr<surfaceScalarField> setPhi();
|
||||
|
||||
//- Return old-time cell volumes
|
||||
DimensionedField<scalar, volMesh>& setV0();
|
||||
|
||||
@ -415,16 +415,19 @@ const Foam::surfaceScalarField& Foam::fvMesh::phi() const
|
||||
}
|
||||
|
||||
|
||||
Foam::surfaceScalarField& Foam::fvMesh::setPhi()
|
||||
Foam::refPtr<Foam::surfaceScalarField> Foam::fvMesh::setPhi()
|
||||
{
|
||||
if (!phiPtr_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "mesh flux field does not exist, is the mesh actually moving?"
|
||||
<< abort(FatalError);
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return non-const reference
|
||||
refPtr<surfaceScalarField> p;
|
||||
p.ref(*phiPtr_);
|
||||
return p;
|
||||
}
|
||||
|
||||
return *phiPtr_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019,2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -345,7 +345,7 @@ void Foam::cyclicACMIFvPatch::movePoints()
|
||||
const labelListList& newTgtAddr = AMI().tgtAddress();
|
||||
|
||||
const fvMesh& mesh = boundaryMesh().mesh();
|
||||
surfaceScalarField& meshPhi = const_cast<fvMesh&>(mesh).setPhi();
|
||||
surfaceScalarField& meshPhi = const_cast<fvMesh&>(mesh).setPhi().ref();
|
||||
surfaceScalarField::Boundary& meshPhiBf = meshPhi.boundaryFieldRef();
|
||||
|
||||
// Note: phip and phiNonOverlap will be different sizes if new faces
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020,2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -267,7 +267,7 @@ void Foam::cyclicAMIFvPatch::movePoints()
|
||||
// src = src + mapped(tgt) and tgt = tgt + mapped(src)?
|
||||
|
||||
const fvMesh& mesh = boundaryMesh().mesh();
|
||||
surfaceScalarField& meshPhi = const_cast<fvMesh&>(mesh).setPhi();
|
||||
surfaceScalarField& meshPhi = const_cast<fvMesh&>(mesh).setPhi().ref();
|
||||
surfaceScalarField::Boundary& meshPhiBf = meshPhi.boundaryFieldRef();
|
||||
|
||||
if (cyclicAMIPolyPatch_.owner())
|
||||
|
||||
Reference in New Issue
Block a user