|
[Sponsors] |
December 27, 2019, 17:51 |
C_udsi_g
|
#1 |
Member
Andrea
Join Date: Mar 2018
Posts: 62
Rep Power: 8 |
Hello,
i'm trying to calculate the gradient of the WALL SHEAR STRESS but i'm facing a problem. It's a semicirular domain in 3D with a cylinder in the middle. At the Inlet, the left side, velocity is imposed, Outflow is on the right, Bottom and Cylinder is noslip while top is freeslip. i used DEFINE_ADJUST macro to calculate WSS of the wall face and then i allocated the WSS in the cell adjacent to that face thanks to UDMI(0). Then i set UDSI(0) = UDMI(0). UDMI(1) = UDSI_G(0)[0] UDMI(2) = UDSI_G(0)[1] The problem, in my opinion, is that the gradient is affected by numerical error Here is the code: ---------------------------------------------------------------------------------- #include "udf.h" #define ID_ground 6 DEFINE_ON_DEMAND(SELECTING_CELL_MEMORY) { Domain *d; Thread *t; cell_t c; d=Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,0)=0; /*tau_wall*/ C_UDMI(c,t,1)=0; /*D_SQRT(tau_wall)_DX*/ C_UDMI(c,t,2)=0; /*D_SQRT(tau_wall)_DY*/ } end_c_loop(c,t) } } DEFINE_ADJUST(UDS0, d) { Thread *tc, *t0; cell_t c0; face_t f; tc = Lookup_Thread(d,ID_ground); begin_f_loop(f,tc) { real A[ND_ND]; F_AREA(A,f,tc); real area = NV_MAG(A); real tau_wall = NV_MAG(F_STORAGE_R_N3V(f,tc, SV_WALL_SHEAR))/area; c0=F_C0(f,tc); t0=THREAD_T0(tc); C_UDMI(c0,t0,0) = tau_wall; C_UDSI(c0,t0,0) = C_UDMI(c0,t0,0); C_UDMI(c0,t0,1) = C_UDSI_G(c0,t0,0)[0]; C_UDMI(c0,t0,2) = C_UDSI_G(c0,t0,0)[1]; } end_f_loop(f,tc) } iThe gradient problem is showed in the following images: WSS, D_WSS_DX, D_WSS_DY: WSS.jpg D_WSS_DX.jpg D_WSS_DY.jpg Can someone help me? THANKS |
|
December 30, 2019, 00:13 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you've defined UDSI only I 1 cell layer near the wall boundary, isnt it?
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 30, 2019, 05:25 |
|
#3 |
Member
Andrea
Join Date: Mar 2018
Posts: 62
Rep Power: 8 |
Exactly, I'm studing scouring of the seabed. That's the quantity of material removed from the ground by the sea current.
|
|
December 30, 2019, 21:27 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
may be you should define USDI = 0 everywhere first.
also it could be useful to switch off 'node values' in contours, so you can see fields without interpolation
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 30, 2019, 22:35 |
|
#5 |
Member
Andrea
Join Date: Mar 2018
Posts: 62
Rep Power: 8 |
Since UDM=0 is initialized in EXECUTE_ON_DEMAND, UDM(c0,t0) is overwritten in the cell near boundary, UDS is 0 everywhere and has a value just near wall. When i inspect contour i usually turn off nodes value and see just cell values.
Could it be that the gradient is wrong since i didn't assign nodes and faces but just cell value? Seems strange because i'm not using GreenGaus node based but Least squared. I really don't know why this behavior. Have you some experience in DEFINE_UDS_FLUX? maybe i can avoid C_UDSI_G define a new flux function and solving the scalar without assign it in the wall cells |
|
January 2, 2020, 00:35 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
I don't think you should assign nodes and faces values
Is your simulation is steady state? How do you calculate UDS?
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 2, 2020, 04:00 |
|
#7 |
Member
Andrea
Join Date: Mar 2018
Posts: 62
Rep Power: 8 |
Yes, is a steady state calculation.
I want to solve the divergence of WALL SHEAR STRESS times friction velocity, (div(WSS*U_star)). First i tryed to allocate the value of (D(tau_wall)/DX * U_star_x + tau_wall*D(U_star_x)/DX + D(tau_wall)/DY * U_star_y + tau_wall*D(U_star_y)/DY) directly into cell C0. Since the gradient of tau_wall through the definition of UDSI = tau_wall suffers of numerical error due to oscillations, i tryed to solve UDS imposing 0 as diffusivity coefficient and redefine UDS flux. UDS FLUX is defined as: u_star_x = U/sqrt(U^2+V^2), u_star_y = V/sqrt(U^2+V^2), u_star_z = 0, at the c0 cell adjacent to wall and u,v,w= 0 everywhere else but it is not working. When i solve UDSI en error of floating point exception pops up. !!! C_UDMI(c0,t0,0) = tau_wall !!! define in UDF previously posted ------------------------------------------------------------------------------------------------------------------------------------ #include "udf.h" #define rho 1000 /* Water Density ; */ DEFINE_UDS_FLUX(UDS1_Q_FLUX,f,t,i) { cell_t c0, c1 = -1; Thread *t0, *t1 = NULL; real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0; c0 = F_C0(f,t); t0 = F_C0_THREAD(f,t); F_AREA(A, f, t); /* If face lies at domain boundary, use face values; */ /* If face lies IN the domain, use average of adjacent cells. */ if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/ NV_DS(psi_vec, =, C_UDMI(c0,t0,0)*F_U(f,t)/sqrt(F_U(f,t)*F_U(f,t) + F_V(f,t)*F_V(f,t)), C_UDMI(c0,t0,0)*F_V(f,t)/sqrt(F_U(f,t)*F_U(f,t) + F_V(f,t)*F_V(f,t)), 0, *, rho); flux = NV_DOT(psi_vec, A); /* flux through Face */ } else { c1 = F_C1(f,t); /* Get cell on other side of face */ t1 = F_C1_THREAD(f,t); NV_DS(psi_vec, =, C_UDMI(c0,t0,0)*C_U(c0,t0)/sqrt(C_U(c0,t0)*C_U(c0,t0) + C_V(c0,t0)*C_V(c0,t0)) , C_UDMI(c0,t0,0)*C_V(c0,t0)/sqrt(C_U(c0,t0)*C_U(c0,t0) + C_V(c0,t0)*C_V(c0,t0)) , 0 ,*,rho); NV_DS(psi_vec, +=, C_UDMI(c1,t1,0)*C_U(c1,t1)/sqrt(C_U(c1,t1)*C_U(c1,t1) + C_V(c1,t1)*C_V(c1,t1)) , C_UDMI(c0,t0,1)*C_V(c1,t1)/sqrt(C_U(c1,t1)*C_U(c1,t1) + C_V(c1,t1)*C_V(c1,t1)) , 0 ,*,rho); flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */ } return flux; } ----------------------------------------------------------------------------------------------------------------------------- Last edited by Andrea159357; January 2, 2020 at 05:13. |
|
January 10, 2020, 05:57 |
|
#8 |
Member
Andrea
Join Date: Mar 2018
Posts: 62
Rep Power: 8 |
I've found the problem. UDF was not write for parallel usage.
The numerical error of the gradient is located at the interface of the partition of domain passed to the different cores |
|
January 10, 2020, 06:52 |
|
#9 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
so what did you change?
if loop over faces is embedded into DEFINE_UDS_FLUX(UDS1_Q_FLUX,f,t,i) macro?
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 10, 2020, 07:34 |
|
#10 |
Member
Andrea
Join Date: Mar 2018
Posts: 62
Rep Power: 8 |
No, DEFINE_UDS_FLUX was an alternative to avoid numerical error in DEFINE_ADJUST.
I'm studying how to parallelize my UDF (DEFINE_ADJUST to avoid this problem). I think that the gradient is counted two times because of mirrores cells at boundary (Exterior cells). When i will come up with a solution i'll post a parallelized version of the UDF for define Adjust |
|
January 12, 2020, 19:35 |
|
#11 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you may check ansys fluent customization manual -> parallel consideration
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|