|
[Sponsors] |
If the implementation of the User CEL Fortran routine can accelerate the calculation? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 8, 2019, 14:57 |
If the implementation of the User CEL Fortran routine can accelerate the calculation?
|
#1 |
Member
phd
Join Date: Oct 2013
Posts: 76
Rep Power: 13 |
Hi, there
Recently I start to re do the user CEL Example 1 (user designed Momentum source) in CFX solver modelling guide as shown in the following websites: https://www.sharcnet.ca/Software/Ans.../i1320678.html I found the function of the User Fortran Routine in this case actually can be simply replaced by the ‘CEL if function’ in the form of : if(x >= 0.5 && x<=1.5 && y>=1.25 && y<=1.75, 1000, 0) Then why do we bother the use the Fortran code to do so? Will it bring faster calculation? I asked this question because I’d like to insert three array of coordinates (X, Y, Z) and one array of Momentum source values into the solver. I know can insert it via ‘initialize profile Data’ but it seems the simulation in such way has been largely retarded by the inserted source term. Why does the simulation been retarded? Can we resolve this problem by User Fortran? Thank you very much! |
|
April 8, 2019, 15:22 |
|
#2 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
The example you cited illustrates how to use UserFortran, not a guideline for how to deal with IF blocks in the logic. The source example could have had other requirements, and still require User Fortran.
User CEL functions were added circa CFX-5.5 (@2002/2003) while the IF statement was added in ANSYS CFX-12.0 (@2009). On your specific use case, you are trying to set up a momentum source. Here are a few questions - The source is distributed in space, correct? - The distribution is not continuous but discrete, and it can be interpolated to other locations from the discrete information, correct? If both answers are true, you can either use the 3D interpolation functionality, and manage the information/set up via CEL expressions as you describe it. CEL vs UserFortran? UserFortran is CEL where the user provides values where the logic is not trivial to describe with the available CEL statements provided. Faster vs slower? The speed comparison is not between CEL and UserFortran, but between the built-in algorithm to achieve the expected result and the algorithm you want to code in your UserFortran routine/functions. This is algorithm dependent; therefore, not trivial to answer. Hope the above helps, |
|
April 8, 2019, 16:12 |
|
#3 |
Member
phd
Join Date: Oct 2013
Posts: 76
Rep Power: 13 |
Hi, Opaque,
Thanks for your always helpful answers. I have observed the simulation has been largely retarded by adding the source term via ‘initialize profile Data’. Is there any explanation on that? Is it because the solver has to read the external .csv file each (pseudo) time step? I thought/hope User Fortran can resolve this problem because with its help the solver may not need to read the .csv. |
|
April 8, 2019, 16:31 |
|
#4 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
The .csv is read only once, but the data is interpolated every time is needed even if it is the same between iterations.
If I recall correctly there was a workaround (you may have to search the forum for Update Loop), but it should be along the following: - Create an additional variable (unspecified) - Using the Edit in Command Editor functionality, add the Update Loop = None to the additional variable above. - Activate it in the domain panel, and set it to the interpolation function column of interest. - Use the additional variable in your source term as you already did with the interpolation function. The above basically stores the interpolated values into the additional variable you created, and it is never updated. The source terms just copy the values from the additional variable as needed (no need to re-interpolate) Hope the above helps, |
|
April 8, 2019, 16:39 |
|
#5 |
Member
phd
Join Date: Oct 2013
Posts: 76
Rep Power: 13 |
Thanks! At each node I have assigned a source term exactly at that node. In such case will the solver still need interpolation at each time step? Or it is the interpolation of the nodal values to surrounding control volumes?
|
|
April 8, 2019, 16:44 |
|
#6 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
Depends on the numerical discretization used for that particular term.
Finding the value of the source described by its location x,y,z coordinates instead of an integer value in a table is an interpolation step where the weights of the neighboring points are 0, and the local weight is = 1. Still the same effort. |
|
Tags |
user fortran |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Run a user fortran routine in parallel | Smilodon | CFX | 2 | March 28, 2017 05:35 |
User fortran error when running CFX-10 in parallel | CFDworker | CFX | 3 | September 22, 2015 09:59 |
CEL vs. USER FORTRAN | Zaktatir | CFX | 0 | February 16, 2013 07:29 |
Comparison between C/C++ and Fortran? | rick | Main CFD Forum | 45 | September 6, 2011 01:52 |
User Fortran and interior node information | John | CFX | 0 | August 26, 2008 23:24 |