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] How to use funkySetFields for surface scalar 'phi'? (https://www.cfd-online.com/Forums/openfoam-community-contributions/131717-how-use-funkysetfields-surface-scalar-phi.html)

wzx1989221 March 19, 2014 17:59

How to use funkySetFields for surface scalar 'phi'?
 
Hi everyone,

I met a problem when using funkySetFields for surface scalar field 'phi'. Basically I want to non-dimensionalise my case through dividing the fields by its reference values. I used the code below for velocity and pressure fields and they worked fine.

Code:

funkySetFields -field p -keepPatches -expression 'p/0.030625' -time 63 -condition "mag(vector(pos().x,pos().y,0))<=1.0"
Code:

funkySetFields -field U -keepPatches -expression 'U/0.175' -time 63 -condition "mag(vector(pos().x,pos().y,0))<=1.0"
However, when it comes to the surface scalar field 'phi', the error turned up like this:
Code:

--> FOAM FATAL ERROR:
 Parser Error for driver FieldValueExpressionDriver at "1.5-11" :"syntax error, unexpected number"
"phi/0.01575"
      ^^^^^^^
------|

Context of the error:


- Driver constructed from scratch
  Evaluating expression "phi/0.01575"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1081.

This is the code I use for phi:
Code:

funkySetFields -field phi -expression 'phi/0.01575' -time 63
Why I can't use funkySetFields for phi? Is there anything wrong in my code?

I really appreciate it if someone could give me a hand. Thank you very much.

Kind regards,
Tony

gschaider March 20, 2014 14:18

Quote:

Originally Posted by wzx1989221 (Post 480972)
Hi everyone,

I met a problem when using funkySetFields for surface scalar field 'phi'. Basically I want to non-dimensionalise my case through dividing the fields by its reference values. I used the code below for velocity and pressure fields and they worked fine.

Code:

funkySetFields -field p -keepPatches -expression 'p/0.030625' -time 63 -condition "mag(vector(pos().x,pos().y,0))<=1.0"
Code:

funkySetFields -field U -keepPatches -expression 'U/0.175' -time 63 -condition "mag(vector(pos().x,pos().y,0))<=1.0"
However, when it comes to the surface scalar field 'phi', the error turned up like this:
Code:

--> FOAM FATAL ERROR:
 Parser Error for driver FieldValueExpressionDriver at "1.5-11" :"syntax error, unexpected number"
"phi/0.01575"
      ^^^^^^^
------|

Context of the error:


- Driver constructed from scratch
  Evaluating expression "phi/0.01575"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1081.

This is the code I use for phi:
Code:

funkySetFields -field phi -expression 'phi/0.01575' -time 63
Why I can't use funkySetFields for phi? Is there anything wrong in my code?

I really appreciate it if someone could give me a hand. Thank you very much.

Kind regards,
Tony

You can. But phi is a surfaceScalarField and 0.01575 is (for technical reasons) a volScalarField. So 'phi/interpolate(0.01575)' should do the trick. Have a look at Documentation/swak4FoamReference.org for details.

BTW: for a condition you'll want to use fpos() for the face positions

wzx1989221 March 20, 2014 17:36

Dear Bernhard,

Thank you very much for the solution and your kind notice.

I tried with interpolate() and it worked for internal fields, however, I couldn't change the values on the boundary (BTW, I am using cyclic boundary condition). Is it possible to get the flux value on boundary changed as well?

Thanks and regards,
Tony

gschaider March 21, 2014 18:38

Quote:

Originally Posted by wzx1989221 (Post 481189)
Dear Bernhard,

Thank you very much for the solution and your kind notice.

I tried with interpolate() and it worked for internal fields, however, I couldn't change the values on the boundary (BTW, I am using cyclic boundary condition). Is it possible to get the flux value on boundary changed as well?

Currently no. The parser underneath funkySetFields only works on internalFields (and changing that requires a lot of work for that one application). funkySetBoundaryFields might work

wzx1989221 March 22, 2014 07:30

Hi Bernhard,

Many thanks for your kind reply. I will have a look at that.

Kind regards,
Tony


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