funkySetBoundaryFields and matematical function
1 Attachment(s)
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 "(1pow(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 "(1pow(xCoord/xCoordMax,2)) * Umax * vector(0,1,0)* ERF"; } ); } 
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 
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 
Quote:

Thanks again:
I found on the contribution (see this link http://www.cfdonline.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.0e10;R=max(r);ERF=((1+((erf((time()0.1)/0.025)))/2);uprof=(1pow(r/R,2))*Umax*ERF*normal();"; valueExpression "(uprof)"; timelines(); value uniform (0 1 0); } Unfortunately :confused: 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 
Quote:

Your guess was right! Now it runs, I hope it will recognize the time() properly :) !!
thank you for your support! alex 
Quote:

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 
Quote:

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? 
groovyStandardBC library
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 
All times are GMT 4. The time now is 15:24. 