diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options index de06a175b4..fd6a34a69b 100644 --- a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options @@ -3,6 +3,7 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/overset/include/lnInclude EXE_LIBS = \ -lfiniteVolume \ diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H index 62036fcc76..fbff6cb801 100644 --- a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H @@ -31,3 +31,25 @@ Info<< "Reading diffusivity DT\n" << endl; dimensionedScalar DT("DT", dimViscosity, transportProperties); + + bool oversetPatchErrOutput = + simple.dict().getOrDefault("oversetPatchErrOutput", false); + + // Dummy phi for oversetPatchErrOutput + tmp tdummyPhi; + if (oversetPatchErrOutput) + { + tdummyPhi = tmp::New + ( + IOobject + ( + "dummyPhi", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar(dimless, Zero) + ); + } diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/overLaplacianDyMFoam.C b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/overLaplacianDyMFoam.C index 4c75305702..1683a2db29 100644 --- a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/overLaplacianDyMFoam.C +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/overLaplacianDyMFoam.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016-2017 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,6 +58,7 @@ Description #include "fvOptions.H" #include "simpleControl.H" #include "dynamicFvMesh.H" +#include "oversetPatchPhiErr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -99,6 +100,11 @@ int main(int argc, char *argv[]) fvOptions.constrain(TEqn); TEqn.solve(); fvOptions.correct(T); + + if (oversetPatchErrOutput) + { + oversetPatchPhiErr(TEqn, tdummyPhi.ref()); + } } #include "write.H" diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/overPotentialFoam.C b/applications/solvers/basic/potentialFoam/overPotentialFoam/overPotentialFoam.C index b41908e526..6e3072a73c 100644 --- a/applications/solvers/basic/potentialFoam/overPotentialFoam/overPotentialFoam.C +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/overPotentialFoam.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd + Copyright (C) 2017-2022 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -149,7 +149,6 @@ int main(int argc, char *argv[]) mesh.update(); - surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); // Since solver contains no time loop it would never execute // function objects so do it ourselves diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createControls.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createControls.H deleted file mode 100644 index 320608dfcf..0000000000 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createControls.H +++ /dev/null @@ -1,4 +0,0 @@ -bool ddtCorr -( - pimple.dict().getOrDefault("ddtCorr", true) -); diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H index 979dfa7763..f69bfd980f 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H @@ -69,6 +69,8 @@ mesh.setFluxRequired(p.name()); // Mask field for zeroing out contributions on hole cells #include "createCellMask.H" +// Create bool field with interpolated cells +#include "createInterpolatedCells.H" Info<< "Creating turbulence model\n" << endl; autoPtr turbulence diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/overRhoPimpleDyMFoam.C b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/overRhoPimpleDyMFoam.C index 1b8b2f44b7..f7c5f4b9f4 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/overRhoPimpleDyMFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/overRhoPimpleDyMFoam.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016-2017 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,6 @@ Description #include "dynamicFvMesh.H" #include "fluidThermo.H" #include "turbulentFluidThermoModel.H" -#include "bound.H" #include "pimpleControl.H" #include "pressureControl.H" #include "CorrectPhi.H" @@ -89,10 +88,8 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" #include "readDyMControls.H" - // Store divrhoU from the previous mesh so that it can be mapped // and used in correctPhi to ensure the corrected phi has the // same divergence @@ -128,7 +125,6 @@ int main(int argc, char *argv[]) { if (pimple.firstIter() || moveMeshOuterCorrectors) { - // Do any mesh changes mesh.update(); @@ -137,52 +133,22 @@ int main(int argc, char *argv[]) MRF.update(); #include "setCellMask.H" - - const surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - - // Zero Uf on old faceMask (H-I) - rhoUf() *= faceMaskOld; - - surfaceVectorField rhoUfint(fvc::interpolate(rho*U)); - - // Update Uf and phi on new C-I faces - rhoUf() += (1-faceMaskOld)*rhoUfint; - - // Update Uf boundary - forAll(rhoUf().boundaryField(), patchI) - { - rhoUf().boundaryFieldRef()[patchI] = - rhoUfint.boundaryField()[patchI]; - } - - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf(); + #include "setInterpolatedCells.H" + #include "correctRhoPhiFaceMask.H" if (correctPhi) { + // Corrects flux on separated regions #include "correctPhi.H" } - // Zero phi on current H-I - const surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); - - phi *= faceMask; - U *= cellMask; - // Make the fluxes relative to the mesh-motion fvc::makeRelative(phi, rho, U); - } - - if (checkMeshCourantNo) - { - #include "meshCourantNo.H" + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } } diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H index 9c5414fb5c..227610a01b 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H @@ -25,17 +25,6 @@ surfaceScalarField phiHbyA fvc::interpolate(rho)*fvc::flux(HbyA) ); -if (ddtCorr) -{ - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - - phiHbyA += - faceMaskOld*MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi, rhoUf)); -} - fvc::makeRelative(phiHbyA, rho, U); MRF.makeRelative(fvc::interpolate(rho), phiHbyA); @@ -134,8 +123,4 @@ if (thermo.dpdt()) } } -surfaceScalarField faceMask -( - localMin(mesh).interpolate(cellMask) -); phi *= faceMask; diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/readControls.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/readControls.H deleted file mode 100644 index 83b43ffbf1..0000000000 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/readControls.H +++ /dev/null @@ -1,9 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().getOrDefault("correctPhi", false); - -checkMeshCourantNo = - pimple.dict().getOrDefault("checkMeshCourantNo", false); - - -ddtCorr = pimple.dict().getOrDefault("ddtCorr", true); diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/createFields.H index 4c203d0266..050cb87146 100644 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/createFields.H @@ -124,3 +124,6 @@ dimensionedScalar initialMass("initialMass", fvc::domainIntegrate(rho)); // Mask field for zeroing out contributions on hole cells #include "createCellMask.H" + +// Create bool field with interpolated cells +#include "createInterpolatedCells.H" diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/overBuoyantPimpleDyMFoam.C b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/overBuoyantPimpleDyMFoam.C index a212d2277d..b603ade06a 100644 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/overBuoyantPimpleDyMFoam.C +++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/overBuoyantPimpleDyMFoam.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,6 +50,7 @@ Description #include "CorrectPhi.H" #include "cellCellStencilObject.H" #include "localMin.H" +#include "oversetAdjustPhi.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -86,9 +87,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readTimeControls.H" - - #include "readControls.H" #include "readDyMControls.H" #include "compressibleCourantNo.H" @@ -128,45 +126,14 @@ int main(int argc, char *argv[]) MRF.update(); #include "setCellMask.H" - - const surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - - // Zero Uf on old faceMask (H-I) - rhoUf() *= faceMaskOld; - - //fvc::correctRhoUf(rhoUfint, rho, U, phi); - surfaceVectorField rhoUfint(fvc::interpolate(rho*U)); - - // Update Uf and phi on new C-I faces - rhoUf() += (1-faceMaskOld)*rhoUfint; - - // Update Uf boundary - forAll(rhoUf().boundaryField(), patchI) - { - rhoUf().boundaryFieldRef()[patchI] = - rhoUfint.boundaryField()[patchI]; - } - - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf(); + #include "setInterpolatedCells.H" + #include "correctRhoPhiFaceMask.H" if (correctPhi) { #include "correctPhi.H" } - // Zero phi on current H-I - const surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); - - phi *= faceMask; - U *= cellMask; - // Make the fluxes relative to the mesh-motion fvc::makeRelative(phi, rho, U); } diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/pEqn.H index 4234e181f6..06b6f99fc9 100644 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/pEqn.H @@ -21,17 +21,14 @@ surfaceScalarField phiHbyA fvc::flux(rho*HbyA) + phig ); -if (ddtCorr) +if (adjustFringe) { - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - - phiHbyA += - faceMaskOld*MRF.zeroFilter(rhorAUf*fvc::ddtCorr(rho, U, phi)); + fvc::makeRelative(phiHbyA,rho, U); + oversetAdjustPhi(phiHbyA, U); + fvc::makeAbsolute(phiHbyA,rho, U); } + MRF.makeRelative(fvc::interpolate(rho), phiHbyA); // Update the pressure BCs to ensure flux consistency @@ -122,8 +119,4 @@ if (thermo.dpdt()) } } -surfaceScalarField faceMask -( - localMin(mesh).interpolate(cellMask) -); phi *= faceMask; diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/readControls.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/readControls.H deleted file mode 100644 index 83b43ffbf1..0000000000 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/overBuoyantPimpleDyMFoam/readControls.H +++ /dev/null @@ -1,9 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().getOrDefault("correctPhi", false); - -checkMeshCourantNo = - pimple.dict().getOrDefault("checkMeshCourantNo", false); - - -ddtCorr = pimple.dict().getOrDefault("ddtCorr", true); diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H index deee56b423..e1e2ea02e8 100644 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,7 +37,10 @@ scalar meanCoNum = 0.0; if (mesh.nInternalFaces()) { - surfaceScalarField phiMask(localMin(mesh).interpolate(cellMask)); + surfaceScalarField phiMask + ( + localMin(mesh).interpolate(cellMask + interpolatedCells) + ); scalarField sumPhi(fvc::surfaceSum(mag(phiMask*phi))().internalField()); diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H index aef0116f7b..cffb2558ce 100644 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H @@ -1,5 +1,4 @@ // Solve the Momentum equation - MRF.correctBoundaryVelocity(U); tmp tUEqn diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createControls.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createControls.H deleted file mode 100644 index eec5afdfc8..0000000000 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createControls.H +++ /dev/null @@ -1,26 +0,0 @@ -#include "createTimeControls.H" - -bool correctPhi -( - pimple.dict().getOrDefault("correctPhi", false) -); - -bool checkMeshCourantNo -( - pimple.dict().getOrDefault("checkMeshCourantNo", false) -); - -bool massFluxInterpolation -( - pimple.dict().getOrDefault("massFluxInterpolation", false) -); - -bool adjustFringe -( - pimple.dict().getOrDefault("oversetAdjustPhi", false) -); - -bool ddtCorr -( - pimple.dict().getOrDefault("ddtCorr", true) -); diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H deleted file mode 100644 index 1bc385c90a..0000000000 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H +++ /dev/null @@ -1,273 +0,0 @@ -// Interpolation used -interpolationCellPoint UInterpolator(HbyA); - -// Determine faces on outside of interpolated cells -bitSet isOwnerInterpolatedFace(mesh.nInternalFaces()); -bitSet isNeiInterpolatedFace(mesh.nInternalFaces()); - -// Determine donor cells -labelListList donorCell(mesh.nInternalFaces()); - -scalarListList weightCellCells(mesh.nInternalFaces()); - -// Interpolated HbyA faces -vectorField UIntFaces(mesh.nInternalFaces(), Zero); - -// Determine receptor neighbour cells -labelList receptorNeigCell(mesh.nInternalFaces(), -1); - -{ - const cellCellStencilObject& overlap = Stencil::New(mesh); - const labelList& cellTypes = overlap.cellTypes(); - const labelIOList& zoneID = overlap.zoneID(); - - label nZones = gMax(zoneID)+1; - PtrList meshParts(nZones); - labelList nCellsPerZone(nZones, Zero); - - // A mesh subset for each zone - forAll(meshParts, zonei) - { - meshParts.set - ( - zonei, - // Select cells where the zoneID == zonei - new fvMeshSubset(mesh, zonei, zoneID) - ); - } - - for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) - { - label ownType = cellTypes[mesh.faceOwner()[faceI]]; - label neiType = cellTypes[mesh.faceNeighbour()[faceI]]; - if - ( - ownType == cellCellStencil::INTERPOLATED - && neiType == cellCellStencil::CALCULATED - ) - { - isOwnerInterpolatedFace.set(faceI); - - const vector& fc = mesh.faceCentres()[faceI]; - - for (label zoneI = 0; zoneI < nZones; zoneI++) - { - if (zoneI != zoneID[mesh.faceOwner()[faceI]]) - { - const fvMesh& partMesh = meshParts[zoneI].subMesh(); - const labelList& cellMap = meshParts[zoneI].cellMap(); - label cellI = partMesh.findCell(fc); - - if (cellI != -1) - { - // Determine weights - labelList stencil(partMesh.cellCells()[cellI]); - - stencil.append(cellI); - - label st = stencil.size(); - - donorCell[faceI].setSize(st); - - weightCellCells[faceI].setSize(st); - - scalarField weights(st); - - forAll(stencil, i) - { - scalar d = mag - ( - partMesh.cellCentres()[stencil[i]] - - fc - ); - weights[i] = 1.0/d; - donorCell[faceI][i] = cellMap[stencil[i]]; - } - weights /= sum(weights); - - weightCellCells[faceI] = weights; - - forAll(stencil, i) - { - UIntFaces[faceI] += - weightCellCells[faceI][i] - *UInterpolator.interpolate - ( - fc, - donorCell[faceI][i] - ); - } - - break; - } - } - } - - receptorNeigCell[faceI] = mesh.faceNeighbour()[faceI]; - } - else if - ( - ownType == cellCellStencil::CALCULATED - && neiType == cellCellStencil::INTERPOLATED - ) - { - isNeiInterpolatedFace.set(faceI); - - const vector& fc = mesh.faceCentres()[faceI]; - for (label zoneI = 0; zoneI < nZones; zoneI++) - { - if (zoneI != zoneID[mesh.faceNeighbour()[faceI]]) - { - const fvMesh& partMesh = meshParts[zoneI].subMesh(); - const labelList& cellMap = meshParts[zoneI].cellMap(); - label cellI = partMesh.findCell(fc); - - if (cellI != -1) - { - // Determine weights - labelList stencil(partMesh.cellCells()[cellI]); - - stencil.append(cellI); - - label st = stencil.size(); - - donorCell[faceI].setSize(st); - - weightCellCells[faceI].setSize(st); - - scalarField weights(st); - - forAll(stencil, i) - { - scalar d = mag - ( - partMesh.cellCentres()[stencil[i]] - - fc - ); - weights[i] = 1.0/d; - donorCell[faceI][i] = cellMap[stencil[i]]; - } - weights /= sum(weights); - - weightCellCells[faceI] = weights; - - forAll(stencil, i) - { - UIntFaces[faceI] += - weightCellCells[faceI][i] - *UInterpolator.interpolate - ( - fc, - donorCell[faceI][i] - ); - } - - break; - } - } - } - - receptorNeigCell[faceI] = mesh.faceOwner()[faceI]; - } - } -} - -// contravariant U -vectorField U1Contrav(mesh.nInternalFaces(), Zero); - -surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf()); - -forAll(isNeiInterpolatedFace, faceI) -{ - label cellId = -1; - if (isNeiInterpolatedFace.test(faceI)) - { - cellId = mesh.faceNeighbour()[faceI]; - } - else if (isOwnerInterpolatedFace.test(faceI)) - { - cellId = mesh.faceOwner()[faceI]; - } - - if (cellId != -1) - { - const vector& n = faceNormals[faceI]; - vector n1(Zero); - - // 2-D cases - if (mesh.nSolutionD() == 2) - { - for (direction cmpt=0; cmpt mag(n.y()) && mag(n.x()) > mag(n.z())) - { - n1 = vector(n.y(), -n.x(), 0); - } - else if (mag(n.y()) > mag(n.z())) - { - n1 = vector(0, n.z(), -n.y()); - } - else - { - n1 = vector(-n.z(), 0, n.x()); - } - } - n1.normalise(); - - const vector n2 = normalised(n ^ n1); - - tensor rot = - tensor - ( - n.x() ,n.y(), n.z(), - n1.x() ,n1.y(), n1.z(), - n2.x() ,n2.y(), n2.z() - ); - -// tensor rot = -// tensor -// ( -// n & x ,n & y, n & z, -// n1 & x ,n1 & y, n1 & z, -// n2 & x ,n2 & y, n2 & z -// ); - - U1Contrav[faceI].x() = - 2*transform(rot, UIntFaces[faceI]).x() - - transform(rot, HbyA[receptorNeigCell[faceI]]).x(); - - U1Contrav[faceI].y() = transform(rot, HbyA[cellId]).y(); - - U1Contrav[faceI].z() = transform(rot, HbyA[cellId]).z(); - - HbyA[cellId] = transform(inv(rot), U1Contrav[faceI]); - } -} diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/overPimpleDyMFoam.C b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/overPimpleDyMFoam.C index 848973c292..2d917e2b15 100644 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/overPimpleDyMFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/overPimpleDyMFoam.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,12 +46,9 @@ Description #include "fvOptions.H" #include "cellCellStencilObject.H" -#include "zeroGradientFvPatchFields.H" #include "localMin.H" -#include "interpolationCellPoint.H" -#include "transform.H" -#include "fvMeshSubset.H" #include "oversetAdjustPhi.H" +#include "oversetPatchPhiErr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,10 +65,9 @@ int main(int argc, char *argv[]) #include "setRootCaseLists.H" #include "createTime.H" #include "createDynamicFvMesh.H" + #include "createDyMControls.H" #include "initContinuityErrs.H" - pimpleControl pimple(mesh); - #include "createFields.H" #include "createUf.H" #include "createMRF.H" @@ -88,7 +84,9 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" + #include "readOversetDyMControls.H" + #include "CourantNo.H" #include "setDeltaT.H" @@ -97,45 +95,20 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - bool changed = mesh.update(); + mesh.update(); - if (changed) + if (mesh.changing()) { #include "setCellMask.H" #include "setInterpolatedCells.H" + #include "correctPhiFaceMask.H" - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); + fvc::makeRelative(phi, U); - // Zero Uf on old faceMask (H-I) - Uf *= faceMaskOld; - // Update Uf and phi on new C-I faces - Uf += (1-faceMaskOld)*fvc::interpolate(U); - phi = mesh.Sf() & Uf; - - // Zero phi on current H-I - surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); - phi *= faceMask; - } - - - if (mesh.changing() && correctPhi) - { - // Calculate absolute flux from the mapped surface velocity - #include "correctPhi.H" - } - - // Make the flux relative to the mesh motion - fvc::makeRelative(phi, U); - - if (mesh.changing() && checkMeshCourantNo) - { - #include "meshCourantNo.H" + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } } // --- Pressure-velocity PIMPLE corrector loop diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H index 142dfa783f..5f8971e2a0 100644 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H @@ -1,36 +1,11 @@ -// Option 1: interpolate rAU, do not block out rAU on blocked cells volScalarField rAU("rAU", 1.0/UEqn.A()); -mesh.interpolate(rAU); -// Option 2: do not interpolate rAU but block out rAU -//surfaceScalarField rAUf("rAUf", fvc::interpolate(blockedCells*rAU)); - - -// Option 3: do not interpolate rAU but zero out rAUf on faces on holes -// But what about: -// -// H -// H I C C C C -// H -// surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField H("H", UEqn.H()); volVectorField HbyA("HbyA", U); HbyA = constrainHbyA(rAU*H, U, p); -if (massFluxInterpolation) -{ - #include "interpolatedFaces.H" -} - -if (runTime.outputTime()) -{ - H.write(); - rAU.write(); - HbyA.write(); -} - if (pimple.nCorrPISO() <= 1) { tUEqn.clear(); @@ -38,33 +13,16 @@ if (pimple.nCorrPISO() <= 1) phiHbyA = fvc::flux(HbyA); -if (ddtCorr) -{ - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - phiHbyA += rAUf*faceMaskOld*fvc::ddtCorr(U, Uf); -} - MRF.makeRelative(phiHbyA); -// WIP -if (p.needReference()) -{ - fvc::makeRelative(phiHbyA, U); - adjustPhi(phiHbyA, U, p); - fvc::makeAbsolute(phiHbyA, U); -} - - if (adjustFringe) { fvc::makeRelative(phiHbyA, U); - oversetAdjustPhi(phiHbyA, U); + oversetAdjustPhi(phiHbyA, U, zoneIdMass); fvc::makeAbsolute(phiHbyA, U); } + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn @@ -79,27 +37,26 @@ while (pimple.correctNonOrthogonal()) if (pimple.finalNonOrthogonalIter()) { phi = phiHbyA - pEqn.flux(); - // option 2: - // rAUf*fvc::snGrad(p)*mesh.magSf(); + pEqn.relax(); + U = + cellMask* + ( + HbyA + - rAU*fvc::reconstruct((pEqn.flux())/rAUf) + ); + U.correctBoundaryConditions(); + fvOptions.correct(U); + } + + if (oversetPatchErrOutput) + { + oversetPatchPhiErr(pEqn, phiHbyA); } } - +// Excludes error in interpolated/hole cells #include "continuityErrs.H" -// Explicitly relax pressure for momentum corrector -p.relax(); -volVectorField gradP(fvc::grad(p)); - -// Option 2: zero out velocity on blocked out cells -//U = HbyA - rAU*cellMask*gradP; -// Option 3: zero out velocity on blocked out cells -// This is needed for the scalar Eq (k,epsilon, etc) -// which can use U as source term -U = cellMask*(HbyA - rAU*gradP); -U.correctBoundaryConditions(); - -fvOptions.correct(U); { Uf = fvc::interpolate(U); @@ -109,9 +66,4 @@ fvOptions.correct(U); // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); - -surfaceScalarField faceMask -( - localMin(mesh).interpolate(cellMask) -); phi *= faceMask; diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/readControls.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/readControls.H deleted file mode 100644 index 238a3e5c8f..0000000000 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/readControls.H +++ /dev/null @@ -1,10 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().getOrDefault("correctPhi", false); - -checkMeshCourantNo = pimple.dict().getOrDefault("checkMeshCourantNo", false); - -massFluxInterpolation = - pimple.dict().getOrDefault("massFluxInterpolation", false); - -ddtCorr = pimple.dict().getOrDefault("ddtCorr", true); diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H index e4f473cbf3..74568e701c 100644 --- a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H @@ -24,7 +24,3 @@ bool adjustFringe ( simple.dict().getOrDefault("oversetAdjustPhi", false) ); -bool massFluxInterpolation -( - simple.dict().getOrDefault("massFluxInterpolation", false) -); diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H index 78555ec5ce..611b54878e 100644 --- a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H @@ -1,18 +1,10 @@ { - surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); - volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", faceMask*fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = constrainHbyA(cellMask*rAU*UEqn.H(), U, p); - //mesh.interpolate(HbyA); - if (massFluxInterpolation) - { - #include "interpolatedFaces.H" - } - tUEqn.clear(); surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); diff --git a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/createFields.H index 5fc2185ab5..57ff76c20a 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/createFields.H @@ -129,10 +129,5 @@ compressibleInterPhaseTransportModel turbulence // Mask field for zeroing out contributions on hole cells #include "createCellMask.H" -surfaceScalarField faceMask -( - localMin(mesh).interpolate(cellMask) -); - // Create bool field with interpolated cells #include "createInterpolatedCells.H" diff --git a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/overCompressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/overCompressibleInterDyMFoam.C index 4367efe6bd..e4bf331604 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/overCompressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/overCompressibleInterDyMFoam.C @@ -80,9 +80,6 @@ int main(int argc, char *argv[]) #include "setRootCaseLists.H" #include "createTime.H" #include "createDynamicFvMesh.H" - pimpleControl pimple(mesh); - - #include "createTimeControls.H" #include "createDyMControls.H" #include "createFields.H" @@ -109,7 +106,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" if (LTS) { @@ -154,40 +151,10 @@ int main(int argc, char *argv[]) // Update cellMask field for blocking out hole cells #include "setCellMask.H" #include "setInterpolatedCells.H" - - faceMask = - localMin(mesh).interpolate(cellMask.oldTime()); - - // Zero Uf on old faceMask (H-I) - Uf *= faceMask; - - const surfaceVectorField Uint(fvc::interpolate(U)); - // Update Uf and phi on new C-I faces - Uf += (1-faceMask)*Uint; - - // Update Uf boundary - forAll(Uf.boundaryField(), patchI) - { - Uf.boundaryFieldRef()[patchI] = - Uint.boundaryField()[patchI]; - } - - phi = mesh.Sf() & Uf; - - // Correct phi on individual regions - if (correctPhi) - { - #include "correctPhi.H" - } + #include "correctPhiFaceMask.H" mixture.correct(); - // Zero phi on current H-I - faceMask = localMin(mesh).interpolate(cellMask); - - phi *= faceMask; - U *= cellMask; - // Make the flux relative to the mesh motion fvc::makeRelative(phi, U); @@ -202,10 +169,6 @@ int main(int argc, char *argv[]) #include "alphaControls.H" #include "compressibleAlphaEqnSubCycle.H" - const surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); rhoPhi *= faceMask; turbulence.correctPhasePhi(); diff --git a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/pEqn.H index 7def40d509..b69ce2e75d 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/overCompressibleInterDyMFoam/pEqn.H @@ -10,19 +10,6 @@ fvc::flux(HbyA) ); - if (ddtCorr) - { - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - phiHbyA += - MRF.zeroFilter - ( - fvc::interpolate(rho*rAU)*faceMaskOld*fvc::ddtCorr(U, Uf) - ); - } - MRF.makeRelative(phiHbyA); surfaceScalarField phig diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H index 3f2e6080cc..3368850e46 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,10 @@ scalar meanCoNum = 0.0; if (mesh.nInternalFaces()) { - surfaceScalarField phiMask(localMin(mesh).interpolate(cellMask)); + surfaceScalarField phiMask + ( + localMin(mesh).interpolate(cellMask + interpolatedCells) + ); scalarField sumPhi ( diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/alphaSuSp.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/alphaSuSp.H index 6e9483044f..09a1c854bf 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/alphaSuSp.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/alphaSuSp.H @@ -7,3 +7,5 @@ volScalarField::Internal divU ? fvc::div(phiCN() + mesh.phi()) : fvc::div(phiCN()) ); + +divU *= interpolatedCells*cellMask; diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H deleted file mode 100644 index 584b8eca25..0000000000 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H +++ /dev/null @@ -1,30 +0,0 @@ -bool correctPhi -( - pimple.dict().getOrDefault("correctPhi", true) -); - -bool checkMeshCourantNo -( - pimple.dict().getOrDefault("checkMeshCourantNo", false) -); - -bool moveMeshOuterCorrectors -( - pimple.dict().getOrDefault("moveMeshOuterCorrectors", false) -); - - -bool massFluxInterpolation -( - pimple.dict().getOrDefault("massFluxInterpolation", false) -); - -bool adjustFringe -( - pimple.dict().getOrDefault("oversetAdjustPhi", false) -); - -bool ddtCorr -( - pimple.dict().getOrDefault("ddtCorr", true) -); diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H index 9121e2a46d..8cfb10551e 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H @@ -40,8 +40,12 @@ volVectorField U nonInt.insert("HbyA"); nonInt.insert("grad(p_rgh)"); nonInt.insert("nHat"); + nonInt.insert("surfaceIntegrate(nHatf)"); + nonInt.insert("surfaceIntegrate(phi+meshPhi)"); nonInt.insert("surfaceIntegrate(phi)"); nonInt.insert("surfaceIntegrate(phiHbyA)"); + nonInt.insert("surfaceSum(((S|magSf)*S)"); + nonInt.insert("surfaceIntegrate(((rAUf*magSf)*snGradCorr(p_rgh)))"); nonInt.insert("cellMask"); nonInt.insert("cellDisplacement"); nonInt.insert("interpolatedCells"); diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/overInterDyMFoam.C b/applications/solvers/multiphase/interFoam/overInterDyMFoam/overInterDyMFoam.C index 1dd554aba7..ae66370b76 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/overInterDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/overInterDyMFoam.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2016-2017 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,14 +49,11 @@ Description #include "turbulentTransportModel.H" #include "pimpleControl.H" #include "fvOptions.H" -#include "CorrectPhi.H" #include "fvcSmooth.H" #include "cellCellStencilObject.H" #include "localMin.H" -#include "interpolationCellPoint.H" -#include "transform.H" -#include "fvMeshSubset.H" #include "oversetAdjustPhi.H" +#include "oversetPatchPhiErr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -76,8 +73,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - pimpleControl pimple(mesh); - #include "createTimeControls.H" + #include "createDyMControls.H" #include "createFields.H" #include "createAlphaFluxes.H" @@ -97,11 +93,8 @@ int main(int argc, char *argv[]) dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0) ); - if (correctPhi) - { - #include "correctPhi.H" - } #include "createUf.H" + #include "createControls.H" #include "setCellMask.H" #include "setInterpolatedCells.H" @@ -119,7 +112,8 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" + #include "readOversetDyMControls.H" if (LTS) { @@ -158,50 +152,17 @@ int main(int argc, char *argv[]) talphaPhi1Corr0.clear(); } - gh = (g & mesh.C()) - ghRef; - ghf = (g & mesh.Cf()) - ghRef; - // Update cellMask field for blocking out hole cells #include "setCellMask.H" #include "setInterpolatedCells.H" + #include "correctPhiFaceMask.H" - const surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); + gh = (g & mesh.C()) - ghRef; + ghf = (g & mesh.Cf()) - ghRef; - // Zero Uf on old faceMask (H-I) - Uf *= faceMaskOld; - - const surfaceVectorField Uint(fvc::interpolate(U)); - // Update Uf and phi on new C-I faces - Uf += (1-faceMaskOld)*Uint; - - // Update Uf boundary - forAll(Uf.boundaryField(), patchI) - { - Uf.boundaryFieldRef()[patchI] = - Uint.boundaryField()[patchI]; - } - - phi = mesh.Sf() & Uf; - - // Correct phi on individual regions - if (correctPhi) - { - #include "correctPhi.H" - } mixture.correct(); - // Zero phi on current H-I - const surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); - phi *= faceMask; - U *= cellMask; - // Make the flux relative to the mesh motion fvc::makeRelative(phi, U); @@ -213,14 +174,14 @@ int main(int argc, char *argv[]) } } + if (adjustFringe) + { + oversetAdjustPhi(phi, U, zoneIdMass); + } #include "alphaControls.H" #include "alphaEqnSubCycle.H" - const surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); rhoPhi *= faceMask; mixture.correct(); diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H index 921b4f673b..3b4df83409 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H @@ -1,64 +1,31 @@ { rAU = 1.0/UEqn.A(); - //mesh.interpolate(rAU); - - surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField H("H", UEqn.H()); volVectorField HbyA("HbyA", U); - //HbyA = rAU*UEqn.H(); - HbyA = constrainHbyA(rAU*H, U, p_rgh); - if (massFluxInterpolation) - { - #include "interpolatedFaces.H" - } + HbyA = constrainHbyA(rAU*H, U, p_rgh); surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); - if (ddtCorr) - { - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - phiHbyA += - fvc::interpolate(rho*rAU)*faceMaskOld*fvc::ddtCorr(U, Uf); - } MRF.makeRelative(phiHbyA); - if (p_rgh.needReference()) - { - fvc::makeRelative(phiHbyA, U); - adjustPhi(phiHbyA, U, p_rgh); - fvc::makeAbsolute(phiHbyA, U); - } - - if (adjustFringe) - { - fvc::makeRelative(phiHbyA, U); - oversetAdjustPhi(phiHbyA, U); - fvc::makeAbsolute(phiHbyA, U); - } - surfaceScalarField phig ( ( mixture.surfaceTensionForce() - - ghf*fvc::snGrad(rho) - )*faceMask*rAUf*mesh.magSf() + - ghf*fvc::snGrad(cellMask*rho) + )*rAUf*faceMask*mesh.magSf() ); phiHbyA += phig; if (adjustFringe) { - fvc::makeRelative(phiHbyA, U); - oversetAdjustPhi(phiHbyA, U); - fvc::makeAbsolute(phiHbyA, U); + oversetAdjustPhi(phiHbyA, U, zoneIdMass); } // Update the pressure BCs to ensure flux consistency @@ -90,6 +57,10 @@ U.correctBoundaryConditions(); fvOptions.correct(U); } + if (oversetPatchErrOutput) + { + oversetPatchPhiErr(p_rghEqn, phiHbyA); + } } #include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H deleted file mode 100644 index 78eb3cccb9..0000000000 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H +++ /dev/null @@ -1,16 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().getOrDefault("correctPhi", false); - -checkMeshCourantNo = - pimple.dict().getOrDefault("checkMeshCourantNo", false); - -moveMeshOuterCorrectors = - pimple.dict().getOrDefault("moveMeshOuterCorrectors", false); - -massFluxInterpolation = - pimple.dict().getOrDefault("massFluxInterpolation", false); - -ddtCorr = pimple.dict().getOrDefault("ddtCorr", true); - -adjustFringe = pimple.dict().getOrDefault("oversetAdjustPhi", false); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/correctPhi.H b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/correctPhi.H deleted file mode 100644 index 6c85d967a4..0000000000 --- a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/correctPhi.H +++ /dev/null @@ -1,11 +0,0 @@ -CorrectPhi -( - U, - phi, - p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU)), - divU, - pimple -); - -#include "continuityErrs.H" diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/createFields.H b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/createFields.H index 476a2780af..d560a9fcba 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/createFields.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/createFields.H @@ -149,10 +149,5 @@ surfaceScalarField alphaPhi10 // Mask field for zeroing out contributions on hole cells #include "createCellMask.H" -surfaceScalarField faceMask -( - localMin(mesh).interpolate(cellMask) -); - // Create bool field with interpolated cells #include "createInterpolatedCells.H" diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/overInterPhaseChangeDyMFoam.C b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/overInterPhaseChangeDyMFoam.C index ab83f493e0..8248fd084b 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/overInterPhaseChangeDyMFoam.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/overInterPhaseChangeDyMFoam.C @@ -82,9 +82,7 @@ int main(int argc, char *argv[]) #include "setRootCaseLists.H" #include "createTime.H" #include "createDynamicFvMesh.H" - pimpleControl pimple(mesh); - #include "createTimeControls.H" #include "createDyMControls.H" #include "initContinuityErrs.H" #include "createFields.H" @@ -118,7 +116,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" // Store divU from the previous mesh so that it can be mapped // and used in correctPhi to ensure the corrected phi has the @@ -153,40 +151,10 @@ int main(int argc, char *argv[]) // Update cellMask field for blocking out hole cells #include "setCellMask.H" #include "setInterpolatedCells.H" - - faceMask = - localMin(mesh).interpolate(cellMask.oldTime()); - - - // Zero Uf on old faceMask (H-I) - Uf *= faceMask; - - const surfaceVectorField Uint(fvc::interpolate(U)); - // Update Uf and phi on new C-I faces - Uf += (1-faceMask)*Uint; - - // Update Uf boundary - forAll(Uf.boundaryField(), patchI) - { - Uf.boundaryFieldRef()[patchI] = - Uint.boundaryField()[patchI]; - } - - phi = mesh.Sf() & Uf; - - if (correctPhi) - { - #include "correctPhi.H" - } + #include "correctPhiFaceMask.H" mixture->correct(); - // Zero phi on current H-I - faceMask = localMin(mesh).interpolate(cellMask); - - phi *= faceMask; - U *= cellMask; - // Make the flux relative to the mesh motion fvc::makeRelative(phi, U); } @@ -214,10 +182,6 @@ int main(int argc, char *argv[]) mixture->correct(); #include "alphaEqnSubCycle.H" - const surfaceScalarField faceMask - ( - localMin(mesh).interpolate(cellMask) - ); rhoPhi *= faceMask; interface.correct(); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/pEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/pEqn.H index 41a8ef3cb6..850888b9f4 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/overInterPhaseChangeDyMFoam/pEqn.H @@ -8,16 +8,6 @@ fvc::flux(HbyA) ); - - if (ddtCorr) - { - surfaceScalarField faceMaskOld - ( - localMin(mesh).interpolate(cellMask.oldTime()) - ); - phiHbyA += faceMaskOld*fvc::ddtCorr(U, Uf); - } - if (p_rgh.needReference()) { fvc::makeRelative(phiHbyA, U); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C index c866c774b4..0d44f20186 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/pairGAMGAgglomeration/pairGAMGAgglomerate.C @@ -36,6 +36,18 @@ void Foam::pairGAMGAgglomeration::agglomerate const scalarField& faceWeights ) { + const label nFaces = mesh.lduAddr().lowerAddr().size(); + if (faceWeights.size() != nFaces) + { + FatalErrorInFunction + << "Supplied number of face weights " << faceWeights.size() + << " does not correspond to the number of faces " << nFaces << endl + << "This may be because of using a geometry-based" + << " agglomeration method instead of a matrix-based one" + << exit(FatalError); + } + + // Start geometric agglomeration from the given faceWeights scalarField* faceWeightsPtr = const_cast(&faceWeights); diff --git a/src/fvOptions/Make/options b/src/fvOptions/Make/options index 29475c26f5..7dee5ac9cd 100644 --- a/src/fvOptions/Make/options +++ b/src/fvOptions/Make/options @@ -13,7 +13,8 @@ EXE_INC = \ -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ - -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude LIB_LIBS = \ -lfiniteVolume \ @@ -26,4 +27,5 @@ LIB_LIBS = \ -lturbulenceModels \ -lincompressibleTurbulenceModels \ -lcompressibleTurbulenceModels \ - -lreactionThermophysicalModels + -lreactionThermophysicalModels \ + -loverset diff --git a/src/fvOptions/cellSetOption/cellSetOption.C b/src/fvOptions/cellSetOption/cellSetOption.C index beb3a66377..3f0310dd4c 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.C +++ b/src/fvOptions/cellSetOption/cellSetOption.C @@ -30,6 +30,7 @@ License #include "cellSet.H" #include "cellBitSet.H" #include "volFields.H" +#include "cellCellStencilObject.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -53,6 +54,7 @@ Foam::fv::cellSetOption::selectionModeTypeNames_ { selectionModeType::smPoints, "points" }, { selectionModeType::smCellSet, "cellSet" }, { selectionModeType::smCellZone, "cellZone" }, + { selectionModeType::smCellType, "cellType" } }); @@ -97,6 +99,10 @@ void Foam::fv::cellSetOption::setSelection(const dictionary& dict) } break; } + case smCellType: + { + break; + } default: { FatalErrorInFunction @@ -234,6 +240,21 @@ void Foam::fv::cellSetOption::setCellSelection() } break; } + case smCellType: + { + labelHashSet selectedCells; + const cellCellStencilObject& overlap = Stencil::New(mesh_); + const labelList& cellTypes = overlap.cellTypes(); + forAll(cellTypes, celli) + { + if (cellTypes[celli] == cellCellStencil::POROUS) + { + selectedCells.insert(celli); + } + cells_ = selectedCells.sortedToc(); + } + break; + } default: { FatalErrorInFunction @@ -300,6 +321,7 @@ bool Foam::fv::cellSetOption::isActive() ( selectionMode_ == smGeometric || selectionMode_ == smPoints + || selectionMode_ == smCellType ) { // Geometric selection mode(s) diff --git a/src/fvOptions/cellSetOption/cellSetOption.H b/src/fvOptions/cellSetOption/cellSetOption.H index 32fe7f1fdd..06c7e3ecb6 100644 --- a/src/fvOptions/cellSetOption/cellSetOption.H +++ b/src/fvOptions/cellSetOption/cellSetOption.H @@ -162,7 +162,8 @@ public: smCellSet, //!< "cellSet" smCellZone, //!< "cellZone" smPoints, //!< "points" - smGeometric //!< "geometric" + smGeometric, //!< "geometric" + smCellType //!< "overset type cells" }; //- List of selection mode type names diff --git a/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C b/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C index 3794742ecc..a2b92fefd4 100644 --- a/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C +++ b/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C @@ -30,6 +30,7 @@ License #include "addToRunTimeSelectionTable.H" #include "fvMatrix.H" #include "volFields.H" +#include "cellCellStencilObject.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -67,14 +68,14 @@ void Foam::fv::velocityDampingConstraint::addDamping(fvMatrix& eqn) label nDamped(0); const label nTotCells(returnReduce(cells_.size(), sumOp