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

writing a udf for a specific body force

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 10, 2014, 21:01
Post writing a udf for a specific body force
  #1
New Member
 
Amirali
Join Date: Oct 2014
Posts: 3
Rep Power: 11
rima_se2003 is on a distinguished road
hi
i managed to solve a problem with matlab and now i have a matrix which consists of magnitude of a force which is applied to the particles in all of the domain. in this matrix i component is equivalent to x position and j component is equivalent to y position. now if want to write a udf to take this force file and apply it to particles as a body force. could anyone help me how to write this udf ? should i use define_dpm_body_ force or another macro? how could i read this matrix file? thanks
rima_se2003 is offline   Reply With Quote

Old   October 13, 2014, 11:04
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Basic steps for your udf file:

1. Define a global array to contain your force. If you have a two-dimensional problem, and the matrix that you calculated is 400x600, your global array should be 400x600x2 (x2 because you need two components of the force).
2. Write a DEFINE_ON_DEMAND macro to read the contents of your data file into the global array.
3. Write a DEFINE_DPM_BODY_FORCE macro. This macro should:
A. Find the location of the particle using P_POS(p).
B. Calculate from the position which entry of your matrix should be used.
C. Get the corresponding force from the global array.
D. Assign the force to the particle.

When you do the real calculation, you should first execute the DEFINE_ON_DEMAND macro, before you do the dpm calculations. In this way, the data file will only be read once, which will speed up your calculations a lot.

Good luck!
pakk is offline   Reply With Quote

Old   October 15, 2014, 02:13
Default
  #3
New Member
 
Amirali
Join Date: Oct 2014
Posts: 3
Rep Power: 11
rima_se2003 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Basic steps for your udf file:

1. Define a global array to contain your force. If you have a two-dimensional problem, and the matrix that you calculated is 400x600, your global array should be 400x600x2 (x2 because you need two components of the force).
2. Write a DEFINE_ON_DEMAND macro to read the contents of your data file into the global array.
3. Write a DEFINE_DPM_BODY_FORCE macro. This macro should:
A. Find the location of the particle using P_POS(p).
B. Calculate from the position which entry of your matrix should be used.
C. Get the corresponding force from the global array.
D. Assign the force to the particle.

When you do the real calculation, you should first execute the DEFINE_ON_DEMAND macro, before you do the dpm calculations. In this way, the data file will only be read once, which will speed up your calculations a lot.

Good luck!
thank you very much pakk for your very useful guidance. how could i read a global array file with the define_on_demand macro? is there exists any prepared code to use?
rima_se2003 is offline   Reply With Quote

Old   October 15, 2014, 03:37
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
That is standard programming with arrays in c. There are many websites that explain it better than I can, just google for "arrays in c".
pakk is offline   Reply With Quote

Reply

Tags
body force, dpm, reading force matrix, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
ActuatorDiskExplicitForce in OF2.1. Help be_inspired OpenFOAM Programming & Development 10 September 14, 2018 12:12
Writing txt file in an UDF sayan_bose Fluent UDF and Scheme Programming 1 February 3, 2014 08:52
having problem in writing a UDF for specific heat in fluent 14.0 nands_bullwalker Fluent UDF and Scheme Programming 1 June 29, 2013 11:32
error message cuteapathy CFX 14 March 20, 2012 07:45
Help: UDF of "particle body force" !!! zhaoh FLUENT 3 January 16, 2007 21:17


All times are GMT -4. The time now is 17:06.