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

Is it possible to use gradient adaption for two different parameters?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 17, 2017, 21:20
Default Is it possible to use gradient adaption for two different parameters?
  #1
Member
 
Join Date: Jun 2015
Posts: 46
Rep Power: 11
Hossein1 is on a distinguished road
I am using 'dynamic gradient adaption' for mesh refinement. However, I'd like to be able to apply refinement not only based on phase gradient but also wherever there is a velocity gradient as well.
Please let me know whether it is possible and how.

Thanks
Hossein1 is offline   Reply With Quote

Old   April 19, 2018, 07:00
Default answer
  #2
New Member
 
Join Date: Apr 2018
Posts: 8
Rep Power: 8
torjo is on a distinguished road
Hi,

It is possible, but its a bit of work.

Specify a UDS and use a DEFINE_AT_END udf to fill it with VOF.
This gives you access to the VOF gradient via the UDSI_G macro.

Use this to make another UDF that takes UDSI_G and whatever other scalar you wish to adapt with, and flag a user defined memory (UDM) such that it either adaps or coarsens.

e.g.

If UDSI_G>0.1 || dv/dx>0.1
UDM=1
else
UDM=0

then just set the adaption to be depending on the UDM (adapt if UDM>0.5 coarsen if UDM<0.5).


I hope this makes somewhat sence, else i will be happy to elaborate.

BR.
Torjo
torjo is offline   Reply With Quote

Old   April 29, 2020, 11:35
Default
  #3
Senior Member
 
rupak504's Avatar
 
Lolita
Join Date: Aug 2016
Posts: 118
Rep Power: 10
rupak504 is on a distinguished road
Quote:
Originally Posted by torjo View Post
Hi,

It is possible, but its a bit of work.

Specify a UDS and use a DEFINE_AT_END udf to fill it with VOF.
This gives you access to the VOF gradient via the UDSI_G macro.

Use this to make another UDF that takes UDSI_G

I hope this makes somewhat sence, else i will be happy to elaborate.

BR.
Torjo
Hello torjo

This is a similar problem you described above. I wish to find gradients of alpha variables in the VOF model. I already checked the expert activation and tried C_VOF_G, it still gives the error. One of the papers, I read they used UDS to define the alpha and then UDSI_G to find the gradient of alpha.


Above you have written "Specify a UDS and use a DEFINE_AT_END udf to fill it with VOF" what do you mean by this statement?

What I did was, I defined a UDS in the fluent, choosing alpha as the new variable, then I used UDSI_G to find the gradient of the alpha variable but it still gives the error.

Any help would be highly appreciated.

regards
rupak504 is offline   Reply With Quote

Old   April 29, 2020, 12:55
Default VF Gradient
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
If using C_VOF_G gives segmentation violation, then the memory has not been assigned. However, if the value is 0, then the arguments passed to C_VOF_G could be wrong.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 30, 2020, 04:25
Default VF gradient
  #5
Senior Member
 
rupak504's Avatar
 
Lolita
Join Date: Aug 2016
Posts: 118
Rep Power: 10
rupak504 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
If using C_VOF_G gives segmentation violation, then the memory has not been assigned. However, if the value is 0, then the arguments passed to C_VOF_G could be wrong.
Code:
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "metric.h"
#include "mem.h"
#define CON 1

DEFINE_ADJUST(store_gradient, domain)
{
	Thread *t;
	Thread **pt;
	cell_t c;
	int phase_domain_index = 0.;
	Domain *pDomain = DOMAIN_SUB_DOMAIN(domain, phase_domain_index);
	{
		Alloc_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
		Scalar_Reconstruction(pDomain, SV_VOF, -1, SV_VOF_RG, NULL);
		Scalar_Derivatives(pDomain, SV_VOF, -1, SV_VOF_G, SV_VOF_RG,Vof_Deriv_Accumulate);
	}

	mp_thread_loop_c(t, domain, pt)
		if (FLUID_THREAD_P(t))
		{
			Thread *ppt = pt[phase_domain_index];

                        begin_c_loop(c, t)
			{
				C_UDMI(c, t, 0) = C_VOF_G(c, ppt)[0];
                                Message("UDMI0: %g\n", C_UDMI(c, t, 0));
			}
			end_c_loop(c, t)
		}
	Free_Storage_Vars(pDomain, SV_VOF_RG, SV_VOF_G, SV_NULL);
}
With this, I am not getting any segmentation errors.

Code:
UDMI0: 0
UDMI0: 0
UDMI0: 0
UDMI0: 0
UDMI0: 0
UDMI0: 0
UDMI0: -1.95115e-41
UDMI0: 0
UDMI0: 0
UDMI0: 0
UDMI0: 0
I am getting messages like this. Here, I have not switched on the expert option.

Now, I tried to use the expert option and set keep memory "yes".

Code:
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "metric.h"
#include "mem.h"
#define CON 1

/************************************************** *******************/
/* Finding dot product of gradT and gradalpha(liq) */
/************************************************** *******************/

DEFINE_ADJUST(store_gradient, domain)
{
	Thread *t;
	Thread **pt;
	cell_t c;
	int phase_domain_index = 0.;
	Domain *pDomain = DOMAIN_SUB_DOMAIN(domain, phase_domain_index);

	mp_thread_loop_c(t, domain, pt)
		if (FLUID_THREAD_P(t))
		{
			Thread *ppt = pt[phase_domain_index];

			begin_c_loop(c, t)
			{

                C_UDMI(c, t, 0) = NV_DOT(C_VOF_G(c, ppt), C_T_G(c,t));
				Message("UDMI0: %g\n", C_UDMI(c, t, 0));

			}
			end_c_loop(c, t)
		}
}
But, here I got segmentation error.

Last edited by rupak504; April 30, 2020 at 05:05. Reason: update
rupak504 is offline   Reply With Quote

Old   April 30, 2020, 06:20
Default Values
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
You appear to be getting correct values based on your first code with allocation of storage. Do note that most of these values would be 0 since most of the cells either have phase-1 or phase-2. Only at the interface the values would be positive or negative. So, run this UDF, go to Contour Plots and then plot the value for UDM. You should observe non-zero values at the interface.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 30, 2020, 19:33
Default
  #7
Senior Member
 
rupak504's Avatar
 
Lolita
Join Date: Aug 2016
Posts: 118
Rep Power: 10
rupak504 is on a distinguished road
Quote:
Originally Posted by vinerm View Post
You appear to be getting correct values based on your first code with allocation of storage. Do note that most of these values would be 0 since most of the cells either have phase-1 or phase-2. Only at the interface the values would be positive or negative. So, run this UDF, go to Contour Plots and then plot the value for UDM. You should observe non-zero values at the interface.
I have got a doubt regarding the source term, that we add to the continuity equation. For example, let's say boiling problem, many a place people have given if (T(l)>Tsat) condition before mass transfer rate, many a place they did not. Which one is correct?


regards
rupak504 is offline   Reply With Quote

Old   May 1, 2020, 16:37
Default Mass Transfer Mechanism
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Mass transfer by evaporation is always due to vapor pressure being different from saturation pressure. Evaporation temperature is a function of pressure above the water. E.g., water boils at 373 K at sea level but same water boils at 345 K at the top of Mount Everest. The reason being low pressure. For the same reason, water in a pond is colder than atmosphere, due to same phenomenon fruit or vegetable or wet clothes dry even if not kept in the sun and without any wind; the vapor pressure in the atmosphere decides at what temperature the water should evaporate. There is a corresponding saturation temperature for each vapor pressure. If temperature of liquid is greater than the saturation temperature for a given pressure, then water evaporates. So, if we are talking about evaporation, mass transfer from liquid to vapor is possible only if liquid temperature is greater than the saturation temperature.
rupak504 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply

Tags
gradient adaption, mesh refinement, two-phase flow, vof


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
question regarding LES of pipe flow - pimpleFoam Dan1788 OpenFOAM Running, Solving & CFD 37 December 26, 2017 15:42
Gradient Computation: finite differences and adjoint method doan.nak SU2 3 November 22, 2017 06:37
Temperature gradient for the internal Field. Philipp Dietrich OpenFOAM Programming & Development 0 July 2, 2014 04:15
can I use static enthalpy gradient to describe dT Jay CFX 0 August 7, 2008 00:01
Editing of adaption parameters CFX-5.5 Sergei CFX 2 July 11, 2002 03:11


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