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

saving calculated results in text file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 4, 2014, 10:52
Smile saving calculated results in text file
  #1
New Member
 
Houssam
Join Date: Mar 2014
Location: Tunisia
Posts: 12
Rep Power: 12
houss is on a distinguished road
Send a message via Skype™ to houss
Hi Foamers!
i am simulating the flow in a axial diffuser with rhosimplefoam. i definde a coded functionobject to get values like (ptot,rho,u,p,pressure loss between inlet and outlet) on certain patches (INLET AND OUTLET). Now i am able to display these values through the solver running but i want actually to save these in a separate file for each outputinterval..briefly it should look like this:
ui pi ri ptoti uo po ro ptoto pl
x x x x x x x x
...
..

controldict

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.3.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application rhoSimpleFoam;

startFrom startTime;

startTime 0;

stopAt endTime;

endTime 6;

deltaT 1;

writeControl timeStep;

writeInterval 3;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression off;

timeFormat general;

timePrecision 6;

graphFormat raw;

runTimeModifiable true;

functions
{
#include "pressure_loss"
}






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

pressure_loss

pressure_loss
{
type coded;
functionObjectLibs ("libutilityFunctionObjects.so");
redirectType error;
enabled true;
outputControl timeStep;
outputInterval 1;
fields
(
phi
rho
U
p
);
code
#{
//LABEL PATCHES
label IN = mesh().boundaryMesh().findPatchID("INLET");
label OUT = mesh().boundaryMesh().findPatchID("OUTLET");

//const fvPatchVectorField& in_u = U.boundaryField()[IN];
if (IN == -1)
{
Info <<"patch named INLET DOES NOT EXIST!"<< endl;
}
if (OUT == -1)
{
Info <<"patch named OUTLET DOES NOT EXIST!"<< endl;
}
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
scalar u_i = 0.0;
u_i = mag(average(U.boundaryField()[IN]));
Info<<"AVERAGED VELOCITY INLET =\n"<<u_i<< endl;

const volScalarField& p = mesh().lookupObject<volScalarField>("p");
scalar p_i = 0.0;
p_i = average(p.boundaryField()[IN]);
Info<<"AVERAGED STATIC PRESSURE INLET =\n"<<p_i<< endl;

const volScalarField& rho = mesh().lookupObject<volScalarField>("rho");
scalar r_i = 0.0;
r_i = average(rho.boundaryField()[IN]);
Info<<"AVERAGED DENSITY INLET =\n"<<r_i<< endl;

const surfaceScalarField& phi = mesh().lookupObject<surfaceScalarField>("phi");
scalar m_i = 0.0;
m_i = sum(phi.boundaryField()[IN]);
Info<<"MASSFLOW INLET =\n" <<m_i<<"\n\n" <<endl;

scalar u_o = 0.0;
u_o = mag(average(U.boundaryField()[OUT]));
Info<<"AVERAGED VELOCITY OUTLET =\n"<<u_o<< endl;
scalar p_o = 0.0;
p_o = average(p.boundaryField()[OUT]);
Info<<"AVERAGED STATIC PRESSURE OUTLET =\n"<<p_o<< endl;
scalar r_o = 0.0;
r_o = average(rho.boundaryField()[OUT]);
Info<<"AVERAGED DENSITY OUTLET =\n"<<r_o<< endl;

scalar m_o = 0.0;
m_o = sum(phi.boundaryField()[OUT]);
Info<<"MASSFLOW OUTLET =\n" <<m_o<<"\n\n" <<endl;

//CALCULATE TOTAL PRESSURE DROP
scalar p_l = 0.0;
p_l = p_i + r_i*pow(u_i,2)/2 -(p_o + r_o*pow(u_o,2)/2);
Info<<"PRESSURE DROP =\n"<<p_l<<endl;

#};

}

i would really appreciate your help.
houss 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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error FerdiFuchs OpenFOAM Community Contributions 27 April 16, 2014 16:14
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 11:59
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57


All times are GMT -4. The time now is 14:15.