June 29, 2020, 22:38
|
Runtime sampling various variables in Parallel
|
#1
|
Member
Akshay Patil
Join Date: Nov 2015
Location: Pune, India
Posts: 35
Rep Power: 10
|
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!
Code:
//Reading the homogeneous averaging properties file
Info<< "Reading averageProperties\n" << endl;
IOdictionary averageProperties
(
IOobject
(
"averageProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
//Number of grid points in X, Y, and Z directions
dimensionedVector gridPoints
(
"gridPoints",
dimensionSet(0, 0, 0, 0, 0, 0, 0),
averageProperties
);
//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
forAll(collapsedProfileZ,zIndex)
{
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
|
|
|