|
[Sponsors] |
Problems with the C_FACE, C_FACE_THREAD, F_C0, and THREAD_C0 functions |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 18, 2012, 10:21 |
Problems with the F_CENTROID not producing unique values for unique faces
|
#1 |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
Hello,
I am working on a project with the goal of accessing a cell some distance from a wall. I start with the handle to a face thread and loop through the faces in it, take the cell those faces are adjacent to and then access the face on the other side of the cell and repeat until I am far enough away. I have constructed sample code (which crashes) below Code:
#include "udf.h" #define HEAT_ID 6 DEFINE_ON_DEMAND(example){ Thread *t; Domain *d; face_t f; face_t adjFace; Thread *adjFaceThread; cell_t adjCell; Thread *adjCellThread; real Ts; real adjCellTemp; real adjFaceTemp; d = Get_Domain(1); t = Lookup_Thread(d,HEAT_ID); begin_f_loop(f, t){ Ts = F_T(f,t); //get cell temperature ts printf("Ts= %f\n f = %d\n",Ts,f); adjCell = F_C0(f,t); printf("adjCell=%d\n",adjCell); adjCellThread = THREAD_T0(t); adjFace = C_FACE(adjCell,adjCellThread,3); printf("adjFace=%d\n",adjFace); adjFaceThread = C_FACE_THREAD(adjCell,adjCellThread,3); adjCellTemp = C_T(adjCell,adjCellThread); printf("adjCellTemp = %f\n",adjCellTemp); adjFaceTemp = F_T(adjFace,adjFaceThread); printf("adjFaceTemp=%f\n",adjFaceTemp); printf("T-adj-cell = %f, T-adj-face3 = %f,\n",adjCellTemp,adjFaceTemp); }end_f_loop(f,t) } Last edited by cMichael; May 24, 2012 at 17:08. Reason: Problem Changed |
|
May 18, 2012, 12:30 |
Clarification
|
#2 |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
I am saying that F_T(f,ft); works if you substitute ft which is a face thread when you use a cell thread instead
|
|
May 24, 2012, 17:02 |
Update
|
#3 |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
So C is an all around terrible language (if your trying to debug using the interpreted function compiler) so I got fed up with it and decided to break the problem into two programs, one program to extract the data i needed from fluent (thus minimizing the amount of time spent in c) and one program in java to do the heavy lifting with multiple threads and the like.
The java program is finished and well tested with example cases and I cant figure out why it wouldn't work. Then I took a closer look at the output from my c function. Right now thread is hard coded to be the surface i want to extract data from. here is an exerp. Code:
printf("next thread loop started\n"); printf("Extracting faces from thread %d\n",THREAD_ID(t)); begin_f_loop(f, t) { F_CENTROID(centroid,f,t); temperature = F_T(f,t); F_AREA(normalVec,f,t); area = NV_MAG(normalVec); fprintf(file,"%e,%e,%e/%e/%e,%e,%e/%e\n",centroid[0],centroid[1],centroid[2],temperature,normalVec[0],normalVec[1],normalVec[2],area); } end_f_loop(f,t); 5.574897e-03,5.462289e-02,-0.000000e+00/3.478730e+02/-0.000000e+00,-2.488653e-07,2.488653e-07/2.488653e-07 6.570358e-03,5.462289e-02,-0.000000e+00/3.497709e+02/-0.000000e+00,-2.488654e-07,2.488654e-07/2.488654e-07 7.565820e-03,5.462289e-02,-0.000000e+00/3.516786e+02/-0.000000e+00,-2.488654e-07,2.488654e-07/2.488654e-07 8.561281e-03,5.462289e-02,-0.000000e+00/3.535121e+02/-0.000000e+00,-2.488653e-07,2.488653e-07/2.488653e-07 The problem is if i highlight any one of the centroids (the first 3 numbers on each line separated by commas "x,y,z/") I get 18 duplicate results. for example here are some of line 1's duplicates: 5.574897e-03,5.462289e-02,-0.000000e+00/3.480813e+02/-0.000000e+00,-2.488653e-07,2.488653e-07/2.488653e-07 5.574897e-03,5.462289e-02,-0.000000e+00/3.493082e+02/-0.000000e+00,-2.488653e-07,2.488653e-07/2.488653e-07 5.574897e-03,5.462289e-02,-0.000000e+00/3.505020e+02/-0.000000e+00,-2.488648e-07,2.488648e-07/2.488648e-07 in groups of 4 evenly throughout all the faces in the face thread (about 23000 of them) I guess my question now is shouldn't F_CENTROID produce a unique result for each face? Someone please help! no one has replied! |
|
May 25, 2012, 04:45 |
|
#4 |
Member
Daniel Tanner
Join Date: Apr 2009
Posts: 54
Rep Power: 18 |
Are you running this simulation in parallel? Does the number of duplicates equal the number of cpu?
|
|
May 25, 2012, 09:31 |
Thank you for answering.
|
#5 | |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
Quote:
The other thing I had considered was the geometry I was testing, it is a heat sink with 16 fins, also not a numerical match. |
||
May 25, 2012, 10:30 |
Interesting developement
|
#6 |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
While stepping through code in my Java program I noticed an interesting pattern between each face and its closest cell.
Face(-0.011347,0.059237,0.0) Cell(-0.011347,0.050459,0.003125) Face(0.01052981,0.0495872,0.0) Cell(0.0105522,0.04980443,0.003125) Face(-0.01333886,0.04980443,0.0) Cell(-0.01333886,0.04980457,0.003125) It seems an interesting pattern has developed in that the closest cell to any face seems to be on some other plain entirely (a shift of .003125). This pattern holds true for all faces in my domain. |
|
May 25, 2012, 14:58 |
Problem solved!
|
#7 |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
In my definition for the centroid values i used
real centroid[2]; because I am working on something where there will never be a 2d case so i figured it would be ok to hard code it as a 3d case to make sure whoever used this code after me wouldn't make the mistake that it could be. our of curiosity I tried real centroid[ND_ND]; it now returns much more reasonable values (as in there are no more duplicates). For some reason unknown to me the ND_ND constant appears to be of some great importance. I hope this prevents someone else from wasting as much time on this problem as i did. |
|
May 27, 2012, 05:38 |
|
#8 |
New Member
moon
Join Date: Feb 2012
Posts: 26
Rep Power: 14 |
Hi,
I dont inderstand one thing ,how fluent calculate gradient in cell at boundary condition ,and what is the difference between gradient and reconstruction macro (i read the udf manual but i didnt inderstood ) thank you a lot |
|
May 29, 2012, 09:35 |
|
#9 |
New Member
Join Date: May 2012
Posts: 7
Rep Power: 14 |
Hey sorry I don't know what your asking, if you can be more clear I will try to help but it sounds right now like you posted in the wrong thread.
|
|
Tags |
centroid, duplicate output, f_c0, f_centroid, unique faces |
|
|