diff --git a/foamlib/_dictionaries.py b/foamlib/_dictionaries.py index fb13f01..e20e1de 100644 --- a/foamlib/_dictionaries.py +++ b/foamlib/_dictionaries.py @@ -23,7 +23,19 @@ else: numpy = True -from pyparsing import Group, Keyword, Opt, ZeroOrMore, Literal, Forward, common +from pyparsing import ( + Forward, + Group, + Keyword, + Literal, + OneOrMore, + Opt, + Word, + ZeroOrMore, + common, + identchars, + identbodychars, +) FoamDimensionSet = namedtuple( "FoamDimensionSet", @@ -66,6 +78,7 @@ def __post_init__(self) -> None: _YES = Keyword("yes").set_parse_action(lambda s, loc, tks: True) _NO = Keyword("no").set_parse_action(lambda s, loc, tks: False) +_WORDS = OneOrMore(Word(identchars, identbodychars+"(),")).set_parse_action(lambda s, loc, tks: " ".join(tks)) _VALUE = Forward() _LIST = Opt( Literal("List") + Literal("<") + common.identifier + Literal(">") @@ -91,14 +104,7 @@ def __post_init__(self) -> None: ) _VALUE << ( - _FIELD - | _LIST - | _DIMENSIONED - | _DIMENSIONS - | common.number - | _YES - | _NO - | common.identifier + _FIELD | _LIST | _DIMENSIONED | _DIMENSIONS | common.number | _YES | _NO | _WORDS ) diff --git a/tests/test_dictionaries.py b/tests/test_dictionaries.py index a8419f2..3b7c668 100644 --- a/tests/test_dictionaries.py +++ b/tests/test_dictionaries.py @@ -162,3 +162,11 @@ def test_internal_field(pitz: FoamCase) -> None: assert u == pytest.approx(u_arr) pitz.run() + + +def test_fv_schemes(pitz: FoamCase) -> None: + div_schemes = pitz.fv_schemes["divSchemes"] + assert isinstance(div_schemes, FoamDictionary) + scheme = div_schemes["div(phi,U)"] + assert isinstance(scheme, str) + assert scheme == "bounded Gauss linearUpwind grad(U)"