|
[Sponsors] |
December 21, 2018, 18:21 |
Scheme File Needed For UDF to Work?
|
#1 |
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
See the attached *.SCM file (scheme file) and *.C file (UDF). These were given to me in response to an inquiry about printing results to a text file along a line in the domain. I've never heard of scheme files until this. And my UDF knowledge is quite limited. The UDF uses "DEFINE_ON_DEMAND," but if you execute it on demand from the GUI without the scheme file (via Ribbon > User Defined > Execute On Demand), the FOR loop at line 45 of the UDF does not seem to work. This leads me to believe the scheme file activates something that permits the FOR loop to work. But I don't know what.
My end goal would be to scrap the scheme file and just use the UDF to simplify things (more files means more complexity, which I don't want). But I don't know what the scheme file is doing that the UDF requires. Note, I'm using v182 Fluent. Thanks in advance, M Ridzon |
|
December 23, 2018, 23:20 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Scheme file
Code:
(if (not (rp-var-object 'line_id))(rp-var-define 'line_id 999 'int #f)) (if (not (rp-var-object 'line_name))(rp-var-define 'line_name 'axis 'string #f)) (define (idnumb idname) (let () (rpsetvar 'line_id (surface-name->id idname)) (rpsetvar 'line_name idname) (ti-menu-load-string (format #f "di s-m (~a)" (rpgetvar 'line_id))) (ti-menu-load-string "de ud eod \"write_line_data::libudf\"") )) for instance to set your line name "name" and ID "414" you should execute in Fluent console following command: Code:
(rpsetvar 'line_id 414) (rpsetvar 'line_name name) Code:
(rpgetvar 'line_id) (rpgetvar 'line_name) so lets assume you've created line called "myline1", than after you've read scheme file (in fluent GUI file->read -> scheme), put in fluent console following: Code:
(idnumb 'myline1) best regards |
|
December 23, 2018, 23:24 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
udf
Code:
#include "udf.h" #include "surf.h" #include "cxsurf.h" #include "cxiface.h" #include "dx.h" DEFINE_ON_DEMAND(write_line_data) { Surface *s; Surf_Point *p; Domain *d = Get_Domain(1); int i, j, k, l,index, nw,nfp; real value, x, y, z; char *what; char *datafn; int line_id; FILE *fp; datafn = RP_Get_String("line_name"); line_id = RP_Get_Integer("line_id"); fp = fopen(datafn,"w+"); /* 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->cells pointer to cells of each point s->nfl facet list */ s = SurfaceList+line_id; what = "x-velocity"; /* header */ fprintf(fp," x-coordinate, y-coordinate, z-coordinate,"); fprintf(fp,"%16s",what); fprintf(fp,"\n"); Node_Function_Values(d,what); p = s->points; for(i=0;i<s->np;i++) { x = Get_Surface_Point_Coord(p,X_DIM); y = Get_Surface_Point_Coord(p,Y_DIM); z = Get_Surface_Point_Coord(p,Z_DIM); value = Surface_Value(p); fprintf(fp,"% 16.9E,% 16.9E,% 16.9E",x,y,z); fprintf(fp,",% 16.9E",value); fprintf(fp,"\n"); p += 1; } fclose(fp); } Code:
datafn = RP_Get_String("line_name"); line_id = RP_Get_Integer("line_id"); Code:
datafn = "myline1"; line_id = 111; |
|
December 29, 2018, 09:36 |
|
#4 |
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
@AlexanderZ, thank you! This was very helpful information. As I was troubleshooting further, I learned something very odd, that maybe you can comment about. I modified the UDF to omit the scheme file. I opened Fluent and loaded the Case and Data files. I then loaded the UDF and executed it. I learned that the UDF outputs no data (i.e., blank file except for its header line), unless you first "display" the lines. That is, go to the Ribbon > Setting Up Domain > Display. Then display the whole model including the line(s). This led me to believe the software has no awareness of lines existing in the Case file when it's initially loaded. In fact, I noticed the following in the TUI when loading the Case file:
Code:
Welcome to ANSYS Fluent Release 18.2.2 Copyright 2017 SAS IP, Inc. All Rights Reserved. Unauthorized use, distribution or duplication is prohibited. This product is subject to U.S. laws governing export and re-export. For full Legal Notice, see documentation. Build Time: Jul 25 2017 20:06:56 Build Id: 10098 Cleanup script file is C:\Users\Ridzon\Documents\_P\cleanup-fluent-Ridzon-E6530-22600.bat > Reading "\"| gunzip -c \"C:/Users/Ridzon/Documents/_P/manifold.cas.gz\"\""... 77880 tetrahedral cells, zone 2, binary. 17940 triangular wall faces, zone 3, binary. 54 triangular outflow faces, zone 4, binary. 54 triangular velocity-inlet faces, zone 5, binary. 54 triangular velocity-inlet faces, zone 6, binary. 54 triangular velocity-inlet faces, zone 7, binary. 146682 triangular interior faces, zone 9, binary. 17880 nodes, binary. 17880 node flags, binary. Opening library "C:\Users\Ridzon\Documents\_P\libudf"... Library "C:\Users\Ridzon\Documents\_P\libudf\win64\3ddp\libudf.dll" opened write_line_data Done. WARNING -- More than one Viscous Model found active. ---- Changing Viscous Model to k-epsilon... Building... mesh materials, interface, domains, mixture zones, wall-group.1 outlet.1 inlet.3 inlet.2 inlet.1 default-interior fluid.1 Done. Preparing mesh for display... Done. Reading "\"| gunzip -c \"C:/Users/Ridzon/Documents/_P/manifold.dat.gz\"\""... Done. |
|
December 30, 2018, 21:53 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
your line is not a part of mesh, that is why you will never see lines at BUILD part
If the line exists, you dont need to display it best regards |
|
December 31, 2018, 09:34 |
|
#6 |
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
This doesn't seem to make sense, because the UDF does not work unless I first "display" the line. Displaying it seems to trigger and acknowledge the line's existence in the model, which then allows the UDF to output meaningful data. If I don't "display" the line first, the UDF output is blank.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFoam "Permission denied" and "command not found" problems. | iyidaniel@yahoo.co.uk | OpenFOAM Running, Solving & CFD | 11 | January 2, 2018 07:47 |
[Other] How to use finite area method in official OpenFOAM 2.2.0? | Detian Liu | OpenFOAM Meshing & Mesh Conversion | 4 | November 3, 2015 04:04 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 04:23 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 12:44 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |