|
[Sponsors] |
August 30, 2016, 09:25 |
Error writing output file
|
#1 |
New Member
William
Join Date: Apr 2013
Posts: 11
Rep Power: 13 |
I am trying to compile code from Sandia: http://www.sandia.gov/cfd-water/uvdisinfection.htm, specifically: http://www.sandia.gov/cfd-water/file...Win-serial.zip.
There are two main parts to this UDF: 1) calculate a quantity and 2) write that quantity to an output file. The first part works fine (with the second part removed). However, I get the following error when trying to write to file: ..\..\src\demand2.c(44): error C2223: left of '->dpm_summary' must point to struct/union which refers to the following line: fprintf(fuv,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,14); Is thread->head not a struct/union? Is there an easy fix for this? Thanks! Code:
/***********************************************************************/ /* UDF for computing the UV dosage along a particle trajectory */ /***********************************************************************/ #include "udf.h" #include "dpm.h" #include "sg_disco.h" #define fileuv "output.dpm" #define C_DO(c,t)C_STORAGE_R_XV(c,t,SV_DO_IRRAD,0) static real uv_intensity_0; static real x0, y00, z0; FILE *fuv; DEFINE_DPM_SCALAR_UPDATE(uv_dosage, cell, thread, initialize, p) { cphase_state_t *c = &(p->cphase); if (initialize) { p->user[0] = 0.; uv_intensity_0 = C_DO(cell,thread); x0=p->state.pos[0]; y00=p->state.pos[1]; z0=p->state.pos[2]; } else { p->user[0] += P_DT(p) * .5 * (uv_intensity_0 + C_DO(cell,thread)); uv_intensity_0 = C_DO(cell,thread); } } DEFINE_DPM_OUTPUT(uv_output, header, fp, p, thread, plane) { char name[100]; if (header) { fuv = fopen(fileuv,"w"); if (NNULLP(thread)) { fprintf(fuv,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,14); } else fprintf(fuv,"(%s %d)\n",plane->sort_file_name,14); fprintf(fuv,"(%10s %10s %10s %10s %10s %10s %10s" " %10s %10s %10s %10s %10s %10s %10s %s)\n", "X0","Y0","Z0", "X","Y","Z","U","V","W","diameter","T","mass-flow", "time","UV-Dosage","name"); fclose(fuv); } else { fuv = fopen(fileuv,"a"); sprintf(name,"%s:%d",p->injection->name,p->part_id); fprintf(fuv, "((%10.6g %10.6g %10.6g %10.6g %10.6g %10.6g " "%10.6g %10.6g %10.6g %10.6g %10.6g %10.6g %10.6g %10.6g) %s)\n", x0,y00,z0, 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); fclose(fuv); } } Last edited by wilandlane; August 30, 2016 at 10:48. |
|
August 30, 2016, 10:50 |
|
#2 |
New Member
William
Join Date: Apr 2013
Posts: 11
Rep Power: 13 |
I may have solved the problem by changing the line
fprintf(fuv,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,14); to fprintf(fuv,"(%s %d)\n",THREAD_HEAD(thread)->dpm_summary.sort_file_name,14); This was based on an example from the most recent (17.1) UDF user manual. It compiled without problem and I am post processing now. Last edited by wilandlane; August 30, 2016 at 14:53. |
|
July 1, 2020, 10:32 |
|
#3 |
Senior Member
André
Join Date: Mar 2016
Posts: 133
Rep Power: 10 |
I have a very similar UDF I am trying to use. Could you help me interpret the code on this? Thanks!
__________________
Sapere aude! |
|
August 5, 2021, 06:31 |
|
#4 |
New Member
AnsysUser
Join Date: Jul 2016
Posts: 9
Rep Power: 10 |
Thank you for posting this.
I have managed to get rid of C2223 error by changing to THREAD_HEAD(thread)->dpm_summary.sort_file_name Saved my time. Thank you again. |
|
August 20, 2021, 15:15 |
[Couldn't track the initial position x0,y0,z0 in dpm file]
|
#5 |
New Member
Join Date: Oct 2018
Posts: 6
Rep Power: 8 |
Hi All,
Allow me to ask my question on this past thread as I don't want to create a new thread using the same udf code. I am new to UV reactor modeling and am using this UDF for self learning purposes. I was following the tutorial provided from the same website. However, when I checked the outlet.dpm file, I noticed that the x0, y0, z0 are not recorded. HTML Code:
(outlet 14) ( X0 Y0 Z0 X Y Z U V W diameter T mass-flow time UV-Dosage name) (( 0 0 0 -0.715 -0.0332915 -1.469 -1.0478 -0.175635 0.0297988 0.0001 1 4.9776e-24 1.93107 18.5201) injection-1:1) (( 0 0 0 -0.715 -0.0519024 -1.39937 -0.580425 -0.128457 0.0482263 0.0001 1 4.9776e-24 1.93299 19.9172) injection-1:8) (( 0 0 0 -0.715 -0.019126 -1.43368 -1.01811 -0.140606 -0.10238 0.0001 1 4.9776e-24 1.89647 22.112) injection-1:10) (( 0 0 0 -0.715 -0.03798 -1.36966 -0.43873 0.319689 0.0774602 0.0001 1 4.9776e-24 2.44014 21.4925) injection-1:12) (( 0 0 0 HTML Code:
DEFINE_DPM_SCALAR_UPDATE(uv_dosage, cell, thread, initialize, p) { cphase_state_t *c = &(p->cphase); if (initialize) { p->user[0] = 0.; uv_intensity_0 = C_DO(cell,thread); x0=p->state.pos[0]; y00=p->state.pos[1]; z0=p->state.pos[2]; } else { p->user[0] += P_DT(p) * .5 * (uv_intensity_0 + C_DO(cell,thread)); uv_intensity_0 = C_DO(cell,thread); } } |
|
Tags |
fluent, fluent - udf, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 | towanda | OpenFOAM Community Contributions | 6 | September 5, 2015 22:03 |
[swak4Foam] funkySetFields compilation error | tayo | OpenFOAM Community Contributions | 39 | December 3, 2012 06:18 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |
ParaView Compilation | jakaranda | OpenFOAM Installation | 3 | October 27, 2008 12:46 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |