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

[swak4Foam] Possible to sum across different patches?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 16, 2013, 09:35
Default Possible to sum across different patches?
  #1
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Dear Foamers,

I hope this question doesn't already exist in the forum.
I would like to calculate an average value which should be evaluated over different patches.
Is it possible to do this with swak4foam?

Furthermore I would like to compute the difference on each patch to this (global) average value.

So far I am able to evaluate the expressions seperately, i.e. I am computing the average value on patch1, compute the difference of my variable (temperature) to this value on patch 1, and I am doing the same for the other patches.

It would be great if I could compute an expression like this
HTML Code:
gAv= \sum_{Outlet j} \sum{i \in Outlet_j} T_i A_i /A(Outlet j)
and compute the difference at each patch seperately
HTML Code:
\sum_{i \in Outlet j} (T_i A_i - gAv)
I hope that this is understandable.

Thank you very much in advance for an answer or sharing your experiences.

Kind Regards
Anne
Anne Lincke is offline   Reply With Quote

Old   September 16, 2013, 15:41
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Anne Lincke View Post
Dear Foamers,

I hope this question doesn't already exist in the forum.
I would like to calculate an average value which should be evaluated over different patches.
Is it possible to do this with swak4foam?

Furthermore I would like to compute the difference on each patch to this (global) average value.

So far I am able to evaluate the expressions seperately, i.e. I am computing the average value on patch1, compute the difference of my variable (temperature) to this value on patch 1, and I am doing the same for the other patches.

It would be great if I could compute an expression like this
HTML Code:
gAv= \sum_{Outlet j} \sum{i \in Outlet_j} T_i A_i /A(Outlet j)
and compute the difference at each patch seperately
HTML Code:
\sum_{i \in Outlet j} (T_i A_i - gAv)
I hope that this is understandable.

Thank you very much in advance for an answer or sharing your experiences.

Kind Regards
Anne
Yep. It is possible with external variables. Assuming you have tow patches called here and there
Code:
variables (
  "sumHere{here}=sum(T*area());"
  "sumThere{there}=sum(T*area());"
  "areaHere{here}=sum(area());"
  "areaThere{there}=sum(area());"
  "totalAverage=(sumHere+sumThere)/(areaHere+areaThere);"
);
then use the totalAverage in the expression you're actually calculating. If you're only working on patch here you could leave out the {here} but the way it is written above it should work for both patches and you can save yourself some typing with the dictionary-include.
kostnermo likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   September 17, 2013, 03:27
Default
  #3
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Dear Bernhard,
thank you very much for the fast reply!
I will try to make this evaluation run with your instructions as soon as possible.

Best Regards
Anne
Anne Lincke is offline   Reply With Quote

Old   July 22, 2016, 10:41
Default
  #4
Senior Member
 
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10
manuc is on a distinguished road
Dear Bernard

I have two patches (w_l,w_lb --> both of them of different area and mesh distribution) and I want to find combined nusselt No. for them.
When I do the below it crashes:
--------------------------------------------------------------
Test234
{
type patchExpression;
patches (
w_l
w_lb
);
verbose true;
variables (
"Tsat=300;"
"lc2D=0.0786;"
"sumHere{w_l}=sum(snGrad(T)*area()/(T-Tsat);"
/*"dtwl{w_l}=T-Tsat;"
"dtwlb{w_lb}=T-Tsat;"*/
"sumThere{w_lb}=sum(snGrad(T)*area()/(T-Tsat));"
"areaHere{w_l}=sum(area());"
"areaThere{w_lb}=sum(area());"
"totalAverage=(sumHere+sumThere)/(areaHere+areaThere);"*/

);
expression "totalAverage";
accumulations (
max
min
average
sum
);

------------------------------------------------------------------
But when I try to debug and remove the division by (T-Tsat) it runs ,but not what I need..

----------------------------------------------------------------------------
Test234
{
type patchExpression;
patches (
w_l
w_lb
);
verbose true;
variables (
"Tsat=300;"
"lc2D=0.0786;"
"sumHere{w_l}=sum(snGrad(T)*area());"
/*"dtwl{w_l}=T-Tsat;"
"dtwlb{w_lb}=T-Tsat;"*/
"sumThere{w_lb}=sum(snGrad(T)*area());"
"areaHere{w_l}=sum(area());"
"areaThere{w_lb}=sum(area());"
"totalAverage=(sumHere+sumThere)/(areaHere+areaThere);"*/

);
expression "totalAverage";
accumulations (
max
min
average
sum
);

-----------------------------------------------------------------

Also it creates 2 output files w_l and w_lb .Is this expected

Could you please comment on it..

My scenario: A wall cut into two patches so that I could use one of the as inlet for flow if needed.At present both considered as wall. So I want Nusselt number at the whole wall and I need averaging over both patches.
__________________
Regards
Manu
manuc is offline   Reply With Quote

Old   July 26, 2016, 04:39
Default
  #5
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Hey Manu,

have you tried to just replace Tsat by the constant value, i.e. 300?
Maybe the coder has problems to detect the variable Tsat inside the variable definition part.....

Best,
Anne
Anne Lincke is offline   Reply With Quote

Old   July 26, 2016, 07:15
Default
  #6
Senior Member
 
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10
manuc is on a distinguished road
Hello Anne

I did try that,but doesnt work.Bye the way when used only for a single patch the same piece of file works.But when I try to find avg. of two patches it fails.
__________________
Regards
Manu
manuc is offline   Reply With Quote

Old   July 26, 2016, 07:19
Default
  #7
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Quote:
Originally Posted by manuc View Post
"sumHere{w_l}=sum(snGrad(T)*area()/(T-Tsat);"
In the expression above one bracket is missing. Maybe this is the error?!
Anne Lincke is offline   Reply With Quote

Old   July 26, 2016, 07:44
Default
  #8
Senior Member
 
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10
manuc is on a distinguished road
Nope:

I tried that the error reported is:

Build : 2.4.0-dcea1e13ff76
Exec : DNSbuoyantBoussinesqPimpleFoam -parallel
Date : Jul 26 2016
Time : 13:43:04
Host : "n11-40"
PID : 24612
Case : /home/manuchakkingal/OpenFOAM/manuchakkingal-2.4.0/run/2d_NC_porous_4_by_4_Ra_10_6
nProcs : 4
Slaves :
3
(
"n11-40.24613"
"n11-40.24614"
"n11-40.24615"
)

Pstream initialized with:
floatTransfer : 0
nProcsSimpleSum : 0
commsType : nonBlocking
polling iterations : 0
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
__________________
Regards
Manu
manuc is offline   Reply With Quote

Old   July 26, 2016, 07:46
Default
  #9
Senior Member
 
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 15
Anne Lincke is on a distinguished road
Looks as if there might be a division by zero....
Anne Lincke is offline   Reply With Quote

Old   July 26, 2016, 07:47
Default
  #10
Senior Member
 
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10
manuc is on a distinguished road
I will check it "for division by zero"..Thanks
__________________
Regards
Manu
manuc is offline   Reply With Quote

Reply


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
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 05:28
Possible bug with stitchMesh and cyclics in OpenFoam Jack001 OpenFOAM Pre-Processing 0 May 21, 2016 08:00
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 04:03
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


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