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

Read in Formula via Dictionary

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 23, 2016, 08:43
Default Read in Formula via Dictionary
  #1
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Hi guys,

quick question, I created an own Dict and reading in a formular via
Code:
word    cd(word(sensorDict.subDict("solving").lookup("cd")));
where cd is defined in the dict as:
Code:
cd            "1+10*Foam::exp(Re,0.66666667)";
Next I want to use this relation in my main loop, so I need to convert this word string to what exactly?

Thanks for help
hxaxtma is offline   Reply With Quote

Old   January 25, 2016, 04:28
Default
  #2
Senior Member
 
Join Date: Jan 2014
Posts: 179
Rep Power: 12
hxaxtma is on a distinguished road
Hi, I tried with
Code:
 #include <cstdlib>
scalar cd_form=atof(cd.c_str());
Code is now compiling and it is printing the formula as string, but not using it as mathematical operator.

Any ideas?
hxaxtma is offline   Reply With Quote

Old   January 25, 2016, 04:29
Default
  #3
Senior Member
 
Join Date: Oct 2013
Posts: 397
Rep Power: 19
chriss85 will become famous soon enough
This means you will need to have a parser/interpreter. I'm not sure if there is one in OpenFOAM, yiou might have some luck with swak4Foam though.
chriss85 is offline   Reply With Quote

Old   January 27, 2016, 12:47
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
I think you might want equationReader.

swak4Foam could be suitable, but if you want to parse a user-entered equation and use it at your discretion within your application, then that is exactly what equationReader was intended for. Be careful, though... any interpreted equations will take longer to evaluate than hard-coded equations.
__________________
~~~
Follow me on twitter @DavidGaden
marupio 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
Read properties per component from an input file dictionary Cyp OpenFOAM Programming & Development 29 November 1, 2015 22:41
Including lists in a dictionary. Divyaprakash OpenFOAM Programming & Development 0 June 18, 2015 07:14
writing subDict in a dictionary ubaid OpenFOAM Programming & Development 3 October 25, 2014 18:17
Reading a field(?) within a dictionary ecbmxer OpenFOAM Programming & Development 0 July 14, 2014 17:21
Overwriting dictionary from BC Phicau OpenFOAM Programming & Development 1 January 25, 2013 05:24


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