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

Coupling a fortran file with CFX

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ghorrocks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 24, 2015, 03:18
Default Coupling a fortran file with CFX
  #1
New Member
 
M. A. Moghanloo
Join Date: Oct 2015
Posts: 8
Rep Power: 10
mahdiaghaie2003@gmail.com is on a distinguished road
Dear friends
I have time dependent first order differntial equation, solved by runge kutta method in a fortran file. The out put of the calculation is power for a heated pipe. Now how i can compile or execute the fortran file with the simulated pipe in cfx for a transient case? I do not have any experience for this type of coupling.
Thanks
mahdiaghaie2003@gmail.com is offline   Reply With Quote

Old   October 24, 2015, 05:22
Default
  #2
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,700
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
If the fortran calculation is not coupled to the CFD it is very easy - just put the output into a 1D interpolation function.

If the fortran is coupled to the CFD you will need to put the fortran (or a link to it) in a user fortran routine.
ghorrocks is online now   Reply With Quote

Old   October 24, 2015, 05:52
Default
  #3
New Member
 
M. A. Moghanloo
Join Date: Oct 2015
Posts: 8
Rep Power: 10
mahdiaghaie2003@gmail.com is on a distinguished road
Regarding to problem physics, it is impossible to run fortran and cfx in decoupled format (the fortran file needs some parameters of fluid domain like density and velicity during run. The code gives feedbacks from fluid domain and then calculates power for cfx). Now how i can couple my code with cfx. Please explain the procedure step by step.
mahdiaghaie2003@gmail.com is offline   Reply With Quote

Old   October 24, 2015, 05:56
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,700
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
My last post described what is required for a coupled fortran routine. There are some examples of how to do this in the CFX documentation. I do not have time to write a step by step guide, especially as one already exists.
highorder_cfd likes this.
ghorrocks is online now   Reply With Quote

Old   October 24, 2015, 06:29
Default
  #5
New Member
 
M. A. Moghanloo
Join Date: Oct 2015
Posts: 8
Rep Power: 10
mahdiaghaie2003@gmail.com is on a distinguished road
Thanks a lot for answer. How i can have this document ?Please if possible send it for me.
mahdiaghaie2003@gmail.com is offline   Reply With Quote

Old   October 24, 2015, 08:31
Default
  #6
Senior Member
 
Join Date: Feb 2011
Posts: 496
Rep Power: 18
Antanas is on a distinguished road
Quote:
Originally Posted by mahdiaghaie2003@gmail.com View Post
Thanks a lot for answer. How i can have this document ?Please if possible send it for me.
If you have CFX, then you have help files.
Antanas is offline   Reply With Quote

Old   November 17, 2015, 20:00
Default
  #7
New Member
 
Nguyen Duc Thuyen
Join Date: Jul 2014
Posts: 7
Rep Power: 11
tandem is on a distinguished road
1. You read carefully the part 18.2.1 in CFX of Help CFX. You will know the location to get your Junction Box Routine or User Function.
2. Write Junction Box Routine or User Function to caculate coupling
3. Note that, you have to compile your Junction Box Routine or User Function by "cfx5mkext -64bit name's Junction Box Routine or User Function"
4. Read examples of part 18.8 in CFX of Help CFX
tandem is offline   Reply With Quote

Old   November 26, 2015, 07:28
Question
  #8
New Member
 
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10
CFXNewbie is on a distinguished road
Thank you for your answers so far!

I have a very similar problem. I have read chapter 18: User Fortran, but I still have no idea how to compile the code. Do I need just a standard Fortran 77 compiler here? As a simple example, I wanted to test this user routine:

#include "cfx5ext.h"
dllexport(test)
SUBROUTINE TEST (NLOC,NRET,NARG,RET,ARGS,CRESLT,CZ,DZ,IZ,LZ,RZ)
C
INTEGER NLOC,NARG,NRET
CHARACTER CRESLT*(*)
REAL ARGS(NLOC,NARG), RET(NLOC,NRET)
C
INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)
C

RET = 2000*ARGS(1,1)

END


Using a Fortran 77 or Fortran 90 compiler produces errors. What do I have to do?

Thanks a lot!
CFXNewbie is offline   Reply With Quote

Old   November 26, 2015, 11:24
Default
  #9
Senior Member
 
Join Date: Jun 2009
Posts: 1,803
Rep Power: 32
Opaque will become famous soon enough
RET is an array of size NLOC x NRET; therefore, should you not fill in NLOC x NRET entries instead of

RET = 2000 * ARGS(1,1)

For example,

DO IRET = 1,NRET
DO ILOC = 1, NLOC
RET(ILOC,IRET) = 2000 * ARGS(1,1)
ENDDO
ENDDO

Also, you did not say what error has been detected by the compiler..
Opaque is offline   Reply With Quote

Old   November 30, 2015, 12:34
Default
  #10
New Member
 
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10
CFXNewbie is on a distinguished road
Thank you for your help!
I've tried

#include "cfx5ext.h"
dllexport(reibmodell)
SUBROUTINE REIBMODELL (NLOC,NRET,NARG,RET,ARGS,CRESLT,CZ,DZ,IZ,LZ,RZ)
C
INTEGER NLOC,NARG,NRET
CHARACTER CRESLT*(*)
REAL ARGS(NLOC,NARG), RET(NLOC,NRET)
C
INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)
C

DO IRET = 1,NRET
DO ILOC = 1, NLOC
RET(ILOC,IRET) = 2000 * ARGS(1,1)
ENDDO
ENDDO


END

Thanks a lot!
Attached Images
File Type: png errors.PNG (22.7 KB, 56 views)

Last edited by CFXNewbie; December 15, 2015 at 10:32.
CFXNewbie is offline   Reply With Quote

Old   November 30, 2015, 14:23
Default
  #11
Senior Member
 
Join Date: Jun 2009
Posts: 1,803
Rep Power: 32
Opaque will become famous soon enough
It would be good to see your compilation line.

It seems the preprocessing directive # are not being used, that is the compile line did not include cpp, or fpp support.
Opaque is offline   Reply With Quote

Old   December 1, 2015, 04:39
Default
  #12
New Member
 
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10
CFXNewbie is on a distinguished road
I think so, too.

Does #include "cfx5ext.h" only work, when Ansys CFX is installed on the system? Because on this machine I don't have Ansys. On the computer, on which I can use Ansys I can compile only Fortran 90 code.

On the attached image you can see the complete Force 3.0 screen with source code, errors....

Thank you!!

Last edited by CFXNewbie; December 15, 2015 at 10:33.
CFXNewbie is offline   Reply With Quote

Old   December 13, 2015, 07:39
Default
  #13
New Member
 
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10
CFXNewbie is on a distinguished road
Think I finally got it, thanks!

Last edited by CFXNewbie; December 15, 2015 at 10:33.
CFXNewbie is offline   Reply With Quote

Reply


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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 19:43
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 09:17
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 10:59
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


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