|
[Sponsors] |
February 9, 2013, 09:44 |
Problem with functionObjects in parallel
|
#1 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
I'm using this functionObjects in controlDict so I can extract them later via foamLog to check some qualities of my solution:
Code:
functions { kineticEnergy { type coded; functionObjectLibs ( "libutilityFunctionObjects.so" ); redirectType error; code #{ const volVectorField& U = mesh().lookupObject<volVectorField>("U"); const scalarField& mu = mesh().lookupObject<volScalarField>("mu"); const scalarField& rho = mesh().lookupObject<volScalarField>("rho"); const scalarField& p = mesh().lookupObject<volScalarField>("p"); scalar C = average(sqrt(1.4*p/rho)); scalar TKE =0.5*average(magSqr(U-average(U))).value(); scalar lambdaf=1.0/average(magSqr(diag(fvc::grad(U)))); scalar Reyf = average(rho/mu)*sqrt(4.0*TKE*lambdaf/3.0); Info << "TKE = " << TKE << endl; Info << "Reyf = " << Reyf << endl; Info << "MaPrime = " << 2.0*TKE/C/3.0 << endl; #}; } } Code:
reduce(TKE,sumOp<scalar>()); reduce(Reyf,sumOp<scalar>()); reduce(Lambdaf,sumOp<scalar>()); I'm doing this manually now which is Info << TKE/16.0 << endl; and I know that I can use dict.lookup but that involves reading file in every single time step which is heavily inefficient |
|
February 9, 2013, 16:16 |
|
#2 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
Code:
const volScalarField& p = mesh().lookupObject<volScalarField>("p"); const scalarField& vols = mesh().V(); scalar pSum = gSum(vols*p); scalar volTot = gSum(vols); scalar pAv = pSum/volTot; or.... you could simply write Code:
scalar pAv = gAverage(p); |
|
February 11, 2013, 15:27 |
|
#3 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
Thanks niklas but my problem is not with the calculation, my problem is in the parallel case, the calculations you have mentioned would be calculated on every sub-domain which one would be printed out in the screen when you use Info<< ? Obviously you should reduce it among different processes and THIS is my problem, if I use sumOp it should be divided to number of processes or I should use some other operator other than sumOp.
|
|
February 12, 2013, 02:28 |
|
#4 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
just try my code. Did you try it?
Did you notise the g in front of sum, gSum. Can you guess what the g stands for. The Info stream is only for processor 0, you also have an Sout stream, then it will write the statement for every processor. I think that you are not using the -parallel flag when you are running the parallel case. |
|
February 12, 2013, 06:27 |
|
#5 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
Thanks niklas, that all make sense now but unfortunately it does not work in functionobjects of libutilityFunctionObjecs.so
btw: I use -parallel flag Last edited by anishtain4; February 12, 2013 at 08:52. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Parallel running of 3D multiphase turbulence model (unknown problem!!) | MOHAMMAD67 | OpenFOAM Running, Solving & CFD | 7 | November 23, 2015 11:53 |
fluent parallel problem in win7 x64 system | dunga82 | FLUENT | 8 | April 19, 2012 21:23 |
[snappyHexMesh] processorWeights problem with snappyhexmesh in parallel | oskar | OpenFOAM Meshing & Mesh Conversion | 0 | July 7, 2011 11:05 |
Parallel UDF problem, hello world version | pilou | FLUENT | 0 | March 10, 2011 09:20 |
cfx4 parallel sover Problem!! HELP | Richard.A | CFX | 2 | August 3, 2002 04:54 |