Obtain equation residuals in UDF
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 |
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) |
Quote:
#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); } } } |
What is nres?
Hi Ji,
Nice to see some undocumented macros at use, but what is 'nres' variable representing? |
Quote:
|
:(
Quote:
If anybody could have the same question and have solve it,please help me. Thank you. |
...post the error
Could you post the error you get not from your own memory, but from the computer screen?
|
Quote:
(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":confused: Thank you!! |
Is it possible to post the code? Apparently you're trying to use as array something that's not.
|
Quote:
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. |
All times are GMT -4. The time now is 10:38. |