예제 #1
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
예제 #2
0
def __mapVolField__( theSourceField, meshToMeshInterp, patchMap, cuttingPatches ) :
    aTargetField = None
    
    meshTarget = meshToMeshInterp.toMesh()
    aFieldName = theSourceField.name()

    aFieldClass = getFieldClass( theSourceField )
    if aFieldClass.ext_foundObject( meshTarget, aFieldName ) :
        aTargetField = aFieldClass.ext_lookupObject( meshTarget, aFieldName )
    else:
        from Foam.OpenFOAM import IOobject, fileName    
        aTargetIOobject = IOobject( aFieldName,
                                    fileName( meshTarget.time().timeName() ),
                                    meshTarget,
                                    IOobject.READ_IF_PRESENT,
                                    IOobject.AUTO_WRITE )
        if aTargetIOobject.headerOk() :
            aTargetField = aFieldClass( aTargetIOobject, meshTarget )
            pass
        pass
    
    from Foam import fvc
    meshSource = meshToMeshInterp.fromMesh()
    ext_Info() << tab <<"interpolating \"" << aFieldName << "\"" << nl
    ext_Info() << tab << tab << "source : \"" << meshSource.time().path() << "\"" << nl
    ext_Info() << tab << tab << tab << fvc.domainIntegrate( theSourceField ) << nl
    ext_Info() << tab << tab << tab << theSourceField.ext_min() << nl
    ext_Info() << tab << tab << tab << theSourceField.ext_max() << nl

    from Foam.sampling import meshToMesh
    meshToMeshInterp.interpolate( aTargetField, theSourceField, meshToMesh.INTERPOLATE )

    ext_Info() << tab << tab << "target : \"" << meshTarget.time().path() << "\"" << nl
    ext_Info() << tab << tab << tab << fvc.domainIntegrate( aTargetField ) << nl
    ext_Info() << tab << tab << tab << aTargetField.ext_min() << nl
    ext_Info() << tab << tab << tab << aTargetField.ext_max() << nl
   
    return aTargetField
예제 #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