Merge branch 'feature-FaceCellWave-cyclicACMI' into 'develop'
FaceCellWave: travel through coupled ACMI. See #3139 See merge request Development/openfoam!677
This commit is contained in:
commit
60ffaba71d
@ -350,13 +350,15 @@ Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::scalarField> Foam::polyPatch::areaFraction() const
|
||||
Foam::tmp<Foam::scalarField> Foam::polyPatch::areaFraction
|
||||
(
|
||||
const pointField& points
|
||||
) const
|
||||
{
|
||||
auto tfraction = tmp<scalarField>::New(size());
|
||||
auto& fraction = tfraction.ref();
|
||||
|
||||
const vectorField::subField faceAreas = this->faceAreas();
|
||||
const pointField& points = this->points();
|
||||
|
||||
forAll(*this, facei)
|
||||
{
|
||||
@ -369,6 +371,18 @@ Foam::tmp<Foam::scalarField> Foam::polyPatch::areaFraction() const
|
||||
}
|
||||
|
||||
|
||||
const Foam::tmp<Foam::scalarField>& Foam::polyPatch::areaFraction() const
|
||||
{
|
||||
return areaFraction_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyPatch::areaFraction(const tmp<scalarField>& fraction)
|
||||
{
|
||||
areaFraction_ = fraction;
|
||||
}
|
||||
|
||||
|
||||
const Foam::labelUList& Foam::polyPatch::faceCells() const
|
||||
{
|
||||
if (!faceCellsPtr_)
|
||||
|
@ -88,6 +88,9 @@ class polyPatch
|
||||
//- Demand-driven: global edge addressing
|
||||
mutable std::unique_ptr<labelList> mePtr_;
|
||||
|
||||
//- Cached area fraction
|
||||
tmp<scalarField> areaFraction_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -441,9 +444,16 @@ public:
|
||||
//- Return face cell centres
|
||||
tmp<vectorField> faceCellCentres() const;
|
||||
|
||||
//- Return the area fraction as the ratio of the stored face area
|
||||
//- and the area given by the face points
|
||||
tmp<scalarField> areaFraction() const;
|
||||
//- Calculate the area fraction as the ratio of the stored face
|
||||
// area and the area given by the face points.
|
||||
tmp<scalarField> areaFraction(const pointField& points) const;
|
||||
|
||||
//- Return the cached area fraction. Usually only set for the
|
||||
//- non-overlap patches on ACMI.
|
||||
const tmp<scalarField>& areaFraction() const;
|
||||
|
||||
//- Set cached area fraction
|
||||
void areaFraction(const tmp<scalarField>&);
|
||||
|
||||
|
||||
// Addressing into mesh
|
||||
|
@ -342,6 +342,7 @@ void Foam::activePressureForceBaffleVelocityFvPatchVectorField::updateCoeffs()
|
||||
).neighbFvPatch().Sf();
|
||||
}
|
||||
|
||||
|
||||
// Update this wall patch
|
||||
vectorField::subField Sfw = patch().patch().faceAreas();
|
||||
vectorField newSfw((1 - areaFraction)*initWallSf_);
|
||||
@ -350,16 +351,41 @@ void Foam::activePressureForceBaffleVelocityFvPatchVectorField::updateCoeffs()
|
||||
Sfw[facei] = newSfw[facei];
|
||||
}
|
||||
const_cast<scalarField&>(patch().magSf()) = mag(patch().Sf());
|
||||
// Cache fraction
|
||||
const_cast<polyPatch&>(patch().patch()).areaFraction
|
||||
(
|
||||
tmp<scalarField>::New
|
||||
(
|
||||
patch().patch().size(),
|
||||
(1-areaFraction)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Update owner side of cyclic
|
||||
const_cast<vectorField&>(cyclicPatch.Sf()) = areaFraction*initCyclicSf_;
|
||||
|
||||
const_cast<scalarField&>(cyclicPatch.magSf()) = mag(cyclicPatch.Sf());
|
||||
const_cast<polyPatch&>(cyclicPatch.patch()).areaFraction
|
||||
(
|
||||
tmp<scalarField>::New
|
||||
(
|
||||
cyclicPatch.patch().size(),
|
||||
areaFraction
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// Update neighbour side of cyclic
|
||||
const_cast<vectorField&>(nbrPatch.Sf()) = areaFraction*nbrCyclicSf_;
|
||||
|
||||
const_cast<scalarField&>(nbrPatch.magSf()) = mag(nbrPatch.Sf());
|
||||
const_cast<polyPatch&>(cyclicPatch.patch()).areaFraction
|
||||
(
|
||||
tmp<scalarField>::New
|
||||
(
|
||||
nbrPatch.patch().size(),
|
||||
areaFraction
|
||||
)
|
||||
);
|
||||
|
||||
curTimeIndex_ = this->db().time().timeIndex();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
Copyright (C) 2023-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -146,29 +146,40 @@ void Foam::wallDistAddressing::correct(volScalarField& y)
|
||||
globalWallsPtr_.reset(new globalIndex(nWalls));
|
||||
const globalIndex& globalWalls = globalWallsPtr_();
|
||||
|
||||
labelList seedFaces(nWalls);
|
||||
List<wallPointAddressing> seedInfo(nWalls);
|
||||
DynamicList<label> seedFaces(nWalls);
|
||||
DynamicList<wallPointAddressing> seedInfo(nWalls);
|
||||
|
||||
|
||||
nWalls = 0;
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
const auto& fc = C.boundaryField()[patchi];
|
||||
const auto& areaFraction = fc.patch().patch().areaFraction();
|
||||
|
||||
forAll(fc, patchFacei)
|
||||
{
|
||||
seedFaces[nWalls] = fc.patch().start()+patchFacei;
|
||||
seedInfo[nWalls] = wallPointAddressing
|
||||
if
|
||||
(
|
||||
fc[patchFacei],
|
||||
gt.encode
|
||||
!areaFraction
|
||||
|| (areaFraction()[patchFacei] > 0.5) // mostly wall
|
||||
)
|
||||
{
|
||||
seedFaces.append(fc.patch().start()+patchFacei);
|
||||
seedInfo.append
|
||||
(
|
||||
Pstream::myProcNo(),
|
||||
nWalls,
|
||||
gt.nullTransformIndex()
|
||||
),
|
||||
scalar(0.0)
|
||||
);
|
||||
wallPointAddressing
|
||||
(
|
||||
fc[patchFacei],
|
||||
gt.encode
|
||||
(
|
||||
Pstream::myProcNo(),
|
||||
nWalls,
|
||||
gt.nullTransformIndex()
|
||||
),
|
||||
scalar(0.0)
|
||||
)
|
||||
);
|
||||
}
|
||||
nWalls++;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ License
|
||||
|
||||
#include "inverseDistanceDiffusivity.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "patchWave.H"
|
||||
#include "HashSet.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
|
@ -27,7 +27,6 @@ License
|
||||
|
||||
#include "inverseVolumeDiffusivity.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "patchWave.H"
|
||||
#include "HashSet.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
|
@ -299,11 +299,11 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
|
||||
{
|
||||
if (isA<wallPolyPatch>(patch))
|
||||
{
|
||||
const scalarField areaFraction(patch.areaFraction());
|
||||
const auto& areaFraction = patch.areaFraction();
|
||||
|
||||
forAll(areaFraction, facei)
|
||||
forAll(patch, facei)
|
||||
{
|
||||
if (areaFraction[facei] > 0.5)
|
||||
if (!areaFraction || areaFraction()[facei] > 0.5)
|
||||
{
|
||||
localWallFaces.append(facei + patch.start());
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022,2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -217,10 +217,24 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas
|
||||
return;
|
||||
}
|
||||
|
||||
forAll(noSf, facei)
|
||||
{
|
||||
const scalar w = min(maxTol, max(tolerance_, mask[facei]));
|
||||
noSf[facei] = noFaceArea[facei]*(scalar(1) - w);
|
||||
tmp<scalarField> scale
|
||||
(
|
||||
scalar(1)
|
||||
- min
|
||||
(
|
||||
max(mask, tolerance_),
|
||||
maxTol
|
||||
)
|
||||
);
|
||||
|
||||
// Scale area
|
||||
forAll(noSf, facei)
|
||||
{
|
||||
noSf[facei] = noFaceArea[facei]*scale()[facei];
|
||||
}
|
||||
// Cache scaling
|
||||
const_cast<polyPatch&>(nonOverlapPatch).areaFraction(scale);
|
||||
}
|
||||
|
||||
if (!createAMIFaces_)
|
||||
@ -235,10 +249,15 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas
|
||||
// Scale the coupled patch face areas
|
||||
vectorField::subField Sf = acmipp.faceAreas();
|
||||
|
||||
tmp<scalarField> scale(max(tolerance_, mask));
|
||||
|
||||
// Scale area
|
||||
forAll(Sf, facei)
|
||||
{
|
||||
Sf[facei] = faceArea[facei]*max(tolerance_, mask[facei]);
|
||||
Sf[facei] = faceArea[facei]*scale()[facei];
|
||||
}
|
||||
// Cache scaling
|
||||
const_cast<cyclicACMIPolyPatch&>(acmipp).areaFraction(scale);
|
||||
|
||||
// Re-normalise the weights since the effect of overlap is already
|
||||
// accounted for in the area
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -821,8 +821,17 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
||||
}
|
||||
|
||||
// Merge into global storage
|
||||
|
||||
const auto& areaFraction = patch.areaFraction();
|
||||
|
||||
forAll(receiveInfo, i)
|
||||
{
|
||||
if (areaFraction && areaFraction()[i] <= 0.5)
|
||||
{
|
||||
// not coupled
|
||||
continue;
|
||||
}
|
||||
|
||||
const label meshFacei = cycPatch.start()+i;
|
||||
|
||||
const Type& newInfo = receiveInfo[i];
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020,2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -235,6 +235,8 @@ void Foam::cellDistFuncs::correctBoundaryFaceCells
|
||||
Map<label>& nearestFace
|
||||
) const
|
||||
{
|
||||
const auto& pbm = mesh().boundaryMesh();
|
||||
|
||||
// Size neighbours array for maximum possible (= size of largest patch)
|
||||
DynamicList<label> neighbours(maxPatchSize(patchIDs));
|
||||
|
||||
@ -242,15 +244,22 @@ void Foam::cellDistFuncs::correctBoundaryFaceCells
|
||||
const vectorField& cellCentres = mesh().cellCentres();
|
||||
const labelList& faceOwner = mesh().faceOwner();
|
||||
|
||||
forAll(mesh().boundaryMesh(), patchi)
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (patchIDs.found(patchi))
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchi];
|
||||
const polyPatch& patch = pbm[patchi];
|
||||
const auto& areaFraction = patch.areaFraction();
|
||||
|
||||
// Check cells with face on wall
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
if (areaFraction && (areaFraction()[patchFacei] <= 0.5))
|
||||
{
|
||||
// is mostly coupled
|
||||
continue;
|
||||
}
|
||||
|
||||
getPointNeighbours(patch, patchFacei, neighbours);
|
||||
|
||||
label celli = faceOwner[patch.start() + patchFacei];
|
||||
@ -283,20 +292,42 @@ void Foam::cellDistFuncs::correctBoundaryPointCells
|
||||
{
|
||||
// Correct all (non-visited) cells with point on wall
|
||||
|
||||
const auto& pbm = mesh().boundaryMesh();
|
||||
const vectorField& cellCentres = mesh().cellCentres();
|
||||
|
||||
forAll(mesh().boundaryMesh(), patchi)
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (patchIDs.found(patchi))
|
||||
{
|
||||
const polyPatch& patch = mesh().boundaryMesh()[patchi];
|
||||
|
||||
const polyPatch& patch = pbm[patchi];
|
||||
const auto& localFaces = patch.localFaces();
|
||||
const labelList& meshPoints = patch.meshPoints();
|
||||
const labelListList& pointFaces = patch.pointFaces();
|
||||
|
||||
forAll(meshPoints, meshPointi)
|
||||
bitSet isWallPoint(meshPoints.size(), true);
|
||||
{
|
||||
const label vertI = meshPoints[meshPointi];
|
||||
const auto& areaFraction = patch.areaFraction();
|
||||
|
||||
// Check cells with face on wall
|
||||
forAll(patch, patchFacei)
|
||||
{
|
||||
if (!areaFraction || (areaFraction()[patchFacei] <= 0.5))
|
||||
{
|
||||
// face mostly coupled
|
||||
isWallPoint.unset(localFaces[patchFacei]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
forAll(meshPoints, patchPointi)
|
||||
{
|
||||
const label vertI = meshPoints[patchPointi];
|
||||
|
||||
if (!isWallPoint[patchPointi])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const labelList& neighbours = mesh().pointCells(vertI);
|
||||
|
||||
@ -304,7 +335,7 @@ void Foam::cellDistFuncs::correctBoundaryPointCells
|
||||
{
|
||||
if (!nearestFace.found(celli))
|
||||
{
|
||||
const labelList& wallFaces = pointFaces[meshPointi];
|
||||
const labelList& wallFaces = pointFaces[patchPointi];
|
||||
|
||||
label minFacei = -1;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020,2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,37 +41,45 @@ template<class TransferType, class TrackingData>
|
||||
void Foam::patchDataWave<TransferType, TrackingData>::setChangedFaces
|
||||
(
|
||||
const labelHashSet& patchIDs,
|
||||
labelList& changedFaces,
|
||||
List<TransferType>& faceDist
|
||||
DynamicList<label>& changedFaces,
|
||||
DynamicList<TransferType>& faceDist
|
||||
) const
|
||||
{
|
||||
const polyMesh& mesh = cellDistFuncs::mesh();
|
||||
|
||||
label nChangedFaces = 0;
|
||||
|
||||
forAll(mesh.boundaryMesh(), patchi)
|
||||
{
|
||||
if (patchIDs.found(patchi))
|
||||
{
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
const auto& areaFraction = patch.areaFraction();
|
||||
|
||||
const auto faceCentres(patch.faceCentres());
|
||||
|
||||
const Field<Type>& patchField = initialPatchValuePtrs_[patchi];
|
||||
|
||||
forAll(patch.faceCentres(), patchFacei)
|
||||
forAll(faceCentres, patchFacei)
|
||||
{
|
||||
label meshFacei = patch.start() + patchFacei;
|
||||
if
|
||||
(
|
||||
!areaFraction
|
||||
|| (areaFraction()[patchFacei] > 0.5) // mostly wall
|
||||
)
|
||||
{
|
||||
label meshFacei = patch.start() + patchFacei;
|
||||
changedFaces.append(meshFacei);
|
||||
|
||||
changedFaces[nChangedFaces] = meshFacei;
|
||||
|
||||
faceDist[nChangedFaces] =
|
||||
TransferType
|
||||
faceDist.append
|
||||
(
|
||||
patch.faceCentres()[patchFacei],
|
||||
patchField[patchFacei],
|
||||
0.0
|
||||
TransferType
|
||||
(
|
||||
faceCentres[patchFacei],
|
||||
patchField[patchFacei],
|
||||
0.0
|
||||
)
|
||||
);
|
||||
|
||||
nChangedFaces++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -222,8 +230,8 @@ void Foam::patchDataWave<TransferType, TrackingData>::correct()
|
||||
// Count walls
|
||||
label nWalls = sumPatchSize(patchIDs_);
|
||||
|
||||
List<TransferType> faceDist(nWalls);
|
||||
labelList changedFaces(nWalls);
|
||||
DynamicList<TransferType> faceDist(nWalls);
|
||||
DynamicList<label> changedFaces(nWalls);
|
||||
|
||||
setChangedFaces(patchIDs_, changedFaces, faceDist);
|
||||
|
||||
|
@ -115,8 +115,8 @@ private:
|
||||
void setChangedFaces
|
||||
(
|
||||
const labelHashSet& patchIDs,
|
||||
labelList&,
|
||||
List<TransferType>&
|
||||
DynamicList<label>& changedFaces,
|
||||
DynamicList<TransferType>& faceDist
|
||||
) const;
|
||||
|
||||
//- Copy MeshWave values into *this
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,50 +36,49 @@ License
|
||||
void Foam::patchWave::setChangedFaces
|
||||
(
|
||||
const labelHashSet& patchIDs,
|
||||
labelList& changedFaces,
|
||||
List<wallPoint>& faceDist
|
||||
DynamicList<label>& changedFaces,
|
||||
DynamicList<wallPoint>& faceDist
|
||||
) const
|
||||
{
|
||||
const polyMesh& mesh = cellDistFuncs::mesh();
|
||||
|
||||
label nChangedFaces = 0;
|
||||
|
||||
forAll(mesh.boundaryMesh(), patchi)
|
||||
{
|
||||
if (patchIDs.found(patchi))
|
||||
{
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchi];
|
||||
|
||||
forAll(patch.faceCentres(), patchFacei)
|
||||
const auto& areaFraction = patch.areaFraction();
|
||||
|
||||
const auto faceCentres(patch.faceCentres());
|
||||
|
||||
forAll(faceCentres, patchFacei)
|
||||
{
|
||||
label meshFacei = patch.start() + patchFacei;
|
||||
|
||||
changedFaces[nChangedFaces] = meshFacei;
|
||||
|
||||
faceDist[nChangedFaces] =
|
||||
wallPoint
|
||||
(
|
||||
patch.faceCentres()[patchFacei],
|
||||
0.0
|
||||
);
|
||||
|
||||
nChangedFaces++;
|
||||
if
|
||||
(
|
||||
!areaFraction
|
||||
|| (areaFraction()[patchFacei] > 0.5) // mostly wall
|
||||
)
|
||||
{
|
||||
changedFaces.append(patch.start() + patchFacei);
|
||||
faceDist.append(wallPoint(faceCentres[patchFacei], 0.0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const label facei : sourceIDs_)
|
||||
{
|
||||
changedFaces[nChangedFaces] = facei;
|
||||
changedFaces.append(facei);
|
||||
|
||||
faceDist[nChangedFaces] =
|
||||
faceDist.append
|
||||
(
|
||||
wallPoint
|
||||
(
|
||||
mesh.faceCentres()[facei],
|
||||
0.0
|
||||
);
|
||||
|
||||
nChangedFaces++;
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,8 +181,8 @@ void Foam::patchWave::correct()
|
||||
|
||||
label nPatch = sumPatchSize(patchIDs_) + sourceIDs_.size();
|
||||
|
||||
List<wallPoint> faceDist(nPatch);
|
||||
labelList changedFaces(nPatch);
|
||||
DynamicList<wallPoint> faceDist(nPatch);
|
||||
DynamicList<label> changedFaces(nPatch);
|
||||
|
||||
// Set to faceDist information to facecentre on walls.
|
||||
setChangedFaces(patchIDs_, changedFaces, faceDist);
|
||||
|
@ -89,8 +89,8 @@ class patchWave
|
||||
void setChangedFaces
|
||||
(
|
||||
const labelHashSet& patchIDs,
|
||||
labelList& changedFaces,
|
||||
List<wallPoint>& changedInfo
|
||||
DynamicList<label>& changedFaces,
|
||||
DynamicList<wallPoint>& faceDist
|
||||
) const;
|
||||
|
||||
//- Copy MeshWave cell values. Return number of illegal/unset
|
||||
|
Loading…
Reference in New Issue
Block a user