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

Logging/writing postProcess values

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 26, 2019, 20:12
Default Logging/writing postProcess values
  #1
Senior Member
 
Brett
Join Date: May 2013
Posts: 212
Rep Power: 13
Bdew8556 is on a distinguished road
Hey foamers,

I've got a simulation where I'm interested in knowing information at the patches once its converged.

I know how to do this in the command line, for example:

postProcess -func 'patchAverage(name=outlet,p,U)' -latestTime

will give me the patch average of pressure and velocity on the patch 'outlet'. All good.
However how do I get it to log/write this information to a text file?

What if I wanted to repeat this command for several other patches and have their information recorded in the same log file??

Any thoughts??
Bdew8556 is offline   Reply With Quote

Old   June 27, 2019, 04:53
Default
  #2
Senior Member
 
Zander Meiring
Join Date: Jul 2018
Posts: 125
Rep Power: 7
yambanshee is on a distinguished road
in linux, having a > at the end of a command tells it to write to a file rather than a terminal. If it's a two of them (ie: >>) then it only appends to a file, instead of rewriting.

So to accomplish what you want:

postProcess -func 'patchAverage(name=outlet,p,U)' -latestTime > output

and it will create the file called output, and write in there instead of terminal.


Alternatively, look into adding functions in your control dict. For patch averaging for example, you'd want something along the lines of this at the bottom of your controldict file:

Code:
functions
{
	patchAverage
	{
    		#includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg"
    		operation       areaAverage;
   		fields          (p, U);
		writeControl    runTime;
		writeInterval   1;
	}
	
}
for more information, read up on function objects at https://www.openfoam.com/documentati...n-objects.html
yambanshee is offline   Reply With Quote

Old   June 28, 2019, 00:20
Default
  #3
Senior Member
 
Brett
Join Date: May 2013
Posts: 212
Rep Power: 13
Bdew8556 is on a distinguished road
Thanks for that!

That's definitely the nicest response I've ever had, usually people just pick out what they think is wrong with your comment!

I'm using OpenFoam on windows, are the arrows ( >, >> ) still the same?

I wonder if you could elaborate a bit more on:

#includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg"

Thanks heaps again
Bdew8556 is offline   Reply With Quote

Old   July 1, 2019, 05:00
Default
  #4
Senior Member
 
Zander Meiring
Join Date: Jul 2018
Posts: 125
Rep Power: 7
yambanshee is on a distinguished road
Quote:
Originally Posted by Bdew8556 View Post
Thanks for that!

That's definitely the nicest response I've ever had, usually people just pick out what they think is wrong with your comment!

I'm using OpenFoam on windows, are the arrows ( >, >> ) still the same?

I wonder if you could elaborate a bit more on:

#includeEtc "caseDicts/postProcessing/surfaceFieldValue/surfaceRegion.cfg"

Thanks heaps again
-I have no idea about OF for windows

the include grabs the file within the quotation marks from the directory 'etc', which is located in your openFoam install file path. Most of these type of postProcessing scripts are small scripts built up on top of each other, and the key is finding one you are interested in. My recommendation is to navigate to this folder. Within it, there are files with a .cfg extension, and files with no extension (at least that's the case on linux). These extensionless ones show demonstrations of how to use different post processing functions. For example, in postProcessing/surfaceFieldValue/ there is a file called 'patchAverage' which contains:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Web:      www.OpenFOAM.com
     \\/     M anipulation  |
-------------------------------------------------------------------------------
Description
    Calculates the average value of one or more fields on a patch.

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

name    <patchName>;
fields  (<field names>);

operation average;
#includeEtc "caseDicts/postProcessing/surfaceFieldValue/patch.cfg"

// ************************************************************************* //
This file shows you everything you need in the function objects to perform a patch average, and you can copy the middle straight into your functions in controlDict, with your specific options edited. In this case, that would be the 'name' and 'fields' variables
yambanshee is offline   Reply With Quote

Reply

Tags
openfaom, postprocess, scripting

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
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 32 June 16, 2021 06:55
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
Velocity values are normal but pressure values are too big rv82 OpenFOAM Running, Solving & CFD 4 April 13, 2015 03:59
Setting patch field values equal to internal field values leroyv OpenFOAM Programming & Development 1 October 21, 2014 15:49
Plotting raw data values Wilesco Siemens 0 January 5, 2006 05:34


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