CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

how to read a journal or scheme from UDF?

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 31, 2015, 05:06
Default how to read a journal or scheme from UDF?
  #1
Member
 
Join Date: Jul 2013
Posts: 75
Rep Power: 5
upeksa is on a distinguished road
I want to know how to read an scheme (or journal) file from a UDF. So I have this code:

#include "udf.h"
#include <stdio.h>

FILE *fout;

DEFINE_ON_DEMAND(start_iteration)
{
Domain *d =Get_Domain(1);
char buffer[100];

fout = fopen("iteration.scm", "r");
fscanf(fout, "%[^\t\n]", buffer);
fclose(fout);
}

and my scheme file "iteration.scm" is simply:

it 100

So the aim in this case is to run 100 iteration from the execute on demand.

On the other hand, when I add to the code a line

Message0("\n%s", buffer);

The TUI displays the message "it 100", but nothing happens.

Before any answers, I know that this UDF does not make much sense, I only want to know if it is possible to run a scheme or journal file from UDF.

Thanks for your help.
upeksa is offline   Reply With Quote

Old   March 31, 2015, 06:13
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 791
Rep Power: 9
`e` is on a distinguished road
I don't believe there is a way of calling scheme code (including TUI commands) from inside a UDF. Please let us know if you find a way!

What are you trying to achieve overall? Why not simply run a scheme file instead of the execute on demand UDF?

The Message and Message0 utilities print text to the user's screen and cannot execute commands to Fluent.
`e` is offline   Reply With Quote

Old   March 31, 2015, 11:05
Default
  #3
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 121
Rep Power: 6
Kokemoor is on a distinguished road
Any time you could call an on-demand UDF, you should be able call a journal or scheme macro.

If you want some other UDF macro (adjust, execute at end, etc.) to call scheme/TUI "on-demand", the best I've come up with is to create a calculation activity that runs a macro every iteration conditional on some scheme boolean, and use the UDF to set that boolean to true whenever you want to run that command, then back to false next iteration.
Kokemoor is offline   Reply With Quote

Old   March 31, 2015, 18:08
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 791
Rep Power: 9
`e` is on a distinguished road
True, if you need to run scheme code between iterations or time steps you could setup a calculation activity to load the scheme file each time. I've used this technique and run the scheme file every time (and written an empty file from the UDF if there's nothing required for the current iteration/time step).
`e` is offline   Reply With Quote

Old   October 24, 2016, 09:00
Default
  #5
New Member
 
anonymous
Join Date: Dec 2015
Posts: 4
Rep Power: 2
chris_aut is on a distinguished road
Quote:
Originally Posted by `e` View Post
True, if you need to run scheme code between iterations or time steps you could setup a calculation activity to load the scheme file each time. I've used this technique and run the scheme file every time (and written an empty file from the UDF if there's nothing required for the current iteration/time step).
hi `e`,
may I ask you how you did this?
I do have a journal file that does a mesh adaption whenever I stop/interrupt simulation and click via GUI file-read-journal and selct the right *.jou-file.
Now I want to use an EXECUTE_AT_END UDF to run this mentioned journal file (automatically) when for example during my 100000 iterations 1000 iterations are done.
Many thanks for your help/reply
chris_aut is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 UDS_rambler FLUENT 2 November 22, 2011 10:46
compile UDF in journal file ivanbuz FLUENT 2 September 28, 2009 14:56
using UDF to read file Ellen FLUENT 5 November 25, 2008 18:38
how to read matlab script/results to UDF lamlash FLUENT 0 July 17, 2006 08:58
Integrating Scheme with a FLUENT journal file Pete Willemsen FLUENT 0 May 19, 2006 17:00


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