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

Reading data from node file in UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By pakk
  • 2 Post By avd28

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 23, 2015, 16:35
Default Reading data from node file in UDF
  #1
New Member
 
Join Date: May 2015
Posts: 29
Rep Power: 11
avd28 is on a distinguished road
Hi,

I'm looking to write a UDF for mesh motion, for which I need to read the nodal positions of each node in the mesh. I have exported the data in an ascii format from Export->Solution Data in FLUENT.

In this case the file contains the nodal positions of a wall zone, which is to move sinusoidally.

However, there is something wrong in the way the udf reads the data. The mesh develops some form of extension and is generally deformed.

I'm attaching the udf I wrote, the mesh file I'm trying to read and the screenshot of what happens to the mesh when I apply the udf to it.

I suspect that there's something wrong in the way the udf is reading the data but I do not know what. I did try writing a program that reads the data from the file and writes it out again. As can guess, the written data was completely different from what I was expecting.

Any insights will be appreciated.

P.S It appears that the mesh data file exceeds the forum's maximum size, so I'll be including a dropbox link for that here.
https://www.dropbox.com/s/ki7wb0cuuh..._115k.out?dl=0
Attached Images
File Type: jpg deformed_mesh.jpg (49.3 KB, 15 views)
Attached Files
File Type: c periodic_msh_motion_m.c (1.7 KB, 17 views)

Last edited by avd28; August 23, 2015 at 16:35. Reason: Adding tags
avd28 is offline   Reply With Quote

Old   August 24, 2015, 12:30
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I think your method is much too complex, but maybe I don't understand fully what you are doing.

What I think you are doing:
1. Save positions to a file.
2. Read positions from that file.
3. Calculation displacement.
4. Make the new coordinate equal to the position read from the file plus the calculated displacement.

The big risk is that the order in which the data is saved, should be exactly the same as the order in which the nodes are read during the calculation, and although that might seem logical, Fluent does not have to do that.

But as far as I can see, you can get the same effect much easier:
1. Calculate additional displacement.
2. Make the new coordinate equal to the old coordinate plus the additional displacement.

So, dx becomes additional displacement:
Code:
waveform= sin (2 * time) - sin (2 * previous_time);
dx[0]=amplitude*(A[0]/NV_MAG(A)*waveform);
dx[1]=amplitude*(A[1]/NV_MAG(A)*waveform);
dx[2]=amplitude*(A[2]/NV_MAG(A)*waveform);
And further on,
Code:
NODE_COORD(v)[0]+=dx[0];
 NODE_COORD(v)[1]+=dx[1];
 NODE_COORD(v)[2]+=dx[2];
In that way, you don't need that file at all...
Far likes this.
pakk is offline   Reply With Quote

Old   August 24, 2015, 17:49
Default
  #3
New Member
 
Join Date: May 2015
Posts: 29
Rep Power: 11
avd28 is on a distinguished road
I actually tried that, but it does not generate the correct mesh motion. If I decrease the timestep, the amplitude increases beyond specified limits and actually causes negative volumes to be generated.
However, I'm glad to say I did solve the problem in question. It was related to an indexing problem in the array that stored the data read from the file.

I have attached the udf as it works as present. It references mesh coordinate data from a file which can be exported by Fluent.

File -> Export -> Solution Data
Attached Files
File Type: c periodic_msh_motion_m.c (1.7 KB, 18 views)
pakk and Chiara_riccio like this.
avd28 is offline   Reply With Quote

Reply

Tags
dynamic mesh, udf


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 in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 11:03
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 18:18


All times are GMT -4. The time now is 00:27.