CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   what's wrong with my UDF??? (https://www.cfd-online.com/Forums/fluent/41390-whats-wrong-my-udf.html)

lk zhu June 14, 2006 20:17

what's wrong with my UDF???
 
Hi,everyone! I want to use VOF model and add a energy source in water.the sources should be added at position of the free surface using UDF.IN order to capture the free surface, i use the macro of C_VOF(The free surface cross all the cell where the volume fraction is different from 0 or 1).But things go contrary to my wishes, it can't run well .Can anybody help me to solove this problem? the udf and error messeges are as follows.

Thanks in advance

#include "udf.h" DEFINE_SOURCE(cell_heat_source,cell,thread,dS,eqn) {

real source;

C_VOF(cell,thread);

if(C_VOF(cell,thread)<1&&C_VOF(cell,thread)>0) {

source=25000;

dS[eqn]=0; }

else

source=dS[eqn]=0;

return source; }

Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: ()


rom June 15, 2006 02:20

Re: what's wrong with my UDF???
 
If you hook this udf to the mixture fluent will bug out because it does not know which volume fraction do you want to access. There are at least 2 phases which are both part of the mixture, so you will have to supply aditional informations and tell fluent which phase you want to access.
This is done by using the corresponding sub thread for the phase. Assuming your primary phase is water, then correct udf will look like this:


#include "udf.h"

DEFINE_SOURCE(cell_heat_source,cell,mixture_thread ,dS,eqn)
{
real source;
int phase_domain_index = 0; /* primary phase index is 0 */
Thread *water_thread = THREAD_SUB_THREAD(mixture_thread,phase_domain_inde x);

if(C_VOF(cell,water_thread)<1&&C_VOF(cell,water_th read)>0)
{
source=25000;
dS[eqn]=0;
}
else
source=dS[eqn]=0;

return source;
}

Good luck, RoM

lk zhu June 16, 2006 02:52

Re: what's wrong with my UDF???
 
Thanx RoM for your reply ! I have try it in 3D and it worked very well.


All times are GMT -4. The time now is 02:33.