CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   how can see Cp values? (https://www.cfd-online.com/Forums/openfoam-post-processing/115303-how-can-see-cp-values.html)

wyldckat April 7, 2013 10:59

About funkyDoCalc - answered here: http://www.cfd-online.com/Forums/ope...tml#post418889

immortality April 9, 2013 06:14

dear Bruno thank you.the Cp tool seems to work nice and the problem is resolved well.
Then this topic is closed for futurers now and will be opened if anyone has a question.

immortality April 19, 2013 14:05

I have to ask another question about Cp.
how can I add the field of Cp in the solver?(I want to use that in calculating total pressure)
thanks.:)

wyldckat April 19, 2013 16:09

Hi Ehsan,

In essence, the same way as these two tutorials:
If you study the two tutorials, you'll see that the stuff on the second tutorial is placed into the icoFoam solver!

Have fun! Best regards,
Bruno

immortality April 20, 2013 14:49

thank you.I read them carefully.very suitable.
but Cp is a field that I think should be calculated by the solver itself.but it is not in creatFields.H
I had added Cp in createFields.H without any success before.
I think I can calculate total pressure without any need to Cp from the formula:p0=p+1/2*rho*sqr(U) instead of isentropic relation.because the difference is so little.but how to do this?
add this in solver or can obtain it on inlet and outlet patches like p by (I prefer swak4Foam because it calculates values in each time step not only in writing times) postProcessing functions?

gork June 25, 2013 10:04

Dear Fomers,

I am having issues on the same topic. I need to write out either the Cp or kappa field.
As far as I understand, there are 3 possibilities:
1) changing the filed definition from NO_WRITE to MUST_WRITE?
2) using a post-processing utility?
3) using the writeRegisteredObject function in controlDict

I am using a MultiRegionSolver based on chtMultiRegionFoam in OF 2.2.0 with

thermoType
{
type heRhoThermo;
mixture multiComponentMixture;
transport polynomial;
thermo janaf;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}

I did not get one of the possible ways working:
1) I did not find where Cp or kappa fields are created and where to manage the output

2) I tried to combine the specificHeat utility presented by wyldckat with the wallHeatFlux utility in order to cope with MultiRegions. Ends up with the error:

HTML Code:

Not Implemented
    Trying to construct an genericFvPatchField on patch SphereFront_Gas of field h

    From function genericFvPatchField<Type>::genericFvPatchField(const fvPatch& p, const DimensionedField<Type, volMesh>& iF)
    in file genericFvPatchField/genericFvPatchField.C at line 44.

FOAM aborting
#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::error::abort() in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  Foam::genericFvPatchField<double>::genericFvPatchField(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libgenericPatchFields.so"
#3  Foam::fvPatchField<double>::addpatchConstructorToTable<Foam::genericFvPatchField<double> >::New(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libgenericPatchFields.so"
#4  Foam::fvPatchField<double>::New(Foam::word const&, Foam::word const&, Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#5  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::GeometricBoundaryField(Foam::fvBoundaryMesh const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::List<Foam::word> const&, Foam::List<Foam::word> const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#6  at rhoReactionThermos.C:0
#7  Foam::heThermo<Foam::rhoReactionThermo, Foam::SpecieMixture<Foam::multiComponentMixture<Foam::polynomialTransport<Foam::species::thermo<Foam::janafThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleEnthalpy>, 8> > > >::heThermo(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyReactionThermophysicalModels.so"
#8  Foam::rhoThermo::addfvMeshConstructorToTable<Foam::heRhoThermo<Foam::rhoReactionThermo, Foam::SpecieMixture<Foam::multiComponentMixture<Foam::polynomialTransport<Foam::species::thermo<Foam::janafThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleEnthalpy>, 8> > > > >::New(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyReactionThermophysicalModels.so"
#9  Foam::autoPtr<Foam::rhoThermo> Foam::basicThermo::New<Foam::rhoThermo>(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#10  Foam::rhoThermo::New(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#11 
 in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/bin/specificHeat"
#12  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#13 
 in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/bin/specificHeat"
Aborted (core dumped)

3) Neither Cp nor kappa are listed as possible registered Objects when I use the 'bananas' trick

I would prefer having a solution for 2) but would appreciate any hints :)

regards Georg

gork June 27, 2013 02:52

Quote:

Originally Posted by gork (Post 435881)
Dear Fomers,

I am having issues on the same topic. I need to write out either the Cp or kappa field.
As far as I understand, there are 3 possibilities:
1) changing the filed definition from NO_WRITE to MUST_WRITE?
2) using a post-processing utility?
3) using the writeRegisteredObject function in controlDict

I am using a MultiRegionSolver based on chtMultiRegionFoam in OF 2.2.0 with

thermoType
{
type heRhoThermo;
mixture multiComponentMixture;
transport polynomial;
thermo janaf;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}

I did not get one of the possible ways working:
1) I did not find where Cp or kappa fields are created and where to manage the output

2) I tried to combine the specificHeat utility presented by wyldckat with the wallHeatFlux utility in order to cope with MultiRegions. Ends up with the error:

HTML Code:

Not Implemented
    Trying to construct an genericFvPatchField on patch SphereFront_Gas of field h

    From function genericFvPatchField<Type>::genericFvPatchField(const fvPatch& p, const DimensionedField<Type, volMesh>& iF)
    in file genericFvPatchField/genericFvPatchField.C at line 44.

FOAM aborting
#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::error::abort() in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2  Foam::genericFvPatchField<double>::genericFvPatchField(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libgenericPatchFields.so"
#3  Foam::fvPatchField<double>::addpatchConstructorToTable<Foam::genericFvPatchField<double> >::New(Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libgenericPatchFields.so"
#4  Foam::fvPatchField<double>::New(Foam::word const&, Foam::word const&, Foam::fvPatch const&, Foam::DimensionedField<double, Foam::volMesh> const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#5  Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::GeometricBoundaryField(Foam::fvBoundaryMesh const&, Foam::DimensionedField<double, Foam::volMesh> const&, Foam::List<Foam::word> const&, Foam::List<Foam::word> const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#6  at rhoReactionThermos.C:0
#7  Foam::heThermo<Foam::rhoReactionThermo, Foam::SpecieMixture<Foam::multiComponentMixture<Foam::polynomialTransport<Foam::species::thermo<Foam::janafThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleEnthalpy>, 8> > > >::heThermo(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyReactionThermophysicalModels.so"
#8  Foam::rhoThermo::addfvMeshConstructorToTable<Foam::heRhoThermo<Foam::rhoReactionThermo, Foam::SpecieMixture<Foam::multiComponentMixture<Foam::polynomialTransport<Foam::species::thermo<Foam::janafThermo<Foam::perfectGas<Foam::specie> >, Foam::sensibleEnthalpy>, 8> > > > >::New(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyReactionThermophysicalModels.so"
#9  Foam::autoPtr<Foam::rhoThermo> Foam::basicThermo::New<Foam::rhoThermo>(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#10  Foam::rhoThermo::New(Foam::fvMesh const&, Foam::word const&) in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/lib/libMyFluidThermophysicalModels.so"
#11 
 in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/bin/specificHeat"
#12  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#13 
 in "/home/broesigk/OpenFOAM/broesigk-2.2.0/platforms/linux64GccDPOpt/bin/specificHeat"
Aborted (core dumped)

3) Neither Cp nor kappa are listed as possible registered Objects when I use the 'bananas' trick

I would prefer having a solution for 2) but would appreciate any hints :)

regards Georg

problem solved...

PeterBishop October 4, 2013 08:46

Hi,

I downloaded and compiled specificHeat utility and it worked like a charm!:)
Now I'm tryin to extend it to reactingMixture, I want to calculate Cp as posprocessing of reactingFoam solution.

Any help would be appreciated!
Thanks

wyldckat October 5, 2013 01:32

Greetings Peter,
Quote:

Originally Posted by PeterBishop (Post 455040)
Now I'm tryin to extend it to reactingMixture, I want to calculate Cp as posprocessing of reactingFoam solution.

Any help would be appreciated!

I'll need an example case and a detailed description of what exactly you're trying to do.

Best regards,
Bruno

Linse November 18, 2013 14:57

Quote:

Originally Posted by gork
problem solved...

Dear Georg,

I guess, some users would be happy if you explained in a few sentences how you solved the problem. ;-)

gork November 26, 2013 02:37

1 Attachment(s)
Quote:

Originally Posted by Linse (Post 462439)
Dear Georg,

I guess, some users would be happy if you explained in a few sentences how you solved the problem. ;-)

Dear Bernhard,

sorry for taking a bit time to answer, I had to have a look at the files again...

In the end I managed to get the post processing utility presented by Bruno working for my multi region case. If I remember correctly it was the wallFvPatch.H that was missing when I posted my error - it just had to be included as well (like in the wallHeatFlux untility)

regards, Georg

immortality June 16, 2015 06:03

Hi again!
when I want to run the modified rhoCentralFoam for OF 2.4.0 it complains about unknown dimension of Cv and also Cp while it was running good before in 2.2.2 version. this is the warning:
Code:

--> FOAM Warning :
From function Foam::expressionField::read(const dictionary& dict)
in file expressionField.C at line 130
No entry 'dimension' in "/home/ehsan/OpenFoam/kOmegaSST-WR/system/controlDict.functions.CvField" for field CRRv
Not resetting the dimensions of the field

Creating expression field CRRv ...[0] swak4Foam: Allocating new repository for sampledMeshes
[1] swak4Foam: Allocating new repository for sampledMeshes
[2] swak4Foam: Allocating new repository for sampledMeshes
[3] swak4Foam: Allocating new repository for sampledMeshes
[0] swak4Foam: Allocating new repository for sampledGlobalVariables
[1] swak4Foam: Allocating new repository for sampledGlobalVariables
[3] swak4Foam: Allocating new repository for sampledGlobalVariables
[2] swak4Foam: Allocating new repository for sampledGlobalVariables

its the Cp and Cv Field in controlDict:
Code:

CvField {
        type expressionField;
        autowrite false;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cv()";
        fieldName CRRv;
    }

    CpField {
        type expressionField;
        autowrite false;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cp()";
        fieldName CRRp;
    }

how to resolve it?
thank you very much.:)

wyldckat June 17, 2015 15:23

Quote:

Originally Posted by immortality (Post 550545)
how to resolve it?
thank you very much.:)

Googled:
Code:

swak4Foam expressionField
First answer: http://www.cfd-online.com/Forums/ope...sionfield.html

immortality August 13, 2015 04:13

Hello to everyone,
what's wrong about Cp and Cv fields need to be used in the equations of the case? it shows the error bellow.
Code:

ehsan@ehsan-N56JK:~/OpenFoam_Cases/kOmegaSST-WR$ rhoCentralFoam
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.4.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.4.0-dcea1e13ff76
Exec  : rhoCentralFoam
Date  : Aug 13 2015
Time  : 12:35:32
Host  : "ehsan-N56JK"
PID    : 2709
Case  : /home/ehsan/OpenFoam_Cases/kOmegaSST-WR
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading thermophysical properties

Selecting thermodynamics package
{
    type            hePsiThermo;
    mixture        pureMixture;
    transport      sutherland;
    thermo          janaf;
    equationOfState perfectGas;
    specie          specie;
    energy          sensibleEnthalpy;
}

Reading field U

Creating turbulence model

Selecting turbulence model type RASModel
Selecting RAS turbulence model kOmegaSST
kOmegaSSTCoeffs
{
    alphaK1        0.85034;
    alphaK2        1;
    alphaOmega1    0.5;
    alphaOmega2    0.85616;
    gamma1          0.5532;
    gamma2          0.4403;
    beta1          0.075;
    beta2          0.0828;
    betaStar        0.09;
    a1              0.31;
    c1              10;
    Cmu            0.09;
    Prt            1;
    b1              1;
    F3              false;
}

fluxScheme: Kurganov

Starting time loop

Mean and max Courant Numbers = 0.0284841995776 0.0869432167197
deltaT = 1.19047619048e-08
Time = 1.1904762e-08

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal:  Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal:  Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0
swak4Foam: Allocating new repository for sampledGlobalVariables
--> FOAM Warning :
    From function ConcretePluginFunction<DriverType>::exists
    in file lnInclude/ConcretePluginFunction.C at line 121
    Constructor table of plugin functions for PatchValueExpressionDriver is not initialized


--> FOAM FATAL ERROR:
 Parser Error for driver PatchValueExpressionDriver at "1.1-4" :"field CRRp not existing or of wrong type"
"CRRp/CRRv"
  ^^^^
--| 

Context of the error:


- From dictionary: /home/ehsan/OpenFoam_Cases/kOmegaSST-WR/0/U.boundaryField.right
  Evaluating expression "CRRp/CRRv"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1189.

FOAM exiting

while the fields are defined in controlDict as:
Code:

CvField {
        type expressionField;
        dimension [0 2 -2 -1 0 0 0];
        autowrite false;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cv()";
        fieldName CRRv;
    }

    CpField {
        type expressionField;
        dimension [0 2 -2 -1 0 0 0];
        autowrite false;//false;
        outputControl timeStep;
        outputInterval 1;
        expression "thermo_Cp()";
        fieldName CRRp;
    }

thanks for helping.

wyldckat August 13, 2015 09:30

Quick answer: Sorry, I don't have enough time to develop a case myself for diagnosing this right now, but the problem seems to be due to the function object not running before the first time step. If the function object had ran before the first time step, then the object should have been registered.

Although I have the vague idea I've seen this error before... was a function object of type "readFields" in the function object list you had in the original case?

immortality August 13, 2015 11:18

this is the function object that I use in controlDict that isn't of type readFields. now I don't have any function object of that type.
Code:

writeMissingFields
    {
        type writeRegisteredObject;
        functionObjectLibs ( "libIOFunctionObjects.so" );
        objectNames ("phi" "Cp" "Cv");
        outputControl    outputTime;
    }


wyldckat August 13, 2015 11:57

I knew this looked familiar to me:


edit: I found this by Googling:
Code:

site:cfd-online.com "wyldckat" "Cv"

immortality August 14, 2015 11:23

Hi everyone,
although the run had been done correctly, now that I want to run again in of 2.4.0 and new swak4Foam, it shows errors on Cp and Cv fields, I tried to examine various combinations of "thermo:Cv", "thermo_Cv()", "CRRv" and with and without aliases with no success.
for example if I use CRRv as below:
Code:

CvField {
        type expressionField;
        dimensions [0 2 -2 -1 0 0 0];
        autowrite false;//false;
        outputControl timeStep;
        outputInterval 1;
        aliases {
        thermo:Cv myCv;
                }
        expression "thermo:Cv";
        fieldName CRRv;
    }

an error is shown as this one:
Code:

Creating expression field CRRv ...swak4Foam: Allocating new repository for sampledMeshes
swak4Foam: Allocating new repository for sampledGlobalVariables

"Loaded plugin functions for 'FieldValueExpressionDriver':"
  rhoTurb_R:
    "volSymmTensorField rhoTurb_R()"
  rhoTurb_alphaEff:
    "volScalarField rhoTurb_alphaEff()"
  rhoTurb_devRhoReff:
    "volSymmTensorField rhoTurb_devRhoReff()"
  rhoTurb_epsilon:
    "volScalarField rhoTurb_epsilon()"
  rhoTurb_k:
    "volScalarField rhoTurb_k()"
  rhoTurb_muEff:
    "volScalarField rhoTurb_muEff()"
  rhoTurb_mut:
    "volScalarField rhoTurb_mut()"
  thermo_Cp:
    "volScalarField thermo_Cp()"
  thermo_Cv:
    "volScalarField thermo_Cv()"
  thermo_T:
    "volScalarField thermo_T()"
  thermo_alpha:
    "volScalarField thermo_alpha()"
  thermo_hc:
    "volScalarField thermo_hc()"
  thermo_he:
    "volScalarField thermo_he()"
  thermo_mu:
    "volScalarField thermo_mu()"
  thermo_p:
    "volScalarField thermo_p()"
  thermo_psi:
    "volScalarField thermo_psi()"
  thermo_rho:
    "volScalarField thermo_rho()"



--> FOAM FATAL ERROR:
 Parser Error for driver FieldValueExpressionDriver at "1.1-6" :"field thermo not existing or of wrong type"
"thermo:Cv"
  ^^^^^^
--|   

Context of the error:


- Driver constructed from scratch
  Evaluating expression "thermo:Cv"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1189.

FOAM exiting


wyldckat August 14, 2015 14:58

Hi Ehsan,

Fortunately you sent me the case via email, otherwise we would be playing "guess why this happens" for several more days... Instead, it took me... maybe 15 minutes to fix the problems?
Well, I'm assuming the issues are fixed in the case I sent you, because it takes a very long time to run the solver and I'm also not certain what the results should be :(.

But OK, I'll report here what the problems were, regarding this error message:
Code:

--> FOAM FATAL ERROR:
 Parser Error for driver PatchValueExpressionDriver at "1.1-4" :"field CRRp not existing or of wrong type"
"CRRp/CRRv"
  ^^^^
--|

It's actually reaaaaally simple... in the file "system/controlDict", you had this:
Code:

functions
{
//#include "WR_Output"
//#include "WR_excess_Output"
}

Which means that all function objects were disabled, because the file "WR_Output" that has the function objects you were pointing out, ended up never being used, because it wasn't included. The solution was to simply change it to this:
Code:

functions
{
#include "WR_Output"
//#include "WR_excess_Output"
}

And you were expecting that we would be able to diagnose the problem without this extremely important detail :(

Anyway, the next error that was triggered was the one you reported here: http://www.cfd-online.com/Forums/ope...rnal-bool.html - which I can now answer properly there... although technically I had already given you the answer on that thread!!! :rolleyes:

Best regards,
Bruno

agustinvo October 12, 2015 09:33

Hi,

I have followed this thread last week since I wanted to write Cp as the OP wanted, but if you write:

Code:

volScalarField Cp
    (
        IOobject
        (
            "Cp",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        thermo.Cp()
    );

it will never write it. Then I noticed that, if instead that you put:

Code:

volScalarField Cp
    (
        IOobject
        (
            "cp",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        thermo.Cp()
    );

now the heat capacity will appear in your time folders. Later on, in the code of course you have to rewrite "cp=thermo.Cp()".


All times are GMT -4. The time now is 02:55.