|
[Sponsors] |
How to make user routine just be called once in one time step? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 27, 2017, 13:43 |
How to make user routine just be called once in one time step?
|
#1 |
New Member
Tony
Join Date: Mar 2016
Posts: 24
Rep Power: 10 |
I defined a user routine to predict the pressure of outlet boundary condition. The user routine is a one-dimensional code and I want it's just excuted once in one time step. In other words, I use it to predict pressure at outlet for next time step.
I found that, if I directly exert the expression of the user routine for the pressure boundary condition, the user routine would be excuted for all loops in one time step. This is not what I want. My solution is to define a variable to store the value returned by user routine. The variable is set as Update Loop = TRANS_LOOP , which means this variable will only be updated once during a time step. Value of the variable is defined by the expression of user routine. At the end of a time step, the variable starts to be computed, so the user routine would be excuted. Therefore the user routine runs once in one time step. However, in this way, I find a problem that the user routine would be excuted tens of times at the last time step where I stop the simulation. Here is my question: 1. are there other ways to make user routine just be called once in one time step? 2. in my way, why would the user routine be excuted tens of times at the last time step where I stop the simulation. Thanks. |
|
March 27, 2017, 19:36 |
|
#2 |
Senior Member
Join Date: Jun 2009
Posts: 1,878
Rep Power: 33 |
Once you get into UserFortran programming, you are the one who understands every details of what is being done in your source code. It is not possible for the software to determine the internal dependencies of your function, so it assumes it can change with any of the variables, say coefficient loop within a time step.
ANSYS CFX memory management tools allow you to store the information that you know remains constant between calls, then you can store the critical information and retrieve it in subsequent calls. Is there precomputed information available for this call ? Y: locate the results in your private USER space, return such values N: compute the values needed, store into your private USER space for future calls. You must determine when a new timestep starts, so you update the results in the private space. Hope the above helps, |
|
March 28, 2017, 05:27 |
|
#3 |
New Member
Tony
Join Date: Mar 2016
Posts: 24
Rep Power: 10 |
Thank you! And I also find a hint in the help document. It is in 18.7.3. User CEL Example 3:
Note that the integrated quantity is passed into the inlet temperature function as an argument. The CFX-Solver recalculates these values during the coefficient loop so that the value is always up to date. As I see, the subroutine may be called in any ways I did not expected. The method I posted is not good. I guess actually the subroutine would still be called a lot of times while saving result or transient result. Now I define a variable in subroutine to record the current time step. I use the intrinsic fortran function SAVE to store the variable. In the next call to the subroutine, the main interations would be excuted if the new time step is different from the stored value, or the main interations would be skipped. In this way, the user routine is inevitablly still called a lot of times but some computation time can be saved. I have another question. Can I just use SAVE to store the data which would be used in next call? Camparing with using CFX memory management tools, do you see any drawbacks of using SAVE? I just SAVE four arrays of real number. Each array is of about 10000 numbers. |
|
October 22, 2018, 00:06 |
|
#4 |
New Member
陈晨
Join Date: Oct 2018
Posts: 7
Rep Power: 8 |
dear friend, could you explain me how to save array in user fortran. When i try to save array"save variable[NLOC]" error showed"cannot save automatic array". thanks for your reply
|
|
Tags |
time step, user routine |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Transient simulation not converging | skabilan | OpenFOAM Running, Solving & CFD | 14 | December 17, 2019 00:12 |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 12:08 |
simpleFoam error - "Floating point exception" | mbcx4jc2 | OpenFOAM Running, Solving & CFD | 12 | August 4, 2015 03:20 |
Help for the small implementation in turbulence model | shipman | OpenFOAM Programming & Development | 25 | March 19, 2014 11:08 |
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 | flakid | OpenFOAM Installation | 16 | December 28, 2010 09:48 |