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] is it possible to write a simple program in groovyBC according to C++ language? (https://www.cfd-online.com/Forums/openfoam-community-contributions/112697-possible-write-simple-program-groovybc-according-c-language.html)

immortality February 3, 2013 05:42

is it possible to write a simple program in groovyBC according to C++ language?
 
the condition?expression1:expression2 makes limitations for me.I need more freedom in conditions.are we limited to groovyBC syntax or exists a way to extend this to if-elseif-else conditions?i need to set several conditions for all fractionExpression,valueExpression and gradientExpression.

immortality February 4, 2013 00:44

i need to be certain.any answer?

gschaider February 4, 2013 04:13

Quote:

Originally Posted by immortality (Post 405731)
the condition?expression1:expression2 makes limitations for me.I need more freedom in conditions.are we limited to groovyBC syntax or exists a way to extend this to if-elseif-else conditions?i need to set several conditions for all fractionExpression,valueExpression and gradientExpression.

You're not serious with that question, right? Of course you can do if-elseif-cascades:
Code:

cond1 ? val1 : (cond2 ? val2 : val3)

immortality February 4, 2013 04:26

i said a simple example.my bc's are unfortunately much complicated.it should include sub or supersonic and inflow or outflow conditions at each patch.thanks.

gschaider February 4, 2013 14:37

Quote:

Originally Posted by immortality (Post 405855)
i said a simple example.

Where? Not in this thread

There is no simpler example
Quote:

Originally Posted by immortality (Post 405855)
my bc's are unfortunately much complicated.it should include sub or supersonic and inflow or outflow conditions at each patch.thanks.

Modularize the expressions to make them more readable with variables. A sketch (fill out the dots yourself):

Code:

variables (
  "isSupersonic= .....;"
  "isInflow= .....;"
  "superSonicInVal=....;"
  "subsonicInval=.....;"
);

valueExpression=isInflow ? ( isSuperSonic ? superSonicInVal : subsonicInval) : ...";
fractionExpression= isInflow ? ....";

That should make it readable and consistent.


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