|
[Sponsors] |
December 22, 2017, 06:50 |
modifying Dictionary
|
#1 |
Member
Join Date: Jul 2010
Posts: 55
Rep Power: 16 |
Hi,
I would like to write a Python/PyFoam script to modify a base setup and perform batch runs. I have a file called "initialConditions" in "0/include" directory which I define initial values. I would like to modify the values within this file. To do so I use "ParsedParameterFile" but when I run my script I get the following error: Code:
PyFoam.RunDictionary.ParsedParameterFile.PyFoamParserError: Error in PyFoamParser: 'Syntax error in file /media/Data/Work_Research/Codes/OFSims/sim/OF4x/Large_domain/test_PyFoam/Test/ClonedCase/0/include/initialConditions at token' @ 'flowVelocity' (Type: NAME ) in line 9 at position 561 I would really appreciate any comments and suggestions. Many thanks Ashkan Last edited by ashkan; December 24, 2017 at 00:57. |
|
December 24, 2017, 00:59 |
|
#2 |
Member
Join Date: Jul 2010
Posts: 55
Rep Power: 16 |
Problem solved
|
|
September 8, 2021, 15:45 |
|
#3 |
Member
Gabriel Felix
Join Date: May 2021
Location: Brazil
Posts: 35
Rep Power: 6 |
||
September 9, 2021, 08:57 |
|
#4 |
Member
Gabriel Felix
Join Date: May 2021
Location: Brazil
Posts: 35
Rep Power: 6 |
I have found the problem. In my initialConditions file there was spaces instead of tabs in the indentation. I just had to substitute them and certify that all the indentation was made with tabs.
The ParsedParameterFile worked fine after this modification. Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2012 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ flowVelocity (0 -20 0); // m/s flowStaticPressure 101325; // Pa flowTemperature 298; // K nuTildaVal 4.5e-5; // m^2/s nutVal 3.5e-6; // m^2/s rhoVal 1.225; // kg/m^3 nuVal 1.5e-5; // m^2/s epsilonVal 0.0495; // m^2/s^3 kVal 0.06; // m^2/s^2 // ************************************************************************* // |
|
September 9, 2021, 19:55 |
|
#5 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
That is strange. If the parser had a tab/space problem I would expect it to fail on tabs. Simply because I usually make my text editor write tabs as spaces (and therefore could have missed tabs-related problems)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
September 9, 2021, 20:19 |
|
#6 |
Member
Gabriel Felix
Join Date: May 2021
Location: Brazil
Posts: 35
Rep Power: 6 |
In my file there were spaces and tabs mixed. I had had edited the file and in some places there were spaces and on others tabs. So the parser must hava had trouble on dealing with tabs and spaces mixed.
|
|
September 12, 2021, 18:19 |
|
#7 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Could you provide me with an example file?
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
|
September 13, 2021, 14:38 |
|
#8 | ||
Member
Gabriel Felix
Join Date: May 2021
Location: Brazil
Posts: 35
Rep Power: 6 |
I took another look into it and realised that the error was in my editor. I usually edit the OF files in Notepad++, as I use WSL. When I use tab to indent in Notepad++ it adds a different number of spaces than which was already in the file causing problems in indentation. I used nano to check the file after editiong in npp, as npp shown no indentation problems.
In this topic the user had the same problem as I, and the solution that the community came up with worked fine for me. However, I still check in nano if there are indentation issues on the file before running it. Quoating the discussion: Question: Quote:
Quote:
|
|||
September 14, 2021, 14:50 |
|
#9 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Still strange. The different Tabs and Spaces shouldn't matter for an OpenFOAM-File. For a Python file: yes
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
Tags |
parsedparameterfile, pyfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ill defined primitiveEntry starting at keyword 'value' on line 197 ChangeDictionary | Struggle_Achieve | OpenFOAM Pre-Processing | 2 | December 20, 2017 04:58 |
Including lists in a dictionary. | Divyaprakash | OpenFOAM Programming & Development | 0 | June 18, 2015 07:14 |
New Boundary Condition: Reading Dictionary Problem | Koga | OpenFOAM Programming & Development | 0 | November 26, 2012 06:01 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 07:51 |
FoamX error aachenBomb case | Ervin Adorean (Adorean) | OpenFOAM Pre-Processing | 13 | March 7, 2005 04:50 |