diff --git a/applications/solvers/multiphase/cavitatingFoam/Allwclean b/applications/solvers/multiphase/cavitatingFoam/Allwclean new file mode 100755 index 0000000000000000000000000000000000000000..62548246e9a0fe529bef20fa7211ff2c396511e9 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/Allwclean @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wclean +wclean cavitatingDyMFoam + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/multiphase/cavitatingFoam/Allwmake b/applications/solvers/multiphase/cavitatingFoam/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..211c1978b2a1c17c5dd744e9ec105e3e28409140 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/Allwmake @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wmake +wmake cavitatingDyMFoam + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/Make/files b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..57cd74e01d8bbfc12289b067b4384aab2c9abcf8 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/Make/files @@ -0,0 +1,3 @@ +cavitatingDyMFoam.C + +EXE = $(FOAM_APPBIN)/cavitatingDyMFoam diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/Make/options b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..fa204ce58f0fdee1455d5339c34ad633135d2ac3 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/Make/options @@ -0,0 +1,22 @@ +EXE_INC = \ + -I.. \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude + +EXE_LIBS = \ + -lincompressibleTransportModels \ + -lincompressibleTurbulenceModel \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lfiniteVolume \ + -lbarotropicCompressibilityModel \ + -ldynamicMesh \ + -lmeshTools \ + -ldynamicFvMesh diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..45bc766761a0270ce9458fa1648b2cdb3d105c51 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Application + cavitatingFoam + +Description + Transient cavitation code based on the homogeneous equilibrium model + from which the compressibility of the liquid/vapour "mixture" is obtained. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dynamicFvMesh.H" +#include "barotropicCompressibilityModel.H" +#include "twoPhaseMixture.H" +#include "turbulenceModel.H" +#include "pimpleControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #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 "compressibleCourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + Info<< "Time = " << runTime.timeName() << nl << endl; + + 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(); + } + + if (mesh.changing()) + { + Info<< "Execution time for mesh.update() = " + << runTime.elapsedCpuTime() - timeBeforeMeshUpdate + << " s" << endl; + + #include "correctPhi.H" + } + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + #include "rhoEqn.H" + #include "gammaPsi.H" + #include "UEqn.H" + + // --- Pressure corrector loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + turbulence->correct(); + } + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H new file mode 100644 index 0000000000000000000000000000000000000000..8115b791e9c876108a87c3556df04ad9ba985437 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/correctPhi.H @@ -0,0 +1,48 @@ +{ + wordList pcorrTypes + ( + p.boundaryField().size(), + zeroGradientFvPatchScalarField::typeName + ); + + forAll (p.boundaryField(), i) + { + if (p.boundaryField()[i].fixesValue()) + { + pcorrTypes[i] = fixedValueFvPatchScalarField::typeName; + } + } + + volScalarField pcorr + ( + IOobject + ( + "pcorr", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("pcorr", p.dimensions(), 0.0), + pcorrTypes + ); + + surfaceScalarField rhof(fvc::interpolate(rho, "div(phiv,rho)")); + dimensionedScalar rAUf("(1|A(U))", dimTime, 1.0); + + while (pimple.correctNonOrthogonal()) + { + fvScalarMatrix pcorrEqn + ( + fvm::laplacian(rAUf, pcorr) == fvc::ddt(rho) + fvc::div(phiv*rhof) + ); + + pcorrEqn.solve(); + + if (pimple.finalNonOrthogonalIter()) + { + phiv -= pcorrEqn.flux()/rhof; + } + } +} diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..a4e9e0b40f6c77500d7b55adad6daa8d399c3279 --- /dev/null +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/pEqn.H @@ -0,0 +1,85 @@ +{ + if (pimple.nCorrPIMPLE() == 1) + { + p = + ( + rho + - (1.0 - gamma)*rhol0 + - ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat + )/psi; + } + + surfaceScalarField rhof("rhof", fvc::interpolate(rho)); + + volScalarField rAU(1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", rhof*fvc::interpolate(rAU)); + + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + phiv = (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, rho, U, phivAbs); + fvc::makeRelative(phiv, U); + + surfaceScalarField phiGradp(rAUf*mesh.magSf()*fvc::snGrad(p)); + + phiv -= phiGradp/rhof; + + volScalarField rho0(rho - psi*p); + + while (pimple.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvc::ddt(rho) + + psi*correction(fvm::ddt(p)) + + fvc::div(phiv, rho) + + fvc::div(phiGradp) + - fvm::laplacian(rAUf, p) + ); + + pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phiv += (phiGradp + pEqn.flux())/rhof; + phivAbs = fvc::absolute(phiv, U); + } + } + + Info<< "Predicted p max-min : " << max(p).value() + << " " << min(p).value() << endl; + + rho == max(rho0 + psi*p, rhoMin); + + #include "gammaPsi.H" + + p = + ( + rho + - (1.0 - gamma)*rhol0 + - ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat + )/psi; + + p.correctBoundaryConditions(); + + Info<< "Phase-change corrected p max-min : " << max(p).value() + << " " << min(p).value() << endl; + + // Correct velocity + + U = HbyA - rAU*fvc::grad(p); + + // Remove the swirl component of velocity for "wedge" cases + if (pimple.dict().found("removeSwirl")) + { + label swirlCmpt(readLabel(pimple.dict().lookup("removeSwirl"))); + + Info<< "Removing swirl component-" << swirlCmpt << " of U" << endl; + U.field().replace(swirlCmpt, 0.0); + } + + U.correctBoundaryConditions(); + + Info<< "max(U) " << max(mag(U)).value() << endl; +} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C index 3a150c6f70792102426a0c851279fe19c0838c66..18d5b3324288146561b458c4a01b3d9487b0baf6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.C @@ -84,4 +84,13 @@ Foam::fanFvPatchField<Type>::fanFvPatchField {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::Field<Type> > Foam::fanFvPatchField<Type>::jump() const +{ + return uniformJumpFvPatchField<Type>::jump(); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H index 463ebeb543602d0a1dd0e4291b626b6ef1101307..bf0762f4788ffed8dba16c2b3208df6fa4ec009d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchField.H @@ -172,6 +172,9 @@ public: // Evaluation functions + //- Return the "jump" across the patch + tmp<Field<Type> > jump() const; + //- Update the coefficients associated with the patch field virtual void updateCoeffs(); }; @@ -185,6 +188,10 @@ fanFvPatchField<scalar>::fanFvPatchField const DimensionedField<scalar, volMesh>&, const dictionary& ); + +template<> +tmp<Field<scalar> > fanFvPatchField<scalar>::jump() const; + template<> void fanFvPatchField<scalar>::updateCoeffs(); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C index 668d43483de22fd7e282f9d999bea437d36ee6a3..7922b66fe37a337e117501c2b5e2639ba66001b1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fan/fanFvPatchFields.C @@ -30,18 +30,16 @@ License #include "Tuple2.H" #include "polynomial.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeTemplatePatchTypeField -( - fvPatchScalarField, - fanFvPatchScalarField -); + makeTemplatePatchTypeField + ( + fvPatchScalarField, + fanFvPatchScalarField + ); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -115,15 +113,10 @@ Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Specialisation of the jump-condition for the pressure template<> -void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs() +Foam::tmp<Foam::Field<Foam::scalar> > +Foam::fanFvPatchField<Foam::scalar>::jump() const { - if (this->updated()) - { - return; - } - if (this->cyclicPatch().owner()) { const surfaceScalarField& phi = @@ -139,15 +132,33 @@ void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs() Un /= patch().lookupPatchField<volScalarField, scalar>("rho"); } - this->jump_ = this->jumpTable_->value(Un); + return this->jumpTable_->value(Un); + } + else + { + return refCast<const fanFvPatchField<scalar> > + ( + this->neighbourPatchField() + ).jump(); } - - uniformJumpFvPatchField<scalar>::updateCoeffs(); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<> +void Foam::fanFvPatchField<Foam::scalar>::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + if (this->cyclicPatch().owner()) + { + this->jump_ = jump(); + } + + uniformJumpFvPatchField<scalar>::updateCoeffs(); +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C index e58270ec638df26b663319261278f6661d3f9b12..9ef4be21a407f055c7f5831627e1e14a4120e49f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJump/fixedJumpFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -138,7 +138,8 @@ template<class Type> void Foam::fixedJumpFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - os.writeKeyword("patchType") << "cyclic" << token::END_STATEMENT << nl; + os.writeKeyword("patchType") << this->interfaceFieldType() + << token::END_STATEMENT << nl; jump_.writeEntry("jump", os); this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C index d9cdc383a3f56c64518e87484ee8a442e27eae72..4c3290cf2d7e1d5a8b4c5006cd9c69601bab82fe 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedJumpAMI/fixedJumpAMIFvPatchField.C @@ -141,7 +141,8 @@ template<class Type> void Foam::fixedJumpAMIFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); - os.writeKeyword("patchType") << "cyclicAMI" << token::END_STATEMENT << nl; + os.writeKeyword("patchType") << this->interfaceFieldType() + << token::END_STATEMENT << nl; jump_.writeEntry("jump", os); this->writeEntry("value", os); } diff --git a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/system/fvSolution b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/system/fvSolution index 19d27d99becf5739284643fa38934c9dc77f7cc8..962f2cdfd602b003125d7dcea347374b3442e273 100644 --- a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/system/fvSolution +++ b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/system/fvSolution @@ -67,6 +67,7 @@ PIMPLE nCorrectors 2; nNonOrthogonalCorrectors 0; nAlphaSubCycles 2; + nAlphaCorr 1; pRefValue 0; pRefPoint (0.1 0.1 1); }