def fun_pEqn(mesh, runTime, simple, p, rhok, U, phi, turbulence, gh, ghf,
             p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr):

    rAU = ref.volScalarField(ref.word("rAU"), 1.0 / UEqn.A())

    rAUf = ref.surfaceScalarField(ref.word("(1|A(U))"),
                                  ref.fvc.interpolate(rAU))

    U << rAU * UEqn.H()

    phi << (ref.fvc.interpolate(U) & mesh.Sf())

    ref.adjustPhi(phi, U, p_rgh)

    buoyancyPhi = rAUf * ghf() * ref.fvc.snGrad(rhok) * mesh.magSf()
    phi -= buoyancyPhi

    for nonOrth in range(simple.nNonOrthCorr() + 1):
        p_rghEqn = ref.fvm.laplacian(rAUf, p_rgh) == ref.fvc.div(phi)

        p_rghEqn.setReference(pRefCell, ref.getRefCellValue(p_rgh, pRefCell))

        p_rghEqn.solve()

        if nonOrth == simple.nNonOrthCorr():
            # Calculate the conservative fluxes
            phi -= p_rghEqn.flux()

            # Explicitly relax pressure for momentum corrector
            p_rgh.relax()

            # Correct the momentum source with the pressure gradient flux
            # calculated from the relaxed pressure
            U -= rAU * ref.fvc.reconstruct(
                (buoyancyPhi + p_rghEqn.flux()) / rAUf)
            U.correctBoundaryConditions()
            pass
        pass

    cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                           cumulativeContErr)

    p << p_rgh + rhok * gh

    if p_rgh.needReference():
        p += ref.dimensionedScalar(
            ref.word("p"), p.dimensions(),
            pRefValue - ref.getRefCellValue(p, pRefCell))
        p_rgh << p - rhok * gh
        pass

    return cumulativeContErr
예제 #2
0
def fun_pEqn( mesh, runTime, simple, thermo, rho, p, h, psi, U, phi, turbulence, \
                      gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr, initialMass):

    rho << thermo.rho()
    rho.relax()

    rAU = 1.0 / UEqn.A()
    rhorAUf = ref.surfaceScalarField(ref.word("(rho*(1|A(U)))"),
                                     ref.fvc.interpolate(rho() * rAU))

    U << rAU * UEqn.H()

    phi << ref.fvc.interpolate(rho) * (ref.fvc.interpolate(U()) & mesh.Sf())

    closedVolume = ref.adjustPhi(phi, U, p_rgh)

    buoyancyPhi = rhorAUf * ghf * ref.fvc.snGrad(rho) * mesh.magSf()
    phi -= buoyancyPhi

    while simple.correctNonOrthogonal():

        p_rghEqn = (ref.fvm.laplacian(rhorAUf, p_rgh) == ref.fvc.div(phi))
        p_rghEqn.setReference(pRefCell, ref.getRefCellValue(p_rgh, pRefCell))
        p_rghEqn.solve()

        if simple.finalNonOrthogonalIter():
            # Calculate the conservative fluxes
            phi -= p_rghEqn.flux()

            # Explicitly relax pressure for momentum corrector
            p_rgh.relax()

            # Correct the momentum source with the pressure gradient flux
            # calculated from the relaxed pressure
            U -= rAU * ref.fvc.reconstruct(
                (buoyancyPhi + p_rghEqn.flux()) / rhorAUf)
            U.correctBoundaryConditions()
            pass
        pass

    cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                           cumulativeContErr)

    p << p_rgh + rho * gh

    # For closed-volume cases adjust the pressure level
    # to obey overall mass continuity
    if closedVolume:
        p += (initialMass -
              ref.fvc.domainIntegrate(psi * p)) / ref.fvc.domainIntegrate(psi)
        p_rgh << p - rho * gh
        pass

    rho << thermo.rho()
    rho.relax()

    ref.ext_Info() << "rho max/min : " << rho.ext_max().value(
    ) << " " << rho.ext_min().value() << ref.nl

    return cumulativeContErr
def fun_pEqn( mesh, runTime, simple, p, rhok, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr ):

  rAU = ref.volScalarField( ref.word( "rAU" ), 1.0 / UEqn.A() )
  
  rAUf = ref.surfaceScalarField( ref.word( "(1|A(U))" ), ref.fvc.interpolate( rAU ) )

  U << rAU * UEqn.H()

  phi << ( ref.fvc.interpolate( U ) & mesh.Sf() )

  ref.adjustPhi( phi, U, p_rgh );

  buoyancyPhi = rAUf * ghf() * ref.fvc.snGrad( rhok ) * mesh.magSf()
  phi -= buoyancyPhi

  while simple.correctNonOrthogonal():
    p_rghEqn = ref.fvm.laplacian( rAUf, p_rgh ) == ref.fvc.div( phi )

    p_rghEqn.setReference( pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )
    
    p_rghEqn.solve()

    if simple.finalNonOrthogonalIter():
      # Calculate the conservative fluxes
      phi -= p_rghEqn.flux()
      
      # Explicitly relax pressure for momentum corrector
      p_rgh.relax()

      # Correct the momentum source with the pressure gradient flux
      # calculated from the relaxed pressure
      U -= rAU * ref.fvc.reconstruct( ( buoyancyPhi + p_rghEqn.flux() ) / rAUf )
      U.correctBoundaryConditions()
      pass
    pass

  cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )

  p << p_rgh + rhok * gh

  if p_rgh.needReference():
    p += ref.dimensionedScalar( ref.word( "p" ), p.dimensions(), pRefValue - ref.getRefCellValue( p, pRefCell ) )
    p_rgh << p - rhok * gh
    pass
  
  return cumulativeContErr
def fun_pEqn( mesh, runTime, simple, thermo, rho, p, h, psi, U, phi, turbulence, \
                      gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr, initialMass):
      
      rho << thermo.rho()
      rho.relax()

      rAU = 1.0 / UEqn.A()
      rhorAUf = ref.surfaceScalarField( ref.word( "(rho*(1|A(U)))" ), ref.fvc.interpolate( rho() * rAU ) )
      
      U << rAU * UEqn.H()
      
      #UEqn.clear()
      
      phi << ref.fvc.interpolate( rho ) * ( ref.fvc.interpolate( U() ) & mesh.Sf() )
      
      closedVolume = ref.adjustPhi( phi, U, p_rgh )
      
      buoyancyPhi = rhorAUf * ghf * ref.fvc.snGrad( rho ) * mesh.magSf()
      
      phi -= buoyancyPhi

      for nonOrth in range( simple.nNonOrthCorr() + 1 ):

          p_rghEqn = ( ref.fvm.laplacian( rhorAUf, p_rgh ) == ref.fvc.div( phi ) )
          
          p_rghEqn.setReference( pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )
          p_rghEqn.solve()

          if nonOrth == simple.nNonOrthCorr():
              # Calculate the conservative fluxes
              phi -= p_rghEqn.flux()
              
              # Explicitly relax pressure for momentum corrector
              p_rgh.relax()
              
              # Correct the momentum source with the pressure gradient flux
              # calculated from the relaxed pressure
              U -= rAU * ref.fvc.reconstruct( ( buoyancyPhi + p_rghEqn.flux() ) / rhorAUf )
              U.correctBoundaryConditions()
              pass
          pass
  
      cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )
      
      p << p_rgh + rho * gh

      # For closed-volume cases adjust the pressure level
      # to obey overall mass continuity
      if closedVolume:
          p += ( initialMass - ref.fvc.domainIntegrate( psi * p ) ) / ref.fvc.domainIntegrate( psi ) 
          p_rgh << p - rho * gh
          pass
      rho << thermo.rho()
      rho.relax()
      
      ref.ext_Info() << "rho max/min : " <<  rho.ext_max().value() << " " << rho.ext_min().value() << ref.nl
      
      return cumulativeContErr
예제 #5
0
def _pEqn( runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, phiAbs, alpha1, rho, g, interface, pimple, pRefCell, pRefValue, cumulativeContErr ):
    rAU = 1.0 / UEqn.A()
    rAUf = ref.fvc.interpolate( rAU )

    U << rAU * UEqn.H()
    phiAbs << ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phiAbs )

    if p_rgh.needReference():
        ref.fvc.makeRelative( phiAbs, U )
        ref.adjustPhi( phiAbs, U, p_rgh )
        ref.fvc.makeAbsolute( phiAbs, U )
        pass
    phi << phiAbs + ( ref.fvc.interpolate( interface.sigmaK() ) * ref.fvc.snGrad( alpha1 ) - ghf * ref.fvc.snGrad( rho ) ) * rAUf * mesh.magSf()

    while pimple.correctNonOrthogonal():
        p_rghEqn = ( ref.fvm.laplacian( rAUf, p_rgh ) == ref.fvc.div( phi ) )

        p_rghEqn.setReference( pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )

        p_rghEqn.solve( mesh.solver( p_rgh.select( pimple.finalInnerIter() ) ) )
        
        if pimple.finalNonOrthogonalIter():
            phi -= p_rghEqn.flux()
            pass
        pass

    U += rAU * ref.fvc.reconstruct( ( phi() - phiAbs ) / rAUf ) # mixed calculations
    U.correctBoundaryConditions()

    cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )

    phiAbs << phi
    # Make the fluxes relative to the mesh motion
    ref.fvc.makeRelative( phi, U )

    p == p_rgh + rho * gh

    if p_rgh.needReference():
        p += ref.dimensionedScalar( ref.word( "p" ),
                                    p.dimensions(),
                                    pRefValue - ref.getRefCellValue( p, pRefCell ) );
        p_rgh << p - rho * gh
        pass
    
    return cumulativeContErr
예제 #6
0
def fun_pEqn( runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, rho, pimple, corr, pRefCell, pRefValue, cumulativeContErr ):
    rAU = 1.0/UEqn.A()
     
    rAUf = ref.fvc.interpolate( rAU )
    
    U << rAU * UEqn.H()

    phiU = ref.surfaceScalarField( ref.word( "phiU" ),
                                   ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) )
                               
    ref.adjustPhi( phiU, U, p )
    
    phi << phiU - ghf * ref.fvc.snGrad( rho ) * rAUf * mesh.magSf()

    for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
        p_rghEqn = ref.fvm.laplacian( rAUf, p_rgh ) == ref.fvc.div( phi ) 
        p_rghEqn.setReference(pRefCell, ref.getRefCellValue( p_rgh, pRefCell ) )

        p_rghEqn.solve( mesh.solver( p_rgh.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )
        
        if nonOrth == pimple.nNonOrthCorr():
           phi -= p_rghEqn.flux()
           pass
        pass
    
    U += rAU * ref.fvc.reconstruct( ( phi() - phiU ) / rAUf ) # mixed calculations
    U.correctBoundaryConditions()

    cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )
    
    p == p_rgh + rho * gh

    if p_rgh.needReference():
       p += ref.dimensionedScalar( ref.word( "p" ),
                                   p.dimensions(),
                                   pRefValue - ref.getRefCellValue( p, pRefCell ) )
       p_rgh << p - rho * gh
       pass
    
    return cumulativeContErr
예제 #7
0
def _pEqn(runTime, mesh, UEqn, U, p, p_rgh, gh, ghf, phi, alpha1, rho, g,
          interface, corr, pimple, pRefCell, pRefValue, cumulativeContErr):
    rAU = 1.0 / UEqn.A()

    rAUf = ref.fvc.interpolate(rAU)

    U << rAU * UEqn.H()

    phiU = ref.surfaceScalarField(ref.word("phiU"),
                                  (ref.fvc.interpolate(U) & mesh.Sf()) +
                                  ref.fvc.ddtPhiCorr(rAU, rho, U, phi))

    ref.adjustPhi(phiU, U, p)

    phi << (phiU +
            (ref.fvc.interpolate(interface.sigmaK()) * ref.fvc.snGrad(alpha1) -
             ghf * ref.fvc.snGrad(rho)) * rAUf * mesh.magSf())

    for nonOrth in range(pimple.nNonOrthCorr() + 1):
        p_rghEqn = ref.fvm.laplacian(rAUf, p_rgh) == ref.fvc.div(phi)
        p_rghEqn.setReference(pRefCell, pRefValue)

        p_rghEqn.solve(
            mesh.solver(p_rgh.select(pimple.finalInnerIter(corr, nonOrth))))

        if nonOrth == pimple.nNonOrthCorr():
            phi -= p_rghEqn.flux()
            pass
        pass

    U += rAU * ref.fvc.reconstruct((phi() - phiU) / rAUf)  # mixed calculations
    U.correctBoundaryConditions()

    cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                           cumulativeContErr)

    p == p_rgh + rho * gh

    if p_rgh.needReference():
        p += ref.dimensionedScalar(
            ref.word("p"), p.dimensions(),
            pRefValue - ref.getRefCellValue(p, pRefCell))
        p_rgh << p - rho * gh
        pass
    return cumulativeContErr
예제 #8
0
def _createFields(runTime, mesh):

    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
    man.interfaceProperties  # Load corresponding library to be able to use the following BC - "constantAlphaContactAngleFvPatchScalarField"
    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()

    # Need to store rho for ddt(rho, U)
    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT),
        alpha1 * rho1 + (1.0 - alpha1) * rho2,
        alpha1.ext_boundaryField().types())
    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 interface from alpha1 distribution
    interface = man.interfaceProperties(alpha1, U, twoPhaseProperties)

    # Construct incompressible turbulence model
    turbulence = man.incompressible.turbulenceModel.New(
        U, phi, twoPhaseProperties)

    g = man.readGravitationalAcceleration(runTime, mesh)

    #dimensionedVector g0(g);

    #Read the data file and initialise the interpolation table
    #interpolationTable<vector> timeSeriesAcceleration( runTime.path()/runTime.caseConstant()/"acceleration.dat" );

    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, p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, pRefValue, interface, turbulence, g, gh, ghf
def createFields( runTime, mesh, g ):
  
  ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
  
  ref.ext_Info() << "Reading field T\n" << ref.nl
  T = man.volScalarField( man.IOobject( ref.word( "T" ),
                                        ref.fileName( runTime.timeName() ),
                                        mesh,
                                        ref.IOobject.MUST_READ,
                                        ref.IOobject.AUTO_WRITE ), mesh )

  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 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 )
    
  laminarTransport, beta, TRef, Pr, Prt = readTransportProperties( U, phi )
  
  ref.ext_Info()<< "Creating turbulence model\n" << ref.nl
  turbulence = man.incompressible.RASModel.New(U, phi, laminarTransport)

  # Kinematic density for buoyancy force
  rhok = man.volScalarField( man.IOobject( ref.word( "rhok" ),
                                           ref.fileName( runTime.timeName() ),
                                           mesh ), man( 1.0 - beta * ( T() - TRef ), man.Deps( T ) ) )
  
  # kinematic turbulent thermal thermal conductivity m2/s
  ref.ext_Info() << "Reading field kappat\n" << ref.nl
  kappat = man.volScalarField( man.IOobject( ref.word( "kappat" ),
                                             ref.fileName( runTime.timeName() ),
                                             mesh,
                                             ref.IOobject.MUST_READ,
                                             ref.IOobject.AUTO_WRITE ), mesh )

  ref.ext_Info() << "Calculating field g.h\n" << ref.nl
  gh = man.volScalarField( ref.word( "gh" ), man( g & mesh.C(), man.Deps( mesh ) ) )
  
  ghf = man.surfaceScalarField( ref.word( "ghf" ), man( g & 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 + rhok * gh )

  pRefCell = 0
  pRefValue = 0.0

  pRefCell, pRefValue = ref.setRefCell( p, p_rgh, mesh.solutionDict().subDict( ref.word( "SIMPLE" ) ), pRefCell, pRefValue )

  if p_rgh.needReference():
    p += ref.dimensionedScalar( ref.word( "p" ),p.dimensions(), pRefValue - ref.getRefCellValue( p, pRefCell ) )
    pass
  
  return T, p_rgh, U, phi, laminarTransport, turbulence, rhok, kappat, gh, ghf, p, pRefCell, pRefValue, beta, TRef, Pr, Prt
예제 #10
0
def _createFields(runTime, mesh):

    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()

    # Need to store rho for ddt(rho, U)
    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.READ_IF_PRESENT),
        alpha1 * rho1 + (1.0 - alpha1) * rho2,
        alpha1.ext_boundaryField().types(),
    )
    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 interface from alpha1 distribution
    interface = man.interfaceProperties(alpha1, U, twoPhaseProperties)

    # Construct incompressible turbulence model
    turbulence = man.incompressible.turbulenceModel.New(U, phi, twoPhaseProperties)

    g = man.readGravitationalAcceleration(runTime, mesh)

    # dimensionedVector g0(g);

    # Read the data file and initialise the interpolation table
    # interpolationTable<vector> timeSeriesAcceleration( runTime.path()/runTime.caseConstant()/"acceleration.dat" );

    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,
        p,
        alpha1,
        U,
        phi,
        rho1,
        rho2,
        rho,
        rhoPhi,
        twoPhaseProperties,
        pRefCell,
        pRefValue,
        interface,
        turbulence,
        g,
        gh,
        ghf,
    )
예제 #11
0
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
예제 #12
0
def fun_pEqn( runTime, i, mesh, p, rho, turb, thermo, thermoFluid, kappa, UEqn, U, phi, psi, \
              initialMass, p_rgh, gh, ghf, nNonOrthCorr, cumulativeContErr, rhoMax, rhoMin, pRefCell, pRefValue ):
    
    rho << thermo.rho()
    rho << rho.ext_max( rhoMin[ i ] )
    rho << rho.ext_min( rhoMax[ i ] )
    rho.relax()

    rAU = 1.0 / UEqn.A()
    rhorAUf = ref.surfaceScalarField( ref.word( "(rho*(1|A(U)))" ), ref.fvc.interpolate( rho * rAU ) )

    U << rAU * UEqn.H()
    #UEqn.clear()

    phi << ref.fvc.interpolate( rho ) * ( ref.fvc.interpolate( U ) & mesh.Sf() )
    closedVolume = ref.adjustPhi( phi, U, p_rgh )
    compressibility = ref.fvc.domainIntegrate( psi )
    compressible = ( compressibility.value() > ref.SMALL)

    buoyancyPhi = rhorAUf * ghf * ref.fvc.snGrad( rho ) * mesh.magSf()
    phi -= buoyancyPhi

    # Solve pressure
    for nonOrth in range( nNonOrthCorr + 1 ):
        p_rghEqn = ref.fvm.laplacian( rhorAUf, p_rgh ) == ref.fvc.div( phi ) 

        if compressible:
            tmp = ref.getRefCellValue(p_rgh, pRefCell)
            pass
        else:
            tmp = pRefValue
            pass
        p_rghEqn.setReference( pRefCell, tmp )

        p_rghEqn.solve()

        if nonOrth == nNonOrthCorr:
            # Calculate the conservative fluxes
            phi -= p_rghEqn.flux()

            # Explicitly relax pressure for momentum corrector
            p_rgh.relax()

            # Correct the momentum source with the pressure gradient flux
            # calculated from the relaxed pressure
            U -= rAU * ref.fvc.reconstruct( ( buoyancyPhi + p_rghEqn.flux() ) / rhorAUf )
            U.correctBoundaryConditions()
            pass
        pass

    p << p_rgh + rho * gh
    
    cumulativeContErr = ref.ContinuityErrs( phi, runTime, mesh, cumulativeContErr )

    # For closed-volume cases adjust the pressure level
    # to obey overall mass continuity
    if closedVolume and compressible:
        p += ( initialMass - ref.fvc.domainIntegrate( thermo.rho() ) ) / compressibility
        p_rgh << p() - rho * gh
        pass

    rho << thermo.rho();
    rho << rho.ext_max( rhoMin[ i ] )
    rho << rho.ext_min( rhoMax[ i ] )
    rho.relax()

    ref.ext_Info() << "Min/max rho:" << rho.ext_min().value() << ' ' << rho.ext_max().value() << ref.nl

    # Update thermal conductivity
    kappa << thermo.Cp() * turb.alphaEff()
    
    return cumulativeContErr