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

define_on_demand:Initialization of a scalar

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   June 28, 2017, 02:05
Smile define_on_demand:Initialization of a scalar
  #1
New Member
 
Mat
Join Date: Jan 2017
Posts: 11
Rep Power: 2
mataus is on a distinguished road
How to use a define_on_demand macro to initialize a scalar in the field?
mataus is offline   Reply With Quote

Old   June 28, 2017, 05:47
Default
  #2
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 143
Rep Power: 2
KaLium is on a distinguished road
This is for all cells:
Code:
DEFINE_ON_DEMAND (scalar_init) 
{
  float x = 1.0; /*your value here*/
  Thread *thread;  
  cell_t cell;   
  Domain *domain = Get_Domain(1);         
  thread_loop_c(thread,domain)     
  {       
    begin_c_loop(cell,thread)              
    {       
    C_UDSI(cell,thread,0) = x;        
    }       
    end_c_loop(cell,thread)     
  }  
}
KaLium is offline   Reply With Quote

Old   June 28, 2017, 07:45
Default
  #3
New Member
 
Mat
Join Date: Jan 2017
Posts: 11
Rep Power: 2
mataus is on a distinguished road
Thank you so much for the reply.
Actually, I am looking for assigning a constant value('0') for all the cells in a particular thread at the start of the calculation.
I wrote my UDF like this

#include "udf.h"

DEFINE_ON_DEMAND(rec)
{
Domain *d;
int zone_id=3;
Thread *t = Lookup_Thread(d,zone_id);
cell_t c;
d = Get_Domain(1);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0) = 0;
}
end_c_loop(c,t)
}
}

Then I interpret this udf. but i dont know how to proceed further.
how can i assign the value '0' for all the cells at the beginning of calculation?
Will it assign automatically after i interpret the udf?
mataus is offline   Reply With Quote

Old   June 28, 2017, 08:46
Default
  #4
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 143
Rep Power: 2
KaLium is on a distinguished road
Do you have some non-zero values in UDM-0?

You have to use the DEFINE_ON_DEMAND - macro with manual command.

http://jullio.pe.kr/fluent6.1/help/h...-use-on-demand

Or you can use the Fluent patch panel:

https://www.sharcnet.ca/Software/Flu...g/node1035.htm
KaLium is offline   Reply With Quote

Old   June 28, 2017, 08:49
Post
  #5
New Member
 
Mat
Join Date: Jan 2017
Posts: 11
Rep Power: 2
mataus is on a distinguished road
Thank you so much...
mataus is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Division by zero exception - loop over scalarField Pat84 OpenFOAM Programming & Development 6 February 18, 2017 06:57
Issue symmetryPlane 2.5d extruded airfoil simulation 281419 OpenFOAM Running, Solving & CFD 5 November 28, 2015 14:09
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 2 April 10, 2015 05:42
Diverging solution in transonicMRFDyMFoam tsalter OpenFOAM Running, Solving & CFD 30 July 7, 2014 06:20
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 01:47


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