Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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 
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 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)

    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
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 13
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,
    )
Ejemplo n.º 14
0
# Create velocity field
UPatchTypes = pyWordList(['fixedValue', 'zeroGradient', 'zeroGradient', 'fixedValue'])

U = man.volVectorField ( man.IOobject( ref.word("U"),
                                       ref.fileName(runTime.timeName()),
                                       mesh,
                                       ref.IOobject.NO_READ,
                                       ref.IOobject.AUTO_WRITE),
                         mesh,
                         ref.dimensionedVector( ref.word(), ref.dimensionSet( 0.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0 ), ref.vector( 0.0, 0.0, 0.0 ) ),
                         UPatchTypes )

U.ext_boundaryField()[0] << ref.vector( 0.0, 0.1, 0.0 )
U.ext_boundaryField()[3] << ref.vector( 0.0, 0.0, 0.0 )

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

# Write all dictionaries to file
runTime.writeNow()

from icoFlux.embedded import solver as icoFoam
icoSolver = icoFoam(runTime, U, p, phi, transportProperties)

pRes = [] #initial pressure residual
uRes = [] #initial velocity residual
it   = []
iteration = []
iteration.append(0)


# Main iterate function
def createFields(runTime, mesh):
    # Load boundary conditions
    import adjointOutletPressure
    import adjointOutletVelocity

    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
    ref.setRefCell(p, mesh.solutionDict().subDict(ref.word("SIMPLE")), pRefCell, pRefValue)

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

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

    phia = createPhia(runTime, mesh, Ua)

    paRefCell = 0
    paRefValue = 0.0
    ref.setRefCell(pa, mesh.solutionDict().subDict(ref.word("SIMPLE")), paRefCell, paRefValue)

    laminarTransport = man.singlePhaseTransportModel(U, phi)

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

    zeroSensitivity = ref.dimensionedScalar(ref.word("0"), ref.dimVelocity * ref.dimVelocity, 0.0)
    zeroAlpha = ref.dimensionedScalar(ref.word("0"), ref.dimless / ref.dimTime, 0.0)

    lambda_ = ref.dimensionedScalar(laminarTransport.lookup(ref.word("lambda")))
    alphaMax = ref.dimensionedScalar(laminarTransport.lookup(ref.word("alphaMax")))

    inletCells = mesh.boundary()[ref.word("inlet")].faceCells()
    # outletCells = mesh.boundary()[ ref.word( "outlet" ) ].faceCells()

    alpha = man.volScalarField(
        man.IOobject(
            ref.word("alpha"),
            ref.fileName(runTime.timeName()),
            mesh,
            ref.IOobject.READ_IF_PRESENT,
            ref.IOobject.AUTO_WRITE,
        ),
        lambda_ * (Ua & U).ext_max(zeroSensitivity),
    )

    zeroCells(alpha, inletCells)
    # zeroCells( alpha, outletCells )

    return (
        p,
        U,
        phi,
        pa,
        Ua,
        phia,
        alpha,
        laminarTransport,
        turbulence,
        zeroSensitivity,
        zeroAlpha,
        lambda_,
        alphaMax,
        inletCells,
        pRefCell,
        pRefValue,
        paRefCell,
        paRefValue,
    )
Ejemplo n.º 16
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() << "Calculating field alpha1\n" << ref.nl
    alpha2 = man.volScalarField( ref.word( "alpha2" ), 1.0 - alpha1 )

    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)
    
    rho10 = ref.dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase1Name() ).lookup( ref.word( "rho0" ) ) )
    rho20 = ref.dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase2Name() ).lookup( ref.word( "rho0" ) ) )
   
    psi1 = ref.dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase1Name() ).lookup( ref.word( "psi" ) ) )
    psi2 = ref.dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase2Name() ).lookup( ref.word( "psi" ) ) )

    pMin = ref.dimensionedScalar( twoPhaseProperties.lookup( ref.word( "pMin" ) ) )
    
    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 + gh * ( alpha1 * rho10 + alpha2 * rho20 ) ) / ( 1.0 - gh * ( alpha1 * psi1 + alpha2 * psi2 ) ) ).ext_max( pMin ) ) #

    rho1 = rho10 + psi1 * p
    rho2 = rho20 + psi2 * p

    rho = man.volScalarField( man.IOobject( ref.word( "rho" ),
                                            ref.fileName( runTime.timeName() ),
                                            mesh,
                                            ref.IOobject.READ_IF_PRESENT,
                                            ref.IOobject.AUTO_WRITE ),
                              alpha1 * rho1 + alpha2 * rho2 )

    # 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 ),
                                     man.fvc.interpolate( rho ) * phi )

    dgdt = alpha2.pos() * man.fvc.div( phi ) / alpha2.ext_max( 0.0001 )

    # Construct interface from alpha1 distribution
    interface = man.interfaceProperties( alpha1, U, twoPhaseProperties )

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

    return p_rgh, alpha1, alpha2, U, phi, twoPhaseProperties, rho10, rho20, psi1, psi2, pMin, \
           gh, ghf, p, rho1, rho2, rho, rhoPhi, dgdt, interface, turbulence
Ejemplo n.º 17
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() << "Calculating field alpha1\n" << ref.nl
    alpha2 = man.volScalarField(ref.word("alpha2"), 1.0 - alpha1)

    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)

    rho10 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase1Name()).lookup(
            ref.word("rho0")))
    rho20 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase2Name()).lookup(
            ref.word("rho0")))

    psi1 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase1Name()).lookup(
            ref.word("psi")))
    psi2 = ref.dimensionedScalar(
        twoPhaseProperties.subDict(twoPhaseProperties.phase2Name()).lookup(
            ref.word("psi")))

    pMin = ref.dimensionedScalar(twoPhaseProperties.lookup(ref.word("pMin")))

    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 + gh * (alpha1 * rho10 + alpha2 * rho20)) /
         (1.0 - gh * (alpha1 * psi1 + alpha2 * psi2))).ext_max(pMin))  #

    rho1 = rho10 + psi1 * p
    rho2 = rho20 + psi2 * p

    rho = man.volScalarField(
        man.IOobject(ref.word("rho"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT, ref.IOobject.AUTO_WRITE),
        alpha1 * rho1 + alpha2 * rho2)

    # 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),
        man.fvc.interpolate(rho) * phi)

    dgdt = alpha2.pos() * man.fvc.div(phi) / alpha2.ext_max(0.0001)

    # Construct interface from alpha1 distribution
    interface = man.interfaceProperties(alpha1, U, twoPhaseProperties)

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

    return p_rgh, alpha1, alpha2, U, phi, twoPhaseProperties, rho10, rho20, psi1, psi2, pMin, \
           gh, ghf, p, rho1, rho2, rho, rhoPhi, dgdt, interface, turbulence
Ejemplo n.º 18
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
def createFields(runTime, mesh):
    # Load boundary conditions
    import adjointOutletPressure
    import adjointOutletVelocity

    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
    ref.setRefCell(p,
                   mesh.solutionDict().subDict(ref.word("SIMPLE")), pRefCell,
                   pRefValue)

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

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

    phia = createPhia(runTime, mesh, Ua)

    paRefCell = 0
    paRefValue = 0.0
    ref.setRefCell(pa,
                   mesh.solutionDict().subDict(ref.word("SIMPLE")), paRefCell,
                   paRefValue)

    laminarTransport = man.singlePhaseTransportModel(U, phi)

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

    zeroSensitivity = ref.dimensionedScalar(ref.word("0"),
                                            ref.dimVelocity * ref.dimVelocity,
                                            0.0)
    zeroAlpha = ref.dimensionedScalar(ref.word("0"), ref.dimless / ref.dimTime,
                                      0.0)

    lambda_ = ref.dimensionedScalar(laminarTransport.lookup(
        ref.word("lambda")))
    alphaMax = ref.dimensionedScalar(
        laminarTransport.lookup(ref.word("alphaMax")))

    inletCells = mesh.boundary()[ref.word("inlet")].faceCells()
    # outletCells = mesh.boundary()[ ref.word( "outlet" ) ].faceCells()

    alpha = man.volScalarField(
        man.IOobject(ref.word("alpha"), ref.fileName(runTime.timeName()), mesh,
                     ref.IOobject.READ_IF_PRESENT, ref.IOobject.AUTO_WRITE),
        lambda_ * (Ua & U).ext_max(zeroSensitivity))

    zeroCells(alpha, inletCells)
    # zeroCells( alpha, outletCells )

    return p, U, phi, pa, Ua, phia, alpha, laminarTransport, turbulence, zeroSensitivity, zeroAlpha, \
           lambda_, alphaMax, inletCells, pRefCell, pRefValue, paRefCell, paRefValue