def readPISOControls_010500_dev(mesh): from Foam.OpenFOAM import dictionary, readInt, Switch, word piso = dictionary(mesh.solutionDict().subDict(word("PISO"))) nCorr = readInt(piso.lookup(word("nCorrectors"))) nNonOrthCorr = 0 if piso.found(word("nNonOrthogonalCorrectors")): nNonOrthCorr = readInt(piso.lookup(word("nNonOrthogonalCorrectors"))) pass momentumPredictor = True if piso.found(word("momentumPredictor")): momentumPredictor = Switch(piso.lookup(word("momentumPredictor"))) pass transonic = False if piso.found(word("transonic")): transonic = Switch(piso.lookup(word("transonic"))) pass nOuterCorr = 1 if piso.found(word("nOuterCorrectors")): nOuterCorr = readInt(piso.lookup(word("nOuterCorrectors"))) pass ddtPhiCorr = False if piso.found(word("ddtPhiCorr")): ddtPhiCorr = Switch(piso.lookup(word("ddtPhiCorr"))) pass return piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr, ddtPhiCorr
def readSIMPLEControls_010500_dev(mesh): from Foam.OpenFOAM import Switch from Foam.OpenFOAM import word simple = mesh.solutionDict().subDict(word("SIMPLE")) from Foam.OpenFOAM import readInt nNonOrthCorr = 0 if (simple.found(word("nNonOrthogonalCorrectors"))): nNonOrthCorr = readInt(simple.lookup(word("nNonOrthogonalCorrectors"))) pass momentumPredictor = True if (simple.found(word("momentumPredictor"))): momentumPredictor = Switch(simple.lookup(word("momentumPredictor"))) pass fluxGradp = False if (simple.found(word("fluxGradp"))): fluxGradp = Switch(simple.lookup(word("fluxGradp"))) pass transonic = False if (simple.found(word("transSonic"))): transonic = Switch(simple.lookup(word("transSonic"))) pass return simple, nNonOrthCorr, momentumPredictor, fluxGradp, transonic
def readFluidMultiRegionPISOControls( mesh ) : from Foam.OpenFOAM import word, readInt, Switch piso = mesh.solutionDict().subDict( word( "PISO" ) ) nCorr = readInt( piso.lookup( word( "nCorrectors" ) ) ) nNonOrthCorr = 0 if piso.found( word( "nNonOrthogonalCorrectors" ) ): nNonOrthCorr = readInt( piso.lookup( word( "nNonOrthogonalCorrectors" ) ) ) pass momentumPredictor = True if piso.found( word( "momentumPredictor" ) ): momentumPredictor = Switch( piso.lookup( word( "momentumPredictor" ) ) ) pass transonic = False if piso.found( word( "transonic" ) ): transonic = Switch(piso.lookup( word( "transonic" ) ) ) pass nOuterCorr = 1 if piso.found( word( "nOuterCorrectors" ) ): nOuterCorr = readInt(piso.lookup( word( "nOuterCorrectors" ) ) ) return piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr
def readSIMPLEControls_010700(mesh): from Foam.OpenFOAM import Switch from Foam.OpenFOAM import word simple = mesh.solutionDict().subDict(word("SIMPLE")) nNonOrthCorr = simple.lookupOrDefault(word("nNonOrthogonalCorrectors"), 0) momentumPredictor = simple.lookupOrDefault(word("momentumPredictor"), Switch(True)) transonic = simple.lookupOrDefault(word("transonic"), Switch(False)) return simple, nNonOrthCorr, momentumPredictor, transonic
def readPISOControls_010600_dev(mesh): from Foam.OpenFOAM import dictionary, readInt, Switch, word piso = dictionary(mesh.solutionDict().subDict(word("PISO"))) nCorr = readInt(piso.lookup(word("nCorrectors"))) nNonOrthCorr = piso.lookupOrDefault(word("nNonOrthogonalCorrectors"), 0) momentumPredictor = piso.lookupOrDefault(word("momentumPredictor"), Switch(True)) transonic = piso.lookupOrDefault(word("transonic"), Switch(False)) nOuterCorr = piso.lookupOrDefault(word("nOuterCorrectors"), 1) return piso, nCorr, nNonOrthCorr, momentumPredictor, transonic, nOuterCorr
def readFluidMultiRegionPIMPLEControls( mesh ) : from Foam.OpenFOAM import word, readInt, Switch pimple = mesh.solutionDict().subDict( word( "PIMPLE" ) ) nCorr = readInt( pimple.lookup( word( "nCorrectors" ) ) ) nNonOrthCorr = pimple.lookupOrDefault( word( "nNonOrthogonalCorrectors" ), 0 ) momentumPredictor =pimple.lookupOrDefault( word( "momentumPredictor" ), Switch( True ) ) return pimple, nCorr, nNonOrthCorr, momentumPredictor
def readTimeControls_010600_dev( runTime ): from Foam.OpenFOAM import Switch, word, readScalar, GREAT adjustTimeStep = Switch( runTime.controlDict().lookup( word( "adjustTimeStep" ) ) ) maxCo = readScalar( runTime.controlDict().lookup( word( "maxCo" ) ) ) maxDeltaT = runTime.controlDict().lookupOrDefault( word( "maxDeltaT" ), GREAT, 0, 1 ) return adjustTimeStep, maxCo, maxDeltaT
def readPIMPLEControls( mesh ): from Foam.OpenFOAM import Switch from Foam.OpenFOAM import word from Foam.OpenFOAM import readInt pimple = mesh.solutionDict().subDict( word( "PIMPLE" ) ) nOuterCorr = readInt( pimple.lookup( word( "nOuterCorrectors" ) ) ) nCorr = readInt( pimple.lookup( word( "nCorrectors" ) ) ) nNonOrthCorr = pimple.lookupOrDefault( word( "nNonOrthogonalCorrectors" ), 0 ) momentumPredictor = pimple.lookupOrDefault( word( "momentumPredictor" ), Switch( True ) ) transonic = pimple.lookupOrDefault( word( "transonic" ), Switch( False ) ) return pimple, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic
def create_fields(runTime, mesh): from Foam.OpenFOAM import ext_Info, nl ext_Info() << "Reading thermophysical properties\n" << nl from Foam.thermophysicalModels import basicPsiThermo, autoPtr_basicPsiThermo thermo = basicPsiThermo.New(mesh) p = thermo.p() h = thermo.h() psi = thermo.psi() from Foam.OpenFOAM import 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()) 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) from Foam.OpenFOAM import dimensionedScalar pMin = dimensionedScalar(mesh.solutionDict().subDict( word("PIMPLE")).lookup(word("pMin"))) ext_Info() << "Creating turbulence model\n" << nl from Foam import compressible turbulence = compressible.turbulenceModel.New(rho, U, phi, thermo()) # initialMass = fvc.domainIntegrate(rho) ext_Info() << "Creating field DpDt\n" << nl from Foam import fvc from Foam.finiteVolume import surfaceScalarField DpDt = fvc.DDt( surfaceScalarField(word("phiU"), phi / fvc.interpolate(rho)), p) from Foam.finiteVolume import MRFZones mrfZones = MRFZones(mesh) mrfZones.correctBoundaryVelocity(U) from Foam.finiteVolume import porousZones pZones = porousZones(mesh) from Foam.OpenFOAM import Switch pressureImplicitPorosity = Switch(False) return thermo, turbulence, p, h, psi, rho, U, phi, pMin, DpDt, mrfZones, pZones, pressureImplicitPorosity
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 readTimeControls_010401_dev( runTime ): from Foam.OpenFOAM import Switch, word, readScalar, GREAT adjustTimeStep = Switch( runTime.controlDict().lookup( word( "adjustTimeStep" ) ) ) maxCo = readScalar( runTime.controlDict().lookup( word( "maxCo" ) ) ) maxDeltaT = GREAT if runTime.controlDict().found( word( "maxDeltaT" ) ): maxDeltaT = readScalar( runTime.controlDict().lookup( word( "maxDeltaT" ) ) ) pass return adjustTimeStep, maxCo, maxDeltaT
def __init__(self, sigma): from Foam.finiteVolume import volSymmTensorField try: volSymmTensorField.ext_isinstance( sigma ) except TypeError: raise AssertionError( "args[ argc ].__class__ != volSymmTensorField" ) from Foam.OpenFOAM import IOobject, word, fileName IOdictionary.__init__(self, IOobject( word( "rheologyProperties" ), fileName( sigma.time().constant() ), sigma.db(), IOobject.MUST_READ, IOobject.NO_WRITE ) ) self.sigma_ = sigma self.typeName = word( "rheologyModel" ) from Foam.OpenFOAM import Switch self.planeStress_ = Switch( self.lookup( word( "planeStress" ) ) ) from materialModels.rheologyModel.rheologyLaws import rheologyLaw self.lawPtr_ = rheologyLaw.New( word( "law" ), self.sigma_, self.subDict( word( "rheology" ) ) ) pass
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 _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