diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C index 2dca530c145434bf062f6ff8cca9192ec1617af8..c3fde6b3a1a2558a052e6fe1cb1175253b593bff 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C @@ -47,16 +47,15 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" - #include "readThermodynamicProperties.H" - #include "readControls.H" - #include "createFields.H" #include "initContinuityErrs.H" pimpleControl pimple(mesh); - surfaceScalarField phivAbs("phivAbs", phiv); - fvc::makeAbsolute(phivAbs, U); - + #include "readThermodynamicProperties.H" + #include "readControls.H" + #include "createFields.H" + #include "createUf.H" + #include "createPcorrTypes.H" #include "compressibleCourantNo.H" #include "setInitialDeltaT.H" @@ -75,18 +74,8 @@ int main(int argc, char *argv[]) scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); - { - // Calculate the relative velocity used to map relative flux phiv - volVectorField Urel("Urel", U); - - if (mesh.moving()) - { - Urel -= fvc::reconstruct(fvc::meshPhi(U)); - } - - // Do any mesh changes - mesh.update(); - } + // Do any mesh changes + mesh.update(); if (mesh.changing()) { @@ -94,7 +83,16 @@ int main(int argc, char *argv[]) << runTime.elapsedCpuTime() - timeBeforeMeshUpdate << " s" << endl; - #include "correctPhi.H" + if (correctPhi) + { + // Calculate absolute flux from the mapped surface velocity + phiv = mesh.Sf() & Uf; + + #include "correctPhi.H" + + // Make the flux relative to the mesh motion + fvc::makeRelative(phiv, U); + } } // --- Pressure-velocity PIMPLE corrector loop diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H index 8115b791e9c876108a87c3556df04ad9ba985437..52e73a6f4049d38e695e82bbca6befaff8040a04 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H @@ -1,18 +1,4 @@ { - wordList pcorrTypes - ( - p.boundaryField().size(), - zeroGradientFvPatchScalarField::typeName - ); - - forAll (p.boundaryField(), i) - { - if (p.boundaryField()[i].fixesValue()) - { - pcorrTypes[i] = fixedValueFvPatchScalarField::typeName; - } - } - volScalarField pcorr ( IOobject @@ -29,7 +15,7 @@ ); surfaceScalarField rhof(fvc::interpolate(rho, "div(phiv,rho)")); - dimensionedScalar rAUf("(1|A(U))", dimTime, 1.0); + dimensionedScalar rAUf("rAUf", dimTime, 1.0); while (pimple.correctNonOrthogonal()) { diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H index e7f078d1a6578be726065c128ede11fdacf66a44..0f0d5768414323fb1df135a80b7bd1b5e27d2832 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H @@ -18,7 +18,7 @@ HbyA = rAU*UEqn.H(); phiv = (fvc::interpolate(HbyA) & mesh.Sf()) - + rhorAUf*fvc::ddtCorr(U, phivAbs); + + rhorAUf*fvc::ddtCorr(U, Uf); fvc::makeRelative(phiv, U); surfaceScalarField phiGradp(rhorAUf*mesh.magSf()*fvc::snGrad(p)); @@ -43,7 +43,6 @@ if (pimple.finalNonOrthogonalIter()) { phiv += (phiGradp + pEqn.flux())/rhof; - phivAbs = fvc::absolute(phiv, U); } } @@ -82,4 +81,10 @@ U.correctBoundaryConditions(); Info<< "max(U) " << max(mag(U)).value() << endl; + + { + Uf = fvc::interpolate(U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + Uf += mesh.Sf()*(phiv - (mesh.Sf() & Uf))/sqr(mesh.magSf()); + } } diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H new file mode 100644 index 0000000000000000000000000000000000000000..216e9b4247aa70fc76afda34f80f7310118d6035 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H @@ -0,0 +1,9 @@ +#include "readTimeControls.H" + +scalar maxAcousticCo +( + readScalar(runTime.controlDict().lookup("maxAcousticCo")) +); + +bool correctPhi = + pimple.dict().lookupOrDefault<Switch>("correctPhi", true);