CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Accessing foamDictionary keyword ".*"

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 5, 2021, 12:58
Default Accessing foamDictionary keyword ".*"
  #1
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
I have the following in my fvSolution file:

Code:
relaxationFactors
{
    equations
    {
        ".*"            0.9;
        U               0.7;
    }
}
and I want to use foamDictionary to change the values. For the U equation, this is simple, eg:

Code:
Eddy$ foamDictionary -entry relaxationFactors.equations.U -set 0.9 system/fvSolution
New entry U               0.9;
but how do I access the ".*" keyword? I can list the keywords for the relaxationFactors subditionary, viz
Code:
Eddy$ foamDictionary -entry relaxationFactors.equations -keywords system/fvSolution
".*"
U
and this confirms that foamDictionary thinks that the keyword is ".*". But if I try use this, with quotes to stop the wildcard expansion, foamDictionary spits its dummy out:
Code:
Eddy$ foamDictionary -entry 'relaxationFactors.equations.".*"' system/fvSolution
--> FOAM FATAL IO ERROR: 
Cannot find entry relaxationFactors.equations.".*"
Any idea how I can access the ".*" keyword?

Edit: ofc, I could do some dirty hacking with
Code:
sed 's/"\.\*"/banana/' system/fvSolution
to temporarily change the keyword before using foamDictionary, and then change it back, but that is just plain ugly, and may not work if I use ".*" elsewhere in the dictionary.
Tobermory is offline   Reply With Quote

Old   March 5, 2021, 15:53
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 14
clapointe is on a distinguished road
What if you just used sed to replace that entire line? Not as nice as getting foamDictionary to figure out the location for you, but will circumvent the problem you mentioned in the edit.

Caelan
__________________
Public git repository : https://github.com/clapointe2011/public
clapointe is offline   Reply With Quote

Old   March 5, 2021, 16:25
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
Thanks Caelen - yes, that could be a slightly less ugly solution. The good news (thanks to Henry for a quick bug report response) is that the problem is fixed at the moment in the dev version, which clearly has a more advanced suite of dictionary tools. I am just scratching my head now whether I want to (or indeed, can) splice these changes into my v8 distribution, or just live with the ugly hack approach.

Thanks for your input.
Tobermory is offline   Reply With Quote

Old   March 5, 2021, 16:46
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
The answer is - live with it for this patch; the dictionary system has been updated in dev, and will be available in the next major release.
clapointe likes this.
Tobermory is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] snappyHexMesh error "Cannot determine normal vector from patches." lethu OpenFOAM Meshing & Mesh Conversion 1 June 3, 2020 07:49
Problem calling foamDictionary in docker from a python notebook Hisham OpenFOAM Pre-Processing 0 January 7, 2020 07:52
[OpenFOAM.com] OpenFOAMv1806 with amd aocc 1.2 / 1.3 compiler cfdx OpenFOAM Installation 10 February 27, 2019 04:59
Fatal error: invalid wall function specification kcc49 OpenFOAM Running, Solving & CFD 13 September 26, 2018 04:07
chtMultiRegionSimpleFoam: crash on parallel run student666 OpenFOAM Running, Solving & CFD 3 April 20, 2017 11:05


All times are GMT -4. The time now is 10:33.