CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Write out calculated field to time directory

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 3, 2020, 12:59
Default Write out calculated field to time directory
  #1
New Member
 
pardoa
Join Date: May 2018
Posts: 29
Rep Power: 7
pardoa is on a distinguished road
Hello,

I wish to write out to time directories the pressure field and Z component from one of the patches of my domain to later calculate the hydraulic head (p/(rho*g)+Z). I managed to write both values to the screen but fail to do the same to a file. Can anyone help me with this? I'm pretty sure that this is a very simple thing but I don't find the key to make it work.

This is the coded functionObject that I have written so far:

Quote:
head
{
type coded;
functionObjectLibs ("libutilityFunctionObjects.so");
name head;
writeControl writeTime;
codeExecute
#{
//Find the riverbed patch ID

label patchID = mesh().boundaryMesh().findPatchID("riverbed");
//Info << "patchID = " << patchID << endl;

//Look up "p" field at the riverbed patch

const volScalarField& p = mesh().lookupObject<volScalarField>("p");
//Info << "p= " << p << endl;

const fvPatchScalarField& p_river = p.boundaryField()[patchID];
//Info << "p_river = " << p_river << endl;

//Look up "XYZ coordinates" of the riverbed patch

const fvPatchVectorField& faceCentres_river = mesh().C().boundaryField()[patchID];
//Info << "(" << faceCentres_river << ") " << p_river << endl;

fvPatchScalarField p_river
(
IOobject
(
"p_river",
mesh().time().timeName(),
mesh().boundaryMesh(),
IOobject::NO_READ
),
p.boundaryField()[patchID]
);

p_river.write();

// Create the hydraulic head field
/*fvPatchScalarField head
(
IOobject
(
"head",
mesh().time().timeName(),
boundaryMesh(),
IOobject::NO_READ
),
p_river/(9.81*1000)
);

// Write data to the screen
Info<< "head": << head.value() << endl;

// Write values to time directories
head.write();*/
#};
}
Many thanks in advance!
Álvaro
pardoa is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
AMI speed performance danny123 OpenFOAM 21 October 24, 2020 04:13
laplacianFoam with source term Herwig OpenFOAM Running, Solving & CFD 17 November 19, 2019 13:47
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 05:28
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 09:07
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL AndoniBM OpenFOAM Running, Solving & CFD 2 March 25, 2015 18:44


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