|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Anton Vasilev
Join Date: Oct 2022
Posts: 2
Rep Power: 0 ![]() |
Hello everyone,
I wanted to apply Lorenz force (electric part only) on discrete particles. So I calculated a potential field as a UDS, which seemed OK. Next step was about making a UDF which calculates gradient of scalar and use it as an electric field. There came the problem. UDF was built and loaded without any errors, UDMI was defined manually using GUI, but when I tried to run calculations, it did 1 iteration then boom and SIGSEGV (pic below). Tried to google it - didnt help. I think i'm wrong with allocating, but i dont know how to do it instead. When i try to get to my UDS_G in code it comes to me with SIGSEGV. ![]() code: Code:
#include "udf.h" #include "sg.h" #define Q 0.00000000000054 /* particle electric charge */ #define TSTART 0.0 /* field applied at t = tstart */ DEFINE_ADJUST(setudmi,d) { Thread *t; cell_t c; int n; /*/Calculating Vorticity Derivatives*/ for (n=0; n<n_uds; n++) { uds_derivatives(d,n); } if (NULL != THREAD_STORAGE(t,SV_UDS_I(0) ) && NULL != T_STORAGE_R_NV(t,SV_UDSI_G(0))) thread_loop_c(t,d) { begin_c_loop(c,t) { C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[0]; C_UDMI(c,t,1) = C_UDSI_G(c,t,0)[1]; } end_c_loop(c,t) } } void uds_derivatives(Domain *d, int n) { /* Code to compute derivative of a variable. Variable storage allocation first.... */ MD_Alloc_Storage_Vars(d, SV_UDSI_RG(n), SV_UDSI_G(n), SV_NULL); Scalar_Reconstruction(d, SV_UDS_I(n), -1, SV_UDSI_RG(n), NULL); Scalar_Derivatives(d, SV_UDS_I(n), -1, SV_UDSI_G(n), SV_UDSI_RG(n), NULL); return; } DEFINE_DPM_BODY_FORCE(lorenz,p,i) { Thread *t = P_CELL_THREAD(p); cell_t c = P_CELL(p); real bforce; real e_x, e_y; e_x = C_UDMI(c,t,0); /* 1000000; /* C_UDSI_G(c,t,0)[0]; */ e_y = C_UDMI(c,t,1); /* 1000000; /* C_UDSI_G(c,t,0)[1]; */ if(P_TIME(p)>=TSTART) { if(i==0) bforce=-Q*e_x;/*C_UDMI(c,t,0);*/ else if(i==1) bforce=-Q*e_y;/*C_UDMI(c,t,1);*/ } else { bforce=0.0; } return (bforce/P_MASS(p)); } ![]() thanks! p.s. my first one, pls don't judge... |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Anton Vasilev
Join Date: Oct 2022
Posts: 2
Rep Power: 0 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
I do CFD
Join Date: Mar 2022
Posts: 7
Rep Power: 4 ![]() |
||
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
mary
Join Date: Mar 2023
Posts: 4
Rep Power: 3 ![]() |
Hi, may I know how do you solve it?
|
|
![]() |
![]() |
![]() |
Tags |
c_udsi, c_udsi_g, dpm, gradient, lorenz |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
What's wrong with COMSOL? | andy.sun.wei | COMSOL | 9 | March 23, 2022 12:30 |
udf error | srihari | FLUENT | 1 | October 31, 2016 14:18 |
source term in near wall cell | rajcfd | OpenFOAM Pre-Processing | 5 | February 1, 2016 10:31 |
[swak4Foam] fails in parallel with -otherTime? | Phicau | OpenFOAM Community Contributions | 3 | June 26, 2013 13:00 |
Wrong oriented faces due to opposite face bends? | Arnoldinho | OpenFOAM | 5 | August 16, 2012 05:00 |