# have considered using condition in SWAK functions?

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

 July 7, 2013, 03:11 have considered using condition in SWAK functions? #1 Senior Member     Ehsan Join Date: Oct 2012 Location: Iran Posts: 2,210 Rep Power: 20 i want to know applying conditions on time in SWAK function postProcessing is applicable or not?(in one time period have one expression to be calculated and another expression in another time period) __________________ Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked.

 July 7, 2013, 10:24 #2 Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,021 Blog Entries: 39 Rep Power: 109 Hi Ehsan, How about giving an example of what you want to do, already in code? Best regards, Bruno __________________ OpenFOAM: FAQ | Getting started Forum: How to get help, to post code/output and forum guide What am I doing/planning: blog/wiki Read this before sending me PM

 July 20, 2013, 13:11 #3 Senior Member     Ehsan Join Date: Oct 2012 Location: Iran Posts: 2,210 Rep Power: 20 Hi Bruno like this: Code: ```totalPressure_left { type swakExpression; valueType patch; patchName left; accumulations ( average ); variables ( "gamma1=1.4;" "gamma2=1.35;" "R=287.14;" ); expression "time()<.002 ? sum(p*(pow(1+(gamma1-1)/2*magSqr(U)/(gamma1*R*T),(gamma1/(gamma1-1))))*rho*area())/sum(rho*area()) : sum(p*(pow(1+(gamma2-1)/2*magSqr(U)/(gamma2*R*T),(gamma2/(gamma2-1))))*rho*area())/sum(rho*area())"; verbose true; outputControlMode outputTime; outputInterval 1; }``` __________________ Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked.

 July 21, 2013, 09:16 #4 Super Moderator   Bruno Santos Join Date: Mar 2009 Location: Lisbon, Portugal Posts: 10,021 Blog Entries: 39 Rep Power: 109 Hi Ehsan, Sorry, no time to test this myself. My guess is that if you can add 2 fields directly on the resulting expression, then you should be able to use a condition as well. Best regards, Bruno __________________ OpenFOAM: FAQ | Getting started Forum: How to get help, to post code/output and forum guide What am I doing/planning: blog/wiki Read this before sending me PM

July 22, 2013, 18:18
#5
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,017
Rep Power: 43
Quote:
 Originally Posted by immortality i want to know applying conditions on time in SWAK function postProcessing is applicable or not?(in one time period have one expression to be calculated and another expression in another time period)
That works. Two things:
- both expression have to give the same result type otherwise the parser will throw up (can't switch from vector to scalar)
- internally BOTH expressions are evaluated, but only the one that fits the condition is used (apart from taking a bit more time this can lead to problems if the expression that is not used with the current condition is mathematically invalid. "log(time()-0.002)" in your example for instance)

Quote:
 Originally Posted by immortality Hi Bruno like this: Code: ```totalPressure_left { type swakExpression; valueType patch; patchName left; accumulations ( average ); variables ( "gamma1=1.4;" "gamma2=1.35;" "R=287.14;" ); expression "time()<.002 ? sum(p*(pow(1+(gamma1-1)/2*magSqr(U)/(gamma1*R*T),(gamma1/(gamma1-1))))*rho*area())/sum(rho*area()) : sum(p*(pow(1+(gamma2-1)/2*magSqr(U)/(gamma2*R*T),(gamma2/(gamma2-1))))*rho*area())/sum(rho*area())"; verbose true; outputControlMode outputTime; outputInterval 1; }```
__________________
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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post yosuke1984 OpenFOAM Verification & Validation 3 May 6, 2015 06:16 Sargam05 OpenFOAM 10 May 25, 2013 17:50 Tuca FLOW-3D 1 April 23, 2013 12:02 AlbertoVe Main CFD Forum 1 January 17, 2013 04:11 Matt Umbel Main CFD Forum 14 January 12, 2001 15:34

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