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

UDF programming

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2006, 00:09
Default UDF programming
  #1
fullmonty
Guest
 
Posts: n/a
I need to write a udf to connect my fairly complex Fortran program into my Fluent model.

As a C programming novice, I have been reading the UDF manual and primarily using the example in the UDF manual 8.4.1 as a guide, I have come to the following understanding:

1. Write a C file to take the parameters from the fortran file and pass them to the udf

2. Write an on-demand UDF to display parameters from this C file

3. Compile and Hook the UDF to Fluent

Now my problems...

Firstly, I don't know what the C file in point 1. is supposed to do and how it will pass the fortran parameters to the UDF file.

Secondly, my UDF layout so far is outlined below. The C file I don't quite know what to do with will most likely be called ashdep and is referred to inside the DEFINE_ON_DEMAND parantheses... am I on the right track?

#include "udf.h"

DEFINE_ON_DEMAND(ashdep)

{

Domain *domain;

domain = Get_Domain(1);

Message("Depth of Ash Deposited: %g\n", ash_depth);

}

Any help or suggestions would be very much appreciated.
  Reply With Quote

Old   October 20, 2006, 09:13
Default Re: UDF programming
  #2
max
Guest
 
Posts: n/a
Hi Fullmonty. I think the easiest way to do is to translate your Frotran program into a C program. May be will it take you less time to write a new program than translate the frotran to C and load th parameters through another program. Tell us what you think about that. Good Luck
  Reply With Quote

Old   October 20, 2006, 13:28
Default Re: UDF programming
  #3
jasond
Guest
 
Posts: n/a
I'd say that your understanding is generally correct as you stated it. The one thing I would modify is that the connection between your Fortran code and Fluent need not be through DEFINE_ON_DEMAND. Now, to your two questions:

"Firstly, I don't know what the C file in point 1. is supposed to do..."

The C code you need to write will be the glue between your Fortran code and Fluent. I'll just make something up: suppose I have a Fortran code that computes a velocity magnitude from an analytical solution:


REAL*8 FUNCTION VELPROF(X,Y,Z)


and I want to use that as a velocity boundary condition. The UDF glue that I'll need will look something like:


DEFINE_PROFILE(velmag,t,i)
{
real x[ND_ND];
face_t f;
begin_f_loop(f,t)
{
F_CENTROID(x,f,t);
F_PROFILE(f,t,i) = velprof_mangled(&x[0],&x[1],&x[2]);
}
end_f_loop(f,t)
return;
}


I haven't compiled this, so the details might not be quite right. And we'd need to figure out the whole name mangling issue. At any rate, that's the general idea. The second part of your question (about how parameters are passed back and forth) is harder to answer, but I would expect that you might need to write some code to move data back and forth between your Fortran code and Fluent.

"Secondly, my UDF layout so far is outlined below..."

I don't know exactly what you need to pass back and forth, so I can't say for sure if that is the right track or not. If your Fortran calculation is simple, that might be enough. More detail on what your Fortran calculation needs would help me point you in the right direction.

Jason
  Reply With Quote

Old   October 21, 2006, 00:14
Default Re: UDF programming
  #4
fullmonty
Guest
 
Posts: n/a
Max,

Translating the program into C would be more straight forward, but after this initial trial, I have several other fortran programs which we want to run, and this one alone is extremely long and complicated, so I keep that as my back up plan... along that line however, I know f2c has shown mixed results with this type of translation, do you know a better way?
  Reply With Quote

Old   October 21, 2006, 00:31
Default Re: UDF programming
  #5
fullmonty
Guest
 
Posts: n/a
Jason,

Thanks for the advice on DEFINE statements, my reason for using on_demand was simply because that's how it was illustrated in the example and so I'll continue to investigate other DEFINE statements in the manual to choose one that suits better.

The FORTRAN is an ash deposition program which takes user inputs on boundary layers, viscosities, temperatures etc, and finally returns a deposition volume. It will need to take temperature and particle properties from the FLUENT model and return the Message to the fluent window stating the deposition thickness for a particular area selected.

Your suggestion for the glue program sounds good and I'll have a go at customising it. The program is fairly complex so may need me to ask your advice as I go!

Monty
  Reply With Quote

Old   June 30, 2011, 03:40
Default
  #6
New Member
 
Ehsan
Join Date: Jun 2011
Posts: 9
Rep Power: 15
Ehsan-F is on a distinguished road
Hi fullmonty,
Since the post was for 2006, I am assuming that you already solved the problem! I am doing the same task and my FORTRAN code is not simple to translate to C. I like to know how you solved the problem and which option was the best?
Ehsan
Ehsan-F 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
UDF programming for pressure 3D..HELP coolyihao Fluent UDF and Scheme Programming 4 July 15, 2010 16:28
problem with udf programming in fluent saranyasimi Main CFD Forum 0 December 1, 2009 13:19
UDF programming jaron Fluent UDF and Scheme Programming 0 April 6, 2009 17:55
how to write an UDF programming in 3D coolyihao FLOW-3D 1 March 16, 2009 09:59
two questions about udf programming Vincent FLUENT 1 October 5, 2008 01:24


All times are GMT -4. The time now is 19:25.