Example #1
0
def createFields( runTime, mesh):
    
    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
  
    pThermo = man.basicPsiThermo.New( mesh )
  
    p = man.volScalarField( pThermo.p(), man.Deps( pThermo ) )
    e = man.volScalarField( pThermo.e(), man.Deps( pThermo ) )
    psi = man.volScalarField( pThermo.psi(), man.Deps( pThermo ) )

    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh ),
                              man.volScalarField( pThermo.rho(), man.Deps( pThermo ) ) )

    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.compressibleCreatePhi( runTime, mesh, rho, U )
 
    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New( rho, U, phi, pThermo )
    
    return pThermo, p, e, psi, rho, U, phi, turbulence
def _UEqn( phi, U, p, rho, turbulence, mrfZones, pZones, pressureImplicitPorosity, nUCorr ):
    # Solve the Momentum equation
    UEqn = man.fvVectorMatrix( turbulence.divDevRhoReff( U ), man.Deps( turbulence ) )  + man.fvm.div( phi, U )
    
    UEqn.relax()
    
    mrfZones.addCoriolis( rho, UEqn )
    
    trAU = None
    trTU = None

    if pressureImplicitPorosity:
        tTU = man.volTensorField( ref.tensor( ref.I ) * UEqn.A(), man.Deps( UEqn ) )
        pZones.addResistance( UEqn, tTU )
        trTU = man.volTensorField( tTU.inv(), man.Deps( tTU ) )
        trTU.rename( ref.word( "rAU" ) )

        gradp = ref.fvc.grad(p)

        for UCorr in range( nUCorr ):
            U << ( trTU() & ( UEqn.H() - gradp ) ) # mixed calculations
            pass
        U.correctBoundaryConditions()
        pass
    else:
        pZones.addResistance( UEqn )
        ref.solve( UEqn == -ref.fvc.grad( p ) )
        trAU = man.volScalarField( 1.0 / UEqn.A(), man.Deps( UEqn ) )
        trAU.rename( ref.word( "rAU" ) )
        pass
    
    return UEqn, trAU, trTU
Example #3
0
def createFields( runTime, mesh, rhoO, psi ):
    ref.ext_Info()<< "Reading field p\n" << ref.nl
    p = man.volScalarField( man.IOobject( ref.word( "p" ),
                                          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 )
    
    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.NO_READ,
                                            ref.IOobject.AUTO_WRITE ),
                              rhoO + psi * p )
  
    phi = man.compressibleCreatePhi( runTime, mesh, U, rho )
  
    return p, U, rho, phi
Example #4
0
def solveFluid( i, mesh, thermo, rad, thermoFluid, rho, K, U, phi, h, turb, DpDt, p, psi, initialMass, p_rgh, gh, ghf,\
                oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor,cumulativeContErr, finalIter ) :
    if finalIter:
        mesh.add( ref.word( "finalIteration" ), True )
        pass

    if oCorr == 0 :
        ref.rhoEqn( rho, phi )
        pass
    
    UEqn = fun_UEqn( rho, U, phi, ghf, p_rgh, turb, mesh, momentumPredictor, finalIter )
    fun_hEqn( rho, h, phi, turb, DpDt, thermo, rad,  mesh, oCorr, nOuterCorr, finalIter )
    
    # --- PISO loop
    for corr in range( nCorr ):
        cumulativeContErr =  fun_pEqn( i, mesh, p, rho, turb, thermo, thermoFluid, K, UEqn, U, phi, psi, DpDt, initialMass, p_rgh, gh, ghf,
                                       nNonOrthCorr, oCorr, nOuterCorr, corr, nCorr, cumulativeContErr )
        pass
    
    turb.correct()
    rho << thermo.rho()
    
    if finalIter:
        mesh.remove( ref.word( "finalIteration" ) )
        pass
    
    return cumulativeContErr
Example #5
0
def alphaEqnSubCycle(runTime, pimple, mesh, phi, alpha1, rho, rhoPhi, rho1, rho2, interface):

    nAlphaCorr = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaCorr")))
    nAlphaSubCycles = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaSubCycles")))
    if nAlphaSubCycles > 1:
        totalDeltaT = runTime.deltaT()
        rhoPhiSum = 0.0 * rhoPhi
        alphaSubCycle = ref.subCycle_volScalarField(alpha1, nAlphaSubCycles)
        for item in alphaSubCycle:
            alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr)
            rhoPhiSum << rhoPhiSum + (runTime.deltaT() / totalDeltaT) * rhoPhi
            pass
        # To make sure that variable in the local scope will be destroyed
        # - during destruction of this variable it performs some important actions
        # - there is a difference between C++ and Python memory management, namely
        # if C++ automatically destroys stack variables when they exit the scope,
        # Python relay its memory management of some "garbage collection" algorithm
        # that do not provide predictable behavior on the "exit of scope"
        del alphaSubCycle

        rhoPhi << rhoPhiSum
    else:
        alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr)
        pass
    interface.correct()

    rho == alpha1 * rho1 + (1.0 - alpha1) * rho2

    pass
Example #6
0
def readControls( mesh ):

    potentialFlow = mesh.solutionDict().subDict( ref.word( "potentialFlow" ) )

    nNonOrthCorr = potentialFlow.lookupOrDefault( ref.word( "nNonOrthogonalCorrectors" ), 0 )
  
    return potentialFlow, nNonOrthCorr
Example #7
0
def _createFields( runTime, mesh ):
        
    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField( man.IOobject( ref.word( "p" ),
                                          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 )
    
    fluid = man.singlePhaseTransportModel( U, phi )
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, mesh.solutionDict().subDict( ref.word( "PISO" ) ), pRefCell, pRefValue )

        
    return p, U, phi, fluid, pRefCell, pRefValue
    def updateCoeffs(self):
        try:
            if self.updated():
                return
            phip = ref.surfaceScalarField.ext_lookupPatchField(
                self.patch(), ref.word("phi"))

            phiap = ref.surfaceScalarField.ext_lookupPatchField(
                self.patch(), ref.word("phia"))

            Up = ref.volVectorField.ext_lookupPatchField(
                self.patch(), ref.word("U"))

            Uap = ref.volVectorField.ext_lookupPatchField(
                self.patch(), ref.word("Ua"))

            self == ((phiap / self.patch().magSf() - 1.0) * phip /
                     self.patch().magSf() + (Up & Uap))

            fixedValueFvPatchScalarField.updateCoeffs(self)

            pass
        except Exception, exc:
            import sys, traceback
            traceback.print_exc(file=sys.stdout)
            raise exc
Example #9
0
def _createFields(runTime, mesh, potentialFlow):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(
            ref.word("p"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE
        ),
        mesh,
    )

    p << ref.dimensionedScalar(ref.word("zero"), p.dimensions(), 0.0)

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

    U << ref.dimensionedVector(ref.word("0"), U.dimensions(), ref.vector.zero)

    phi = man.surfaceScalarField(
        man.IOobject(
            ref.word("phi"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE
        ),
        man.fvc.interpolate(U) & man.surfaceVectorField(mesh.Sf(), man.Deps(mesh)),
    )

    pRefCell = 0
    pRefValue = 0.0

    pRefCell, pRefValue = ref.setRefCell(p, potentialFlow, pRefCell, pRefValue)

    return p, U, phi, pRefCell, pRefValue
Example #10
0
def makeGraphs( runTime, mesh, U, turbulence, faceId, patchId, nWallFaces, wallNormal, cellId, flowDirection, y ):
    R = ref.volSymmTensorField( ref.IOobject( ref.word( "R" ),
                                              ref.fileName( runTime.timeName() ),
                                              mesh(),
                                              ref.IOobject.NO_READ,
                                              ref.IOobject.AUTO_WRITE ),
                                turbulence.R() )

    runTime.write()
    
    gFormat = runTime.graphFormat()
    
    ref.makeGraph( y, flowDirection & U(), ref.word( "Uf" ), gFormat )
    
    ref.makeGraph( y, turbulence.ext_nu(), gFormat )
    ref.makeGraph( y, turbulence.ext_k(), gFormat )
    ref.makeGraph( y, turbulence.ext_epsilon(), gFormat )

    ref.makeGraph( y, flowDirection & R & flowDirection, ref.word( "Rff" ), gFormat )
    ref.makeGraph( y, wallNormal & R & wallNormal, ref.word( "Rww" ), gFormat )
    ref.makeGraph( y, flowDirection & R & wallNormal, ref.word( "Rfw" ), gFormat )

    ref.makeGraph( y, R.component( ref.symmTensor.XX ).mag().sqrt(), ref.word( "u" ), gFormat )
    ref.makeGraph( y, R.component( ref.symmTensor.YY ).mag().sqrt(), ref.word( "v" ), gFormat )
    ref.makeGraph( y, R.component( ref.symmTensor.ZZ ).mag().sqrt(), ref.word( "w" ), gFormat )
    ref.makeGraph( y, R.component( ref.symmTensor.XY ), ref.word( "uv" ), gFormat )

    ref.makeGraph( y, ref.fvc.grad( U ).mag(), ref.word( "gammaDot" ), gFormat )
    
    pass
Example #11
0
def solveFluid( i, mesh, thermo, rad, thermoFluid, rho, K, U, phi, h, turb, DpDt, p, psi, initialMass, p_rgh, gh, ghf,\
                oCorr, nCorr, nOuterCorr, nNonOrthCorr, momentumPredictor,cumulativeContErr, finalIter ) :
    if finalIter:
        mesh.add(ref.word("finalIteration"), True)
        pass

    if oCorr == 0:
        ref.rhoEqn(rho, phi)
        pass

    UEqn = fun_UEqn(rho, U, phi, ghf, p_rgh, turb, mesh, momentumPredictor,
                    finalIter)
    fun_hEqn(rho, h, phi, turb, DpDt, thermo, rad, mesh, oCorr, nOuterCorr,
             finalIter)

    # --- PISO loop
    for corr in range(nCorr):
        cumulativeContErr = fun_pEqn(i, mesh, p, rho, turb, thermo,
                                     thermoFluid, K, UEqn, U, phi, psi, DpDt,
                                     initialMass, p_rgh, gh, ghf, nNonOrthCorr,
                                     oCorr, nOuterCorr, corr, nCorr,
                                     cumulativeContErr)
        pass

    turb.correct()
    rho << thermo.rho()

    if finalIter:
        mesh.remove(ref.word("finalIteration"))
        pass

    return cumulativeContErr
Example #12
0
def readGravitationalAcceleration(runTime, mesh):
    ref.ext_Info() << "\nReading gravitationalProperties" << ref.nl

    gravitationalProperties = man.IOdictionary(
        man.IOobject(
            ref.word("gravitationalProperties"),
            ref.fileName(runTime.constant()),
            mesh,
            ref.IOobject.MUST_READ_IF_MODIFIED,
            ref.IOobject.NO_WRITE,
        )
    )

    g = ref.dimensionedVector(gravitationalProperties.lookup(ref.word("g")))
    rotating = ref.Switch(gravitationalProperties.lookup(ref.word("rotating")))

    if rotating:
        Omega = ref.dimensionedVector(gravitationalProperties.lookup(ref.word("Omega")))
    else:
        Omega = ref.dimensionedVector(ref.word("Omega"), -ref.dimTime, ref.vector(0, 0, 0))

    magg = g.mag()
    gHat = g / magg

    return gravitationalProperties, g, rotating, Omega, magg, gHat
Example #13
0
def createFields( runTime, mesh ):
    ref.ext_Info() << "Reading transportProperties\n"

    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                          mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE ) )

    nu = ref.dimensionedScalar( transportProperties.lookup( ref.word( "nu" ) ) ) 

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField( man.IOobject( ref.word( "p" ),
                                          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 )

    pRefCell = 0
    pRefValue = 0.0
   
    pRefCell, pRefValue = ref.setRefCell( p, mesh.solutionDict().subDict( ref.word( "PISO" ) ), pRefCell, pRefValue )

    return transportProperties, nu, p, U, phi, pRefCell, pRefValue
Example #14
0
def _createFields(runTime, mesh):
    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 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)

    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    transportProperties = man.IOdictionary(
        man.IOobject(ref.word("transportProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))

    ref.ext_Info() << "Reading diffusivity D\n" << ref.nl

    DT = ref.dimensionedScalar(transportProperties.lookup(ref.word("DT")))

    phi = man.createPhi(runTime, mesh, U)

    return T, U, transportProperties, DT, phi
Example #15
0
def _createFields(runTime, mesh):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(
            ref.word("p"), 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)

    pRefCell = 0
    pRefValue = 0.0

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

    laminarTransport = man.singlePhaseTransportModel(U, phi)

    turbulence = man.incompressible.turbulenceModel.New(U, phi, laminarTransport)

    return p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport
Example #16
0
def alphaEqnSubCycle(runTime, pimple, mesh, phi, alpha1, rho, rhoPhi, rho1,
                     rho2, interface):

    nAlphaCorr = ref.readLabel(pimple.dict().lookup(ref.word("nAlphaCorr")))
    nAlphaSubCycles = ref.readLabel(pimple.dict().lookup(
        ref.word("nAlphaSubCycles")))
    if (nAlphaSubCycles > 1):
        totalDeltaT = runTime.deltaT()
        rhoPhiSum = 0.0 * rhoPhi

        alphaSubCycle = ref.subCycle_volScalarField(alpha1, nAlphaSubCycles)
        for item in alphaSubCycle:
            alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface,
                     nAlphaCorr)
            rhoPhiSum += (runTime.deltaT() / totalDeltaT) * rhoPhi
            pass
        # To make sure that variable in the local scope will be destroyed
        # - during destruction of this variable it performs some important actions
        # - there is a difference between C++ and Python memory management, namely
        # if C++ automatically destroys stack variables when they exit the scope,
        # Python relay its memory management of some "garbage collection" algorithm
        # that do not provide predictable behavior on the "exit of scope"
        del alphaSubCycle

        rhoPhi << rhoPhiSum
    else:
        alphaEqn(mesh, phi, alpha1, rhoPhi, rho1, rho2, interface, nAlphaCorr)
        pass
    interface.correct()

    rho == alpha1 * rho1 + (1.0 - alpha1) * rho2

    pass
Example #17
0
def _createFields(runTime, mesh):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(ref.word("p"), 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)

    pRefCell = 0
    pRefValue = 0.0

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

    laminarTransport = man.singlePhaseTransportModel(U, phi)

    turbulence = man.incompressible.turbulenceModel.New(
        U, phi, laminarTransport)

    ref.ext_Info() << "Reading field rAU if present\n" << ref.nl
    rAU = man.volScalarField(
        man.IOobject(ref.word("rAU"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT, ref.IOobject.AUTO_WRITE),
        mesh, runTime.deltaT(), ref.zeroGradientFvPatchScalarField.typeName)

    sources = man.IObasicSourceList(mesh)

    return p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue, sources
Example #18
0
def _createFields( runTime, mesh ):
    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 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 )


    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                          mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE ) )


    ref.ext_Info() << "Reading diffusivity D\n" << ref.nl

    DT = ref.dimensionedScalar( transportProperties.lookup( ref.word( "DT" ) ) )

    phi = man.createPhi( runTime, mesh, U )
           
    return T, U, transportProperties, DT, phi 
Example #19
0
def createFields(runTime, mesh):

    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl

    pThermo = man.basicPsiThermo.New(mesh)

    p = man.volScalarField(pThermo.p(), man.Deps(pThermo))
    e = man.volScalarField(pThermo.e(), man.Deps(pThermo))
    psi = man.volScalarField(pThermo.psi(), man.Deps(pThermo))

    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh),
        man.volScalarField(pThermo.rho(), man.Deps(pThermo)))

    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.compressibleCreatePhi(runTime, mesh, rho, U)

    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New(rho, U, phi, pThermo)

    return pThermo, p, e, psi, rho, U, phi, turbulence
Example #20
0
def _createFields(runTime, mesh):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(ref.word("p"), 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)

    pRefCell = 0
    pRefValue = 0.0

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

    laminarTransport = man.singlePhaseTransportModel(U, phi)

    turbulence = man.incompressible.turbulenceModel.New(
        U, phi, laminarTransport)

    return p, U, phi, turbulence, pRefCell, pRefValue, laminarTransport
Example #21
0
def write( runTime, mesh, T ):
    if runTime.outputTime():
        gradT = ref.fvc.grad(T)
       
        gradTx = ref.volScalarField( ref.IOobject( ref.word( "gradTx" ), 
                                                   ref.fileName( runTime.timeName() ),
                                                   mesh,
                                                   ref.IOobject.NO_READ,
                                                   ref.IOobject.AUTO_WRITE ),
                                     gradT.component( ref.vector.X ) )
      
        gradTy = ref.volScalarField( ref.IOobject( ref.word( "gradTy" ),
                                                   ref.fileName( runTime.timeName() ),
                                                   mesh,
                                                   ref.IOobject.NO_READ,
                                                   ref.IOobject.AUTO_WRITE ),
                                     gradT.component( ref.vector.Y ) )

        gradTz = ref.volScalarField( ref.IOobject( ref.word( "gradTz" ),
                                           ref.fileName( runTime.timeName() ),
                                           mesh,
                                           ref.IOobject.NO_READ,
                                           ref.IOobject.AUTO_WRITE ),
                                 gradT.component( ref.vector.Z ) )
        runTime.write()
        pass
Example #22
0
def fun_pEqn( mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, mrfZones, turbulence, UEqn, DpDt, cumulativeContErr, corr, rhoMax, rhoMin ):

    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()

    rAU = 1.0 / UEqn.A()
    U << rAU() * UEqn.H()

    if pimple.transonic():
        phid = ref.surfaceScalarField( ref.word( "phid" ), ref.fvc.interpolate( psi ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) \
                                                                                          + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) ) );
        mrfZones.relativeFlux( ref.fvc.interpolate( psi ), phid )
        
        for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
            pEqn = ref.fvm.ddt( psi, p) + ref.fvm.div( phid, p ) - ref.fvm.laplacian( rho() * rAU, p ) # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )

            if nonOrth == pimple.nNonOrthCorr():
                phi == pEqn.flux()
                pass
            pass
        pass
    else:
        phi << ref.fvc.interpolate( rho ) * ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) + ref.fvc.ddtPhiCorr( rAU, rho, U, phi ) )
        
        mrfZones.relativeFlux( ref.fvc.interpolate( rho ), phi )
        
        for nonOrth in range( pimple.nNonOrthCorr() + 1 ):
            pEqn = ref.fvm.ddt( psi, p ) + ref.fvc.div( phi ) - ref.fvm.laplacian( rho()*rAU, p )  # mixed calculations
            
            pEqn.solve( mesh.solver( p.select( pimple.finalInnerIter( corr, nonOrth ) ) ) )
            
            if nonOrth == pimple.nNonOrthCorr():
                phi += pEqn.flux()
                pass
            pass    
        pass

    ref.rhoEqn( rho, phi )
    cumulativeContErr = ref.compressibleContinuityErrs( rho(), thermo, cumulativeContErr ) # mixed calculations
    # Explicitly relax pressure for momentum corrector
    p.relax()
    
    # Recalculate density from the relaxed pressure
    rho << thermo.rho()
    rho << rho().ext_max( rhoMin )
    rho << rho().ext_min( rhoMax )
    rho.relax()
    ref.ext_Info()<< "rho max/min : " << rho.ext_max().value()  << " " << rho.ext_min().value() << ref.nl

    U -= rAU * ref.fvc.grad( p )
    U.correctBoundaryConditions()

    DpDt << ref.fvc.DDt( ref.surfaceScalarField( ref.word( "phiU" ), phi() / ref.fvc.interpolate( rho ) ), p ) # mixed calculations
    
    return cumulativeContErr
Example #23
0
def fun_pEqn(mesh, runTime, pimple, thermo, rho, p, h, psi, U, phi, turbulence,
             gh, ghf, p_rgh, UEqn, DpDt, cumulativeContErr, corr):
    rho << thermo.rho()

    # Thermodynamic density needs to be updated by psi*d(p) after the
    # pressure solution - done in 2 parts. Part 1:
    thermo.rho() << thermo.rho() - psi() * p_rgh()  # mixed calculations

    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()) +
                                       ref.fvc.ddtPhiCorr(rAU, rho, U, phi))

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

    phi += buoyancyPhi

    p_rghDDtEqn = ref.fvc.ddt(rho) + psi * ref.correction(
        ref.fvm.ddt(p_rgh)) + ref.fvc.div(phi)

    for nonOrth in range(pimple.nNonOrthCorr() + 1):
        p_rghEqn = p_rghDDtEqn - ref.fvm.laplacian(rhorAUf, p_rgh)

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

        if nonOrth == pimple.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

    # Second part of thermodynamic density update
    thermo.rho() << thermo.rho() + psi() * p_rgh  # mixed calculations

    DpDt << ref.fvc.DDt(
        ref.surfaceScalarField(ref.word("phiU"),
                               phi() / ref.fvc.interpolate(rho)),
        p)  # mixed calculations

    ref.rhoEqn(rho, phi)
    cumulativeContErr = ref.compressibleContinuityErrs(
        rho(), thermo, cumulativeContErr)  #mixed calculations

    return cumulativeContErr
def readTimeControls_020000( runTime ):
    adjustTimeStep = runTime.controlDict().lookupOrDefault( ref.word( "adjustTimeStep" ), ref.Switch( False ) )

    maxCo = runTime.controlDict().lookupOrDefault( ref.word( "maxCo" ), 1.0 )

    maxDeltaT = runTime.controlDict().lookupOrDefault( ref.word( "maxDeltaT" ), ref.GREAT )

    return adjustTimeStep, maxCo, maxDeltaT
Example #25
0
def readControls(mesh):

    potentialFlow = mesh.solutionDict().subDict(ref.word("potentialFlow"))

    nNonOrthCorr = potentialFlow.lookupOrDefault(
        ref.word("nNonOrthogonalCorrectors"), 0)

    return potentialFlow, nNonOrthCorr
Example #26
0
def readPIMPLEControls( runTime ):

    solutionDict = ref.fvSolution( runTime )
    
    pimple = solutionDict.subDict( ref.word( "PIMPLE" ) )
    nOuterCorr = pimple.lookupOrDefault( ref.word( "nOuterCorrectors" ), 1);
    
    return nOuterCorr
Example #27
0
def readFluidMultiRegionPIMPLEControls( mesh ) :
    
    pimple = mesh.solutionDict().subDict( ref.word( "PIMPLE" ) )
    nCorr = pimple.lookupOrDefault( ref.word( "nCorrectors" ), 1);
    nNonOrthCorr = pimple.lookupOrDefault( ref.word( "nNonOrthogonalCorrectors" ), 0 )
    momentumPredictor =pimple.lookupOrDefault( ref.word( "momentumPredictor" ), ref.Switch( True ) )
    
    return pimple, nCorr, nNonOrthCorr, momentumPredictor
Example #28
0
def readPIMPLEControls(runTime):

    solutionDict = ref.fvSolution(runTime)

    pimple = solutionDict.subDict(ref.word("PIMPLE"))
    nOuterCorr = pimple.lookupOrDefault(ref.word("nOuterCorrectors"), 1)

    return nOuterCorr
def readFluidMultiRegionSIMPLEControls( mesh ) :
    
    simple = mesh.solutionDict().subDict( ref.word( "SIMPLE" ) )
    nNonOrthCorr = simple.lookupOrDefault( ref.word( "nNonOrthogonalCorrectors" ), 0 )
    momentumPredictor = simple.lookupOrDefault( ref.word( "momentumPredictor" ), ref.Switch( True ) )
    transonic = simple.lookupOrDefault( ref.word( "transonic" ), ref.Switch( False ) )
    
    return simple, nNonOrthCorr, momentumPredictor, transonic
Example #30
0
def readControls(runTime, mesh, pimple):

    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

    correctPhi = pimple.dict().lookupOrDefault(ref.word("correctPhi"), ref.Switch(True))
    checkMeshCourantNo = pimple.dict().lookupOrDefault(ref.word("checkMeshCourantNo"), ref.Switch(False))

    return adjustTimeStep, maxCo, maxDeltaT, correctPhi, checkMeshCourantNo
Example #31
0
def readFluidMultiRegionPIMPLEControls( mesh ) :
    
    pimple = mesh.solutionDict().subDict( ref.word( "PIMPLE" ) )
    nCorr = pimple.lookupOrDefault( ref.word( "nCorrectors" ), 1);
    nNonOrthCorr = pimple.lookupOrDefault( ref.word( "nNonOrthogonalCorrectors" ), 0 )
    momentumPredictor =pimple.lookupOrDefault( ref.word( "momentumPredictor" ), ref.Switch( True ) )
    
    return pimple, nCorr, nNonOrthCorr, momentumPredictor
Example #32
0
def main_standalone( argc, argv ):

    ref.argList.addBoolOption( ref.word( "writep" ), "write the final pressure field" )
    ref.argList.addBoolOption( ref.word( "initialiseUBCs" ), "initialise U boundary conditions" )
    
    args = ref.setRootCase( argc, argv )

    runTime = man.createTime( args )
    
    mesh = man.createMesh( runTime )
    
    potentialFlow, nNonOrthCorr = readControls( mesh )

    p, U, phi, pRefCell, pRefValue = _createFields( runTime, mesh, potentialFlow,args )

    ref.ext_Info() << ref.nl << "Calculating potential flow" << ref.nl
    
    # Since solver contains no time loop it would never execute
    # function objects so do it ourselves.
    runTime.functionObjects().start()
    
    ref.adjustPhi(phi, U, p)
    
    for nonOrth in range( nNonOrthCorr + 1):
        pEqn = ( ref.fvm.laplacian( ref.dimensionedScalar( ref.word( "1" ), ref.dimTime / p.dimensions() * ref.dimensionSet( 0.0, 2.0, -2.0, 0.0, 0.0 ), 1.0 ), p ) 
                == ref.fvc.div( phi ) )
        
        pEqn.setReference( pRefCell, pRefValue )
        pEqn.solve()

        if nonOrth == nNonOrthCorr:
           phi -= pEqn.flux()
           pass
        pass
    
    ref.ext_Info() << "continuity error = " << ref.fvc.div( phi ).mag().weightedAverage( mesh.V() ).value() << ref.nl

    U << ref.fvc.reconstruct( phi )
    U.correctBoundaryConditions()
    ref.ext_Info() << "Interpolated U error = " << ( ( ( ref.fvc.interpolate( U ) & mesh.Sf() ) - phi ).sqr().sum().sqrt()  /mesh.magSf().sum() ).value() << ref.nl

    # Force the write
    U.write()
    phi.write()
    
    if args.optionFound( ref.word( "writep" ) ):
       p.write()
       pass
       
    runTime.functionObjects().end()
    
    ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \
              "  ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl
        
    ref.ext_Info() << "End\n" << ref.nl 

    import os
    return os.EX_OK
def createITstream(pyList):
    size = len(pyList)
    ret = ref.tokenList(size)
    for i in xrange(size):
        ret[i] = ref.token(ref.word(pyList[i]))
        pass
    
    stream = ref.ITstream( ref.word( "dummy"), ret )
    return stream
def createFvMesh(runTime):
    # Read temporary mesh from file - done only so we can get the list of points, faces and cells
    tmpMesh = man.fvMesh( man.IOobject( ref.word("tmp"),
                                        runTime.caseConstant(),
                                        runTime,
                                        ref.IOobject.NO_READ,
                                        ref.IOobject.NO_WRITE ) )
    
    # Get points, faces & Cells - SFOAM implementation should populate these lists from Salome mesh
    points = tmpMesh.points()
    faces = tmpMesh.faces()
    cells = tmpMesh.cells()
    
    #  Now create the mesh - Nothing read from file, although fvSchemes and fvSolution created above must be present
    #  It is necessary to store tmpMesh, because fvMesh::points(), faces(), and cells() return const T&
    #  and fvMesh in next line will be broken, after exiting from this function (tmpMesh are deleted) 
    mesh = man.fvMesh( ref.fvMesh( ref.IOobject( ref.word("region0"),
                                                 runTime.caseConstant(),
                                                 runTime,
                                                 ref.IOobject.MUST_READ,
                                                 ref.IOobject.AUTO_WRITE),
                                   points, faces, cells ),
                       man.Deps( tmpMesh ) )             
    
    # Create boundary patches
    patches = ref.polyPatchListPtr( 4, ref.polyPatch.nullPtr() )
    patches.set(0, ref.polyPatch.New( ref.word("patch"),
                                      ref.word("inlet_F"),
                                      606,
                                      102308,
                                      0,
                                      mesh.boundaryMesh() ) )
    
    patches.set(1, ref.polyPatch.New( ref.word("patch"),
                                      ref.word("outlet_F1"),
                                      818,
                                      102914,
                                      1,
                                      mesh.boundaryMesh() ) )
    
    patches.set(2, ref.polyPatch.New( ref.word("patch"),
                                      ref.word("outlet_F2"),
                                      522,
                                      103732,
                                      2,
                                      mesh.boundaryMesh() ) )
    
    patches.set(3, ref.polyPatch.New( ref.word("wall"), 
                                      ref.word("pipe"),
                                      5842,
                                      104254,
                                      3,
                                      mesh.boundaryMesh() ) )
    
    mesh.addFvPatches(patches)
    
    return mesh, patches
def readTimeControls_020000(runTime):
    adjustTimeStep = runTime.controlDict().lookupOrDefault(
        ref.word("adjustTimeStep"), ref.Switch(False))

    maxCo = runTime.controlDict().lookupOrDefault(ref.word("maxCo"), 1.0)

    maxDeltaT = runTime.controlDict().lookupOrDefault(ref.word("maxDeltaT"),
                                                      ref.GREAT)

    return adjustTimeStep, maxCo, maxDeltaT
Example #36
0
def setInitialrDeltaT(runTime, mesh, pimple):
    maxDeltaT = pimple.dict().lookupOrDefault(ref.word("maxDeltaT"), ref.GREAT)
    rDeltaT = man.volScalarField(
        man.IOobject(ref.word("rDeltaT"), ref.fileName(runTime.timeName()),
                     mesh, ref.IOobject.NO_READ,
                     ref.IOobject.AUTO_WRITE), mesh, 1.0 /
        ref.dimensionedScalar(ref.word("maxDeltaT"), ref.dimTime, maxDeltaT),
        ref.zeroGradientFvPatchScalarField.typeName)

    return maxDeltaT, rDeltaT
def setInitialrDeltaT ( runTime, mesh, pimple ):
    maxDeltaT = pimple.dict().lookupOrDefault( ref.word( "maxDeltaT" ), ref.GREAT ); 
    rDeltaT = man.volScalarField( man.IOobject( ref.word( "rDeltaT" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh,
                                                ref.IOobject.NO_READ,
                                                ref.IOobject.AUTO_WRITE ),
                                  mesh,
                                  1.0 / ref.dimensionedScalar( ref.word( "maxDeltaT" ), ref.dimTime, maxDeltaT ),
                                  ref.zeroGradientFvPatchScalarField.typeName )
    
    return maxDeltaT, rDeltaT
Example #38
0
def readTransportProperties( runTime, mesh ):
    
    ref.ext_Info() << "Reading transportProperties\n" << ref.nl
    transportProperties = man.IOdictionary( man.IOobject( ref.word( "transportProperties" ),
                                                          ref.fileName( runTime.constant() ),
                                                           mesh,
                                                          ref.IOobject.MUST_READ_IF_MODIFIED,
                                                          ref.IOobject.NO_WRITE ) )

    nu = ref.dimensionedScalar( transportProperties.lookup( ref.word( "nu" ) ) )

    return transportProperties, nu
Example #39
0
def readTransportProperties(runTime, mesh):
    ref.ext_Info() << "Reading transportProperties\n" << ref.nl

    transportProperties = man.IOdictionary(
        man.IOobject(ref.word("transportProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))

    mu = ref.dimensionedScalar(transportProperties.lookup(ref.word("mu")))

    return transportProperties, mu
Example #40
0
def readControls(runTime, mesh, pimple):
    adjustTimeStep, maxCo, maxDeltaT = ref.readTimeControls(runTime)

    pimpleDict = pimple.dict()

    correctPhi = pimpleDict.lookupOrDefault(ref.word("correctPhi"),
                                            ref.Switch(False))

    checkMeshCourantNo = pimpleDict.lookupOrDefault(
        ref.word("checkMeshCourantNo"), ref.Switch(False))

    return adjustTimeStep, maxCo, maxDeltaT, pimpleDict, correctPhi, checkMeshCourantNo
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
Example #42
0
def _createFields(runTime, mesh, Omega, gHat):

    ref.ext_Info() << "Reading field h\n" << ref.nl
    h = man.volScalarField(
        man.IOobject(
            ref.word("h"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.MUST_READ, ref.IOobject.AUTO_WRITE
        ),
        mesh,
    )

    ref.ext_Info() << "Reading field h0 if present\n" << ref.nl
    h0 = man.volScalarField(
        man.IOobject(
            ref.word("h0"),
            ref.fileName(runTime.findInstance(ref.fileName(ref.word("polyMesh")), ref.word("points"))),
            mesh,
            ref.IOobject.READ_IF_PRESENT,
        ),
        mesh,
        ref.dimensionedScalar(ref.word("h0"), ref.dimLength, 0.0),
    )

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

    ref.ext_Info() << "Creating field hU\n" << ref.nl
    hU = man.volVectorField(
        man.IOobject(ref.word("hU"), ref.fileName(runTime.timeName()), mesh), h * U, U.ext_boundaryField().types()
    )

    ref.ext_Info() << "Creating field hTotal for post processing\n" << ref.nl
    hTotal = man.volScalarField(
        man.IOobject(
            ref.word("hTotal"),
            ref.fileName(runTime.timeName()),
            mesh,
            ref.IOobject.READ_IF_PRESENT,
            ref.IOobject.AUTO_WRITE,
        ),
        h + h0,
    )

    hTotal.write()

    phi = createPhi(runTime, hU, mesh)

    ref.ext_Info() << "Creating Coriolis Force" << ref.nl

    F = ref.dimensionedVector(ref.word("F"), ((2.0 * Omega) & gHat) * gHat)

    return h, h0, U, hU, hTotal, phi, F
Example #43
0
def _createFields( runTime, mesh ):
    
    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField( man.IOobject( ref.word( "p" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.MUST_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            mesh )
    
    ref.ext_Info() << "Reading field Urel\n" << ref.nl

    Urel = man.volVectorField( man.IOobject( ref.word( "Urel" ),
                                             ref.fileName( runTime.timeName() ),
                                             mesh,
                                             ref.IOobject.MUST_READ,
                                             ref.IOobject.AUTO_WRITE ),
                               mesh )
  
    ref.ext_Info() << "Reading/calculating face flux field phi\n" << ref.nl
    phi = man.surfaceScalarField( man.IOobject( ref.word( "phi" ),
                                                ref.fileName( runTime.timeName() ),
                                                mesh,
                                                ref.IOobject.READ_IF_PRESENT,
                                                ref.IOobject.AUTO_WRITE ), 
                                  man.surfaceScalarField( ref.linearInterpolate( Urel ) & mesh.Sf(), man.Deps( mesh, Urel ) ) )
    
    pRefCell = 0
    pRefValue = 0.0
    
    pRefCell, pRefValue = ref.setRefCell( p, mesh.solutionDict().subDict( ref.word( "PIMPLE" ) ), pRefCell, pRefValue )
    
    laminarTransport = man.singlePhaseTransportModel( Urel, phi )
    
    turbulence = man.incompressible.turbulenceModel.New( Urel, phi, laminarTransport )
    
    ref.ext_Info() << "Creating SRF model\n" << ref.nl
    SRF = man.SRF.SRFModel.New( Urel ) 
    
    sources = man.IObasicSourceList( mesh )
    
    # Create the absolute velocity
    U = man.volVectorField( man.IOobject( ref.word( "U" ),
                                          ref.fileName( runTime.timeName() ),
                                          mesh,
                                          ref.IOobject.NO_READ,
                                          ref.IOobject.AUTO_WRITE ),
                            man.volVectorField( Urel() + SRF.U(), man.Deps( Urel, SRF ) ) ) # mixed  calculations

    return p, U, Urel, SRF, phi, turbulence, pRefCell, pRefValue, laminarTransport, sources
def _createControlDict() :
    """
    Creates controlDict dictionary
    """
    a_controlDict = ref.dictionary()
    a_controlDict.add( ref.word( "startFrom" ), ref.word( "startTime" ) )
    a_controlDict.add( ref.word( "startTime" ), 0.0 )
    a_controlDict.add( ref.word( "stopAt" ), ref.word( "endTime" ) )
    a_controlDict.add( ref.word( "endTime" ), 0.05 )
    a_controlDict.add( ref.word( "deltaT" ), 0.01 )
    a_controlDict.add( ref.word( "writeControl" ), ref.word( "timeStep" ) )
    a_controlDict.add( ref.word( "writeInterval" ), 5 )

    return a_controlDict
Example #45
0
def readThermophysicalProperties( runTime, mesh ):
    ref.ext_Info() << "Reading thermophysicalProperties\n" << ref.nl
    
    # Pr defined as a separate constant to enable calculation of k, currently
    # inaccessible through thermo
    thermophysicalProperties = man.IOdictionary( man.IOobject( ref.word( "thermophysicalProperties" ),
                                                               ref.fileName( runTime.constant() ),
                                                               mesh,
                                                               ref.IOobject.MUST_READ,
                                                               ref.IOobject.NO_WRITE ) )
    
    Pr = ref.dimensionedScalar.lookupOrDefault( ref.word( "Pr" ), thermophysicalProperties(), 1.0 )
    
    return thermophysicalProperties, Pr
Example #46
0
def readThermophysicalProperties(runTime, mesh):
    ref.ext_Info() << "Reading thermophysicalProperties\n" << ref.nl

    # Pr defined as a separate constant to enable calculation of k, currently
    # inaccessible through thermo
    thermophysicalProperties = man.IOdictionary(
        man.IOobject(ref.word("thermophysicalProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE))

    Pr = ref.dimensionedScalar.lookupOrDefault(ref.word("Pr"),
                                               thermophysicalProperties(), 1.0)

    return thermophysicalProperties, Pr
Example #47
0
def _createFields(runTime, mesh):
    # Load boundary condition
    from BCs import rho

    ref.ext_Info() << "Reading thermophysical properties\n" << ref.nl
    thermo = man.basicPsiThermo.New(mesh)

    p = man.volScalarField(thermo.p(), man.Deps(thermo))
    e = man.volScalarField(thermo.e(), man.Deps(thermo))
    T = man.volScalarField(thermo.T(), man.Deps(thermo))
    psi = man.volScalarField(thermo.psi(), man.Deps(thermo))
    mu = man.volScalarField(thermo.mu(), man.Deps(thermo))

    inviscid = True
    if mu.internalField().max() > 0.0:
        inviscid = False
        pass

    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)

    pbf, rhoBoundaryTypes = _rhoBoundaryTypes(p)

    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE),
        man.volScalarField(thermo.rho(), man.Deps(thermo)), rhoBoundaryTypes)
    rhoU = man.volVectorField(
        man.IOobject(ref.word("rhoU"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE), rho * U)
    rhoE = man.volScalarField(
        man.IOobject(ref.word("rhoE"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.NO_READ, ref.IOobject.NO_WRITE),
        rho * (e + man.volScalarField(0.5 * U.magSqr(), man.Deps(U))))

    pos = man.surfaceScalarField(
        man.IOobject(ref.word("pos"), ref.fileName(runTime.timeName()), mesh),
        mesh, ref.dimensionedScalar(ref.word("pos"), ref.dimless, 1.0))

    neg = man.surfaceScalarField(
        man.IOobject(ref.word("neg"), ref.fileName(runTime.timeName()), mesh),
        mesh, ref.dimensionedScalar(ref.word("neg"), ref.dimless, -1.0))

    phi = man.surfaceScalarField(
        ref.word("phi"),
        man.surfaceVectorField(mesh.Sf(), man.Deps(mesh))
        & man.fvc.interpolate(rhoU))

    ref.ext_Info() << "Creating turbulence model\n" << ref.nl
    turbulence = man.compressible.turbulenceModel.New(rho, U, phi, thermo)

    return thermo, p, e, T, psi, mu, U, pbf, rhoBoundaryTypes, rho, rhoU, rhoE, pos, neg, inviscid, phi, turbulence
Example #48
0
def _createFields(runTime, mesh):

    ref.ext_Info() << "Reading field p\n" << ref.nl
    p = man.volScalarField(
        man.IOobject(ref.word("p"), 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)

    return p, U, phi
Example #49
0
def readTurbulenceProperties( runTime, mesh, U ):
    
    ref.ext_Info() << "Reading turbulenceProperties\n" << ref.nl
    turbulenceProperties = man.IOdictionary( man.IOobject( ref.word( "turbulenceProperties" ),
                                                           ref.fileName( runTime.constant() ),
                                                           mesh,
                                                           ref.IOobject.MUST_READ_IF_MODIFIED,
                                                           ref.IOobject.NO_WRITE ) )

    force = U / ref.dimensionedScalar( ref.word( "dt" ), ref.dimTime, runTime.deltaTValue() )

    K = man.Kmesh( mesh )
    forceGen = man.UOprocess( K, runTime.deltaTValue(), turbulenceProperties )
    
    return turbulenceProperties, force, K, forceGen
def alphaEqns(runTime, mesh, rho1, rho2, rhoPhi, phic, dgdt, divU, alpha1,
              alpha2, phi, interface, nAlphaCorr):

    alphaScheme = ref.word("div(phi,alpha)")
    alpharScheme = ref.word("div(phirb,alpha)")

    phir = phic * interface.nHatf()

    for gCorr in range(nAlphaCorr):
        Sp = ref.volScalarField.DimensionedInternalField(
            ref.IOobject(ref.word("Sp"), ref.fileName(runTime.timeName()),
                         mesh), mesh,
            ref.dimensionedScalar(ref.word("Sp"), dgdt.dimensions(), 0.0))

        Su = ref.volScalarField.DimensionedInternalField(
            ref.IOobject(ref.word("Su"), ref.fileName(runTime.timeName()),
                         mesh),
            # Divergence term is handled explicitly to be
            # consistent with the explicit transport solution
            divU * alpha1.ext_min(1.0))
        for celli in range(dgdt.size()):
            if dgdt[celli] > 0.0 and alpha1[celli] > 0.0:
                Sp[celli] -= dgdt[celli] * alpha1[celli]
                Su[celli] += dgdt[celli] * alpha1[celli]
                pass
            elif dgdt[celli] < 0.0 and alpha1[celli] < 1.0:
                Sp[celli] += dgdt[celli] * (1.0 - alpha1[celli])
                pass
            pass

        phiAlpha1 = ref.fvc.flux(phi, alpha1, alphaScheme) + ref.fvc.flux(
            -ref.fvc.flux(-phir, alpha2, alpharScheme), alpha1, alpharScheme)

        ref.MULES.explicitSolve(ref.geometricOneField(), alpha1, phi,
                                phiAlpha1, Sp, Su, 1.0, 0.0)

        rho1f = ref.fvc.interpolate(rho1)
        rho2f = ref.fvc.interpolate(rho2)
        rhoPhi << phiAlpha1 * (rho1f - rho2f) + phi * rho2f

        alpha2 << 1.0 - alpha1

        pass

    from Foam.OpenFOAM import ext_Info, nl
    ext_Info() << "Liquid phase volume fraction = " << alpha1.weightedAverage( mesh.V() ).value() \
               << "  Min(alpha1) = " << alpha1.ext_min().value() << "  Min(alpha2) = " << alpha2.ext_min().value() << nl
    pass
def readGravitationalAcceleration(runTime, mesh):
    ref.ext_Info() << "\nReading g" << ref.nl

    g = ref.uniformDimensionedVectorField(
        ref.IOobject(ref.word("g"), ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ, ref.IOobject.NO_WRITE))
    return g
Example #52
0
def readTurbulenceProperties(runTime, mesh, U):

    ref.ext_Info() << "Reading turbulenceProperties\n" << ref.nl
    turbulenceProperties = man.IOdictionary(
        man.IOobject(ref.word("turbulenceProperties"),
                     ref.fileName(runTime.constant()), mesh,
                     ref.IOobject.MUST_READ_IF_MODIFIED,
                     ref.IOobject.NO_WRITE))

    force = U / ref.dimensionedScalar(ref.word("dt"), ref.dimTime,
                                      runTime.deltaTValue())

    K = man.Kmesh(mesh)
    forceGen = man.UOprocess(K, runTime.deltaTValue(), turbulenceProperties)

    return turbulenceProperties, force, K, forceGen
Example #53
0
def fun_pEqn(mesh, runTime, thermo, rho, p, psi, U, phi, turbulence, UEqn,
             cumulativeContErr, nNonOrthCorr):

    rho << thermo.rho()

    rAU = 1.0 / UEqn.A()

    U << rAU * UEqn.H()

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

    for nonOrth in range(nNonOrthCorr + 1):
        pEqn = ref.fvm.ddt(psi, p) + ref.fvm.div(phid, p) - ref.fvm.laplacian(
            rho * rAU, p)

        pEqn.solve()
        pass

    if nonOrth == nNonOrthCorr:
        phi << pEqn.flux()
        pass

    ref.rhoEqn(rho, phi)

    cumulativeContErr = ref.compressibleContinuityErrs(
        rho(), thermo, cumulativeContErr
    )  #it is necessary to force "mixed calculations" implementation

    U -= rAU * ref.fvc.grad(p)
    U.correctBoundaryConditions()

    return cumulativeContErr
Example #54
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 _init__fvPatch__DimensionedField_vector_volMesh__dictionary(
            self, *args):
        if len(args) != 3:
            raise AssertionError("len( args ) != 3")
        argc = 0

        try:
            ref.fvPatch.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError("args[ argc ].__class__ != fvPatch")
        p = args[argc]
        argc += 1

        try:
            ref.DimensionedField_vector_volMesh.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError(
                "args[ argc ].__class__ != DimensionedField_vector_volMesh")
        iF = args[argc]
        argc += 1

        try:
            ref.dictionary.ext_isinstance(args[argc])
        except TypeError:
            raise AssertionError("args[ argc ].__class__ != dictionary")
        dict_ = args[argc]
        argc += 1

        fixedValueFvPatchVectorField.__init__(self, p, iF)

        ref.fvPatchVectorField.__lshift__(
            self, ref.vectorField(ref.word("value"), dict_, p.size()))

        return self
Example #56
0
def setRegionFluidFields( i, fluidRegions, thermoFluid, rhoFluid, KFluid, UFluid, \
                          phiFluid, turbulence, DpDtFluid, initialMassFluid, ghFluid, ghfFluid, p_rghFluid, radiation ):
    mesh = fluidRegions[i]

    thermo = thermoFluid[i]
    rho = rhoFluid[i]
    K = KFluid[i]
    U = UFluid[i]
    phi = phiFluid[i]

    turb = turbulence[i]
    DpDt = DpDtFluid[i]

    p = thermo.p()
    psi = thermo.psi()
    h = thermo.h()

    p_rgh = p_rghFluid[i]
    gh = ghFluid[i]
    ghf = ghfFluid[i]

    rad = radiation[i]

    initialMass = ref.dimensionedScalar(ref.word("massIni"), ref.dimMass,
                                        initialMassFluid[i])

    return mesh, thermo, rho, K, U, phi, turb, DpDt, p, psi, h, initialMass, p_rgh, gh, ghf, rad
Example #57
0
def fun_pEqn(mesh, runTime, simple, U, phi, turbulence, p, UEqn, pRefCell,
             pRefValue, cumulativeContErr):

    p.ext_boundaryField().updateCoeffs()

    rAU = 1.0 / UEqn().A()
    U << rAU * UEqn().H()

    phi << (ref.fvc.interpolate(U, ref.word("interpolate(HbyA)")) & mesh.Sf())

    ref.adjustPhi(phi, U, p)

    # Non-orthogonal pressure corrector loop
    while simple.correctNonOrthogonal():
        pEqn = ref.fvm.laplacian(rAU, p) == ref.fvc.div(phi)

        pEqn.setReference(pRefCell, pRefValue)

        pEqn.solve()

        if simple.finalNonOrthogonalIter():
            phi -= pEqn.flux()
            pass
        pass
    cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh,
                                           cumulativeContErr)

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

    # Momentum corrector
    U -= rAU * ref.fvc.grad(p)
    U.correctBoundaryConditions()

    return cumulativeContErr