integer part , groovyBC
Hi,
Any ideas how to get the integer part of a decimal number inside the groovyBC library? example: integer part of "2.356" to be "2", and "5.897" to be "5" so it is rounding towards zero ?? if it does not exist in the groovyBC, how to do that inside the openFoam library? thanks |
The C++ function floor() would do the trick, but from the groovyBC page it is not evident if these have been implemented. In a related note, I used funkySetFields to set some initial conditions and used an error function distribution. erf() wasn't listed with implemented functions, but it worked anyway. I think if its implemented in standard C/C++ math libraries, it should work.
|
Quote:
BTW: should the behaviour of groovyBC etc differ from the documentaiton feel free to modify the documentation BTW2: if a feature-request pops up in the swak4Foam-Mantis I might implement the floor-function |
Hi,
thanks, yes i solved it that way and here is my square wave of ampitude A, and period T=10 //assign a square wave of amplitude A=0.015 at the U boundary Patch "upperWall" as function of time // Get index of patch at upperWall label indexOfPatch = mesh.boundaryMesh().findPatchID("upperWall"); forAll(mesh.boundaryMesh()[indexOfPatch],celll) { U.boundaryField()[indexOfPatch][celll].component(0) = 0.015 * pow( -1, floor( (runTime.value())/10) ) ; } |
Quote:
Do you know how to use floor function inside openfoam code? I want to do floor(T.internalfield) Best Mahdi |
Quote:
(note that due to the way % is defined in OF you've got to add/subtract 0.5 before/after using the operator to get the result you want. But you'll figure that out) |
Dear Friend
Thanks for your reply . The problem was that if you try to use the floor function inside the openfoam code (notgroovybc) it will gives you the error that floor can be used just for float or long float or double varibales. But i solved it. If you go to primitive folder and change in all the files acording to sqrt ... and then recomplie your openfoam folder ... floor will work will all types of variables Best Mahdi |
Hello Mahdi,
I want to do the same, can you please be more specific about your answer? If you go to primitive folder and change in all the files acording to sqrt ... and then recomplie your openfoam folder ... floor will work will all types of variables which primitive folder? and what did you changed? thank you, Nadine |
Hi Nadine,
I have the same problem, did you fix that? Thanks Simone Quote:
|
All times are GMT -4. The time now is 15:55. |