CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   New Utilities (http://www.cfd-online.com/Forums/openfoam-post-processing/61438-new-utilities.html)

coops July 3, 2007 20:33

Hi All, I am having a littl
 
Hi All,

I am having a little trouble with the results that I am getting from my model at the moment. I would like to try and chase down which terms in the equations may be causing the issues, therefore I would like to post-process each of the term in the initial equations.

1) is it possible to do this?

I have played with some post-processing with the velocity field which was easy but now I am interested in the energy equation terms.

For example I would like to look at the value of the following term:

fvm::div(phi, e)

This is the code that I am using at the moment:



/*---------------------------------------------------------------------------*\
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration |
\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Application
Ucomponents

Description
Writes the three scalar fields, Ux, Uy and Uz, for each component of the
velocity field U for each time

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

# include "addTimeOptions.H"
# include "setRootCase.H"

# include "createTime.H"

// Get times list
instantList Times = runTime.times();

// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"

runTime.setTime(Times[startTime], startTime);

# include "createMesh.H"
# include "readThermodynamicProperties.H"
# include "readTransportProperties.H"

for (label i=startTime; i<endTime; i++)
{
runTime.setTime(Times[i], i);

Info<< "Time = " << runTime.timeName() << endl;

IOobject Theader
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);

IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);


IOobject rhoheader
(
"rho",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);

// Check U exists
if (Theader.headerOk() && Uheader.headerOk() )
{
mesh.readUpdate();

Info<< " Reading T" << endl;
volScalarField T(Theader, mesh);

Info << " Reading U" << endl;
volVectorField U(Uheader, mesh);

Info << " Reading rho" << endl;
volScalarField rho(rhoheader, mesh);

Info << " Calculating phi" << endl;
surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
linearInterpolate(rho*U) & mesh.Sf()
);

Info << " Calculating e" << endl;
volScalarField e
(
IOobject
(
"e",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
Cv*T
);

Info << " Calculating div(phi, e)" << endl;
volScalarField div_phi_e
(
IOobject
(
"div_phi_e",
runTime.timeName(),
mesh,
IOobject::NO_READ
),
fvm::div(phi, e)
);

}
else
{
Info<< " No T" << endl;
}

Info<< endl;
}

return(0);
}


// ************************************************** *********************** //

I am able to read in the various field and calcuate some of them but when I want to calculate div_phi_e I get an error.

I think it is because it is not a volScalarField becuase I am trying to take the divergence of a field that is not a volVectorField, but I don't know what else it should be, or if it is even possible to compute!!!

Many Thanks,

Shaun

gschaider July 4, 2007 04:21

Have a look at chapter 2.4 of
 
Have a look at chapter 2.4 of the Programmer's Guide: Equation discretizations. What you're looking for is fvc::div. The explanation is found there.


All times are GMT -4. The time now is 08:32.