CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   How to extract Cp values at inlet (

tangd August 8, 2006 03:29

If I declare a variable like:
If I declare a variable like:

const fvPatchVectorField& Up =

I get Up value from inlet. But it seems like there is no such declaration for heat capacity Cp so that I can also obtain its values at inlet. My question is how I can get Cp values(inlet)? Thanks!

tangd August 8, 2006 07:59

Sorry, here the question chang
Sorry, here the question changes. If I use janafThermo, the Cp is computed by a function about T. In the code of specieThermo.H, I found:

inline scalar Cp(const scalar T) const;

I guess this Cp is computed from T, right? So how do I access Cp(const scalar T)? Thanks!

fabianpk August 8, 2006 09:46

Here's how I figured it out.
Here's how I figured it out.

Go to the solves directory, /OpenFOAM-1.3/applications/solvers

Surely, some of the solvers use Cp(T), so let's see if one does with this command:

grep Cp * -RI

Oh, it turns out, alot of them also use Cpu time, so lets remove those hits:

grep Cp * -RI | grep -v Cpu

Ahh, the solve dieselEngineFoam uses Cp (which sounds natural), so if you go to combustion/dieselEngineFoam/hEqn.H

you'll see an example of how it's used in the code. the chemistryModel chemistry is defined in createFields.H of the same solver.


tangd August 9, 2006 01:43

Thanks for your information. B
Thanks for your information. By the way, I'm using sonicTurbFoam which doesn't have anything to do with combustion. Is there other possibility to get Cp(T)?

If dieselEngineFoam is helpful to my case, but I don't know how to import this chemistry stuff into my code due to my poor C++ knowledge. Could you advise me more, if I want to access Cp(T)? Thank you for your help!

stefanke August 9, 2006 02:31

you have to instance an approp
you have to instance an appropiate (see l#a16) 'thermo' object which has a member function 'Cp'


autoPtr<hthermo> thermo

The class hThermo comes with the following member function:
tmp<scalarfield> Cp (const scalarField &T, const label patchi)


tangd August 9, 2006 02:48

Thanks! I know what you meant
Thanks! I know what you meant here. But this Cp is scalarField, I also tried this before, what I got is the Cp values at inlet. I want to use the scalar Cp which I think is defined in specieThermo.H:

inline scalar Cp(const scalar T) const;

Is there any way to get this Cp? Thanks again!

tangd August 10, 2006 02:35

I am aware of that this is a C
I am aware of that this is a C++ problem: given the class template, how to access its member? It is kind of hard for me to handle due to my poor C++ skill. Can somebody show me how to manage to do that? Thanks!

tangd August 10, 2006 08:41

I tried my way to define an ob
I tried my way to define an object whose type is specieThermo<class>, that is what I did so far:

first include "specieThermo.H", and declare an object:
specieThermo<scalar> test(scalar);

I expected the object "test" has the member Cp(T). But it doesn't behave the way I hoped. The error message is:

error: request for member 'Cp' in 'Foam::test', which is of non-class type 'Foam::specieThermo<double> ()(Foam::scalar)'

Then I tried to output the object "test" to see what I can get. Then the warning showed up:

warning: the address of 'Foam::specieThermo<double> Foam::testing(Foam::scalar)', will always evaluate as 'true'

What does that mean? I think I did something wrong. So what mistake I did? Please give me some information. Thank you!

tangd August 14, 2006 03:17

I found that there is an examp
I found that there is an example about how to define thermo type in equilibriumFlameT.C, which is:

typedef specieThermo<janafthermo<perfectgas> > thermo;

I think that is the thermo type I need to input when I declare an object specieThermo<thermo> test(thermo); So I guess the next step would be declare a thermo object in order to access Cp(T) value. The format is in my opinion:


Am I right? But I don't understand how to create this objectOfThermo and the mechanism behind this. I just guess objectOfThermo should be related to "thermophysicalProperties". I'm very eager to know if I am on the right way, please give some tips! Thanks!

All times are GMT -4. The time now is 12:00.