CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[PyFoam] First discussion thread about PyFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 29, 2020, 16:26
Default
  #321
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Hi. The reason why the first residual is plotted is that usually you want to know "how bad is the solution we started with"


One possibility to get the data you want is to call the watcher like this

Code:
pyFoamPlotWatcher.py PyFoamRunner.pimpleFoam.logfile --write-files --single-data-files
Then in PyFoamRunner.pimpleFoam.logfile.analyzed/linear_p you'll find all the residuals for p and you can plot them with your favourite program


Altnative would be to add to the customRegexp-file something like this:

Code:
lastIteration {
    theTitle "Last residual";
    type dynamic;
    idNr 1;
    expr "^.+:  Solving for (.+), Initial residual = (.+), Final residual = .+, No Iterations [0-9]+.*$";
    titles (
        "last"
    );
    logscale yes;
    accumulation last;
}
firstIteration {
    $lastIteration;
    type dynamicslave;
    master lastIteration;
    accumulation first;
    titles (
        "first"
    );
}
Important is the "accumulation"-keyword that says "take the last version you find at each time-step. Default is "first" (guess what that means. Yep. The first found value is used).



"count", "sum", "min", "max" are also possible. Finding their meaning is left as an exercise to the reader
Hi gschaider,

Thanks a lot for your detailed response. Much appreciated.

Best Regards
Bodo1993 is offline   Reply With Quote

Old   March 30, 2020, 13:18
Default
  #322
New Member
 
Join Date: Mar 2020
Posts: 1
Rep Power: 0
Kasperr is on a distinguished road
@miguel.delasheras



Hi Miguel,
I'm in the same exact situation, with a docker type installation and the same warnings that I'm not able to resolve. Have you been able to understand the issue?

Last edited by Kasperr; March 30, 2020 at 13:23. Reason: lost the quoted message
Kasperr is offline   Reply With Quote

Old   October 29, 2020, 11:29
Default derivedParameters.py error when only one variable
  #323
New Member
 
David Blacher
Join Date: Jun 2020
Location: Vienna, Austria
Posts: 3
Rep Power: 6
cyberspeck is on a distinguished road
Hi everybody,


It seems that pyFoamPrepareCase.py throws the following error if only one variable is derived using a 'derivedParameters.py' script:


Code:
Traceback (most recent call last):
  File "/home/david/.local/bin/pyFoamPrepareCase.py", line 5, in <module>
    PrepareCase()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 143, in __init__
    **kwargs)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 495, in __init__
    result=self.run()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 664, in run
    self.prepare(sol,cName=cName)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 955, in prepare
    max(*[len(k) for k in derived]))
My derivedParameters.py file looks like this:
Code:
if Re < 2000:
    turbulence = 'laminar'
else:
    turbulence = 'RAS'
Found a temporary fix by removing the '*' in line 955.
Then everything seems to work fine, even if more than one variable is derived.


python 3.6.9
pyFoam-Version: 0.6.11
Some more info on my version in the attached file.


I'm relatively new to pyFoam so maybe this is no bug, but due to my incorrect usage. Has somebody else come across this issue?


Regards,
david
Attached Files
File Type: txt pyFoamVersion.txt (5.8 KB, 4 views)
cyberspeck is offline   Reply With Quote

Old   October 30, 2020, 06:04
Default error when not removing 0 directory
  #324
New Member
 
David Blacher
Join Date: Jun 2020
Location: Vienna, Austria
Posts: 3
Rep Power: 6
cyberspeck is on a distinguished road
Hi everybody,


Another issue I found happens when I run the command:
Code:
pyFoamRunParameterVariation.py elbow-2D-snappy ../geometry.variation --every-variant-one-case-execution --progress --auto-create-database
in order to create meshes for different STL files.
Since I neither require a "0" nor a "0.org" directory, the original case does not contain them.
Now the first variation runs fine, but during the second this shows up:
Code:
Clearing /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy
 PyFoam WARNING on line 685 of file /home/david/.local/lib/python3.6/site-packages/PyFoam/RunDictionary/SolutionDirectory.py : The first timestep in /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy  is  None not a number. Doing nothing
Writing parameters to /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy/PyFoamPrepareCaseParameters
Writing report to /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy/PyFoamPrepareCaseParameters.rst
Not going to clean '0'
Traceback (most recent call last):
  File "/home/david/.local/bin/pyFoamRunParameterVariation.py", line 5, in <module>
    RunParameterVariation()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/RunParameterVariation.py", line 84, in __init__
    **kwargs)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 143, in __init__
    **kwargs)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 495, in __init__
    result=self.run()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/RunParameterVariation.py", line 351, in run
    self.prepare(workCase,overrideParameters=usedVals)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 1123, in prepare
    self.opts.cleanDirectories.remove("0")
ValueError: list.remove(x): x not in list
It seeems that PrepareCase.py correctly realises that there is no '0' directory to be deleted during the clean up.
Consequently, it tries to remove 0" from the list of directories that need to be cleaned (excerpt starting at line 1121):

Code:
        if not hasOrig or self.opts.keepZero:
            self.info("Not going to clean '0'")
            self.opts.cleanDirectories.remove("0")
            cleanZero=False
The error above suggests that the "0" directory is already not on that list, so it cannot be removed from it. Hence the error.


I fixed it for now by adding an if-condition:
Code:
            if "0" in self.opts.cleanDirectories:
                self.opts.cleanDirectories.remove("0")
Don't know why this error does not occur during the first variation.
Maybe "0" is initially in the list of to-be-removed-directories, is then striked from that list during the first variation and then cannot be deleted from the list in any subsequent variations?


Not sure if this is the right place, but I couldn't find a better one to report bugs.
gschaider, where and how would you like me to report future bugs fixes or problems I might find?


Cheers,
david
cyberspeck is offline   Reply With Quote

Old   November 1, 2020, 17:44
Default
  #325
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by cyberspeck View Post
Hi everybody,


Another issue I found happens when I run the command:
Code:
pyFoamRunParameterVariation.py elbow-2D-snappy ../geometry.variation --every-variant-one-case-execution --progress --auto-create-database
in order to create meshes for different STL files.
Since I neither require a "0" nor a "0.org" directory, the original case does not contain them.
Now the first variation runs fine, but during the second this shows up:
Code:
Clearing /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy
 PyFoam WARNING on line 685 of file /home/david/.local/lib/python3.6/site-packages/PyFoam/RunDictionary/SolutionDirectory.py : The first timestep in /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy  is  None not a number. Doing nothing
Writing parameters to /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy/PyFoamPrepareCaseParameters
Writing report to /mnt/c/Users/BlacherD/programming/OpenFOAM/david-7/run/foam-elbow/elbow2D/snappy/geometry.variation_00001_elbow-2D-snappy/PyFoamPrepareCaseParameters.rst
Not going to clean '0'
Traceback (most recent call last):
  File "/home/david/.local/bin/pyFoamRunParameterVariation.py", line 5, in <module>
    RunParameterVariation()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/RunParameterVariation.py", line 84, in __init__
    **kwargs)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 143, in __init__
    **kwargs)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 495, in __init__
    result=self.run()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/RunParameterVariation.py", line 351, in run
    self.prepare(workCase,overrideParameters=usedVals)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 1123, in prepare
    self.opts.cleanDirectories.remove("0")
ValueError: list.remove(x): x not in list
It seeems that PrepareCase.py correctly realises that there is no '0' directory to be deleted during the clean up.
Consequently, it tries to remove 0" from the list of directories that need to be cleaned (excerpt starting at line 1121):

Code:
        if not hasOrig or self.opts.keepZero:
            self.info("Not going to clean '0'")
            self.opts.cleanDirectories.remove("0")
            cleanZero=False
The error above suggests that the "0" directory is already not on that list, so it cannot be removed from it. Hence the error.


I fixed it for now by adding an if-condition:
Code:
            if "0" in self.opts.cleanDirectories:
                self.opts.cleanDirectories.remove("0")
Don't know why this error does not occur during the first variation.
Maybe "0" is initially in the list of to-be-removed-directories, is then striked from that list during the first variation and then cannot be deleted from the list in any subsequent variations?


Not sure if this is the right place, but I couldn't find a better one to report bugs.
gschaider, where and how would you like me to report future bugs fixes or problems I might find?


Cheers,
david

Definitve place to report such things would be https://sourceforge.net/p/openfoam-e...ticketspyfoam/
As openening a fork and making a pull request on https://sourceforge.net/p/openfoam-e.../default/tree/ would probably be an overkill for this one-line fix (that does NOT mean that I don't appreciate the effort to come up with a solution) I'll add it to my local development version to make sure that it goes into the next release (with mention in the release notes unless you wish to remain anonymous)
__________________
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
gschaider is offline   Reply With Quote

Old   November 1, 2020, 17:59
Default
  #326
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by cyberspeck View Post
Hi everybody,


It seems that pyFoamPrepareCase.py throws the following error if only one variable is derived using a 'derivedParameters.py' script:


Code:
Traceback (most recent call last):
  File "/home/david/.local/bin/pyFoamPrepareCase.py", line 5, in <module>
    PrepareCase()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 143, in __init__
    **kwargs)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PyFoamApplication.py", line 495, in __init__
    result=self.run()
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 664, in run
    self.prepare(sol,cName=cName)
  File "/home/david/.local/lib/python3.6/site-packages/PyFoam/Applications/PrepareCase.py", line 955, in prepare
    max(*[len(k) for k in derived]))
My derivedParameters.py file looks like this:
Code:
if Re < 2000:
    turbulence = 'laminar'
else:
    turbulence = 'RAS'
Found a temporary fix by removing the '*' in line 955.
Then everything seems to work fine, even if more than one variable is derived.


python 3.6.9
pyFoam-Version: 0.6.11
Some more info on my version in the attached file.


I'm relatively new to pyFoam so maybe this is no bug, but due to my incorrect usage. Has somebody else come across this issue?


Regards,
david

OK. This one is embarrassing. Seems that in all the years I never wrote a derivedParamters.py that defined only one parameter because then I would have noticed it
I THINK the reason why I wrote it like this was that ancient Python-Versions did only do max as a function on numbers (not as a function of a single iterable). Your fix seems to work at least with Python 2.7 and up but I want to check for older versions before adding it to my codebase
__________________
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
gschaider is offline   Reply With Quote

Old   November 2, 2020, 01:08
Default
  #327
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Hi, I have a 2D geometry (x-y plane) and work with multiphase solver. I want to get the x-weighted average of phase fraction at each level of y (e.g. could reach to hundreds of y levels). Then, I want to repeat that for every time step. So, the output I am looking for is .csv or .txt files for each time step containing the averaged phase fraction data for all y levels.

I would appreciate any hints on how I can do that with swak4foam. Thanks
Bodo1993 is offline   Reply With Quote

Old   November 2, 2020, 19:21
Default
  #328
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Bodo1993 View Post
Hi, I have a 2D geometry (x-y plane) and work with multiphase solver. I want to get the x-weighted average of phase fraction at each level of y (e.g. could reach to hundreds of y levels). Then, I want to repeat that for every time step. So, the output I am looking for is .csv or .txt files for each time step containing the averaged phase fraction data for all y levels.

I would appreciate any hints on how I can do that with swak4foam. Thanks

I think the function object you look for is swakExpressionAverageDistribution.



A description can be found here (approximately after slide 198)

https://openfoamwiki.net/images/7/7a...icTraining.pdf
__________________
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
gschaider is offline   Reply With Quote

Old   November 3, 2020, 13:45
Default
  #329
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Quote:
Originally Posted by gschaider View Post
I think the function object you look for is swakExpressionAverageDistribution.



A description can be found here (approximately after slide 198)

https://openfoamwiki.net/images/7/7a...icTraining.pdf
Thank you. It looks like that it should do the job. From what I understood, the function can do the x-weighted averaging for the full length of y. However, I am not quite sure how can I tell it to do the x-averaging for a specified range of y (instead of the full length).

Also, what would be the proper way to call this function after the results are out, as a postProcessing?
Edit: the answer is that it does not work properly as a post-processing tool.

The output I am looking for is an averaged phase fraction in the x direction for each y level of the domain. Does 'swakExpressionAverageDistribution' outputs a table with a column for the x-averaged quantity and the corresponding y level in another column?
Edit: yes it does, but it has to run on the fly with the simulation.

I apologize if the questions above may be trivial, but I am quite new to swak4Foam. Thanks.

Last edited by Bodo1993; November 19, 2020 at 22:21.
Bodo1993 is offline   Reply With Quote

Old   November 17, 2020, 16:48
Default Stress tensor
  #330
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Hi, I am wondering if there is a way to extract the stress field (normal + shear) using swak4Foam. Thanks in advance.

Last edited by Bodo1993; November 19, 2020 at 22:20.
Bodo1993 is offline   Reply With Quote

Old   November 19, 2020, 22:23
Default
  #331
Senior Member
 
Join Date: Jul 2019
Posts: 148
Rep Power: 7
Bodo1993 is on a distinguished road
Quote:
Originally Posted by Bodo1993 View Post
Thank you. It looks like that it should do the job. From what I understood, the function can do the x-weighted averaging for the full length of y. However, I am not quite sure how can I tell it to do the x-averaging for a specified range of y (instead of the full length).

Also, what would be the proper way to call this function after the results are out, as a postProcessing?
Edit: the answer is that it does not work properly as a post-processing tool.

The output I am looking for is an averaged phase fraction in the x direction for each y level of the domain. Does 'swakExpressionAverageDistribution' outputs a table with a column for the x-averaged quantity and the corresponding y level in another column?
Edit: yes it does, but it has to run on the fly with the simulation.

I apologize if the questions above may be trivial, but I am quite new to swak4Foam. Thanks.
I am not still not quite sure how to tell the function to perform the line averaging on a specified region (not the whole domain).
I would appreciate any assistance.
Bodo1993 is offline   Reply With Quote

Old   January 12, 2021, 07:34
Default populate database of variation
  #332
New Member
 
David Blacher
Join Date: Jun 2020
Location: Vienna, Austria
Posts: 3
Rep Power: 6
cyberspeck is on a distinguished road
Hi all, dear gschaider,


I want to use pyFoamRunParameterVariation.py to start multiple jobs on our cluster.
However, I didn't have the time to configure pyFoam in the correct way for it to be able to submit jobs to the pbs queue itself for meshing and solving.
Instead, I put suitable 'qsub' commands in the script 'caseSetup.sh.template' which are executed by pyFoam.
I first run a parameter variation for meshing only, then I have another variation with new directories which copy the mesh from the previously run cases.

I use the options '--no-execute-solver --no-server-process --no-mesh-create --every-variant-one-case-execution --create-database'


This all works fine, but the database contains only little usefull information.
I guess, this is because pyFoam does not execute the solver itself and therefore doesn't read the logfiles during the runs.
Is there a command I can execute after the jobs are finished to populate the database?
Also, the '.analyzed' directory only contains the pickledPlots.
Is there a way to gather and pickle the data for each case automatically?


Thank you for your help!
cyberspeck is offline   Reply With Quote

Old   January 20, 2021, 12:54
Default pyFoam-2020.5 installation issue on OFv2012 Ubuntu 20.04 WSL2
  #333
New Member
 
Join Date: Dec 2020
Posts: 26
Rep Power: 6
OlivierM is on a distinguished road
Hello,

I followed the installation guide here below
https://openfoamwiki.net/index.php/C...m#Installation

I'm on Ubuntu 20.04 WSL2 with OFv2012.

First I notice that I am not able to use pip but pip3 instead.

Then I did the checking with python3 which was not succesfull for the last step:

>>> print PyFoam.FoamInformation.foamTutorials()

File "<stdin>", line 1
print PyFoam.FoamInformation.foamTutorials()
^
SyntaxError: invalid syntax

then I did

>>> print (sys.path)

['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/oml_400/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/local/lib/python3.8/dist-packages/PyFoam-2020.5-py3.8.egg', '/usr/lib/python3/dist-packages']


I also gave a try to start a run with pyFoamPlotRunner.py but this failed and returned the following:

Traceback (most recent call last):
File "/usr/local/bin/pyFoamPlotRunner.py", line 4, in <module>
__import__('pkg_resources').run_script('PyFoam==20 20.5', 'pyFoamPlotRunner.py')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1452, in run_script
raise ResolutionError( pkg_resources.ResolutionError: Script 'scripts/pyFoamPlotRunner.py' not found in metadata at '/home/oml_400/.local/lib/python3.8/site-packages/PyFoam-2020.5.dist-info'



it looks that the installation has partially failed but I can't find the issue

Would anyone get an idea how to fix this ?

Many thanks
OlivierM is offline   Reply With Quote

Old   February 23, 2021, 11:34
Default PyFoam using WSL bash environment variables are not recognised
  #334
New Member
 
Vera Stevers
Join Date: Feb 2021
Posts: 1
Rep Power: 0
AnnaVera is on a distinguished road
Hi all, I'm new to CFD and Linux for that matter...


So far I've used WSL2 (so on a windows computer) to run OpenFoam which is working fine, and if I run python script using PyFoam from WSL there also seems to be no proglem.

However I tried running this script from PyCharm on windows, because I find it works better, using the WSL python installation as the interpreter. (So basically running the exact same script, using the same python interpreter but from a different location). The script runs, and it works fine mostly, like I can import pyfoam packages and such, so that is not the problem. However it doesnt seem to recognise some of the OpenFoam commands, like the name of the solver and such. So I get messages like:


/bin/sh: 1: simpleFoam: not found

I think this is because the bash environment variables are not recognised in Windows, it doesn't seem to start the .bashrc script. Also, it seems unable to open some folders, as if I don't have the rights to be in that folder maybe? Like:



Can't open /bin/tools/CleanFunctions



I've been trying to get it to work but no luck so far.

Anyone else experienced something similar or has an idea how to fix this?

Thanks a lot!
AnnaVera is offline   Reply With Quote

Old   March 16, 2022, 10:03
Default
  #335
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
Hi
I compiled calcPressureDifference utility
https://openfoamwiki.net/index.php/C...sureDifference
and I ran the case from Wiki
https://openfoamwiki.net/index.php/C...eter_Variation

but I got such error:

Code:
Inlet velocity: 0.0
Last Time =  0
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/3715953/status'
Traceback (most recent call last):
  File "doInletVariation.py", line 47, in <module>
    deltaP=pUtil.get("deltaP")[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/3715968/status'
It seems that the website example code is not working.
Does anybody know how to fix it?
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   March 16, 2022, 19:35
Default
  #336
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gaza View Post
Hi
I compiled calcPressureDifference utility
https://openfoamwiki.net/index.php/C...sureDifference
and I ran the case from Wiki
https://openfoamwiki.net/index.php/C...eter_Variation

but I got such error:

Code:
Inlet velocity: 0.0
Last Time =  0
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/3715953/status'
Traceback (most recent call last):
  File "doInletVariation.py", line 47, in <module>
    deltaP=pUtil.get("deltaP")[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/3715968/status'
It seems that the website example code is not working.
Does anybody know how to fix it?

Problem probably is that the line

Code:
 pUtil.add("deltaP","Pressure at .* Difference .*\] (.+)")
did not match anything in the output of the calcPressureDifference-utility or that that utility does not work correctly. Have you tried running the utility by itself and checked the output?
__________________
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
gschaider is offline   Reply With Quote

Old   March 17, 2022, 09:48
Default
  #337
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
Hi Bernhard,
I am sorry for that. I should read the log files first. Everything is ok with the example code.
I had two mistakes:
1) I did not build mesh with blockMesh
2) I did not have calcPressureDifferenceDict file in the system directory.
After doing these, the code runs well. Thank you for help.


I only get in each time such a line
Code:
 PyFoam WARNING on line 66 of file /usr/local/lib/python2.7/dist-packages/PyFoam-0.6.6-py2.7.egg/PyFoam/LogAnalysis/ExecutionTimeLineAnalyzer.py : 9.73 s  ClockTime = 9 is not a valid number
Is it normal? Or did I do something wrong?


I have also the second question:
what this line basically do?
Code:
pUtil.add("deltaP","Pressure at .* Difference .*\] (.+)")
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   March 17, 2022, 13:47
Default
  #338
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gaza View Post
Hi Bernhard,
I am sorry for that. I should read the log files first. Everything is ok with the example code.
I had two mistakes:
1) I did not build mesh with blockMesh
2) I did not have calcPressureDifferenceDict file in the system directory.
After doing these, the code runs well. Thank you for help.


I only get in each time such a line
Code:
 PyFoam WARNING on line 66 of file /usr/local/lib/python2.7/dist-packages/PyFoam-0.6.6-py2.7.egg/PyFoam/LogAnalysis/ExecutionTimeLineAnalyzer.py : 9.73 s  ClockTime = 9 is not a valid number
Is it normal? Or did I do something wrong?

No. That means that an expression matched "9.73 s ClockTime = 9" which it can't convert to a number (probably it should have matched only 9.73). Reason is probably that the output of OF was changed since the example was written


Quote:
Originally Posted by gaza View Post
I have also the second question:
what this line basically do?
Code:
pUtil.add("deltaP","Pressure at .* Difference .*\] (.+)")

The second argument is a so called regular expression (google it). When a line matches then the part between the () is converted to a number and added as deltaP
gaza likes this.
__________________
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
gschaider is offline   Reply With Quote

Old   March 17, 2022, 15:05
Default
  #339
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16
gaza is on a distinguished road
Ok thank you.
I found this in your presentation which is very useful
https://regex101.com/
__________________
best regards
pblasiak
gaza 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
Divergence detected in AMG solver: k when udf loaded google9002 Fluent UDF and Scheme Programming 3 November 8, 2019 00:34
udf problem jane Fluent UDF and Scheme Programming 37 February 20, 2018 05:17
Guide: Getting Started with the CFD Online Discussion Forums pete Site Help, Feedback & Discussions 8 July 29, 2016 06:00
Error messages atg enGrid 7 August 30, 2013 12:16
Phase locked average in run time panara OpenFOAM 2 February 20, 2008 15:37


All times are GMT -4. The time now is 08:41.