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

On demand UDF error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 10, 2007, 12:54
Default On demand UDF error
  #1
RS
Guest
 
Posts: n/a
Hi-

I am getting the "segmentation violation" error when i execute the on demand udf. I got this udf from fluent website..the only part i changed is SID 14 and s=1+SID This is how I go:

Read the case file...Read the data file...compile the UDF....Allocate memory (3)....execute on demand....ERROR...

I tried reading the UDF before reading case n data file...that dint help...

Heres my UDF:

/* UDF to calculate line integral and line lenght weighted average of a variable. by sra and fm 5/05

To have line integral and line average of variable V on a line S u need to Go to Contour panel and do compute of V on S This will fill the values necessary for computation. */

#include "udf.h" #include "surf.h" #include "cxsurf.h" #include "cxiface.h"

#define SID 14

DEFINE_ON_DEMAND(line_integrals) { Surface *s; int i, j, k, index; float v[2][3]; float face_val, line_int, line_ave, curve_length, tot_length;

/* s is the surface having data of surface id SID s->np no of points. s->nf no of faces. s->points points to array of np points. s->ip pointer to interpolation vector of np points. s->facets facet list of the surface. length of array is nfl. s->cells pointer to cells of each point. s->nfl facet list length. */ s = 1+SID;

tot_length = 0.; line_int = 0.;

for (i = 0, k = 0; k < s->np; i +=s->facets[i]+1, k++) { if (s->facets[i] != 2) continue; /* makes sure only line is there */ /*facet value for line surfaces will be the cell value in which the facet lies*/ face_val = SV_Cell_Field(SVFIELD_CURRENT, s->cells+k); for (j = 0; j < s->facets[i]; j++) { index = s->facets[i+j+1]; /* sets point coord x y z*/ SET_POINT_COORD(v[j][0], s->points[index], X_DIM); SET_POINT_COORD(v[j][1], s->points[index], Y_DIM); SET_POINT_COORD(v[j][2], s->points[index], Z_DIM); } /* Length calculation */ curve_length = sqrt(SQR(v[0][0]-v[1][0])+SQR(v[0][1]-v[1][1])+SQR(v[0][2]-v[1][2])); tot_length += curve_length; line_int += curve_length * face_val; }

line_ave = line_int/tot_length; Message("Line integral of currently displayed variable on line of ID %d : %6f\n", SID, line_int); Message("Line length average of currently displayed variable on line of ID %d : %6f\n", SID, line_ave); }

  Reply With Quote

Reply


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] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM Community Contributions 300 October 29, 2014 18:00
c++ libraries and solver compiling vaina74 OpenFOAM Installation 13 February 3, 2012 17:43
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51
user defined function cfduser CFX 0 April 29, 2006 10:58


All times are GMT -4. The time now is 07:26.