Menu

#61 adjust parser to read regexp from openfoam 1.7.x syntax

acknowledged
nobody
None
normal
feature
havenottried
none
The Library
general
2011-05-15
2011-05-14
fabian6
No

Hi,

it would be great, if the parser is able to handle the regexp from openfoam,i.e.

in the fvSolution file some settings for the relaxation could look like:

"(k|omega|epsilon)" 0.3;

or for the solver "p.*"{someSolver}, similar for the fields.

What do you think!?
Fabian

Discussion

  • Bernhard Gschaider

    I'd think that its already there in the released version. Try this code snipplet:

    from os import path,environ
    from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile

    fvsol=ParsedParameterFile(path.join(environ["FOAM_TUTORIALS"],
    ŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒ "heatTransfer/buoyantSimpleFoam/buoyantCavity",
    ŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒ "system/fvSolution"))
    assert(fvsol["relaxationFactors"]["omega"]==0.7)
    print fvsol["relaxationFactors"]["omega"]

     
  • fabian6

    fabian6 - 2011-05-15

    Yes, this works, you are right. Though if one tries to get all entries of the relxationFactors by
    print fvsol["relaxationFactors"]

    then the entry is missing:
    {'h': 0.29999999999999999, 'p_rgh': 0.69999999999999996, 'U': 0.29999999999999999, 'rho': 0.69999999999999996}

     
  • Bernhard Gschaider

    The problem is that the regular-expression key has to be treated separately. As it can theoretically have multiple values one can not put it into a regular dictionary.
    When printing the dictionary in OF-Format then the regular-expression will be printed. Check with pyFoamEchoDictionary.py

     

Log in to post a comment.