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 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) from Foam.transportModels import singlePhaseTransportModel fluid = singlePhaseTransportModel(U, phi) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell(p, mesh.solutionDict().subDict(word("PISO")), pRefCell, pRefValue) return p, U, phi, fluid, pRefCell, pRefValue
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 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) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell(p, mesh.solutionDict().subDict(word("PISO")), pRefCell, pRefValue) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel(U, phi) from Foam import incompressible sgsModel = incompressible.LESModel.New(U, phi, laminarTransport) return p, U, phi, laminarTransport, sgsModel, pRefCell, pRefValue
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 thermophysical properties\n" << nl ext_Info() << "Reading field T\n" << nl T = volScalarField( IOobject( word( "T" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) 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 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 ) laminarTransport, beta, TRef,Pr, Prt = readTransportProperties( U, phi ) ext_Info() << "Creating turbulence model\n" << nl from Foam import incompressible turbulence = incompressible.RASModel.New( U, phi, laminarTransport ) ext_Info() << "Calculating field beta*(g.h)\n" << nl from Foam.finiteVolume import surfaceScalarField betaghf = surfaceScalarField( word( "betagh" ), beta * ( g & mesh.Cf() ) ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) # Kinematic density for buoyancy force rhok = volScalarField( IOobject( word( "rhok" ), fileName( runTime.timeName() ), mesh ), 1.0 - beta * ( T - TRef ) ) return T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, betaghf, pRefCell, pRefValue, rhok
def create_fields( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading field p\n" << nl from Foam.OpenFOAM import IOobject, word, fileName from Foam.finiteVolume import volScalarField p = volScalarField( IOobject( word( "p" ), 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 ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel( U, phi ) from Foam import incompressible turbulence = incompressible.RASModel.New( U, phi, laminarTransport ) from Foam.finiteVolume import porousZones pZones = porousZones( mesh ) from Foam.OpenFOAM import Switch pressureImplicitPorosity = Switch( False ) nUCorr = 0 if pZones.size(): # nUCorrectors for pressureImplicitPorosity if (mesh.solutionDict().subDict( word( "SIMPLE" ) ).found( word( "nUCorrectors" ) ) ) : from Foam.OpenFOAM import readInt nUCorr = readInt( mesh.solutionDict().subDict( word( "SIMPLE" ) ).lookup( word( "nUCorrectors" ) ) ) pass if nUCorr > 0 : pressureImplicitPorosity = True pass pass return p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, pZones, pressureImplicitPorosity, nUCorr
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 thermophysical properties\n" << nl ext_Info() << "Reading field T\n" << nl T = volScalarField( IOobject( word( "T" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) 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 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 ) laminarTransport, beta, TRef,Pr, Prt = readTransportProperties( U, phi ) ext_Info() << "Creating turbulence model\n" << nl from Foam import incompressible turbulence = incompressible.RASModel.New( U, phi, laminarTransport ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PISO" ) ), pRefCell, pRefValue ) # Kinematic density for buoyancy force rhok = volScalarField( IOobject( word( "rhok" ), fileName( runTime.timeName() ), mesh ), 1.0 - beta * ( T - TRef ) ) return T, p, U, phi, laminarTransport, beta, TRef,Pr, Prt, turbulence, pRefCell, pRefValue, rhok
def create_fields(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading field p\n" << nl from Foam.OpenFOAM import IOobject, word, fileName from Foam.finiteVolume import volScalarField p = volScalarField( IOobject(word("p"), 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) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel(U, phi) from Foam import incompressible turbulence = incompressible.RASModel.New(U, phi, laminarTransport) from Foam.finiteVolume import porousZones pZones = porousZones(mesh) from Foam.OpenFOAM import Switch pressureImplicitPorosity = Switch(False) nUCorr = 0 if pZones.size(): # nUCorrectors for pressureImplicitPorosity if (mesh.solutionDict().subDict(word("SIMPLE")).found( word("nUCorrectors"))): from Foam.OpenFOAM import readInt nUCorr = readInt(mesh.solutionDict().subDict( word("SIMPLE")).lookup(word("nUCorrectors"))) pass if nUCorr > 0: pressureImplicitPorosity = True pass pass return p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, pZones, pressureImplicitPorosity, nUCorr
def createFields(runTime, mesh, g): ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import autoPtr_basicPsiThermo, basicPsiThermo thermo = basicPsiThermo.New(mesh) from Foam.finiteVolume import volScalarField from Foam.OpenFOAM import IOobject, word, fileName rho = volScalarField( IOobject(word("rho"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), thermo.rho()) p = thermo.p() h = thermo.h() psi = thermo.psi() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi(runTime, mesh, rho, U) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.RASModel.New(rho, U, phi, thermo()) 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()) 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) #Force p_rgh to be consistent with p p_rgh.ext_assign(p - rho * gh) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, p_rgh, mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue) from Foam import fvc initialMass = fvc.domainIntegrate(rho) totalVolume = mesh.V().ext_sum() return thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, pRefCell, pRefValue, initialMass, totalVolume
def _createFields( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import basicPsiThermo thermo = basicPsiThermo.New( mesh ) from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField rho = volScalarField( IOobject( word( "rho" ), fileName( runTime.timeName() ), mesh, IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE ), thermo.rho() ) p = thermo.p() h = thermo.h() psi = thermo.psi() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi( runTime, mesh, rho, U ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) from Foam.OpenFOAM import dimensionedScalar pMin = dimensionedScalar( mesh.solutionDict().subDict( word( "SIMPLE" ) ).lookup( word( "pMin" ) ) ) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.RASModel.New( rho, U, phi, thermo() ) from Foam.OpenFOAM import dimensionedScalar from Foam import fvc initialMass = fvc.domainIntegrate( rho ) return thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, pMin
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() ) from Foam.finiteVolume import volVectorField ext_Info() << "Reading field U\n" << nl 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 ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PIMPLE" ) ), pRefCell, pRefValue ) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel( U, phi ) from Foam import incompressible turbulence = incompressible.turbulenceModel.New( U, phi, laminarTransport ) from Foam.finiteVolume import zeroGradientFvPatchScalarField ext_Info() << "Reading field rAU if present\n" << nl rAU = volScalarField( IOobject( word( "rAU" ), fileName( runTime.timeName() ), mesh(), IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE ), mesh(), runTime.deltaT(), zeroGradientFvPatchScalarField.typeName ) return p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue
def _createFields( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import basicPsiThermo thermo = basicPsiThermo.New( mesh ) from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField rho = volScalarField( IOobject( word( "rho" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.NO_WRITE ), thermo.rho() ) p = thermo.p() h = thermo.h() psi = thermo.psi() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi( runTime, mesh, rho, U ) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.RASModel.New( rho, U, phi, thermo() ) thermo.correct() pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) from Foam import fvc initialMass = fvc.domainIntegrate(rho) return thermo, rho, p, h, psi, U, phi, turbulence, initialMass, pRefCell, pRefValue
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.NO_WRITE ), mesh ) from Foam.OpenFOAM import dimensionedScalar p.ext_assign( dimensionedScalar( word( "zero" ), p.dimensions(), 0.0 ) ) 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.OpenFOAM import dimensionedVector, vector U.ext_assign( dimensionedVector( word( "0" ), U.dimensions(), vector.zero ) ) from Foam.finiteVolume import surfaceScalarField from Foam import fvc phi = surfaceScalarField( IOobject( word( "phi" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.AUTO_WRITE ), fvc.interpolate( U ) & mesh.Sf() ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) return p, U, phi, pRefCell, pRefValue
def createFields( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading transportProperties\n" from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName transportProperties = IOdictionary( IOobject( word( "transportProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedScalar nu = dimensionedScalar( transportProperties.lookup( word( "nu" ) ) ); ext_Info() << "Reading field p\n" << nl from Foam.finiteVolume import volScalarField p = volScalarField( IOobject( word( "p" ), 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 ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict( word( "PISO" ) ), pRefCell, pRefValue ) return transportProperties, nu, p, U, phi, pRefCell, pRefValue
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()) from Foam.finiteVolume import volVectorField ext_Info() << "Reading field U\n" << nl 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) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict(word("PIMPLE")), pRefCell, pRefValue) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel(U, phi) from Foam import incompressible turbulence = incompressible.turbulenceModel.New(U, phi, laminarTransport) from Foam.finiteVolume import zeroGradientFvPatchScalarField ext_Info() << "Reading field rAU if present\n" << nl rAU = volScalarField( IOobject(word("rAU"), fileName(runTime.timeName()), mesh(), IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), mesh(), runTime.deltaT(), zeroGradientFvPatchScalarField.typeName) return p, U, phi, laminarTransport, turbulence, rAU, pRefCell, pRefValue
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.NO_WRITE), mesh) from Foam.OpenFOAM import dimensionedScalar p.ext_assign(dimensionedScalar(word("zero"), p.dimensions(), 0.0)) 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.OpenFOAM import dimensionedVector, vector U.ext_assign(dimensionedVector(word("0"), U.dimensions(), vector.zero)) from Foam.finiteVolume import surfaceScalarField from Foam import fvc phi = surfaceScalarField( IOobject(word("phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.AUTO_WRITE), fvc.interpolate(U) & mesh.Sf()) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue) return p, U, phi, pRefCell, pRefValue
def _createFields(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import basicThermo, autoPtr_basicThermo thermo = basicThermo.New(mesh) from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField rho = volScalarField( IOobject(word("rho"), fileName(runTime.timeName()), mesh, IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), thermo.rho()) p = thermo.p() h = thermo.h() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi(runTime, mesh, rho, U) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue) from Foam.OpenFOAM import dimensionedScalar pMin = dimensionedScalar(mesh.solutionDict().subDict( word("SIMPLE")).lookup(word("pMin"))) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.RASModel.New(rho, U, phi, thermo()) from Foam import fvc initialMass = fvc.domainIntegrate(rho) from Foam.finiteVolume import porousZones pZones = porousZones(mesh) from Foam.OpenFOAM import Switch pressureImplicitPorosity = Switch(False) nUCorr = 0 if pZones.size(): # nUCorrectors for pressureImplicitPorosity if (mesh.solutionDict().subDict(word("SIMPLE")).found( word("nUCorrectors"))): from Foam.OpenFOAM import readInt nUCorr = readInt(mesh.solutionDict().subDict( word("SIMPLE")).lookup(word("nUCorrectors"))) pass if nUCorr > 0: pressureImplicitPorosity = True pass pass return turbulence, p, h, rho, U, phi, thermo, pZones, pMin, pressureImplicitPorosity, initialMass, nUCorr, pRefCell, pRefValue
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() << "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() from Foam.OpenFOAM import dimensionedScalar Dab = dimensionedScalar(twoPhaseProperties.lookup(word("Dab"))) # Read the reciprocal of the turbulent Schmidt number alphatab = dimensionedScalar(twoPhaseProperties.lookup(word("alphatab"))) # Need to store rho for ddt(rho, U) from Foam.OpenFOAM import scalar rho = volScalarField(word("rho"), alpha1 * rho1 + (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. from Foam.finiteVolume import surfaceScalarField rhoPhi = surfaceScalarField( IOobject(word("rho*phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), rho1 * phi ) # Construct incompressible turbulence model from Foam import incompressible turbulence = incompressible.turbulenceModel.New(U, phi, twoPhaseProperties) 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, p_rgh, mesh.solutionDict().subDict(word("PIMPLE")), 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, alpha1, U, phi, twoPhaseProperties, rho1, rho2, Dab, alphatab, rho, rhoPhi, turbulence, gh, ghf, p, pRefCell, pRefValue, )
def _createFields(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import basicThermo, autoPtr_basicThermo thermo = basicThermo.New(mesh) from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName from Foam.finiteVolume import volScalarField rho = volScalarField( IOobject(word("rho"), fileName(runTime.timeName()), mesh, IOobject.READ_IF_PRESENT, IOobject.AUTO_WRITE), thermo.rho(), ) p = thermo.p() h = thermo.h() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi(runTime, mesh, rho, U) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell(p, mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue) from Foam.OpenFOAM import dimensionedScalar pMin = dimensionedScalar(mesh.solutionDict().subDict(word("SIMPLE")).lookup(word("pMin"))) # ext_Info() << "Creating turbulence model\n" << nl # from Foam import compressible # turbulence = compressible.turbulenceModel.New( rho, U, phi, thermo() ) from Foam import fvc initialMass = fvc.domainIntegrate(rho) from Foam.finiteVolume import porousZones pZones = porousZones(mesh) from Foam.OpenFOAM import Switch pressureImplicitPorousity = Switch(False) nUCorr = 0 if pZones.size(): mesh.solutionDict().subDict(word("SIMPLE")).lookup( word("pressureImplicitPorousity") ) >> pressureImplicitPorousity pass return p, h, rho, U, phi, thermo, pZones, pMin, pressureImplicitPorousity, initialMass, nUCorr, pRefCell, pRefValue
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 ): 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 ): ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import autoPtr_basicPsiThermo, basicPsiThermo thermo = basicPsiThermo.New(mesh) from Foam.finiteVolume import volScalarField from Foam.OpenFOAM import IOobject, word, fileName rho = volScalarField( IOobject( word( "rho" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.NO_WRITE), thermo.rho() ) p = thermo.p() h = thermo.h() psi = thermo.psi() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi( runTime, mesh, rho, U ) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.RASModel.New( rho, U, phi, thermo() ) 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() ) 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 ) #Force p_rgh to be consistent with p p_rgh.ext_assign( p - rho*gh ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, p_rgh, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) from Foam import fvc initialMass = fvc.domainIntegrate( rho ) totalVolume = mesh.V().ext_sum() return thermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, pRefCell, pRefValue, initialMass, totalVolume
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 thermophysical properties\n" << nl ext_Info() << "Reading field T\n" << nl T = volScalarField( IOobject( word( "T" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) 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 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 ) laminarTransport, beta, TRef,Pr, Prt = readTransportProperties( U, phi ) ext_Info() << "Creating turbulence model\n" << nl from Foam import incompressible turbulence = incompressible.RASModel.New( U, phi, laminarTransport ) # Kinematic density for buoyancy force rhok = volScalarField( IOobject( word( "rhok" ), fileName( runTime.timeName() ), mesh ), 1.0 - beta * ( T - TRef ) ) # kinematic turbulent thermal thermal conductivity m2/s ext_Info() << "Reading field kappat\n" << nl kappat = volScalarField( IOobject( word( "kappat" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) 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 + rhok * gh ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( p, p_rgh, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pRefCell, pRefValue ) if p_rgh.needReference(): from Foam.finiteVolume import getRefCellValue from Foam.OpenFOAM import dimensionedScalar p.ext_assign( p + dimensionedScalar( word( "p" ), p.dimensions(), pRefValue - getRefCellValue( p, pRefCell) ) ) pass return T, p, p_rgh, U, phi, laminarTransport, gh, ghf, TRef,Pr, Prt, turbulence, beta, pRefCell, pRefValue, rhok, kappat
def createFields( runTime, mesh, g ): ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import autoPtr_basicThermo, basicThermo thermo = basicThermo.New( mesh ) from Foam.finiteVolume import volScalarField from Foam.OpenFOAM import IOobject, word, fileName rho = volScalarField( IOobject( word( "rho" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.NO_WRITE), thermo.rho() ) p = thermo.p() h = thermo.h() T = thermo.T() 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.compressible import compressibleCreatePhi phi = compressibleCreatePhi( runTime, mesh, rho, U ) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.RASModel.New( rho, U, phi, thermo() ) ext_Info() << "Calculating field g.h\n" << nl gh = volScalarField ( word( "gh" ), g & mesh.C() ) from Foam.OpenFOAM import dimensionedScalar pRef = dimensionedScalar( word( "pRef" ), p.dimensions(), thermo.lookup( word( "pRef" ) ) ) ext_Info() << "Creating field pd\n" << nl pd = volScalarField( IOobject( word( "pd" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) p.ext_assign( pd + rho * gh + pRef ) thermo.correct() pdRefCell = 0 pdRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell( pd, mesh.solutionDict().subDict( word( "SIMPLE" ) ), pdRefCell, pdRefValue ) ext_Info() << "Creating radiation model\n" << nl from Foam.radiation import radiationModel radiation =radiationModel.New( T ) from Foam import fvc initialMass = fvc.domainIntegrate( rho ) return thermo, rho, p, h, T, U, phi, turbulence, gh, pRef, pd, p, pdRefCell, pdRefValue, radiation, initialMass
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 thermophysical properties\n" << nl ext_Info() << "Reading field T\n" << nl T = volScalarField( IOobject(word("T"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) 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 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) laminarTransport, beta, TRef, Pr, Prt = readTransportProperties(U, phi) ext_Info() << "Creating turbulence model\n" << nl from Foam import incompressible turbulence = incompressible.RASModel.New(U, phi, laminarTransport) # Kinematic density for buoyancy force rhok = volScalarField(IOobject(word("rhok"), fileName(runTime.timeName()), mesh), 1.0 - beta * (T - TRef)) # kinematic turbulent thermal thermal conductivity m2/s ext_Info() << "Reading field kappat\n" << nl kappat = volScalarField( IOobject(word("kappat"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh ) 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 + rhok * gh, ) pRefCell = 0 pRefValue = 0.0 from Foam.finiteVolume import setRefCell pRefCell, pRefValue = setRefCell(p, p_rgh, mesh.solutionDict().subDict(word("SIMPLE")), pRefCell, pRefValue) if p_rgh.needReference(): from Foam.finiteVolume import getRefCellValue from Foam.OpenFOAM import dimensionedScalar p.ext_assign(p + dimensionedScalar(word("p"), p.dimensions(), pRefValue - getRefCellValue(p, pRefCell))) pass return ( T, p, p_rgh, U, phi, laminarTransport, gh, ghf, TRef, Pr, Prt, turbulence, beta, pRefCell, pRefValue, rhok, kappat, )
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, 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, )