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

Error writing output file

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By wilandlane

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 30, 2016, 08:25
Default Error writing output file
  #1
New Member
 
William
Join Date: Apr 2013
Posts: 11
Rep Power: 12
wilandlane is on a distinguished road
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 09:48.
wilandlane is offline   Reply With Quote

Old   August 30, 2016, 09:50
Default
  #2
New Member
 
William
Join Date: Apr 2013
Posts: 11
Rep Power: 12
wilandlane is on a distinguished road
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.
pakk likes this.

Last edited by wilandlane; August 30, 2016 at 13:53.
wilandlane is offline   Reply With Quote

Old   July 1, 2020, 09:32
Default
  #3
Senior Member
 
acalado's Avatar
 
André
Join Date: Mar 2016
Posts: 133
Rep Power: 10
acalado is on a distinguished road
I have a very similar UDF I am trying to use. Could you help me interpret the code on this? Thanks!
__________________
Sapere aude!
acalado is offline   Reply With Quote

Old   August 5, 2021, 05:31
Default
  #4
New Member
 
AnsysUser
Join Date: Jul 2016
Posts: 9
Rep Power: 9
Shreman is on a distinguished road
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.
Shreman is offline   Reply With Quote

Old   August 20, 2021, 14:15
Smile [Couldn't track the initial position x0,y0,z0 in dpm file]
  #5
New Member
 
Join Date: Oct 2018
Posts: 6
Rep Power: 7
Danmei is on a distinguished road
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
I suspect the problem comes from the section of Scalar update in the UDF:
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);
    }
}
However I do not know how to resolve it. I'm using Fluent 2021R1. dpm was applied one-way coupling (post processing, I followed every step in the tutorial). Any help/materials are highly appreciated!
Danmei is offline   Reply With Quote

Reply

Tags
fluent, fluent - udf, udf and programming


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
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 21:03
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 05:18
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44
ParaView Compilation jakaranda OpenFOAM Installation 3 October 27, 2008 11:46
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24


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