CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Problem calling foamDictionary in docker from a python notebook

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2020, 07:52
Default Problem calling foamDictionary in docker from a python notebook
Senior Member
Hisham's Avatar
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 13
Hisham is on a distinguished road
Dear Foamers,

I am trying to use the docker image under Windows (1912) and preparing a Jupyter notebook to manage the work. I issue docker commands using subprocesses because I did not have any luck with their Python SDK. Now I am getting familiar with foamDictionary by calling its commands from the notebook. It seems to work except for a special case where I get an error that I cannot decipher.

A Docker command that works from the notebook:
Code: exec containerName sh -c "\"source /opt/OpenFOAM/; cd case; foamDictionary system/controlDict -entry endTime -set 100\"")
The one that doesn't:
Code: exec containerName sh -c "\"source /opt/OpenFOAM/; cd case; foamDictionary 0/U -entry internalField -set \"uniform (0 0 0 )\"\"")
The foamDictionary command itself runs as expected if given directly inside the container! Calling by subprocess however results in (stderr):

/opt/OpenFOAM/OpenFOAM-v1912/etc/ eval: line 67: syntax error near unexpected token `)'
/opt/OpenFOAM/OpenFOAM-v1912/etc/ eval: line 67: `. /opt/OpenFOAM/OpenFOAM-v1912/etc/ 0 0 )'
I don't know how and when were these files called!

A clue could be in how Python issues the command to docker which most likely looks like:
"source /opt/OpenFOAM/; cd case; foamDictionary 0/U -entry internalField -set "uniform (0 0 0 )""
So how to pass the escape character to a function call to keep the "" instead of turning into "". And for why oh why are these bash scripts called, they are not called (directly!) from inside "foamDictionary.C".

I appreciate helpful pointers and grateful for a solution!

Best regards,
Hisham is offline   Reply With Quote


docker, foamdictionary, jupyter, notebook, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
compilation problem with "fvPatch::lookupPatchField" Ya_Squall2010 OpenFOAM Programming & Development 7 October 27, 2014 10:24
Installation problem - calling blockMesh - aylalisa OpenFOAM Installation 5 November 28, 2012 09:55
Gambit - meshing over airfoil wrapping (?) problem JFDC FLUENT 1 July 11, 2011 05:59
The problem of inner iteration when calling the subroutine guoxj CFX 18 October 23, 2010 20:37
OpenFoam-1.5 on Solaris -- compilation problem calling octreeDataPoint(.) constructor cincaipatron OpenFOAM Installation 9 January 11, 2010 06:37

All times are GMT -4. The time now is 05:06.