def setrDeltaT( runTime, mesh, pimple, phi, psi, U, rho, rDeltaT, maxDeltaT ): pimpleDict = pimple.dict() maxCo = pimpleDict.lookupOrDefault( ref.word( "maxCo" ), ref.scalar( 0.8 ) ) rDeltaTSmoothingCoeff = pimpleDict.lookupOrDefault( ref.word( "rDeltaTSmoothingCoeff" ) , ref.scalar( 0.02 ) ) rDeltaTDampingCoeff = pimpleDict.lookupOrDefault( ref.word( "rDeltaTDampingCoeff" ), ref.scalar( 1.0 ) ) maxDeltaT = pimpleDict.lookupOrDefault( ref.word( "maxDeltaT" ), ref.GREAT ) rDeltaT0 = ref.volScalarField( ref.word( "rDeltaT0" ), rDeltaT ) # Set the reciprocal time-step from the local Courant number tmp = ref.fvc.surfaceSum( phi.mag() ) tmp1= ( tmp.dimensionedInternalField() / ( ( 2 * maxCo ) * mesh.V() * rho.dimensionedInternalField() ) ) print tmp1 rDeltaT.dimensionedInternalField() << tmp1().max( 1.0 / ref.dimensionedScalar( ref.word( "maxDeltaT" ), ref.dimTime, maxDeltaT ) ) if pimple.transonic(): phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ref.fvc.interpolate( U ) & mesh.Sf() ) ) rDeltaT.dimensionedInternalField() << rDeltaT.dimensionedInternalField().max( ref.fvc.surfaceSum( phid.mag() ).dimensionedInternalField() / ( ( 2 * maxCo ) * mesh.V() * psi.dimensionedInternalField() ) ) pass # Update tho boundary values of the reciprocal time-step rDeltaT.correctBoundaryConditions() ref.ext_Info() << "Flow time scale min/max = " << ( 1 / rDeltaT.internalField() ).gMin() << ", " << ( 1 / rDeltaT.internalField() ).gMax() << ref.nl if rDeltaTSmoothingCoeff < 1.0: ref.fvc.smooth( rDeltaT, rDeltaTSmoothingCoeff ) pass ref.ext_Info() << "Smoothed flow time scale min/max = " << ( 1 / rDeltaT.internalField() ).gMin() << ", " << ( 1 / rDeltaT.internalField() ).gMax() << ref.nl # Limit rate of change of time scale # - reduce as much as required # - only increase at a fraction of old time scale if rDeltaTDampingCoeff < 1.0 and runTime.timeIndex() > ( runTime.startTimeIndex() + 1 ) : rDeltaT = rDeltaT0 * ( rDeltaT / rDeltaT0 ).max( ref.scalar( 1.0 ) - rDeltaTDampingCoeff ) Info<< "Damped flow time scale min/max = " << ( 1 / rDeltaT.internalField() ).gMin() << ", " << ( 1 / rDeltaT.internalField() ).gMax() << ref.nl pass pass
def alphaEqn( mesh, phi, alpha1, alphatab, Dab, rhoPhi, rho, rho1, rho2, turbulence ): alpha1Eqn = ref.fvm.ddt( alpha1 ) + ref.fvm.div( phi, alpha1 ) - ref.fvm.laplacian( Dab + alphatab * turbulence.ext_nut(), alpha1, ref.word( "laplacian(Dab,alpha1)" ) ) alpha1Eqn.solve() rhoPhi << alpha1Eqn.flux() * ( rho1 - rho2 ) + phi * rho2 rho << alpha1 * rho1 + ( ref.scalar( 1 ) - alpha1 ) * rho2 ref.ext_Info() << "Phase 1 volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \ << " Min(alpha1) = " << alpha1.ext_min().value() << " Max(alpha1) = " << alpha1.ext_max().value() << ref.nl pass
def setrDeltaT(runTime, mesh, pimple, phi, psi, U, rho, rDeltaT, maxDeltaT): pimpleDict = pimple.dict() maxCo = pimpleDict.lookupOrDefault(ref.word("maxCo"), ref.scalar(0.8)) rDeltaTSmoothingCoeff = pimpleDict.lookupOrDefault( ref.word("rDeltaTSmoothingCoeff"), ref.scalar(0.02)) rDeltaTDampingCoeff = pimpleDict.lookupOrDefault( ref.word("rDeltaTDampingCoeff"), ref.scalar(1.0)) maxDeltaT = pimpleDict.lookupOrDefault(ref.word("maxDeltaT"), ref.GREAT) rDeltaT0 = ref.volScalarField(ref.word("rDeltaT0"), rDeltaT) # Set the reciprocal time-step from the local Courant number tmp = ref.fvc.surfaceSum(phi.mag()) tmp1 = (tmp.dimensionedInternalField() / ((2 * maxCo) * mesh.V() * rho.dimensionedInternalField())) print tmp1 rDeltaT.dimensionedInternalField() << tmp1().max( 1.0 / ref.dimensionedScalar(ref.word("maxDeltaT"), ref.dimTime, maxDeltaT)) if pimple.transonic(): phid = ref.surfaceScalarField( ref.word("phid"), ref.fvc.interpolate(psi) * (ref.fvc.interpolate(U) & mesh.Sf())) rDeltaT.dimensionedInternalField() << rDeltaT.dimensionedInternalField( ).max( ref.fvc.surfaceSum(phid.mag()).dimensionedInternalField() / ((2 * maxCo) * mesh.V() * psi.dimensionedInternalField())) pass # Update tho boundary values of the reciprocal time-step rDeltaT.correctBoundaryConditions() ref.ext_Info() << "Flow time scale min/max = " << ( 1 / rDeltaT.internalField()).gMin() << ", " << ( 1 / rDeltaT.internalField()).gMax() << ref.nl if rDeltaTSmoothingCoeff < 1.0: ref.fvc.smooth(rDeltaT, rDeltaTSmoothingCoeff) pass ref.ext_Info() << "Smoothed flow time scale min/max = " << ( 1 / rDeltaT.internalField()).gMin() << ", " << ( 1 / rDeltaT.internalField()).gMax() << ref.nl # Limit rate of change of time scale # - reduce as much as required # - only increase at a fraction of old time scale if rDeltaTDampingCoeff < 1.0 and runTime.timeIndex() > ( runTime.startTimeIndex() + 1): rDeltaT = rDeltaT0 * ( rDeltaT / rDeltaT0).max(ref.scalar(1.0) - rDeltaTDampingCoeff) Info << "Damped flow time scale min/max = " << ( 1 / rDeltaT.internalField()).gMin() << ", " << ( 1 / rDeltaT.internalField()).gMax() << ref.nl pass pass
def _createFields( runTime, mesh, g ): ref.ext_Info() << "Reading field p_rgh\n" << ref.nl p_rgh = man.volScalarField( man.IOobject( ref.word( "p_rgh" ), ref.fileName( runTime.timeName() ), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE ), mesh ) ref.ext_Info() << "Reading field alpha1\n" << ref.nl alpha1 = man.volScalarField( man.IOobject( ref.word( "alpha1" ), ref.fileName( runTime.timeName() ), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE ), mesh ) ref.ext_Info() << "Reading field U\n" << ref.nl U = man.volVectorField( man.IOobject( ref.word( "U" ), ref.fileName( runTime.timeName() ), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE ), mesh ) phi = man.createPhi( runTime, mesh, U ) ref.ext_Info() << "Reading transportProperties\n" << ref.nl twoPhaseProperties = man.twoPhaseMixture( U, phi ) rho1 = twoPhaseProperties.rho1() rho2 = twoPhaseProperties.rho2() Dab = ref.dimensionedScalar( twoPhaseProperties.lookup( ref.word( "Dab" ) ) ) # Read the reciprocal of the turbulent Schmidt number alphatab = ref.dimensionedScalar( twoPhaseProperties.lookup( ref.word( "alphatab" ) ) ) # Need to store rho for ddt(rho, U) rho = man.volScalarField ( ref.word( "rho" ), alpha1 * rho1 + ( ref.scalar(1) - alpha1 ) * rho2 ) rho.oldTime() # Mass flux # Initialisation does not matter because rhoPhi is reset after the # alpha1 solution before it is used in the U equation. rhoPhi = man.surfaceScalarField( man.IOobject( ref.word( "rho*phi" ), ref.fileName( runTime.timeName() ), mesh, ref.IOobject.NO_READ, ref.IOobject.NO_WRITE ), rho1 * phi ) # Construct incompressible turbulence model turbulence = man.incompressible.turbulenceModel.New( U, phi, twoPhaseProperties ) ref.ext_Info() << "Calculating field g.h\n" << ref.nl gh = man.volScalarField ( ref.word( "gh" ), g & man.volVectorField( mesh.C(), man.Deps( mesh ) ) ) ghf = man.surfaceScalarField ( ref.word( "ghf" ), g & man.surfaceVectorField( mesh.Cf(), man.Deps( mesh ) ) ) p = man.volScalarField( man.IOobject( ref.word( "p" ), ref.fileName( runTime.timeName() ), mesh, ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE ), p_rgh + rho * gh ) pRefCell = 0 pRefValue = 0.0 pRefCell, pRefValue = ref.setRefCell( p, p_rgh, mesh.solutionDict().subDict( ref.word( "PIMPLE" ) ), pRefCell, pRefValue ) if p_rgh.needReference(): p += ref.dimensionedScalar( ref.word( "p" ), p.dimensions(), pRefValue - ref.getRefCellValue( p, pRefCell ) ) p_rgh << p - rho * gh pass return p_rgh, alpha1, U, phi, twoPhaseProperties, rho1, rho2, Dab, alphatab, rho, rhoPhi, turbulence, gh, ghf, p, pRefCell, pRefValue