|
[Sponsors] |
November 26, 2003, 22:56 |
DEFINE_DPM_OUTPUT macro UDF HELP
|
#1 |
Guest
Posts: n/a
|
Hi Fluent users I am facing some terrible problems as detailed below. Think I will surely receive some help from fellow fluent users
I am using Fluent (version 6.1.18) to simulate particle trajectories through 3d stator stage of Low-Pressure gas turbine. However while trying to get particle trajectory data using a UDF I have found myself engrossed in some big problems mainly related to shortcomings in the software. Here are the details about the routine 1. I am trying to use DEFINE_DPM_OUTPUT macro in fluent to get the particle positions and velocities at various locations within the stator passage. I compile the udf using fluent and I have Microsoft Visual Studio. Net 2003 installed on the Windows 2000 operating systems to meet the compiling requirements. The test udf I use is a very simple one having just a simple one line print command referring to print a Tracked Particle structure element. It is given below #include "udf.h" #include "dpm.h" #include "surf.h" DEFINE_DPM_OUTPUT(particle, header, fp, p, t, plane) { printf("%d \n", p->state.pos[0]); } Infact, when I compile the program fluent window does not show me any errors and helps to build and load the library in my working directory. When I try to use this UDF thro the Report-Discrete Phase-Sample…. Panel and select my injection it gives an error as given below ------------------------------------------------------ Debug Assertion Failed Program : F:/wina32app/fluent6.1/fluent6.1/ntx86/3d/fl6118s.exe File: fopen.c Line: 54 Expresion: *file !=_T('\0') ------------------------------------------------------ I tried to run this problem under Linux platforms but it does not work there either and gives an error too. I went back to the basics and tried to run the UDF example listed in section 4.6.9 of the Fluent January 2003 documentation the case is given as under /************************************************** ******************* UDF for computing the melting index along a particle trajectory ************************************************** ********************/ #include "udf.h" static real viscosity_0; DEFINE_INIT(melt_setup, domain) { /* if memory for the particle variable titles has not been * allocated yet, do it now */ if (NULLP(user_particle_vars)) Init_User_Particle_Vars(); /* now set the name and label */ strcpy(user_particle_vars[0].name,"melting-index"); strcpy(user_particle_vars[0].label,"Melting Index"); } /* update the user scalar variables */ DEFINE_DPM_SCALAR_UPDATE(melting_index, cell, thread, initialize, p) { cphase_state_t *c = &(p->cphase); if (initialize) { /* this is the initialization call, set: * p->user[0] contains the melting index, initialize to 0 * viscosity_0 contains the viscosity at the start of a time step*/ p->user[0] = 0.; viscosity_0 = c->mu; } else { /* use a trapezoidal rule to integrate the melting index */ p->user[0] += P_DT(p) * .5 * (1/viscosity_0 + 1/c->mu); /* save current fluid viscosity for start of next step */ viscosity_0 = c->mu; } } /* write melting index when sorting particles at surfaces */ DEFINE_DPM_OUTPUT(melting_output, header, fp, p, thread, plane) { char name[100]; if (header) { if (NNULLP(thread)) printf(fp,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,11); else printf(fp,"(%s %d)\n",plane->sort_file_name,11); printf(fp,"(%10s %10s %10s %10s %10s %10s %10s" " %10s %10s %10s %10s %s)\n", "X","Y","Z","U","V","W","diameter","T","mass-flow", "time","melt-index","name"); } else { sprintf(name,"%s:%d",p->injection->name,p->part_id); printf(fp, "((%10.6g %10.6g %10.6g %10.6g %10.6g %10.6g " "%10.6g %10.6g %10.6g %10.6g %10.6g) %s)\n", p->state.pos[0], p->state.pos[1], p->state.pos[2], p->state.V[0], p->state.V[1], p->state.V[2], p->state.diam, p->state.temp, p->flow_rate, p->state.time, p->user[0], name); } } The UDF does not compile because of the printf commands towards the end of DPM output macro. The printf command does not support the pointer arguments. The previous documentation suggests the use of cxprintf function, which did not work with the present case when I tried. Anyways I changed to fprintf just to try. The program compiles but again when I run it from the Report – DPM- Sample panel it shows me the same error as was shown in the earlier one line UDF test case as discussed earlier. |
|
November 27, 2003, 02:26 |
Re: DEFINE_DPM_OUTPUT macro UDF HELP
|
#2 |
Guest
Posts: n/a
|
Hi
You may want to try "CX_Message"... Chendhil. |
|
November 27, 2003, 08:12 |
Re: DEFINE_DPM_OUTPUT macro UDF HELP
|
#3 |
Guest
Posts: n/a
|
It has to be fprintf. printf is meant for screen output whereas the DEFINE_DPM_OUTPUT macro generates a file.
When compiled and hooked correctly and a sample plane is specified under report->discrete_phase->sample..., the following should work (I omitted the p->user[0] for melting index which wasn't needed in my application) #include "udf.h" DEFINE_DPM_OUTPUT(particle_output, header, fp, p, thread, plane) { char name[100]; if (header) { if (NNULLP(thread)) fprintf(fp,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,11); else fprintf(fp,"(%s %d)\n",plane->sort_file_name,11); fprintf(fp,"(%10s %10s %10s %10s %10s %10s %10s" " %10s %10s %10s %s)\n", "X","Y","Z","U","V","W","diameter","T","mass-flow", "time","name"); } else { sprintf(name,"%s:%d",p->injection->name,p->part_id); fprintf(fp, "((%6.5f %6.5f %6.5f %6.5f %6.5f %6.5f " "%6.5f %6.5f %6.5f %6.5f) %s)\n", p->state.pos[0], p->state.pos[1], p->state.pos[2], p->state.V[0], p->state.V[1], p->state.V[2], p->state.diam, p->state.temp, p->flow_rate, p->state.time, name); } } |
|
November 28, 2003, 11:55 |
Re: DEFINE_DPM_OUTPUT macro UDF HELP
|
#4 |
Guest
Posts: n/a
|
Thank you guys
I was able to solve the problem. Think there was Fluent 6.1 and VC compiler mismatch problem on the windows platform. Anyways its solved Puneet |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
DPM UDF particle position using the macro P_POS(p)[i] | dm2747 | FLUENT | 0 | April 17, 2009 02:29 |
How to get the grid size using UDF macro? | Miao | FLUENT | 0 | November 2, 2008 19:59 |
UDF Data Access Macro | Woo Meng Wai | FLUENT | 0 | November 6, 2007 21:23 |
need help whith hooking UDF and DEFINE_INIT macro | cax | FLUENT | 3 | June 6, 2006 13:35 |
-What udf macro for boiling - | thomas | FLUENT | 6 | January 19, 2004 08:31 |