|
[Sponsors] |
April 11, 2014, 13:42 |
dynamic meshing UDF motion coding issue!
|
#1 |
New Member
Lisa Marfell
Join Date: Nov 2013
Posts: 7
Rep Power: 13 |
Hello!
I am trying to simulate a 2D moving piston to analyse the pressure flow field in a closed system. I currently have a rectangular mesh and am trying to write a Define_GEOM macro to define the motion of one moving boundary to simulate the movement piston. I do not have much experience with coding, but have been looking at various tutorials and examples and have so far come up with the following code: #include "udf.h" DEFINE_GEOM(moving_boundary,domain,dt,position) int position; for (int position=0; position<=230.5; position++) { nextposition = position+1; if (position<230.5) { nextposition = - 138399*position*position + 2716.6*position - 0.7678; } position = nextposition; } The code contains a simple sin function: y = -138399x^2 + 2716.6x - 0.7678 which should allow the piston to accelerate and decelerate. The code is designed to move the piston wall from position 0mm to position 230.5mm and then stop. So I want the position to increment at 1mm every iteration from 0mm to 230.5mm at a rate of the sin function shown. I am getting a lot of errors with this though and was hoping someone might be able to help! Originally I used this code: { position[1] = - 138399*position[0]*position[0] + 2716.6*position[0] - 0.7678; } and managed to hook it to my model, however as there is no loop function, the wall only moves slightly once. Any help would be massively appreciated. Thanks! Lisa |
|
Tags |
code, define_geom, dynamic meshing, macro, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf for dynamic mesh | moloykb | Fluent UDF and Scheme Programming | 1 | February 13, 2013 00:06 |
Fluent UDF Discontinuous Motion | lequi7 | Fluent UDF and Scheme Programming | 2 | November 4, 2011 00:18 |
UDF error CG Motion | Alex | FLUENT | 0 | March 22, 2006 18:40 |
UDF, dynamic mesh motion | phil | FLUENT | 0 | September 15, 2004 06:42 |
Problem related with UDF for dynamic mesh | Ryan | FLUENT | 6 | April 29, 2004 10:29 |