CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

If the implementation of the User CEL Fortran routine can accelerate the calculation?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By Opaque
  • 1 Post By Opaque
  • 1 Post By Opaque

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 8, 2019, 13:57
Default 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
lostking18 is on a distinguished road
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!
lostking18 is offline   Reply With Quote

Old   April 8, 2019, 14:22
Default
  #2
Senior Member
 
Join Date: Jun 2009
Posts: 1,862
Rep Power: 33
Opaque will become famous soon enough
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,
lostking18 likes this.
Opaque is offline   Reply With Quote

Old   April 8, 2019, 15:12
Default
  #3
Member
 
phd
Join Date: Oct 2013
Posts: 76
Rep Power: 13
lostking18 is on a distinguished road
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.
lostking18 is offline   Reply With Quote

Old   April 8, 2019, 15:31
Default
  #4
Senior Member
 
Join Date: Jun 2009
Posts: 1,862
Rep Power: 33
Opaque will become famous soon enough
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,
lostking18 likes this.
Opaque is offline   Reply With Quote

Old   April 8, 2019, 15:39
Default
  #5
Member
 
phd
Join Date: Oct 2013
Posts: 76
Rep Power: 13
lostking18 is on a distinguished road
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?
lostking18 is offline   Reply With Quote

Old   April 8, 2019, 15:44
Default
  #6
Senior Member
 
Join Date: Jun 2009
Posts: 1,862
Rep Power: 33
Opaque will become famous soon enough
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.
lostking18 likes this.
Opaque is offline   Reply With Quote

Reply

Tags
user fortran


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run a user fortran routine in parallel Smilodon CFX 2 March 28, 2017 04:35
User fortran error when running CFX-10 in parallel CFDworker CFX 3 September 22, 2015 08:59
CEL vs. USER FORTRAN Zaktatir CFX 0 February 16, 2013 06:29
Comparison between C/C++ and Fortran? rick Main CFD Forum 45 September 6, 2011 00:52
User Fortran and interior node information John CFX 0 August 26, 2008 22:24


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