def _createFields(runTime, mesh, g): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField ext_Info() << "Reading field pd\n" << nl pd = volScalarField( IOobject(word("pd"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh) ext_Info() << "Reading field alpha1\n" << nl alpha1 = volScalarField( IOobject(word("alpha1"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh) ext_Info() << "Reading field U\n" << nl from Foam.finiteVolume import volVectorField U = volVectorField( IOobject(word("U"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh) from Foam.finiteVolume.cfdTools.incompressible import createPhi phi = createPhi(runTime, mesh, U) ext_Info() << "Reading transportProperties\n" << nl from Foam.transportModels import twoPhaseMixture twoPhaseProperties = twoPhaseMixture(U, phi, word("alpha1")) rho1 = twoPhaseProperties.rho1() rho2 = twoPhaseProperties.rho2() # Need to store rho for ddt(rho, U) rho = volScalarField( IOobject(word("rho"), fileName(runTime.timeName()), mesh, 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. from Foam.finiteVolume import surfaceScalarField rhoPhi = surfaceScalarField( IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi) ext_Info() << "Calculating field g.h\n" << nl gh = volScalarField(word("gh"), g & mesh.C()) ghf = surfaceScalarField(word("gh"), g & mesh.Cf()) p = volScalarField( IOobject(word("p"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.AUTO_WRITE), pd + rho * gh) pdRefCell = 0 pdRefValue = 0.0 from Foam.finiteVolume import setRefCell pdRefCell, pdRefValue = setRefCell( pd, mesh.solutionDict().subDict(word("PISO")), pdRefCell, pdRefValue) pRefValue = 0.0 if pd.needReference(): from Foam.OpenFOAM import readScalar, dimensionedScalar from Foam.finiteVolume import getRefCellValue pRefValue = readScalar(mesh.solutionDict().subDict( word("PISO")).lookup(word("pRefValue"))) p.ext_assign( p + dimensionedScalar(word("p"), p.dimensions(), pRefValue - getRefCellValue(p, pdRefCell))) pass # Construct interface from alpha1 distribution from Foam.transportModels import interfaceProperties interface = interfaceProperties(alpha1, U, twoPhaseProperties) # Construct incompressible turbulence model from Foam import incompressible turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties) return p, pd, gh, ghf, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pdRefCell, pdRefValue, pRefValue, interface, turbulence
def _createFields( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField ext_Info() << "Reading field p\n" << nl p_rgh = volScalarField( IOobject( word( "p_rgh" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) ext_Info() << "Reading field alpha1\n" << nl alpha1 = volScalarField( IOobject( word( "alpha1" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) ext_Info() << "Reading field U\n" << nl from Foam.finiteVolume import volVectorField U = volVectorField( IOobject( word( "U" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) from Foam.finiteVolume.cfdTools.incompressible import createPhi phi = createPhi( runTime, mesh, U ) ext_Info() << "Reading transportProperties\n" << nl from Foam.transportModels import twoPhaseMixture twoPhaseProperties = twoPhaseMixture(U, phi) rho1 = twoPhaseProperties.rho1() rho2 = twoPhaseProperties.rho2() # Need to store rho for ddt(rho, U) rho = volScalarField( IOobject( word( "rho" ), fileName( runTime.timeName() ), mesh, 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. from Foam.finiteVolume import surfaceScalarField rhoPhi = surfaceScalarField( IOobject( word( "rho*phi" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.NO_WRITE ), rho1 * phi ) # Construct interface from alpha1 distribution from Foam.transportModels import interfaceProperties interface = interfaceProperties( alpha1, U, twoPhaseProperties ) # Construct incompressible turbulence model from Foam import incompressible turbulence = incompressible.turbulenceModel.New( U, phi, twoPhaseProperties ) from Foam.finiteVolume.cfdTools.general.include import readGravitationalAcceleration g = readGravitationalAcceleration( runTime, mesh) #dimensionedVector g0(g); #Read the data file and initialise the interpolation table #interpolationTable<vector> timeSeriesAcceleration( runTime.path()/runTime.caseConstant()/"acceleration.dat" ); ext_Info() << "Calculating field g.h\n" << nl gh = volScalarField( word( "gh" ), g & mesh.C() ) ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() ) p = volScalarField( IOobject( word( "p" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.AUTO_WRITE ), p_rgh + rho * gh ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell, getRefCellValue pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PISO" ) ), pRefCell, pRefValue ) if p_rgh.needReference(): p.ext_assign( p + dimensionedScalar( word( "p" ), p.dimensions(), pRefValue - getRefCellValue(p, pRefCell) ) ) p_rgh.ext_assign( 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): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField ext_Info() << "Reading field pd\n" << nl pd = volScalarField( IOobject(word("pd"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) ext_Info() << "Reading field alpha1\n" << nl alpha1 = volScalarField( IOobject(word("alpha1"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) ext_Info() << "Reading field U\n" << nl from Foam.finiteVolume import volVectorField U = volVectorField( IOobject(word("U"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) from Foam.finiteVolume.cfdTools.incompressible import createPhi phi = createPhi(runTime, mesh, U) ext_Info() << "Reading transportProperties\n" << nl from Foam.transportModels import twoPhaseMixture twoPhaseProperties = twoPhaseMixture(U, phi, word("alpha1")) rho1 = twoPhaseProperties.rho1() rho2 = twoPhaseProperties.rho2() # Need to store rho for ddt(rho, U) rho = volScalarField( IOobject(word("rho"), fileName(runTime.timeName()), mesh, 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. from Foam.finiteVolume import surfaceScalarField rhoPhi = surfaceScalarField( IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi ) ext_Info() << "Calculating field g.h\n" << nl gh = volScalarField(word("gh"), g & mesh.C()) ghf = surfaceScalarField(word("gh"), g & mesh.Cf()) p = volScalarField( IOobject(word("p"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.AUTO_WRITE), pd + rho * gh ) pdRefCell = 0 pdRefValue = 0.0 from Foam.finiteVolume import setRefCell pdRefCell, pdRefValue = setRefCell(pd, mesh.solutionDict().subDict(word("PISO")), pdRefCell, pdRefValue) pRefValue = 0.0 if pd.needReference(): from Foam.OpenFOAM import readScalar, dimensionedScalar from Foam.finiteVolume import getRefCellValue pRefValue = readScalar(mesh.solutionDict().subDict(word("PISO")).lookup(word("pRefValue"))) p.ext_assign(p + dimensionedScalar(word("p"), p.dimensions(), pRefValue - getRefCellValue(p, pdRefCell))) pass # Construct interface from alpha1 distribution from Foam.transportModels import interfaceProperties interface = interfaceProperties(alpha1, U, twoPhaseProperties) # Construct incompressible turbulence model from Foam import incompressible turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties) return ( p, pd, gh, ghf, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pdRefCell, pdRefValue, pRefValue, interface, turbulence, )
def _createFields(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField ext_Info() << "Reading field p\n" << nl p = volScalarField( IOobject(word("p"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) ext_Info() << "Reading field alpha1\n" << nl alpha1 = volScalarField( IOobject(word("alpha1"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) ext_Info() << "Reading field U\n" << nl from Foam.finiteVolume import volVectorField U = volVectorField( IOobject(word("U"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) from Foam.finiteVolume.cfdTools.incompressible import createPhi phi = createPhi(runTime, mesh, U) ext_Info() << "Reading transportProperties\n" << nl from Foam.transportModels import twoPhaseMixture twoPhaseProperties = twoPhaseMixture(U, phi) rho1 = twoPhaseProperties.rho1() rho2 = twoPhaseProperties.rho2() # Need to store rho for ddt(rho, U) rho = volScalarField( IOobject(word("rho"), fileName(runTime.timeName()), mesh, 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. from Foam.finiteVolume import surfaceScalarField rhoPhi = surfaceScalarField( IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell(p, mesh.solutionDict().subDict(word("PISO")), pRefCell, pRefValue) # Construct interface from alpha1 distribution from Foam.transportModels import interfaceProperties interface = interfaceProperties(alpha1, U, twoPhaseProperties) # Construct incompressible turbulence model from Foam import incompressible turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties) return p, alpha1, U, phi, rho1, rho2, rho, rhoPhi, twoPhaseProperties, pRefCell, pRefValue, interface, turbulence
def _createFields( runTime, mesh, g ): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField ext_Info() << "Reading field p_rgh\n" << nl p_rgh = volScalarField( IOobject( word( "p_rgh" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) ext_Info() << "Reading field alpha1\n" << nl alpha1 = volScalarField( IOobject( word( "alpha1" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) ext_Info() << "Calculating field alpha1\n" << nl from Foam.OpenFOAM import scalar alpha2 = volScalarField( word( "alpha2" ), scalar( 1 ) - alpha1 ) ext_Info() << "Reading field U\n" << nl from Foam.finiteVolume import volVectorField U = volVectorField( IOobject( word( "U" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) from Foam.finiteVolume.cfdTools.incompressible import createPhi phi = createPhi( runTime, mesh, U ) ext_Info() << "Reading transportProperties\n" << nl from Foam.transportModels import twoPhaseMixture twoPhaseProperties = twoPhaseMixture (U, phi) from Foam.OpenFOAM import dimensionedScalar rho10 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase1Name() ).lookup( word( "rho0" ) ) ) rho20 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase2Name() ).lookup( word( "rho0" ) ) ) psi1 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase1Name() ).lookup( word( "psi" ) ) ) psi2 = dimensionedScalar( twoPhaseProperties.subDict( twoPhaseProperties.phase2Name() ).lookup( word( "psi" ) ) ) pMin = dimensionedScalar( twoPhaseProperties.lookup( word( "pMin" ) ) ) ext_Info() << "Calculating field g.h\n" << nl gh = volScalarField( word( "gh" ), g & mesh.C() ) from Foam.finiteVolume import surfaceScalarField ghf = surfaceScalarField( word( "ghf" ), g & mesh.Cf() ) p = volScalarField( IOobject( word( "p" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, 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 = volScalarField( IOobject( word( "rho" ), fileName( runTime.timeName() ), mesh, IOobject.READ_IF_PRESENT, 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. from Foam import fvc rhoPhi = surfaceScalarField( IOobject( word( "rho*phi" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.NO_WRITE ), fvc.interpolate( rho ) * phi ) dgdt = alpha2.pos() * fvc.div( phi ) / alpha2.ext_max( scalar( 0.0001 ) ) # Construct interface from alpha1 distribution from Foam.transportModels import interfaceProperties interface = interfaceProperties( alpha1, U, twoPhaseProperties ) # Construct incompressible turbulence model from Foam import incompressible turbulence = 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