Accompanies OnCFD Newsletter #082: Quick edits with foamDictionary
# Print the top-level keywords present in this dictionary
foamDictionary system/snappyHexMeshDict -keywords
# Print the addLayersControls sub-dictionary
foamDictionary system/snappyHexMeshDict -entry addLayersControls
# List the keywords in the addLayersControls sub-dictionary
foamDictionary system/snappyHexMeshDict -keywords -entry addLayersControls
# Print the ENTRY for nLayerIter in addLayersControls
foamDictionary system/snappyHexMeshDict -entry addLayersControls/nLayerIter
# Print the VALUE of nLayerIter in addLayersControls
foamDictionary system/snappyHexMeshDict -entry addLayersControls/nLayerIter -value
# Set the value for nLayerIter in addLayersControls to 100
foamDictionary system/snappyHexMeshDict -entry addLayersControls/nLayerIter -set 100
# Set a value as the result of another command
# eg set the number of subdomains = to the number of procs on the machine
foamDictionary system/decomposeParDict -entry numberOfSubdomains -set $(nproc)
# Add a new top-level entry with a vector
foamDictionary my-include-file -entry top-level-var -add "(1 2 3)"
# Add an empty sub-dictionary called newdict
foamDictionary my-include-file -entry newdict -add "{}"
# Add an entry called myvar into the newdict sub-dictionary
foamDictionary my-include-file -entry newdict/myvar -add 2000
# Add a complete sub-dictionary:
# eg. add a new geometry file into snappyHexMeshDict
foamDictionary system/snappyHexMeshDict -entry geometry/newgeom.obj \
-add "{type triSurfaceMesh; name my-new-geometry;}"
# Remove the complete "newgeom.obj" sub-dictionary
foamDictionary system/snappyHexMeshDict -entry geometry/newgeom.obj -remove
Thank you for your nice document. It helps me a lot.
I found an interesting issue about the foamDictionary command. When you try to set a value on an existing dictionary with some macro, the command seems to expand all the macros at first and then set the value. Do you know how to avoid this?