|
[Sponsors] |
March 14, 2011, 16:40 |
integer part , groovyBC
|
#1 |
Senior Member
Join Date: Sep 2010
Posts: 226
Rep Power: 17 |
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 |
|
March 14, 2011, 18:01 |
|
#2 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
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.
|
|
March 15, 2011, 05:45 |
|
#3 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
||
March 15, 2011, 05:50 |
|
#4 |
Senior Member
Join Date: Sep 2010
Posts: 226
Rep Power: 17 |
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) ) ; } |
|
October 12, 2012, 11:12 |
|
#5 | |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
Quote:
Do you know how to use floor function inside openfoam code? I want to do floor(T.internalfield) Best Mahdi |
||
October 12, 2012, 17:48 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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)
__________________
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 |
||
October 12, 2012, 21:06 |
|
#7 |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
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 |
|
February 28, 2014, 10:41 |
|
#8 |
Member
nadine moussa
Join Date: Mar 2012
Posts: 30
Rep Power: 14 |
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 |
|
May 26, 2017, 13:09 |
|
#9 | |
New Member
Simone Colucci
Join Date: Mar 2016
Location: Pisa (Italy)
Posts: 23
Rep Power: 10 |
Hi Nadine,
I have the same problem, did you fix that? Thanks Simone Quote:
|
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error Messages: Self intersecting faces, Solid Part is not closed, Floating point. | bigtoasty | STAR-CCM+ | 1 | March 4, 2016 05:05 |
[swak4Foam] Varying heat flux using groovyBC with chtMultiRegionSimpleFoam | hcl734 | OpenFOAM Community Contributions | 5 | December 15, 2015 08:55 |
[swak4Foam] groovyBC interFoam splitted inlet -- massflowrate | FerdiFuchs | OpenFOAM Community Contributions | 1 | October 1, 2014 07:51 |
replacing of shock tube high pressure part with a boundary condition for low pressure | immortality | Main CFD Forum | 0 | May 2, 2013 13:30 |
what boundary condition is proper for simulation of shock-tube low pressure part? | immortality | OpenFOAM Running, Solving & CFD | 0 | May 2, 2013 13:22 |