def readThermodynamicProperties( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermodynamicProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName thermodynamicProperties = IOdictionary( IOobject( word( "thermodynamicProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedScalar R = dimensionedScalar( thermodynamicProperties.lookup( word( "R" ) ) ) Cv = dimensionedScalar( thermodynamicProperties.lookup( word( "Cv" ) ) ) Cp = Cv + R gamma = Cp / Cv from Foam.OpenFOAM import dimless Pr = dimensionedScalar( word( "Pr" ), dimless, 1.0 ) if thermodynamicProperties.found( word( "Pr" ) ) : Pr = dimensionedScalar( thermodynamicProperties.lookup( "Pr" ) ) pass return thermodynamicProperties, R, Cv, Cp, gamma, Pr
def readThermodynamicProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermodynamicProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName thermodynamicProperties = IOdictionary( IOobject( word("thermodynamicProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedScalar rho0 = dimensionedScalar(thermodynamicProperties.lookup(word("rho0"))) p0 = dimensionedScalar(thermodynamicProperties.lookup(word("p0"))) psi = dimensionedScalar(thermodynamicProperties.lookup(word("psi"))) # Density offset, i.e. the constant part of the density rhoO = dimensionedScalar(word("rhoO"), rho0 - psi * p0) return thermodynamicProperties, rho0, p0, psi, rhoO
def readThermodynamicProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermodynamicProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName thermodynamicProperties = IOdictionary( IOobject(word("thermodynamicProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedScalar R = dimensionedScalar(thermodynamicProperties.lookup(word("R"))) Cv = dimensionedScalar(thermodynamicProperties.lookup(word("Cv"))) Cp = Cv + R gamma = Cp / Cv from Foam.OpenFOAM import dimless Pr = dimensionedScalar(word("Pr"), dimless, 1.0) if thermodynamicProperties.found(word("Pr")): Pr = dimensionedScalar(thermodynamicProperties.lookup("Pr")) pass return thermodynamicProperties, R, Cv, Cp, gamma, Pr
def readThermodynamicProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermodynamicProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word thermodynamicProperties = IOdictionary( IOobject(word("thermodynamicProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedScalar R = dimensionedScalar(thermodynamicProperties.lookup(word("R"))) Cv = dimensionedScalar(thermodynamicProperties.lookup(word("Cv"))) return thermodynamicProperties, R, Cv
def readThermodynamicProperties( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermodynamicProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word thermodynamicProperties = IOdictionary( IOobject( word( "thermodynamicProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedScalar R = dimensionedScalar( thermodynamicProperties.lookup( word( "R" ) ) ) Cv = dimensionedScalar( thermodynamicProperties.lookup( word( "Cv" ) ) ) return thermodynamicProperties, R, Cv
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 T\n" << nl T = volScalarField( IOobject( word( "T" ), fileName( runTime.timeName() ), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE ), mesh ) ext_Info() << "Reading transportProperties\n" << nl transportProperties = IOdictionary( IOobject( word( "transportProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) ext_Info() << "Reading diffusivity DT\n" << nl from Foam.OpenFOAM import dimensionedScalar DT = dimensionedScalar( transportProperties.lookup( word( "DT" ) ) ) return T, transportProperties, DT
def readThermodynamicProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermodynamicProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName thermodynamicProperties = IOdictionary( IOobject(word("thermodynamicProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedScalar rho0 = dimensionedScalar(thermodynamicProperties.lookup(word("rho0"))) p0 = dimensionedScalar(thermodynamicProperties.lookup(word("p0"))) psi = dimensionedScalar(thermodynamicProperties.lookup(word("psi"))) # Density offset, i.e. the constant part of the density rhoO = dimensionedScalar(word("rhoO"), rho0 - psi * p0) return thermodynamicProperties, rho0, p0, psi, rhoO
def readTransportProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName ext_Info() << "\nReading transportProperties\n" << nl transportProperties = IOdictionary( IOobject(word("transportProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE, False)) from Foam.OpenFOAM import dimensionedScalar, dimensionedVector nu = dimensionedScalar(transportProperties.lookup(word("nu"))) # Read centerline velocity for channel simulations Ubar = dimensionedVector(transportProperties.lookup(word("Ubar"))) magUbar = Ubar.mag() from Foam.OpenFOAM import vector flowDirection = (Ubar / magUbar).ext_value() return transportProperties, nu, Ubar, magUbar, flowDirection
def readEnvironmentalProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "\nReading environmentalProperties" << nl from Foam.OpenFOAM import IOdictionary, fileName, word, IOobject environmentalProperties = IOdictionary( IOobject(word("environmentalProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedVector g = dimensionedVector(environmentalProperties.lookup(word("g"))) return g, environmentalProperties
def readTransportProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading transportProperties\n" << nl 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 mu = dimensionedScalar(transportProperties.lookup(word("mu"))) return transportProperties, mu
def readEnvironmentalProperties( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "\nReading environmentalProperties" << nl from Foam.OpenFOAM import IOdictionary, fileName, word, IOobject environmentalProperties = IOdictionary( IOobject( word( "environmentalProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedVector g = dimensionedVector( environmentalProperties.lookup( word( "g" ) ) ) return g, environmentalProperties
def readingTransportProperties( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading transportProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, fileName, word transportProperties = IOdictionary( IOobject( word( "transportProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedScalar mu = dimensionedScalar( transportProperties.lookup( word( "mu" ) ) ) return transportProperties, mu
def readTransportProperties( runTime, mesh): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName ext_Info() << "\nReading transportProperties\n" << nl transportProperties = IOdictionary( IOobject( word( "transportProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE, False ) ) from Foam.OpenFOAM import dimensionedScalar, dimensionedVector nu = dimensionedScalar( transportProperties.lookup( word( "nu" ) ) ) # Read centerline velocity for channel simulations Ubar = dimensionedVector( transportProperties.lookup( word( "Ubar" ) ) ) magUbar = Ubar.mag() from Foam.OpenFOAM import vector flowDirection = ( Ubar / magUbar ).ext_value() return transportProperties, nu, Ubar, magUbar, flowDirection
def readGravitationalAcceleration(runTime, mesh): from Foam.OpenFOAM import IOdictionary, word, fileName, IOobject from Foam.OpenFOAM import ext_Info, nl ext_Info() << "\nReading gravitationalProperties" << nl gravitationalProperties = IOdictionary( IOobject(word("gravitationalProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedVector, Switch, dimTime g = dimensionedVector(gravitationalProperties.lookup(word("g"))) rotating = Switch(gravitationalProperties.lookup(word("rotating"))) if rotating: Omega = dimensionedVector(gravitationalProperties.lookup( word("Omega"))) else: Omega = dimensionedVector(word("Omega"), -dimTime, vector(0, 0, 0)) magg = g.mag() gHat = g / magg return gravitationalProperties, g, rotating, Omega, magg, gHat
def readGravitationalAcceleration( runTime, mesh ): from Foam.OpenFOAM import IOdictionary, word, fileName, IOobject from Foam.OpenFOAM import ext_Info, nl ext_Info() << "\nReading gravitationalProperties" << nl gravitationalProperties = IOdictionary( IOobject( word( "gravitationalProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedVector,Switch, dimTime g = dimensionedVector( gravitationalProperties.lookup( word( "g" ) ) ) rotating = Switch( gravitationalProperties.lookup( word( "rotating" ) ) ) if rotating: Omega = dimensionedVector( gravitationalProperties.lookup( word( "Omega" ) ) ) else: Omega = dimensionedVector( word( "Omega" ), -dimTime, vector( 0,0,0 ) ) magg = g.mag() gHat = g / magg return gravitationalProperties, g, rotating, Omega, magg, gHat
def readThermophysicalProperties(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysicalProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName # Pr defined as a separate constant to enable calculation of k, currently # inaccessible through thermo thermophysicalProperties = IOdictionary( IOobject(word("thermophysicalProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedScalar, dimless Pr = dimensionedScalar(word("Pr"), dimless, 1.0) if thermophysicalProperties.found(word("Pr")): Pr = thermophysicalProperties.lookup(word("Pr")) pass return thermophysicalProperties, Pr
def readThermophysicalProperties( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysicalProperties\n" << nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName # Pr defined as a separate constant to enable calculation of k, currently # inaccessible through thermo thermophysicalProperties = IOdictionary( IOobject( word( "thermophysicalProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedScalar, dimless Pr = dimensionedScalar(word( "Pr" ), dimless, 1.0) if thermophysicalProperties.found( word( "Pr" ) ): Pr = thermophysicalProperties.lookup( word( "Pr" ) ) pass return thermophysicalProperties, Pr
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 volVectorField ext_Info() << "Reading field U\n" << nl U = volVectorField( IOobject(word("U"), fileName(runTime.timeName()), mesh, IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh) ext_Info() << "Creating face flux\n" << nl from Foam.OpenFOAM import dimensionedScalar from Foam.finiteVolume import surfaceScalarField phi = surfaceScalarField( IOobject(word("phi"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE), mesh, dimensionedScalar(word("zero"), mesh.Sf().dimensions() * U.dimensions(), 0.0)) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel(U, phi) from Foam import incompressible turbulence = incompressible.RASModel.New(U, phi, laminarTransport) transportProperties = IOdictionary( IOobject(word("transportProperties"), fileName(runTime.constant()), mesh, IOobject.MUST_READ, IOobject.NO_WRITE)) from Foam.OpenFOAM import dimensionedVector, vector Ubar = dimensionedVector(transportProperties.lookup(word("Ubar"))) flowDirection = (Ubar / Ubar.mag()).ext_value() flowMask = flowDirection.sqr() nWallFaces = 0.0 from Foam.OpenFOAM import vector wallNormal = vector.zero patches = mesh.boundary() for patchi in range(mesh.boundary().size()): currPatch = patches[patchi] from Foam.finiteVolume import wallFvPatch if wallFvPatch.ext_isA(currPatch): for facei in range(currPatch.size()): nWallFaces = nWallFaces + 1 if nWallFaces == 1: wallNormal = -mesh.Sf().ext_boundaryField( )[patchi][facei] / mesh.magSf().ext_boundaryField( )[patchi][facei] pass elif nWallFaces == 2: wallNormal2 = mesh.Sf().ext_boundaryField( )[patchi][facei] / mesh.magSf().ext_boundaryField( )[patchi][facei] #- Check that wall faces are parallel from Foam.OpenFOAM import mag if mag(wallNormal & wallNormal2) > 1.01 or mag(wallNormal & wallNormal2) < 0.99: ext_Info( ) << "boundaryFoam: wall faces are not parallel" << nl import os os.abort() pass pass else: ext_Info( ) << "boundaryFoam: number of wall faces > 2" << nl import os os.abort() pass pass pass #- create position array for graph generation y = wallNormal & mesh.C().internalField() from Foam.OpenFOAM import dimensionSet, vector, word gradP = dimensionedVector(word("gradP"), dimensionSet(0.0, 1.0, -2.0, 0.0, 0.0), vector(0.0, 0.0, 0.0)) return U, phi, laminarTransport, turbulence, Ubar, wallNormal, flowDirection, flowMask, y, gradP
def _createFields( runTime, mesh ): from Foam.OpenFOAM import ext_Info, nl from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName 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 ) ext_Info() << "Creating face flux\n" << nl from Foam.OpenFOAM import dimensionedScalar from Foam.finiteVolume import surfaceScalarField phi = surfaceScalarField( IOobject( word( "phi" ), fileName( runTime.timeName() ), mesh, IOobject.NO_READ, IOobject.NO_WRITE ), mesh, dimensionedScalar( word( "zero" ), mesh.Sf().dimensions()*U.dimensions(), 0.0) ) from Foam.transportModels import singlePhaseTransportModel laminarTransport = singlePhaseTransportModel( U, phi ) from Foam import incompressible turbulence = incompressible.RASModel.New( U, phi, laminarTransport ) transportProperties = IOdictionary( IOobject( word( "transportProperties" ), fileName( runTime.constant() ), mesh, IOobject.MUST_READ, IOobject.NO_WRITE ) ) from Foam.OpenFOAM import dimensionedVector, vector Ubar = dimensionedVector( transportProperties.lookup( word( "Ubar" ) ) ) flowDirection = ( Ubar / Ubar.mag() ).ext_value() flowMask = flowDirection.sqr() nWallFaces = 0.0 from Foam.OpenFOAM import vector wallNormal = vector.zero patches = mesh.boundary() for patchi in range( mesh.boundary().size() ): currPatch = patches[patchi] from Foam.finiteVolume import wallFvPatch if wallFvPatch.ext_isType( currPatch ): for facei in range( currPatch.size() ): nWallFaces = nWallFaces +1 if nWallFaces == 1: wallNormal = - mesh.Sf().ext_boundaryField()[patchi][facei] / mesh.magSf().ext_boundaryField()[patchi][facei] pass elif nWallFaces == 2: wallNormal2 = mesh.Sf().ext_boundaryField()[patchi][facei] / mesh.magSf().ext_boundaryField()[patchi][facei] #- Check that wall faces are parallel from Foam.OpenFOAM import mag if mag(wallNormal & wallNormal2) > 1.01 or mag(wallNormal & wallNormal2) < 0.99: ext_Info() << "boundaryFoam: wall faces are not parallel" << nl import os os.abort() pass pass else: ext_Info() << "boundaryFoam: number of wall faces > 2" << nl import os os.abort() pass pass pass #- create position array for graph generation y = wallNormal & mesh.C().internalField() from Foam.OpenFOAM import dimensionSet, vector, word gradP = dimensionedVector( word( "gradP" ), dimensionSet( 0.0, 1.0, -2.0, 0.0, 0.0 ), vector( 0.0, 0.0, 0.0 ) ) return U, phi, laminarTransport, turbulence, Ubar, wallNormal, flowDirection, flowMask, y, gradP