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

Problem calling foamDictionary in docker from a python notebook

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Hisham

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2020, 08:52
Default Problem calling foamDictionary in docker from a python notebook
  #1
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
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:
subprocess.run(docker exec containerName sh -c "\"source /opt/OpenFOAM/setImage_v1912.sh; cd case; foamDictionary system/controlDict -entry endTime -set 100\"")
The one that doesn't:
Code:
subprocess.run(docker exec containerName sh -c "\"source /opt/OpenFOAM/setImage_v1912.sh; 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):

Code:
/opt/OpenFOAM/OpenFOAM-v1912/etc/config.sh/functions: eval: line 67: syntax error near unexpected token `)'
/opt/OpenFOAM/OpenFOAM-v1912/etc/config.sh/functions: eval: line 67: `. /opt/OpenFOAM/OpenFOAM-v1912/etc/config.sh/paraview 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:
Code:
"source /opt/OpenFOAM/setImage_v1912.sh; 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
frantov likes this.
Hisham is offline   Reply With Quote

Reply

Tags
docker, foamdictionary, jupyter, notebook, python


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 9 November 15, 2021 23:01
Installation problem - calling blockMesh - libblockMesh.so aylalisa OpenFOAM Installation 5 November 28, 2012 10:55
Gambit - meshing over airfoil wrapping (?) problem JFDC FLUENT 1 July 11, 2011 06:59
The problem of inner iteration when calling the subroutine guoxj CFX 18 October 23, 2010 21:37
OpenFoam-1.5 on Solaris -- compilation problem calling octreeDataPoint(.) constructor cincaipatron OpenFOAM Installation 9 January 11, 2010 07:37


All times are GMT -4. The time now is 15:47.