Using groovyBC and storedVariables to set periodic mooving walls
Hello,
I am simulating a 2D cavity flow using icoFoam and I want my top and bottom walls to move periodically. Utop=U and Ubottom=0 for nT< t <(n+0.5)T Utop=0 and Ubottom=U for (n+0.5)T< t <(n+1)T Basically T is period and n is period number. During each period for half the period top wall moves with constant velocity and then for remaining half period bottom wall moves. What I used is topMovingWall { type groovyBC; storedVariables ( { name n; initialValue "0"; } ); variables ( "tperiod=20;" "n = (time() % tperiod == 0) ? n+1 : n;" ); valueExpression "vector((time()>n*tperiod && time()<(n+0.5)*tperiod)?0.01:0,0,0)"; } bottomMovingWall { type groovyBC; storedVariables ( { name n; initialValue "0"; } ); variables ( "tperiod=20;" "n = (time() % tperiod == 0) ? n+1 : n;" ); valueExpression "vector((time()>(n+0.5)*tperiod && time()<(n+1)*tperiod)?0.01:0,0,0)"; } For n=0 it works and I get wall motions but my n is not incrementing when a period of T (denoted by tperiod) gets over. |
In case anyone is interested, following worked
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0); boundaryField { topMovingWall { type groovyBC; valueExpression "vector((time()>n*tperiod && time()<(n+0.5)*tperiod)?0.01:0,0,0)"; value uniform (0 0 0); storedVariables ( { name n; initialValue "0"; } ); variables ( "tperiod=20;" "n=(time()>n*tperiod && time()<(n+1)*tperiod)?n:n+1;" ); } bottomMovingWall { type groovyBC; valueExpression "vector((time()>(n+0.5)*tperiod && time()<(n+1)*tperiod)?-0.01:0,0,0)"; value uniform (0 0 0); storedVariables ( { name n; initialValue "0"; } ); variables ( "tperiod=20;" "n=(time()>n*tperiod && time()<(n+1)*tperiod)?n:n+1;" ); } fixWall { type fixedValue; value uniform (0 0 0); } frontAndBack { type empty; } } |
All times are GMT -4. The time now is 23:38. |