CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

i think i'm wrong with allocating C_UDSI_G

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2023, 17:10
Default i think i'm wrong with allocating C_UDSI_G
  #1
New Member
 
Anton Vasilev
Join Date: Oct 2022
Posts: 2
Rep Power: 0
antoheb is on a distinguished road
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));
}
Shortly, when i run it with E_x = *number* it works fine. But i want it to go E_x = C_UDSI_G[0] (etc.) somehow

thanks!
p.s. my first one, pls don't judge...
antoheb is offline   Reply With Quote

Old   January 27, 2023, 11:09
Default
  #2
New Member
 
Anton Vasilev
Join Date: Oct 2022
Posts: 2
Rep Power: 0
antoheb is on a distinguished road
Quote:
Originally Posted by antoheb View Post
Hello everyone
problem solved, thanks
antoheb is offline   Reply With Quote

Old   February 2, 2023, 09:31
Default
  #3
New Member
 
I do CFD
Join Date: Mar 2022
Posts: 7
Rep Power: 4
telegrampay.eth is on a distinguished road
Quote:
Originally Posted by antoheb View Post
problem solved, thanks
how did you solve it?
telegrampay.eth is offline   Reply With Quote

Old   May 2, 2024, 06:33
Default
  #4
New Member
 
mary
Join Date: Mar 2023
Posts: 4
Rep Power: 3
mary24 is on a distinguished road
Hi, may I know how do you solve it?
mary24 is offline   Reply With Quote

Reply

Tags
c_udsi, c_udsi_g, dpm, gradient, lorenz


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's wrong with COMSOL? andy.sun.wei COMSOL 9 March 23, 2022 13:30
udf error srihari FLUENT 1 October 31, 2016 15:18
source term in near wall cell rajcfd OpenFOAM Pre-Processing 5 February 1, 2016 11:31
[swak4Foam] fails in parallel with -otherTime? Phicau OpenFOAM Community Contributions 3 June 26, 2013 14:00
Wrong oriented faces due to opposite face bends? Arnoldinho OpenFOAM 5 August 16, 2012 06:00


All times are GMT -4. The time now is 12:00.