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

Obtain equation residuals in UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By dmoroian
  • 1 Post By gearboy

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 1, 2010, 14:26
Default Obtain equation residuals in UDF
  #1
New Member
 
Robert Bressan
Join Date: Feb 2010
Posts: 1
Rep Power: 0
robert.bressan is on a distinguished road
Hello!

I'm writing an UDF that makes an optimization.
So every iteration, it must check if there was convergence in the solver, so I can make the proper changes in my profiles.

Is there a way to return the current solver residuals?

Regards,
Robert
robert.bressan is offline   Reply With Quote

Old   February 9, 2010, 07:20
Default
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Well not in udf but here is a scheme line that gives you the residuals for the specified or current iteration (see also Wiki Fluent Scheme):

Code:
(get-residual-norms-at 1001)
(solver-residuals)
wc34071209 likes this.
dmoroian is offline   Reply With Quote

Old   March 9, 2010, 03:06
Default
  #3
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by robert.bressan View Post
Hello!

I'm writing an UDF that makes an optimization.
So every iteration, it must check if there was convergence in the solver, so I can make the proper changes in my profiles.

Is there a way to return the current solver residuals?

Regards,
Robert
This is an example to print the residuals on the console.
#include "udf.h"
DEFINE_ON_DEMAND(residual_list)
{
int nw;
real scaled_res;
Domain*domain=Get_Domain(1);
for(nw=0; nw<MAX_EQNS; ++nw)
{
if(strlen(DOMAIN_EQN_LABEL(domain,nw))>0)
{
if(0==DOMAIN_RES_SCALE(domain,nw)[nres-1])
DOMAIN_RES_SCALE(domain,nw)[nres-1]=1;
scaled_res=DOMAIN_RES(domain,nw)[nres-1]/DOMAIN_RES_SCALE(domain,nw)[nres-1];
Message("%s equation,residual=%g\n",DOMAIN_EQN_LABEL(domain,nw ),scaled_res);
}
}
}
wc34071209 likes this.
gearboy is offline   Reply With Quote

Old   March 9, 2010, 03:34
Default What is nres?
  #4
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Ji,
Nice to see some undocumented macros at use, but what is 'nres' variable representing?
dmoroian is offline   Reply With Quote

Old   March 9, 2010, 22:25
Default
  #5
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by dmoroian View Post
Hi Ji,
Nice to see some undocumented macros at use, but what is 'nres' variable representing?
nres is the current number of residuals.
gearboy is offline   Reply With Quote

Old   April 1, 2012, 02:49
Exclamation
  #6
New Member
 
Small Mayi
Join Date: Nov 2011
Posts: 26
Rep Power: 14
ChenZhan is on a distinguished road
Quote:
Originally Posted by gearboy View Post
nres is the current number of residuals.
Dear my friends.Now, a similar problem I had come acrossed when edit a udf, while i copy this code and then try to compile as executable progame, an issue come out, the fluent tell me that subscript required array or poiter types. I think it maybe caused by the nres. Who can tell me how to treat it. I only want to obtain the residuals on the current time in my udf.
If anybody could have the same question and have solve it,please help me. Thank you.
ChenZhan is offline   Reply With Quote

Old   April 1, 2012, 03:02
Default ...post the error
  #7
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Could you post the error you get not from your own memory, but from the computer screen?
dmoroian is offline   Reply With Quote

Old   April 1, 2012, 03:11
Default
  #8
New Member
 
Small Mayi
Join Date: Nov 2011
Posts: 26
Rep Power: 14
ChenZhan is on a distinguished road
Quote:
Originally Posted by dmoroian View Post
Could you post the error you get not from your own memory, but from the computer screen?
Ok
(system "copy "C:\PROGRA~1\ANSYSI~1\v130\fluent"\fluent13.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp\makefile" ")
已复制 1 个文件。
(chdir "libudf")()
(chdir "win64\2ddp")()
# Generating ud_io1.h
test2.c
..\..\src\test2.c(11) : error C2109: 下标要求数组或指针类型
..\..\src\test2.c(12) : error C2109: 下标要求数组或指针类型
..\..\src\test2.c(13) : error C2109: 下标要求数组或指针类型
..\..\src\test2.c(13) : error C2109: 下标要求数组或指针类型
Done.
"下标要求数组或指针类型/chinese" means "subscript requried arrays or pointer types"
Thank you!!
ChenZhan is offline   Reply With Quote

Old   April 1, 2012, 10:08
Default
  #9
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Is it possible to post the code? Apparently you're trying to use as array something that's not.
dmoroian is offline   Reply With Quote

Old   April 2, 2012, 09:47
Default
  #10
New Member
 
Small Mayi
Join Date: Nov 2011
Posts: 26
Rep Power: 14
ChenZhan is on a distinguished road
Quote:
Originally Posted by dmoroian View Post
Is it possible to post the code? Apparently you're trying to use as array something that's not.

I am very appreciated for your help. In order to avoid to determine the convergence in my udf according to the residuals, I had choosen another
variable at the exit boundary ,and by monitoring its change to do the next work.
ChenZhan 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
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
udf temperature/velocity profile-> equation problems roka1mtr FLUENT 2 August 25, 2009 04:44
UDF Addidtional Force to momentum equation sfawal FLUENT 10 July 15, 2009 09:29
UDF to switch on energy equation after X iteration mat w FLUENT 6 December 5, 2005 07:35
DEFINE_DPM_OUTPUT macro UDF HELP Puneet FLUENT 3 November 28, 2003 10:55


All times are GMT -4. The time now is 14:21.