Need help regarding 6DOF udf with face loop
Hello Dear,
I hope this thread will find you well. I am doing a very simple test where i use 6dof udf but in that udf i want to get the velocity from the actual results. The main problem is complex but i receive the same error as shown below. I also wrote the UDF here below for reference. The thing is when i do not use a loop then it works fine but i need to have a loop to get the velocity or some other variable from the results. I hope you understand the problem and give me feedback asap with your experience. Thank you. UDF: /************************************************** ***** SDOF property compiled UDF with external forces/moments ************************************************** *****/ #include "udf.h" static real acc = 4.631; static real mass = 5; static real velocity; DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime) { prop[SDOF_MASS] =5; prop[SDOF_IXX] = 5.2e-5; prop[SDOF_IYY] = 4.1667e-3; prop[SDOF_IZZ] = 1; prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */ prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */ prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */ prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */ prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */ prop[SDOF_ZERO_ROT_Z] = True; /* boolean, allow rotation around z-axis */ { if(time >= 0) { Thread *f_thread; face_t f; velocity=0; begin_f_loop(f, f_thread) { velocity += F_U(f, f_thread); } end_f_loop(f, f_thread) Message("\nV1 %d /n",velocity); prop[SDOF_LOAD_F_X] = mass*acc; } } } Error: "V1 0 /n ========================= ============== ================================================== ================================================== ============ Node 5: Process 20896: Receiv============================================ ============== ======================================== Node 1: Proc=================ess 20948: Received signal ====================SIGSEGV. ================================================== ============================================ ========================================= =============================Node 3: Process 20648: Received si=ed signal gn======================SIGSEGV. ================================================== =al SI========G=============================== S==EG====V. ======= No====== ============ Node 0: Prde 2: Process 17612: Received sig=====================o========================= ======================================== ============ncess 1936: Received signal Sal SIGSEGV. =========================IGSEGV. ================================================== ================================================== ======== Node 4: ===========Process 10852: Rece======ived signal SIGSEGV.=== ================================================== ======================= ================== 999999: mpt_accept: error: accept failed: No such file or directory" |
Can you give the version without that gives no errors?
|
Quote:
Thank you and for example the following code which i just verified and it works but not with the loop. /************************************************** ***** SDOF property compiled UDF with external forces/moments ************************************************** *****/ #include "udf.h" #include "mem.h" #include "metric.h" static real acc = 4.631; static real mass = 5; DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime) { prop[SDOF_MASS] = 5; prop[SDOF_IXX] = 5.2e-5; prop[SDOF_IYY] = 4.1667e-3; prop[SDOF_IZZ] = 1; prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */ prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */ prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */ prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */ prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */ prop[SDOF_ZERO_ROT_Z] = False; /* boolean, allow rotation around z-axis */ { if (time>=0 && time<=0.12) { prop[SDOF_LOAD_F_X] = mass*acc; } } } |
That is very strange, because your loop should not do anything...
Do you get errors if you remove the Message line? Or replace %d (which is wrong) by %f? |
Quote:
": warning C4700: The uninitialized local variable "f_thread" was used." But in my code as you see that i have initialized that then why is it giving a warning? I am really grateful for your help. |
Quote:
|
You are not calculating the average velocity. You are summing velocities...
If you want to do this: sum velocity*volume, and divide by the total volume. |
Quote:
|
Don't do that, that is not a good average. Sum velocity*area and divide by sum of area.
|
Code:
|
Still the %d which I told you is wrong, and still the unweighted sum which I told you is wrong. Why are you showing this wrong code?
|
Quote:
I have wrote the code with area and tried where i have walls moving in x-direction and it worked. But i have only one message command in my code and in console it shows more than 4 times which i do not understand. But the problem is that when i apply the same in my Overset model then it gives the errors and in compiling there are no warnings or errors. I have attached the code below. Please take a look and help me in this regard. /************************************************** ***** SDOF property compiled UDF with external forces/moments ************************************************** *****/ #include "udf.h" static real acc = 4.631; static real mass = 5; static real velocity, vel, areatot; DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime) { prop[SDOF_MASS] =5; prop[SDOF_IXX] = 8.333e-4; prop[SDOF_IYY] = 4.1667e-3; prop[SDOF_IZZ] = 5.2e-5; prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */ prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */ prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */ prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */ prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */ prop[SDOF_ZERO_ROT_Z] = False; /* boolean, allow rotation around z-axis */ { Thread *t; face_t f; real A[ND_ND]; t = DT_THREAD(dt); velocity=0.0; vel=0; areatot=0; begin_f_loop(f, t) { F_AREA(A,f,t); areatot += NV_MAG(A); velocity += F_U(f, t)* NV_MAG(A); } end_f_loop(f, t) vel = velocity/areatot; Message ("v = %f, velocity= %f, Area Total = %f \n", vel, velocity, areatot); prop[SDOF_LOAD_F_X] = mass*acc; } } Error: v = -nan(ind), velocity= 0.000000, Area Total = 0.000000 ============= ============== ============== ================================================== ========================= ================================================== ================================================== ==== ================================================ ====No== Node============================================== ==de 3: Process 15 1256: Received signal ===SIG=SEGV. ================================================== ================================================ Node 2=======================================: Process 8==== == ============300: Received sNode 4: =====ignal Process 16916: Received===============SIG signal SEGV. ============================SIGSEGV. =========================== Node 0================================================= ============================== : P================================rocess 17156: Received signal SIGSEGV. ================================================== ============================= ==================== Node 5: Process= 16700: Recei=ved signal SIGSEGV===. ================================================== ================:============== Process 16904: Received signal SIGSEGV. ==================== ================================================== =============== The fl process could not be started. |
You are correct, I'm sorry, I should have read better!
|
Quote:
|
You have multiple nodes, you need to let them communicate. AlexanderZ showed how.
|
[QUOTE=AlexanderZ;808774][CODE]
Hello AlexanderZ, thank you so much for your reply and it helped me a lot. But i have a problem where i am using overset model and now what i did that i define the motion on walls and for overset fluid domain i defined relative motion and UDF with only properties e.e mass, rotation and translation. Is this the right way to do it because when i define the same udf with motion on both then i get errors. 2nd thing is that i have attached the code below when i used my calculation for (#if !RP_HOST) and solving it parallel but in results i have variable output 6 times and every variable has a different value. If you can help me to get the one value which should be equal to the one we can see in dynamic mesh window. What i understood from manual that all variable values which i see in console are from different nodes and now i want to let them communicate so get the right value which i do not know yet. And for writing a file with variables like time and velocity should i also use #if !RP_HOST or #if RP_NODE, etc.? The results are as follows. Initially the variable V1 has 6 different values but after some time only one has a value and other has ind value which i do not understand. And in later stages the value is equal to the one in dynamic mesh. I need to have only one accurate value which you can see in 2nd results which i can use further in my program for comparison. , First results V1 0.004384 Area Total 0.001615 /n done. Updating mesh at time level N... V1 0.004380 Area Total 0.009207 /n V1 0.004389 Area Total 0.004913 /n V1 0.004389 Area Total 0.005528 /n V1 0.004385 Area Total 0.001727 /n V1 0.004380 Area Total 0.000947 /ndone. 2nd Results V1 -nan(ind) Area Total 0.000000 /n done. Updating mesh at time level N... V1 -nan(ind) Area Total 0.000000 /n V1 0.030577 Area Total 0.023936 /n V1 -nan(ind) Area Total 0.000000 /n V1 -nan(ind) Area Total 0.000000 /n V1 -nan(ind) Area Total 0.000000 /ndone. your help will really appreciated. thank you. /************************************************** ***** SDOF property compiled UDF with external forces/moments ************************************************** *****/ #include "udf.h" static real acc = 4.631; static real mass = 5; static real velocity, vel, area_tot, area[3]; DEFINE_SDOF_PROPERTIES(acce, prop, dt, time, dtime) { prop[SDOF_MASS] =5; prop[SDOF_IXX] = 8.333e-4; prop[SDOF_IYY] = 4.1667e-3; prop[SDOF_IZZ] = 5.2e-5; prop[SDOF_ZERO_TRANS_X] = False;/* boolean, allow translation in x-direction */ prop[SDOF_ZERO_TRANS_Y] = True; /* boolean, suppress translation in y-direction */ prop[SDOF_ZERO_TRANS_Z] = True; /* boolean, suppress translation in z-direction */ prop[SDOF_ZERO_ROT_X] = True; /* boolean, suppress rotation around x-axis */ prop[SDOF_ZERO_ROT_Y] = True; /* boolean, suppress rotation around y-axis */ prop[SDOF_ZERO_ROT_Z] = False; /* boolean, allow rotation around z-axis */ { #if !RP_HOST Thread *t; face_t f; Domain *domain; int nid; domain = THREAD_DOMAIN (DT_THREAD (dt)); nid = THREAD_ID (DT_THREAD (dt)); t = Lookup_Thread (domain, nid); velocity=0.0; area_tot=0; #endif #if !RP_HOST begin_f_loop(f, t) if (PRINCIPAL_FACE_P(f, t)) { F_AREA(area,f,t); area_tot += NV_MAG(area); velocity += F_U(f, t)*NV_MAG(area); } end_f_loop(f, t) /*area_tot=PRF_GRSUM1(noface); velocity=PRF_GRSUM1(velocity);*/ #if RP_NODE vel = velocity/area_tot; Message("\nV1 %f Area Total %f /n",vel, area_tot); #endif #endif |
You added lines where the nodes communicate (PRF_GRSUM1), but they are comments! The solution is right there, why did you remove that part of the code?
|
Quote:
Also in writing a string when i use #if RP_NODE and fprintf to write the time and velocity then i still have more than one value for one time step and also there is a value of zero at every time step. These are two confusion which i am facing right now. It would be really nice if you could explain it as i have read the manual and it was really helpful to understand nodes, serial, host, etc. but not understood the above mentioned confusions. Thank you and have a nice day. |
Quote:
The issue is resolved. |
Hi Burhan,
Well done resolving the issues. Just to help people who visit this thread in future, please could you post a working version of your code? Thanks. Ed |
All times are GMT -4. The time now is 17:24. |