|
[Sponsors] |
October 24, 2015, 03:18 |
Coupling a fortran file with CFX
|
#1 |
New Member
M. A. Moghanloo
Join Date: Oct 2015
Posts: 8
Rep Power: 10 |
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 |
|
October 24, 2015, 05:22 |
|
#2 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143 |
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. |
|
October 24, 2015, 05:52 |
|
#3 |
New Member
M. A. Moghanloo
Join Date: Oct 2015
Posts: 8
Rep Power: 10 |
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.
|
|
October 24, 2015, 05:56 |
|
#4 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143 |
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.
|
|
October 24, 2015, 06:29 |
|
#5 |
New Member
M. A. Moghanloo
Join Date: Oct 2015
Posts: 8
Rep Power: 10 |
Thanks a lot for answer. How i can have this document ?Please if possible send it for me.
|
|
October 24, 2015, 08:31 |
|
#6 |
Senior Member
Join Date: Feb 2011
Posts: 496
Rep Power: 18 |
||
November 17, 2015, 20:00 |
|
#7 |
New Member
Nguyen Duc Thuyen
Join Date: Jul 2014
Posts: 7
Rep Power: 11 |
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 |
|
November 26, 2015, 07:28 |
|
#8 |
New Member
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10 |
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! |
|
November 26, 2015, 11:24 |
|
#9 |
Senior Member
Join Date: Jun 2009
Posts: 1,804
Rep Power: 32 |
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.. |
|
November 30, 2015, 12:34 |
|
#10 |
New Member
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10 |
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! Last edited by CFXNewbie; December 15, 2015 at 10:32. |
|
November 30, 2015, 14:23 |
|
#11 |
Senior Member
Join Date: Jun 2009
Posts: 1,804
Rep Power: 32 |
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. |
|
December 1, 2015, 04:39 |
|
#12 |
New Member
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10 |
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. |
|
December 13, 2015, 07:39 |
|
#13 |
New Member
Emil Günther
Join Date: Nov 2015
Posts: 18
Rep Power: 10 |
Think I finally got it, thanks!
Last edited by CFXNewbie; December 15, 2015 at 10:33. |
|
|
|
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 |