CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] have considered using condition in SWAK functions? (https://www.cfd-online.com/Forums/openfoam-community-contributions/120426-have-considered-using-condition-swak-functions.html)

immortality July 7, 2013 03:11

have considered using condition in SWAK functions?
 
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)

wyldckat July 7, 2013 10:24

Hi Ehsan,

How about giving an example of what you want to do, already in code?

Best regards,
Bruno

immortality July 20, 2013 13:11

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;
      }


wyldckat July 21, 2013 09:16

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

gschaider July 22, 2013 18:18

Quote:

Originally Posted by immortality (Post 438194)
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 (Post 440972)
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;
      }




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