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

how to read a journal or scheme from UDF?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 31, 2015, 06:06
Default how to read a journal or scheme from UDF?
  #1
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
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, 07:13
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`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, 12:05
Default
  #3
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 14
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, 19:08
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`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, 10:00
Default
  #5
New Member
 
anonymous
Join Date: Dec 2015
Posts: 14
Rep Power: 10
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


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
compile UDF in journal file ivanbuz FLUENT 6 February 10, 2020 12:21
999999 (../../src/mpsystem.c@1123):mpt_read: failed:errno = 11 UDS_rambler FLUENT 2 November 22, 2011 10:46
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 09:58
Integrating Scheme with a FLUENT journal file Pete Willemsen FLUENT 0 May 19, 2006 18:00


All times are GMT -4. The time now is 23:48.