CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Read values from previous timesteps (https://www.cfd-online.com/Forums/cfx/87357-read-values-previous-timesteps.html)

vmlxb6 April 18, 2011 11:10

Read values from previous timesteps
 
I wrote a FORTRAN subroutine for a RK-4 order scheme and want to know how do I have access to the values at previous timesteps ?????????

Can anyone help me out ???? Thank you very much.

joey2007 April 18, 2011 15:34

CFX is economic. It stores only what it requires. More than two time steps are never required.

It will be very challaging to overcome this. Contact ANSYS service. May be they can help.

vmlxb6 April 18, 2011 16:39

@ joey2007
 
Can you please explain " It stores only what it requires. More than two time steps are never required" ???

Can CFX STORE values from previous timesteps ???

What I figured out was to use the write and read command in FORTRAN to write/read a value to/from an externally created txt file

The following link gives examples on how to READ/WRITE to an external file.

http://www.livephysics.com/computati...-handling.html

Hope this thread helps other people having similar problems.


Regards.

ghorrocks April 18, 2011 18:27

Quote:

Can CFX STORE values from previous timesteps ???
If you are using second order time differencing it has to store previous time steps. If not there is no reason to store it so it is not stored. So make sure you are using second order time stepping.

If you wish to store a small number of values then writing to a file is OK. But if you want the whole solution field then writing to a file will slow the simulation down. This is not a very elegant solution, better to access the variables that are already stored in CFX than write them to a file.

Or do you need access to variables further back then the last time step?

vmlxb6 April 18, 2011 18:47

@ Ghorrocks
 
I only need access to a small number of variables like displacement and velocity at every timestep. So I guess writing a subroutine is the best way.

BTW whats a second order time differencing ????????

vmlxb6 April 18, 2011 20:14

@ghorrocks
 
Can I have access to velocity and displacement values at previous time steps using 2nd order time differencing ????? I just need the values of velocity and displacement from previous time step.

According to you what would be the best way ???

Matjaz April 19, 2011 04:07

Hi, does this fortran writing to and reading from file in your simulation work OK?
I have the same problem, but when i try to write to file i find that my fortran routine executes many times during the first time step, and then an error occurs. In a file created by fortran routine there are about 3000 entries then.
The cfx fortran manual on the third page says that:
"Note that, in general, your user CEL function will be called several times during each iteration and the value of NLOC will be different for each call. This is because the CFX-Solver will split the specified region (for example, a boundary condition region) into a number of smaller ‘pieces’ and call your function for each piece. Your user subroutine should be coded to deal with this."

It is interesting, that if my routine doesn't write to a file, the values of velocity comes back to cfx solver right, but these are delta_values. What i would like to do is to memorize the total value like: v = v + dv , but i stil haven't figured out how to do it.
Regards, Matjaz

ghorrocks April 19, 2011 06:40

Prof Chaos, I suggest you look 2nd order time differencing up - it is pretty basic CFD stuff so you had better understand it.

I suspect with 2nd order time differencing you will be able to access previous timesteps through fortran. I have never done it, but I suspect it can be done.

joey2007 April 22, 2011 16:07

@vmlxb6: It is quite challenging to know more than Glenn. However it is even more challenging to access field variable values from previous time steps. I discussed it already here:
http://www.cfd-online.com/Forums/cfx...-timestep.html

If you just want to store single values at the actual time step and read again later on, you may use MMS as it is explained in the modeling manual chapter 17.6.

vmlxb6 April 22, 2011 18:56

@ Matjaz
 
My subroutine takes in 4 arguments and returns just 1 argument back i.e the displacement. my code had the statement RET(1,1) = displacement but that wrote thousands of values for RET
Then I changed it to

DO ILOC = 1,NLOC
RET(ILOC,1)=displacement
END DO

This set all my RET values at all the locations to the same value as that of displacement. Now my code works fine.

Hope this helps !!!!!!!!!!!


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