|
[Sponsors] |
July 25, 2016, 13:59 |
Accessing Pressure in my OpenFOAM code
|
#1 | ||
New Member
Dominic
Join Date: May 2016
Posts: 27
Rep Power: 10 |
Hello, I'd like a way to access the pressure parameter in my test case through OpenFOAM syntax. So far, the answers I've seen only refer me to this method:
Quote:
Quote:
|
|||
July 25, 2016, 15:53 |
|
#2 | |
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 13 |
Hi Verse,
where do you use this line of code? Is it in the main function? If it is, you can do it this way Quote:
|
||
July 25, 2016, 16:51 |
|
#3 |
New Member
Dominic
Join Date: May 2016
Posts: 27
Rep Power: 10 |
Hi Jerry, thank you for the answer, it works terrifically.
I was wondering if I could do the same with a different file of a different type, namely pointMotionU? I tried the following and I seem to have run into a different error... Code:
const pointVectorField& MotionU = mesh.lookupObject<pointVectorField>("pointMotionU"); Code:
error: forward declaration of ‘class Foam::pointMesh’ class pointMesh; |
|
July 25, 2016, 18:24 |
|
#4 |
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 13 |
Hi Verse,
I think the problem is because of pointVectorField. Try to replace it with vectorField. It might work. |
|
July 26, 2016, 10:18 |
|
#5 |
New Member
Dominic
Join Date: May 2016
Posts: 27
Rep Power: 10 |
Hi Jerry, the solution turned out to be a bit more complicated, but doing this helped solve the problem:
Code:
pointVectorField& MotionU = const_cast<pointVectorField&> ( mesh.objectRegistry::lookupObject<pointVectorField> ( "pointMotionU" ) ); Thank you for the help! |
|
July 26, 2016, 11:25 |
|
#6 | |
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 13 |
Hi Verse,
You are right. The const_cast has to be added in front to cast away the constness as lookupObject returns const type variable. Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to call 'p' as pressure into my code from OpenFOAM? | atmcfd | OpenFOAM Programming & Development | 9 | March 25, 2016 18:13 |
Parallelizing a code that involves OpenFOAM | Nicolas Périnet | OpenFOAM | 3 | November 24, 2011 01:27 |
Neumann pressure BC and velocity field | Antech | Main CFD Forum | 0 | April 25, 2006 03:15 |
Gas pressure question | Dan Moskal | Main CFD Forum | 0 | October 24, 2002 23:02 |
Hydrostatic pressure in 2-phase flow modeling (CFX4.2) | HB &DS | CFX | 0 | January 9, 2000 14:19 |