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

Calculating Gradient of a Scalar

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 3, 2011, 05:17
Question Calculating Gradient of a Scalar
  #1
New Member
 
Ali
Join Date: Mar 2011
Posts: 27
Rep Power: 15
ali hemmati is on a distinguished road
Hello,

I am going to calculate gradient of a scalar (UDS) which is solved through iterations, and its quantity is known. Here is my 'on demand' UDF which tries(!) to store x-gradient of scalar 0 to scalar 1, yet after executing the UDF, I receive an 'ACCESS VIOLATION' error.
Would you please help me.

Thanks.

Code:
#include "udf.h"

DEFINE_ON_DEMAND(grad_calc)
{

Domain *domain;
Thread *t;
cell_t c;

domain = Get_Domain(1);

	thread_loop_c(t,domain)
	{
		begin_c_loop(c,t)
		{
			C_UDSI(c,t,1) = C_UDSI_G(c,t,0)[0];		
		}
		end_c_loop(c,t)
	}

}
ali hemmati is offline   Reply With Quote

Old   August 3, 2011, 16:10
Default
  #2
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 23
Amir is on a distinguished road
Did you activate 2 UDSs?
Did you set a command in TUI in order to store gradients during iteration?
if yes, before executing this macro, allocate 2nd UDS simply by patching it with arbitrary value.


Amir
Amir is offline   Reply With Quote

Old   August 4, 2011, 05:05
Default
  #3
New Member
 
Ali
Join Date: Mar 2011
Posts: 27
Rep Power: 15
ali hemmati is on a distinguished road
Hi Amir,

Thanks for your help. I pursued these two methods and got desired solution:

1. I solved the problem with defining all UDSs before iterating.
2. I solved the problem just by defining scalar 0 and after convergence, I patched scalar 1 to fluid zone with arbitrary value.

Subsequent to things done above, I executed the UDF without any error.

Thanks again.
ali hemmati is offline   Reply With Quote

Reply

Tags
access violation error, gradient, uds


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
How to compute the gradient of a scalar as a post-processing ayoros OpenFOAM Post-Processing 16 March 21, 2018 07:02
dieselFoam problem!! trying to introduce a new heat transfer model vivek070176 OpenFOAM Programming & Development 10 December 24, 2014 00:48
Gradient of Scalar calculation in 3D BFCskew grids james T Phoenics 0 March 28, 2007 08:12
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27
gradient for scalar quantity tseo FLUENT 6 August 6, 2005 00:15


All times are GMT -4. The time now is 16:29.