|
[Sponsors] |
funkySetBoundaryFields and matematical function |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 9, 2013, 13:38 |
funkySetBoundaryFields and matematical function
|
#1 |
Member
Alex
Join Date: Apr 2010
Posts: 48
Rep Power: 16 |
Hello, I am using the funkySetBoundaryFields from the swak4foam and I found it very useful for setting up the BC using a mathematical function.
I tried to use the formula for a parabolic inlet for velocity in the funkySetBoundaryDict file and it works: -------- velocities { field U; expressions ( { target value; patchName inlet; variables ( "Umax=1.0;" "xCoord=pos().x;" "xCoordMax=max(xCoord);" ); expression "(1-pow(xCoord/xCoordMax,2)) * Umax * vector(0,1,0)"; } ); } ---------- After solving this I want to include the same BC using also a time dependent value in order to see how this boundary condition (and in particular the U inlet of the simulation) changes as a function of time. The function erf (t) introduced here, gives me a behavior going from 0 to 1 with the time evolution and it will be multiplied by the previous equation. Unfortunately the expression that I introduced does not work. I would expect for the first times a velocity equal to 0 but, after certain time (in this case on the order of 0.1 seconds ) a change from 0 values of this ERF function till a 1 value (which means that the total velocity inlet goes from 0 to the parabolic profile as mentioned before). Instead of this expectation, the inlet remain 0 always and there is no flow evolution. I have also plotted this ERF function with matlab and it gives this behaviour (see attachment). The expression is(1+(erf((time()-0.1)/0.025)))/2) I am wondering how the tool uses the time() variable and if really uses the erf(t) correctly. Is anyone able to help me in this? The script is written below. Many thanks. alex velocities { field U; expressions ( { target value; patchName inlet; variables ( "Umax=1.0;" "xCoord=pos().x;" "xCoordMax=max(xCoord);" "ERF=((1+(erf((time()-0.1)/0.025)))/2);" ); expression "(1-pow(xCoord/xCoordMax,2)) * Umax * vector(0,1,0)* ERF"; } ); } |
|
March 9, 2013, 15:46 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Second: the final purpose of this is to have a inlet boundary condition that "switches" on in a smooth wayduring a simulation, right? FSBF is only good for static BCs. What I usually do is set up the boundary as a groovyBC and then to check that I coded it correctly run the replayTranisientBC (comes with swak4Foam) on the case. This loads a set of fields (user definable) into memory and then "only" does the timestepping, update of the boundary conditions on these fields and writing of the fields at the usual times. As there is no solving of equations involved this only needs a fraction of the time the regular solver needs (seconds instead of hours) nad in the end you see whether the BC behaves the way you wanted it to (this of course assumes that the BC does not depend on the rest of the solution). I haven't used the erf myself, just implemented the call to it so I don't think the error is there. Where I CAN imagine a bug (although I don't think so) is the way "time()" is treated in FSBF. Could you try the following: replace in your expression "time()" with 0.1 (or a later time) and see if you get the expected behaviour
__________________
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 |
||
March 11, 2013, 12:13 |
|
#3 |
Member
Alex
Join Date: Apr 2010
Posts: 48
Rep Power: 16 |
Thank you Mr Gschaider for your answer!
I tried with the first step, instead of using the time "time()", putting a value of -0.05 to the erf, which gives me the value : ((1+(erf((-0.05)/0.025)))/2 = 0.0023 and, in the post processing on paraview after running the simulation, the value of U is actually in that order of magnitude (Umagnitude = 0.0023383 m/s). So the erf function works, but it seems that the time() is not the proper one. Could I kindly ask you, if you know, how would you set the groovyBC or the replayTransientBC in the OF? Are there tutorials about this feature so I can try to set myself? Best regards, Alex |
|
March 11, 2013, 17:47 |
|
#4 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
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 |
||
March 12, 2013, 03:28 |
|
#5 |
Member
Alex
Join Date: Apr 2010
Posts: 48
Rep Power: 16 |
Thanks again:
I found on the contribution (see this link http://www.cfd-online.com/Forums/ope...-groovybc.html) the following script which, for my case, becomes: inlet { type groovyBC; variables "Umax=1.0;c=vector(0,0,0);n=vector(1,0,0);p=po s()-c;r=mag(p)+1.0e-10;R=max(r);ERF=((1+((erf((time()-0.1)/0.025)))/2);uprof=(1-pow(r/R,2))*Umax*ERF*normal();"; valueExpression "(-uprof)"; timelines(); value uniform (0 1 0); } Unfortunately during the simulation it gives me the following error which I don't really understand: diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 PIMPLE: iteration 1 swak4Foam: Allocating new repository for sampledGlobalVariables --> FOAM FATAL ERROR: The expected return type scalar is different from the stored result type "vector" From function tmp<Field<Type> > ExpressionResult::getResult() in file lnInclude/ExpressionResultI.H at line 124. FOAM exiting |
|
March 12, 2013, 11:23 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
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 |
||
March 13, 2013, 06:50 |
|
#7 |
Member
Alex
Join Date: Apr 2010
Posts: 48
Rep Power: 16 |
Your guess was right! Now it runs, I hope it will recognize the time() properly !!
thank you for your support! alex |
|
March 13, 2013, 09:32 |
|
#8 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
groovyBC? Yeah. That should know about "time()"
__________________
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 |
|
September 6, 2016, 06:04 |
|
#9 | |
New Member
Behzad Taghilou
Join Date: Jul 2016
Posts: 7
Rep Power: 10 |
Quote:
I used a boundary condition in which various parameters would be defined. for example: outlet { type totalPressure; p0 uniform 0; U U; phi phi; rho none; psi none; gamma 1; value uniform 0; } but I want to put a time dependent boundary for "p0" parameter. when I wrote groovyBC instead of totalPressure type, I could not get access the "p0" parameter. How can I wrote time dependent function for "p0"? thank you in advance. Behzad Taghilou Last edited by Behzad Taghilou; September 6, 2016 at 07:30. |
||
September 6, 2016, 07:37 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
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 |
||
September 6, 2016, 15:27 |
|
#11 | |
New Member
Behzad Taghilou
Join Date: Jul 2016
Posts: 7
Rep Power: 10 |
Quote:
I wrote the groovyTotalPressure instead of totalPressure and it was OK. another BC is this: wall { type tractionDisplacement; traction uniform ( 0 0 0 ); pressure uniform 0; value uniform (0 0 0); } And I need a time dependent function for pressure. what should have been done for this boundary condition? |
||
September 6, 2016, 18:03 |
groovyStandardBC library
|
#12 |
New Member
Behzad Taghilou
Join Date: Jul 2016
Posts: 7
Rep Power: 10 |
I have figured out how to add a new groovyBC to the standard BCs library. I found this groovyTractionDisplacementBC and I thought to use it as a guideline.
Any help or advice is appreciated. Thank you and best regards, Behzad |
|
|
|