CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Do-loop in CFX Perl language (https://www.cfd-online.com/Forums/cfx/94424-do-loop-cfx-perl-language.html)

fated-oracle November 15, 2011 08:37

Do-loop in CFX Perl language
 
Hi!

I have to finish a project for my university, which simulates the fall of a rigid body onto a calm free surface. I did the simulation with a deforming mesh and now I'm supposed to do it with a fixed mesh, moving flow approach (the fluids are water, incompressible and air compressible).

In order to do this I would need the flow velocity to be dependent on the force on the body at each time step (it is a transient simulation). The force on the body can be obtained with a monitor as force_y()@Body. The problem is I need to update the velocity at each time step. I have read this can be done with a junction box routine and a code written in Fortran. The problem is I need to run the simulation on different platforms (windows and linux) and this would require different languages for the specification of the location of the fortran files and different compilers. Besides, as I am new to this approach it would require quite a lot of time as well. I was wondering if there was a way to write this code all in Perl and within the CFX file so as to avoid these problems.

The code would look something like this (in fortran-style):
do i=1:tot number of time steps
Fi=force_y()@Body !I would need to call this et everytime step, where !i is the interested time step
Vi+1=Vi+(g-Fi/M)Dt !where Vi is the old velocity, M is the mass of
!the body Dt is the time step
yvel=Vi+1 !This is the function to be used in CFX Pre for the vertical velocity of the fluid.
end do

As you can see this is rather complicated as it would require a user input call at the beginning of each time step.
Thank you in advance!

stumpy November 15, 2011 09:48

Perl code is only evaluated once, at the start of the solver run, so you can't use that approach. You can make the velocity a function of the force using CEL. The problem is that you don't want the force value to get updated each coefficient loop; instead you want it to hold the value from the previous timestep. You can achieve that by using an Additional Variable that is only updated once per timestep. This is a hidden CCL only feature. Search this forum for "Update Loop = TRANS_LOOP" for more info.

ghorrocks November 15, 2011 19:25

Also note this approach means that you have to model an accelerating frame of reference. Whether these acceleration terms are important for you or not is for you to determine.


All times are GMT -4. The time now is 05:23.