|
[Sponsors] |
March 19, 2002, 01:36 |
Accessing neighbouring cells in UDF
|
#1 |
Guest
Posts: n/a
|
Hi!
I have to write an UDF for momentum source that will replace a hole - the problem is to identify the cells those will lie in the hole. The user should provide two data for this: 1. x,y,z location of the hole and, 2. diameter of the hole. Using these info how can I identify the cells that will represent the hole. I request you kindly a solution for this - I will be very much grateful to you. Thanks, Hiranya |
|
March 21, 2002, 20:18 |
Re: Accessing neighbouring cells in UDF
|
#2 |
Guest
Posts: n/a
|
Hi,
you can use the C-CENTROID function to determine whether the current cell is located inside or outside of the hole. Use this as: real x[ND_ND]; C_CENTROID(x,cell,thread); x0 = x[0]; y0 = x[1]; z0 = x[2]; Of course, this is approximate since part of the cell may be outside the perimeter of the hole even though the centroid is within it. Greg |
|
March 22, 2002, 05:28 |
Re: Accessing neighbouring cells in UDF
|
#3 |
Guest
Posts: n/a
|
Hi,
Thanks for your suggestion. There is a problem - I need to restrict the cell searching in the plane of the hole; otherwise the searching would be within a sphere of the hole-diameter which, I do not want. How can I seacrh the cells in the plane of the hole. Please give some advice. May be for this the user has to give some more inputs. Thanks in advance, Hiranya |
|
March 22, 2002, 06:01 |
Re: Accessing neighbouring cells in UDF
|
#4 |
Guest
Posts: n/a
|
Not sure exactly what you mean.
Do you mean - 1. you want to only loop over cells in a certain x-y plane?? or 2. you want to ensure you only pick cells within the hole independent of say the z-co-ordinate value?? For 1. there is no easy answer - unless you specifically setup your mesh with a cell zone around the location of the hole. Otherwise you will need to loop over the whole domain (actually there are some smart tricks one could use...eg. do a calculation initially and store the cells in the local vicinity of the whole in your own list) For 2. this is relatively easy, since you just ignore the z value returned by the C_CENTROID function and make comparisons in only the x-y plane. Greg |
|
March 22, 2002, 07:58 |
Re: Accessing neighbouring cells in UDF
|
#5 |
Guest
Posts: n/a
|
Sorry for the lack of clarity in my mail.
Actually the plane, on which the hole lies, is an arbitrary plane. It may coincide with say x-y plane or it may be at some angle(s) with the principal cartesian planes. So I want to basically traverse along the plane of the hole (instead of say x-y plane). So I think I would need some some kind of direction vector along the plane. What do you say? I found the trick that you mentioned quite interesting; I have got some idea about it but it is not fully clear how can I execute DEFINE_SOURCE macro only for my own list of cells. Would you please give me some more insight on this. Thanks, Hiranya |
|
March 23, 2002, 00:29 |
Re: Accessing neighbouring cells in UDF
|
#6 |
Guest
Posts: n/a
|
1. you may need to consider what you're going to do with the results etc. to determine the optimum method. ...if you are going to use a source term then you can have two options: a) calculate the right value in the cell when the source is called, or b) combine with a DEFINE_ADJUST which calculates the source for every cell and then saves to C_UDMI location. In DEFINE_COURSE you simply return the pre-computed value.
Doing the first, implies looping over all cells. If you do the later, I suspect you will still find it easiest to loop over all cells and perform a calculation. Restricting the looping over cells to an arbitrary plane is possible. I would imagine, you need to loop over the faces/cell-neighbours of the current cell and apply your direction vector to see which nieghbouring cells to go to next, as you mentioned. Its likely to be a little more tricky.... If I were you, I'd see if I could to it simply with a simple algorithm before doing any optimisation. It might run fast enough to ignore coding any special tricks... Greg |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
accessing solver data with UDF macros | Dushan | FLUENT | 1 | April 22, 2017 22:05 |
Averaging over neighbouring cells in parallel | jposunz | OpenFOAM Programming & Development | 3 | October 29, 2015 09:39 |
Accessing neighbour cells!! | Thiyagarajandhayalan | Siemens | 2 | March 21, 2008 05:26 |
Accessing node values using a UDF | Nico | FLUENT | 2 | December 20, 2007 03:50 |
Neighbouring Cells | Carlos V. | FLUENT | 4 | February 1, 2007 09:45 |