CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Runtime sampling various variables in Parallel

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

LinkBack Thread Tools Search this Thread Display Modes
Old   June 29, 2020, 22:38
Default Runtime sampling various variables in Parallel
Akshay Patil
Join Date: Nov 2015
Location: Pune, India
Posts: 34
Rep Power: 9
Akshay_11235 is on a distinguished road
Dear OpenFOAM-Nerds,

I am trying to write a sampling code which basically averages in the homogeneous directions in my simulations domain. I have a serial code which I wanted to port to parallel case. Here is the code which I use to do my computations. I have checked it against other calculations and it gives me the right results. However, since my underlying code is DNS, I would like to port this code to a parallel mode. Could you suggest some pointers, ideas, details on how I can efficiently (to the best of your knowledge) achieve this? Thanks!

//Reading the homogeneous averaging properties file
Info<< "Reading averageProperties\n" << endl;

IOdictionary averageProperties

//Number of grid points in X, Y, and Z directions
dimensionedVector gridPoints
      dimensionSet(0, 0, 0, 0, 0, 0, 0),

//Declare the averaging index limit defined as Nx*Ny i.e.
scalar avgIndexLimit = (gridPoints.component(0)).value()*(gridPoints.component(1)).value();
scalar cellIndex = 0;
scalar indexLimit = 0;

Info << "The averaging Index limit is: " << avgIndexLimit << nl << endl;

//Create the collapsed profile array
List<scalar> collapsedProfileZ((gridPoints.component(2)).value());

Info << "The 1D profile will be of size: " << collapsedProfileZ.size() << nl << endl;

//Creating the Uavg vector
scalar Uavg = 0;
//Loop through all the z points

    while (indexLimit < avgIndexLimit)
        Uavg += mag(U[cellIndex]);
        cellIndex += 1;
        indexLimit += 1;
    if (indexLimit == avgIndexLimit)
        //Assign the average velocity at the given z coordinate
        collapsedProfileZ[zIndex] = Uavg/avgIndexLimit;

        //Reset the indexLimit to 0 once the averaging over the homogeneous directions is done
        indexLimit = 0;

        //Reset the Uavg to 0
        Uavg = 0;


//Reset the cellIndex back to zero so that the next time step starts at cellIndex=0
cellIndex = 0;

//Print the velocity profile to screen
Info << collapsedProfileZ << nl << endl;

Last edited by Akshay_11235; June 29, 2020 at 22:38. Reason: Incomplete question
Akshay_11235 is offline   Reply With Quote


parallel calculation, runtime processing, sampling

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
runtime postprocessing, parallel case with cyclics Kaffeeknecht OpenFOAM Post-Processing 1 April 20, 2016 10:54
Can not run OpenFOAM in parallel in clusters, help! ripperjack OpenFOAM Running, Solving & CFD 5 May 6, 2014 15:25
Runtime sampling of line alientxtmsgs OpenFOAM Post-Processing 1 April 2, 2014 21:31
parallel Grief: BoundaryFields ok in single CPU but NOT in Parallel JR22 OpenFOAM Running, Solving & CFD 2 April 19, 2013 16:49
Parallel Computing Classes at San Diego Supercomputer Center Jan. 20-22 Amitava Majumdar Main CFD Forum 0 January 5, 1999 12:00

All times are GMT -4. The time now is 00:18.