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

Couple CFX with in-house code via user Fortran

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 19, 2020, 11:53
Smile Couple CFX with in-house code via user Fortran
  #1
New Member
 
Hu
Join Date: Jan 2014
Posts: 22
Rep Power: 12
hcs129 is on a distinguished road
Dear all,
Recently, I am trying to couple CFX with my code and what I need is the velocity field.
So my question is how to obtain the velocity field, i.e., the cell coordinates and the corresponding velocity.
Alternatively, it would be a better way if I can obatin the fluid velocity at any user specified position.
I have read the guide book for CFX modeling, but still have no idea.
Any one can help?
hcs129 is offline   Reply With Quote

Old   July 19, 2020, 13:09
Default
  #2
Member
 
Henrique Stel
Join Date: Apr 2009
Location: Curitiba, Brazil
Posts: 93
Rep Power: 17
Stel is on a distinguished road
Could you provide us more details? Do you want the velocity field cell by cell during the solution or just the final results? What do you need that cant be done directly in cfd post?
Stel is offline   Reply With Quote

Old   July 19, 2020, 18:03
Default
  #3
New Member
 
Hu
Join Date: Jan 2014
Posts: 22
Rep Power: 12
hcs129 is on a distinguished road
Quote:
Originally Posted by Stel View Post
Could you provide us more details? Do you want the velocity field cell by cell during the solution or just the final results? What do you need that cant be done directly in cfd post?
Hi, Stel. I want the transient velocity field during the solution. My in-house code is used for particle simulation and the fluid velocity field is needed to calculate the momentum and energy source terms for both fluid and solid phases.
hcs129 is offline   Reply With Quote

Old   July 19, 2020, 19:03
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,749
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
You will probably need to do this with user fortran.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   July 20, 2020, 07:24
Default
  #5
Member
 
Henrique Stel
Join Date: Apr 2009
Location: Curitiba, Brazil
Posts: 93
Rep Power: 17
Stel is on a distinguished road
So far I've only worked with user fortran for particle tracking in Ansys, but I assume it is the same logic for any user fortran routine: when you call an external function for particle tracking via user fortran, new options become available in CFX Pre. One of them is the variable list you have to provide as arguments for the user fortran Routine, such as velocity, pressure, etc. At the beginning of your routine, you define and call those arguments. By default, any calculation you do with those variables within your routine will be performed cell by cell throughout your domain. Then, the output from your routine returns to the calculation both as a global value or a field variable, depending on how you define it.

You will have to read the user fortran documentation and search for some examples there or here in the forum to get used to the syntax, library generation, etc, but I guess this is the way to go.
Stel is offline   Reply With Quote

Old   July 20, 2020, 07:38
Default
  #6
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,749
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
I am no expert in CFX User Fortran, but I know there is more to fortran in CFX than that. Somebody please correct me I am wrong, but you have two main approaches (described in the CFX Solver Modelling Guide, Chapter 19):
* User defined CEL
* Junction Box routines

User defined CEL are similar to normal CEL functions but user fortran to calculate it rather than the CFX interpreter. This is what Stel describes. These are quite simple to use and can be done with only a moderate amount of CFX fortran knowledge.

But there are also Junction Box routines. These give lower level at different points in the solution process. This allows much more complex models to be implemented such as interaction with other software, but require a detailed knowledge of CFX fortran and memory structures (MMS) to get to work. It is not for the weak hearted. From what Cs Hu describes I think he will need Junction Box routines for his model.

I did a CFX user fortran course run by ANSYS years ago and recall it was quite complex. (Unfortunately I have not used it much since so have forgotten most of it.) If the course still exists it would be a big help for you.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   July 20, 2020, 07:55
Default
  #7
Member
 
Henrique Stel
Join Date: Apr 2009
Location: Curitiba, Brazil
Posts: 93
Rep Power: 17
Stel is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
I am no expert in CFX User Fortran, but I know there is more to fortran in CFX than that. Somebody please correct me I am wrong, but you have two main approaches (described in the CFX Solver Modelling Guide, Chapter 19):
* User defined CEL
* Junction Box routines

User defined CEL are similar to normal CEL functions but user fortran to calculate it rather than the CFX interpreter. This is what Stel describes. These are quite simple to use and can be done with only a moderate amount of CFX fortran knowledge.

But there are also Junction Box routines. These give lower level at different points in the solution process. This allows much more complex models to be implemented such as interaction with other software, but require a detailed knowledge of CFX fortran and memory structures (MMS) to get to work. It is not for the weak hearted. From what Cs Hu describes I think he will need Junction Box routines for his model.

I did a CFX user fortran course run by ANSYS years ago and recall it was quite complex. (Unfortunately I have not used it much since so have forgotten most of it.) If the course still exists it would be a big help for you.
So basically his fortan code is the main program and he makes use of CFX as a parallel solver to provide data for his fortran routine, is that right?

Well, Glenn is right, fortran routines for particle tracking for example are kind of straightforward programs you run just to generate a library to be used in CFX to perform other calculations.

Well, if putting two codes to work in parallel via user fortran is what he wants then I believe he will indeed need some fancier user fortran programming to do so. To be honest with you I didn't even know this was possible in the first place.
Stel is offline   Reply With Quote

Old   July 20, 2020, 09:40
Default
  #8
New Member
 
Hu
Join Date: Jan 2014
Posts: 22
Rep Power: 12
hcs129 is on a distinguished road
Quote:
Originally Posted by Stel View Post
So basically his fortan code is the main program and he makes use of CFX as a parallel solver to provide data for his fortran routine, is that right?

Well, Glenn is right, fortran routines for particle tracking for example are kind of straightforward programs you run just to generate a library to be used in CFX to perform other calculations.

Well, if putting two codes to work in parallel via user fortran is what he wants then I believe he will indeed need some fancier user fortran programming to do so. To be honest with you I didn't even know this was possible in the first place.
So far I have finished the first step, that is, to share data between my program and CFX dynamicly. However, it is challenge to obtain the fluid velocity field.
hcs129 is offline   Reply With Quote

Old   July 20, 2020, 09:41
Default
  #9
New Member
 
Hu
Join Date: Jan 2014
Posts: 22
Rep Power: 12
hcs129 is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
I am no expert in CFX User Fortran, but I know there is more to fortran in CFX than that. Somebody please correct me I am wrong, but you have two main approaches (described in the CFX Solver Modelling Guide, Chapter 19):
* User defined CEL
* Junction Box routines

User defined CEL are similar to normal CEL functions but user fortran to calculate it rather than the CFX interpreter. This is what Stel describes. These are quite simple to use and can be done with only a moderate amount of CFX fortran knowledge.

But there are also Junction Box routines. These give lower level at different points in the solution process. This allows much more complex models to be implemented such as interaction with other software, but require a detailed knowledge of CFX fortran and memory structures (MMS) to get to work. It is not for the weak hearted. From what Cs Hu describes I think he will need Junction Box routines for his model.

I did a CFX user fortran course run by ANSYS years ago and recall it was quite complex. (Unfortunately I have not used it much since so have forgotten most of it.) If the course still exists it would be a big help for you.
Glenn, do you remember the name of the course? Thanks.
hcs129 is offline   Reply With Quote

Old   July 20, 2020, 12:02
Default
  #10
Senior Member
 
Join Date: Jun 2009
Posts: 1,825
Rep Power: 33
Opaque will become famous soon enough
Quote:
Originally Posted by hcs129 View Post
So far I have finished the first step, that is, to share data between my program and CFX dynamicly. However, it is challenge to obtain the fluid velocity field.
Could we ask what is the challenging part?

Have you selected the location in the algorithm where to gather the information?

Do you know the variable name you are trying to gather?

Do you know where the variable is located in the memory system?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   July 20, 2020, 18:36
Default
  #11
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,749
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Quote:
Glenn, do you remember the name of the course? Thanks.
I have searched the ANSYS webpage and I cannot see any CFX Fortran courses. Only Fluent UDF courses. Also I can't find my course notes
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   August 20, 2020, 09:16
Default
  #12
New Member
 
Hu
Join Date: Jan 2014
Posts: 22
Rep Power: 12
hcs129 is on a distinguished road
Quote:
Originally Posted by Opaque View Post
Could we ask what is the challenging part?

Have you selected the location in the algorithm where to gather the information?

Do you know the variable name you are trying to gather?

Do you know where the variable is located in the memory system?
Opaque, I've managed to obtain velocity field, i.e., the velocity components along with its coordinates. I used the getvar subroutine in the junction box routine.
My challenging part now is to quickly find the neighboring vertices for any specified position. For example, there're three points ((0,0,0),(1,1,1),(2,2,2)) and how to find their nearest neighboring vertices (or elements).
I tried the subroutine CAL_MESHMAP but it works only when the points overlap with mesh vertices.
Do you have any suggestion?
hcs129 is offline   Reply With Quote

Reply

Tags
coupling, user fortran

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
User Fortran with CFX 14.5.7 on winnt_amd64 HLo CFX 22 December 13, 2015 08:26
Using Fortran with CFX: How to connect Fortran to CFX? l.te CFX 0 October 21, 2012 11:42
CFX User Fortran: Particle User Sources hustxinxin CFX 0 March 8, 2012 08:37
Comparison between C/C++ and Fortran? rick Main CFD Forum 45 September 6, 2011 00:52
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 18:56


All times are GMT -4. The time now is 03:14.