|
[Sponsors] |
December 23, 2020, 04:55 |
Define_source
|
#1 |
New Member
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6 |
Hi,all
I want to include an absorption on a wall. So I stored the area in DEFINE_ON_DEMAND, as below. Is there anything wrong? Thank you for your time! begin_f_loop(f, tc) { c0 = F_C0(f, tc); t0 = THREAD_T0(tc); C_UDMI(c0, t0, 0) = 1; BOUNDARY_FACE_GEOMETRY(f, tc, A, ds, es, A_by_es, dr0); area = NV_MAG(A); C_UDMI(c0, t0, 1) = area; } end_f_loop(f, tc) |
|
December 23, 2020, 05:21 |
|
#2 |
New Member
amine
Join Date: Dec 2020
Posts: 7
Rep Power: 5 |
Hi , i think that you d'ont need to use BOUNDARY_FACE_GEOMETRY(f, tc, A, ds, es, A_by_es, dr0); since you are not computing flux in skewed mesh region inside boundaries
|
|
December 23, 2020, 06:47 |
|
#3 | |
New Member
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6 |
Quote:
I have a curve that fits from the test data with units kg/m²-s. Although I'm not computing flux, but i need its area and volume to change its unit to kg/m³-s. For use in DEFINE_SOURCE. Or do I distort 'Flux in skewed mesh' in your reply? Thank you for your time! |
||
December 24, 2020, 02:16 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
DEFINE_ON_DEMAND(get_face_area) { Domain *d; Thread *t; face_t f; int i,thread_id; real area = 0.0; real A[ND_ND]; d = Get_Domain(1); area = 0.0; thread_id = *** put here ID of face ***; t = Lookup_Thread(d, thread_id); begin_f_loop(f,t) if PRINCIPAL_FACE_P(f,t) { F_AREA(A,f,t); area+=NV_MAG(A); } end_f_loop(f,t) # if RP_NODE /* Perform node synchronized actions here; Does nothing in Serial */ area = PRF_GRSUM1(area); # endif /* RP_NODE */ Message0("Area of face %d is %e\n",thread_id,area); }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 28, 2020, 00:43 |
|
#5 | |
New Member
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6 |
Dear AlexanderZ,
First of all, Thank you very much for the code you provided, which is very useful. Then I added some other code in it, but it doesn't work. I don't know whether it is a mistake in principle or a mistake in logic. Could you please help me have a look, this has been bothering me for several days. Thank you for your time! Quote:
================================================== ============================ errsignal.c:CX_Signal_monitor_system_propagate_err or: 722==> myid 1: Failure to print error message in async signal safe manner. |
||
December 28, 2020, 01:23 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try this code:
Code:
begin_f_loop(f, t) if PRINCIPAL_FACE_P(f, t) { c0 = F_C0(f, t); t0 = THREAD_T0(t); C_UDMI(c0, t0, 0) = 1; F_AREA(A, f, t); area = NV_MAG(A); F_UDMI(f, t, 1) = area; volume = C_VOLUME(c0, t0); C_UDMI(c0, t0, 2) = volume; /********/ mixture_species_loop(mix_mat, sp, i) { total_mole += C_YI(c0, t0, i) / MATERIAL_PROP(sp, PROP_mwi); } co2_mole_fract = (C_YI(c0, t0, 0) / mw_co2) / total_mole; P_total = ABS_P(C_P(c0, t0), op_pres); P_co2 = P_total * co2_mole_fract; C_UDMI(c0, t0, 3) = P_co2; /********/ Message0("\n Area of face %d is %e,Volume is %e,P is %e \n", thread_id, F_UDMI(f, t, 1), C_UDMI(c0, t0, 2), C_UDMI(c0, t0, 3)); } end_f_loop(f, t)
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 28, 2020, 02:52 |
|
#7 | |
New Member
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6 |
Dear AlexanderZ,
I tried the code, but still 'Received signal SIGSEGV'. So allow me to post the entire code. According to your code, everything works fine, but problems arise with the addition of my 'mixture_species_loop'. By the way, allocated 4 user defined location. Thank you for your time! Quote:
|
||
December 31, 2020, 05:34 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
FIRST of all, compile your code and read log! Code which you've put above has a lot of problems.
Try this one Code:
#include "udf.h" DEFINE_ON_DEMAND(get_face_are) { #if !RP_HOST cell_t c, c0; Domain *d; Thread *tc, *t0, *t; face_t f; int i, thread_id; real area, volume, P_co2, total_mole, co2_mole_fract, P_total,mw_co2; real A[ND_ND]; Material *mix_mat, *sp; d = Get_Domain(1); area = 0.0; volume = 0.0; thread_id = 10; P_co2 = 0.0; total_mole = 0.0; co2_mole_fract = 0.0; mw_co2 = 44.0095; tc = Lookup_Thread(d, thread_id); mix_mat = THREAD_MATERIAL(t); thread_loop_c(t, d) { begin_c_loop(c, t) { C_UDMI(c, t, 0) = 0; } end_c_loop(c,t) } begin_f_loop(f, tc) if PRINCIPAL_FACE_P(f, tc) { c0 = F_C0(f, tc); t0 = THREAD_T0(tc); C_UDMI(c0, t0, 0) = 1; F_AREA(A, f, tc); area = NV_MAG(A); F_UDMI(f, t, 1) = area; volume = C_VOLUME(c0, t0); C_UDMI(c0, t0, 2) = volume; /**/ mixture_species_loop(mix_mat, sp, i) { total_mole += C_YI(c0, t0, i) / MATERIAL_PROP(sp, PROP_mwi); } co2_mole_fract = (C_YI(c0, t0, 0) / mw_co2) / total_mole; P_total = ABS_P(C_P(c0, t0), op_pres); P_co2 = P_total * co2_mole_fract; C_UDMI(c0, t0, 3) = P_co2; Message0("\n Area of face %d is %e,Volume is %e,P is %e \n", thread_id, F_UDMI(f, t0, 1), C_UDMI(c0, t0, 2), C_UDMI(c0, t0, 3)); } end_f_loop(f, t) #endif }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
January 3, 2021, 22:02 |
|
#9 |
New Member
liyingjie
Join Date: May 2020
Posts: 6
Rep Power: 6 |
Dear AlexanderZ,
Thank you very much for your patient answers and professional code. Based on your code, I updated some variables and it's working properly! |
|
Tags |
area, source, udmi |
|
|