Exemplo n.º 1
0
    def __init__( self, runTime ):
        from Foam.OpenFOAM import IOobject, word, fileName
        IOdictionary.__init__( self, IOobject( word( "regionProperties" ), 
                                               fileName( runTime.time().constant() ), 
                                               runTime.db(), 
                                               IOobject.MUST_READ, 
                                               IOobject.NO_WRITE  ) )
        from Foam.OpenFOAM import wordList
        self.fluidRegionNames = wordList( self.lookup( word( "fluidRegionNames" ) ) )
        self.solidRegionNames = wordList( self.lookup( word( "solidRegionNames" ) ) )
	pass
Exemplo n.º 2
0
 def __init__(self, runTime):
     from Foam.OpenFOAM import IOobject, word, fileName
     IOdictionary.__init__(
         self,
         IOobject(word("regionProperties"),
                  fileName(runTime.time().constant()), runTime.db(),
                  IOobject.MUST_READ, IOobject.NO_WRITE))
     from Foam.OpenFOAM import wordList
     self.fluidRegionNames = wordList(self.lookup(word("fluidRegionNames")))
     self.solidRegionNames = wordList(self.lookup(word("solidRegionNames")))
     pass
Exemplo n.º 3
0
def compressibleCreatePhi(runTime, mesh, rhoU):
    from Foam.OpenFOAM import IOobject, word, fileName
    phiHeader = IOobject(word("phi"), fileName(runTime.timeName()), mesh,
                         IOobject.NO_READ)

    from Foam.OpenFOAM import ext_Info, nl
    if phiHeader.headerOk():
        ext_Info() << "Reading face flux field phi\n" << nl
        from Foam.finiteVolume import surfaceScalarField
        phi = surfaceScalarField(
            IOobject(word("phi"), fileName(runTime.timeName()), mesh,
                     IOobject.MUST_READ, IOobject.AUTO_WRITE), mesh)
        pass
    else:
        ext_Info() << "Calculating face flux field phi\n" << nl

        from Foam.OpenFOAM import wordList
        from Foam.finiteVolume import calculatedFvPatchScalarField
        phiTypes = wordList(2, calculatedFvPatchScalarField.typeName)
        from Foam.finiteVolume import surfaceScalarField, linearInterpolate
        phi = surfaceScalarField(
            IOobject(word("phi"), fileName(runTime.timeName()), mesh,
                     IOobject.NO_READ, IOobject.AUTO_WRITE),
            linearInterpolate(rhoU) & mesh.Sf(), phiTypes)
        pass

    return phiHeader, phi, phiTypes
Exemplo n.º 4
0
def correctPhi(runTime, mesh, phi, pd, rho, U, cumulativeContErr, nNonOrthCorr, pdRefCell, pdRefValue):

    from Foam.finiteVolume.cfdTools.incompressible import continuityErrs

    cumulativeContErr = continuityErrs(mesh, phi, runTime, cumulativeContErr)

    from Foam.OpenFOAM import wordList
    from Foam.finiteVolume import zeroGradientFvPatchScalarField

    pcorrTypes = wordList(pd.ext_boundaryField().size(), zeroGradientFvPatchScalarField.typeName)

    from Foam.finiteVolume import fixedValueFvPatchScalarField

    for i in range(pd.ext_boundaryField().size()):
        if pd.ext_boundaryField()[i].fixesValue():
            pcorrTypes[i] = fixedValueFvPatchScalarField.typeName
            pass
        pass

    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName, dimensionedScalar
    from Foam.finiteVolume import volScalarField

    pcorr = volScalarField(
        IOobject(word("pcorr"), fileName(runTime.timeName()), mesh, IOobject.NO_READ, IOobject.NO_WRITE),
        mesh,
        dimensionedScalar(word("pcorr"), pd.dimensions(), 0.0),
        pcorrTypes,
    )

    from Foam.OpenFOAM import dimTime

    rUAf = dimensionedScalar(word("(1|A(U))"), dimTime / rho.dimensions(), 1.0)

    from Foam.finiteVolume import adjustPhi

    adjustPhi(phi, U, pcorr)

    from Foam import fvc, fvm

    for nonOrth in range(nNonOrthCorr + 1):
        pcorrEqn = fvm.laplacian(rUAf, pcorr) == fvc.div(phi)

        pcorrEqn.setReference(pdRefCell, pdRefValue)
        pcorrEqn.solve()

        if nonOrth == nNonOrthCorr:
            phi.ext_assign(phi - pcorrEqn.flux())
            pass

    from Foam.finiteVolume.cfdTools.incompressible import continuityErrs

    cumulativeContErr = continuityErrs(mesh, phi, runTime, cumulativeContErr)

    pass
Exemplo n.º 5
0
def _correctPhi( runTime, mesh, p, rAU, phi, nNonOrthCorr, pRefCell, pRefValue, cumulativeContErr ):
    if mesh.changing():
       for patchi in range( U.boundaryField().size() ):
           if U.boundaryField()[patchi].fixesValue():
              U.boundaryField()[patchi].initEvaluate()
              pass
           pass
       for patchi in range( U.boundaryField().size() ):
           if U.boundaryField()[patchi].fixesValue():
              U.boundaryField()[patchi].evaluate()
              phi.boundaryField()[patchi].ext_assign( U.boundaryField()[patchi] & mesh.Sf().boundaryField()[patchi] )
              pass
           pass
       pass
       
    from Foam.OpenFOAM import wordList
    from Foam.finiteVolume import zeroGradientFvPatchScalarField
    pcorrTypes = wordList( p.ext_boundaryField().size(), zeroGradientFvPatchScalarField.typeName )
    
    from Foam.finiteVolume import fixedValueFvPatchScalarField
    for i in range( p.ext_boundaryField().size() ):
        if p.ext_boundaryField()[i].fixesValue():
           pcorrTypes[i] = fixedValueFvPatchScalarField.typeName
           pass
        pass
    
    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOobject, word, fileName, dimensionedScalar
    pcorr = volScalarField( IOobject( word( "pcorr" ),
                                      fileName( runTime.timeName() ),
                                      mesh(),
                                      IOobject.NO_READ,
                                      IOobject.NO_WRITE ),
                            mesh(),
                            dimensionedScalar( word( "pcorr" ), p.dimensions(), 0.0),
                            pcorrTypes )
     
    for nonOrth in range( nNonOrthCorr + 1 ):
        from Foam import fvm,fvc
        pcorrEqn = ( fvm.laplacian( rAU, pcorr ) == fvc.div( phi ) )

        pcorrEqn.setReference(pRefCell, pRefValue)
        pcorrEqn.solve()

        if nonOrth == nNonOrthCorr:
           phi.ext_assign( phi - pcorrEqn.flux() )
           pass
        pass
    from Foam.finiteVolume.cfdTools.general.include import ContinuityErrs
    cumulativeContErr = ContinuityErrs( phi, runTime, mesh, cumulativeContErr )     

    return cumulativeContErr
Exemplo n.º 6
0
def _correctPhi(runTime, mesh, p, rAU, phi, nNonOrthCorr, pRefCell, pRefValue,
                cumulativeContErr):
    if mesh.changing():
        for patchi in range(U.boundaryField().size()):
            if U.boundaryField()[patchi].fixesValue():
                U.boundaryField()[patchi].initEvaluate()
                pass
            pass
        for patchi in range(U.boundaryField().size()):
            if U.boundaryField()[patchi].fixesValue():
                U.boundaryField()[patchi].evaluate()
                phi.boundaryField()[patchi].ext_assign(
                    U.boundaryField()[patchi]
                    & mesh.Sf().boundaryField()[patchi])
                pass
            pass
        pass

    from Foam.OpenFOAM import wordList
    from Foam.finiteVolume import zeroGradientFvPatchScalarField
    pcorrTypes = wordList(p.ext_boundaryField().size(),
                          zeroGradientFvPatchScalarField.typeName)

    from Foam.finiteVolume import fixedValueFvPatchScalarField
    for i in range(p.ext_boundaryField().size()):
        if p.ext_boundaryField()[i].fixesValue():
            pcorrTypes[i] = fixedValueFvPatchScalarField.typeName
            pass
        pass

    from Foam.finiteVolume import volScalarField
    from Foam.OpenFOAM import IOobject, word, fileName, dimensionedScalar
    pcorr = volScalarField(
        IOobject(word("pcorr"), fileName(runTime.timeName()), mesh(),
                 IOobject.NO_READ, IOobject.NO_WRITE), mesh(),
        dimensionedScalar(word("pcorr"), p.dimensions(), 0.0), pcorrTypes)

    for nonOrth in range(nNonOrthCorr + 1):
        from Foam import fvm, fvc
        pcorrEqn = (fvm.laplacian(rAU, pcorr) == fvc.div(phi))

        pcorrEqn.setReference(pRefCell, pRefValue)
        pcorrEqn.solve()

        if nonOrth == nNonOrthCorr:
            phi.ext_assign(phi - pcorrEqn.flux())
            pass
        pass
    from Foam.finiteVolume.cfdTools.general.include import ContinuityErrs
    cumulativeContErr = ContinuityErrs(phi, runTime, mesh, cumulativeContErr)

    return cumulativeContErr
Exemplo n.º 7
0
def correctPhi( runTime, mesh, phi, p, rho, U, cumulativeContErr, nNonOrthCorr, pRefCell, pRefValue ):
    
    from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
    cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )
    from Foam.OpenFOAM import wordList
    from Foam.finiteVolume import zeroGradientFvPatchScalarField
    pcorrTypes = wordList( p.ext_boundaryField().size(), zeroGradientFvPatchScalarField.typeName )
    
    from Foam.finiteVolume import fixedValueFvPatchScalarField
    for i in range( p.ext_boundaryField().size() ):
       if p.ext_boundaryField()[i].fixesValue():
          pcorrTypes[i] = fixedValueFvPatchScalarField.typeName
          pass
       pass
    
    from Foam.OpenFOAM import IOdictionary, IOobject, word, fileName, dimensionedScalar
    from Foam.finiteVolume import volScalarField
    pcorr = volScalarField( IOobject( word( "pcorr" ),
                                      fileName( runTime.timeName() ),
                                      mesh,
                                      IOobject.NO_READ,
                                      IOobject.NO_WRITE ),
                            mesh,
                            dimensionedScalar( word( "pcorr" ), p.dimensions(), 0.0 ),
                            pcorrTypes  )
    
    from Foam.OpenFOAM import dimTime
    rUAf = dimensionedScalar( word( "(1|A(U))" ), dimTime / rho.dimensions(), 1.0)
    
    from Foam.finiteVolume import adjustPhi
    adjustPhi(phi, U, pcorr)
    
    from Foam import fvc, fvm
    for nonOrth in range( nNonOrthCorr + 1 ):
        pcorrEqn = fvm.laplacian( rUAf, pcorr ) == fvc.div( phi )

        pcorrEqn.setReference(pRefCell, pRefValue)
        pcorrEqn.solve()

        if nonOrth == nNonOrthCorr:
           phi.ext_assign( phi  - pcorrEqn.flux() )
           pass
    
    from Foam.finiteVolume.cfdTools.incompressible import continuityErrs
    cumulativeContErr = continuityErrs( mesh, phi, runTime, cumulativeContErr )
    
    pass
Exemplo n.º 8
0
def main_standalone( argc, argv ):

    from Foam.OpenFOAM.include import setRootCase
    args = setRootCase( argc, argv )

    import os
    root_dir = os.path.join( str( args.rootPath() ), str( args.caseName() ) )

    from Foam.OpenFOAM.include import createMesh
    timeSource = createTime( root_dir, "coarse_mesh" )
    meshSource = createMesh( timeSource )
    
    from Foam.OpenFOAM.include import createMesh
    timeTarget = createTime( root_dir, "fine_mesh" )
    meshTarget = createMesh( timeTarget )

    from Foam.OpenFOAM import wordHashTable, word
    # List of pairs of source/target patches for mapping
    patchMap = wordHashTable()
    #patchMap.insert( word( "lid" ), word( "movingWall" ) )
    
    from Foam.OpenFOAM import wordList, word
    # List of target patches cutting the source domain (these need to be
    # handled specially e.g. interpolated from internal values)
    cuttingPatches = wordList()
    #cuttingPatches = wordList( 1, word( "fixedWalls" ) )

    aName2VolField = extractVolFields( meshSource )

    modifyScalarField( aName2VolField[ 'p' ])
    modifyVectorField( aName2VolField[ 'U' ] )

    aName2VolField = mapVolFields( aName2VolField, meshSource, meshTarget, patchMap, cuttingPatches )

    ext_Info() << "\nEnd\n"

    import os
    return os.EX_OK
Exemplo n.º 9
0
def compressibleCreatePhi( runTime, mesh, rhoU ):
    from Foam.OpenFOAM import IOobject, word, fileName
    phiHeader = IOobject( word( "phi" ),
                          fileName( runTime.timeName() ),
                          mesh,
                          IOobject.NO_READ )
    
    from Foam.OpenFOAM import ext_Info, nl
    if phiHeader.headerOk():
       ext_Info() << "Reading face flux field phi\n" << nl
       from Foam.finiteVolume import surfaceScalarField
       phi = surfaceScalarField( IOobject( word( "phi" ),
                                           fileName( runTime.timeName() ),
                                           mesh,
                                           IOobject.MUST_READ,
                                           IOobject.AUTO_WRITE ),
                                 mesh )
       pass
    else:
       ext_Info() << "Calculating face flux field phi\n" << nl
       
       from Foam.OpenFOAM import wordList
       from Foam.finiteVolume import calculatedFvPatchScalarField
       phiTypes =wordList( 2, calculatedFvPatchScalarField.typeName )
       from Foam.finiteVolume import surfaceScalarField, linearInterpolate
       phi = surfaceScalarField( IOobject( word( "phi" ),
                                           fileName( runTime.timeName() ),
                                           mesh,
                                           IOobject.NO_READ,
                                           IOobject.AUTO_WRITE ),
                                 linearInterpolate( rhoU ) & mesh.Sf(),
                                 phiTypes )
       pass
       
    
    return phiHeader, phi, phiTypes