Wall shear stress calculation

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Yvan Fournier
Posts: 3084
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier » Thu Apr 10, 2014 1:13 pm

Hello,

Adding the following file to your SRC directory should provide a fix, while waiting for 3.0.4:

Regards,

Yvan
Attachments
cs_gui_output.c
(60.36 KiB) Downloaded 125 times

Loïc A.
Posts: 9
Joined: Mon Mar 10, 2014 7:56 pm

Re: Wall shear stress calculation

Post by Loïc A. » Thu Apr 10, 2014 8:54 pm

Hello,

Thank you for your quick response! It works.

Regards,

Loïc.

MartianDuan
Posts: 74
Joined: Fri Aug 02, 2013 4:26 pm

Re: Wall shear stress calculation

Post by MartianDuan » Sun Nov 16, 2014 11:01 pm

Hi Yvan,

I am trying to use code_saturne 3.0.1/3.0.3 to do parallel the large eddy simulation with WALE SGS model. I need to calculate the wall shear stress as well. My cases were set up by sub-routines. From my research I need to modify a branch sub-routine to get the averaged wall shear stress. My main problem is how to allocated the user-defined array, which need to be called in 'clptur.f90'. According to the reply in this topic, that I can define it in the 'cs_parameters.f90'. So What I did was adding the following line in the subroutine 'usipph'

!user defined array to store wall shear stress usertau, and friction velocity userutau
double precision, allocatable, dimension(:) :: usertau, userutau
integer nfac
....
allocate(usertau(nfac))
allocate(userutau(nfac))


The problem is these user defined arraies did not transfer to the 'clptur.f90' and 'cs_user_postprocess_var.f90'. The compile log had been attached.

I also tried Brian Angel's suggestion. Defined the user-defined arraies in the 'user_modules.f90' and call it in 'clptur.f90' and 'cs_user_postprocess_var.f90'. It did solve the compilation problem. But it brought the fatal error 'SIGSEGV signal (forbidden memory area access) intercepted!' during the calculation. The listing file and 'cs_user_modules.f90' is attached as well.

Meanwhile, I try to calculate mean wall shear stress instead of instantaneous one. So I added following lines in 'clptur.f90'. I am not sure is it ok or not.

if(iturb.eq.42.and.idries.eq.0) then
tau = romc*uet**2
tau0 = 0.0d0
uet0 = 0.0d0
if (ntcabs .gt. 3600) then
tau0 = tau0+tau
uet0 = uet0+uet
endif
usertau(ifac) = tau0
userutau(ifac) = uet0
endif


I spend a lot of time on this problem. Hope you can give me some suggestions. If you had some example subroutines, can you please shear it with me?

Thanks in advance,

Yu.
Yvan Fournier wrote:Hello,

I just checked, and this indeed seems to be a bug (it should work in 3.x). I'll try to fix it for 3.0.4, and in the meantime, send you a temporary fix by tomorrow.

Regards,

Yvan
Attachments
listing.log
(42.02 KiB) Downloaded 88 times
cs_user_modules.f90
(2.66 KiB) Downloaded 91 times
compile.log
(16.45 KiB) Downloaded 91 times

Yvan Fournier
Posts: 3084
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier » Mon Nov 17, 2014 5:32 am

Hello,

There were some fixes since 3.0.3, so I really recommend upgrading to patch release 3.0.5 (3.0.6 should be released with 2 or 3 weeks).

Did you call the "init_user_module" somewhere after reading the mesh but before the time loop (for example, in cs_user_initialization.f90/usiniv) ? If you did not, it probably explains the SIGSEGV.

Regards,

Yvan

MartianDuan
Posts: 74
Joined: Fri Aug 02, 2013 4:26 pm

Re: Wall shear stress calculation

Post by MartianDuan » Tue Nov 18, 2014 9:33 pm

Hi Yvan,

It doest solved the problem.

But how to calculate the averaged wall-shear-stress? What I had now is the instantaneous wall-shear stress.

I did added the sum function in the 'clptur.f90', but it dose not work. The lines were like:

if(iturb.eq.42.and.idries.eq.0) then
tau = romc*uet**2
tau0 = 0.0d0
uet0 = 0.0d0
if (ntcabs .gt. 3600) then
tau0 = tau0+tau
uet0 = uet0+uet
endif
usertau(ifac) = tau0
userutau(ifac) = uet0
endif


Thanks in advance,

Yu.
Yvan Fournier wrote:Hello,

There were some fixes since 3.0.3, so I really recommend upgrading to patch release 3.0.5 (3.0.6 should be released with 2 or 3 weeks).

Did you call the "init_user_module" somewhere after reading the mesh but before the time loop (for example, in cs_user_initialization.f90/usiniv) ? If you did not, it probably explains the SIGSEGV.

Regards,

Yvan

Yvan Fournier
Posts: 3084
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier » Wed Nov 19, 2014 6:42 am

Hello,

Could you please follow the forum usage recommendations and post the complete user files ? I suspect you forget to add a "save" attribute, but can't check with just a snippet.

Regards,

Yvan

MartianDuan
Posts: 74
Joined: Fri Aug 02, 2013 4:26 pm

Re: Wall shear stress calculation

Post by MartianDuan » Wed Nov 19, 2014 12:43 pm

Dear Yvan,

Please see my attached 'clptur.f90'. What I added is from line 705 to line 717.

What I did in the 'cs_user_postprocess_var.f90' is just write the wall shear stress and friction velocity in to the us_results.

Thanks in advance,

Yu.
Yvan Fournier wrote:Hello,

Could you please follow the forum usage recommendations and post the complete user files ? I suspect you forget to add a "save" attribute, but can't check with just a snippet.

Regards,

Yvan
Attachments
cs_user_postprocess_var.f90
(21.31 KiB) Downloaded 103 times
clptur.f90
(76.48 KiB) Downloaded 93 times

Yvan Fournier
Posts: 3084
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier » Fri Nov 21, 2014 5:09 pm

Hello,

In your code:

Code: Select all

f(iturb.eq.42.and.idries.eq.0) then
tau = romc*uet**2
tau0 = 0.0d0
uet0 = 0.0d0
if (ntcabs .gt. 3600) then
tau0 = tau0+tau
uet0 = uet0+uet
endif
usertau(ifac) = tau0
userutau(ifac) = uet0
endif
you are resetting tau0 at each time step, even when you are trying to accumulate things.
You need to accumulate in an array reserved for this in your user modules, then divide by the number of time steps (weighted if they are not constant) ipon usage.

In versions 3.3 and above, new functions have been added to easily handle time averages, provided the variable you want to average is defined (+ created) as a field object. In version 3.0, you need to do this yourself.

Regards,

Yvan

MartianDuan
Posts: 74
Joined: Fri Aug 02, 2013 4:26 pm

Re: Wall shear stress calculation

Post by MartianDuan » Wed Nov 26, 2014 11:48 am

Hi Yvan,

Thanks very much. The problem solved now. Although my solution is a little bit different from your suggestion. I initialized the user defined array with value zero in the 'cs_use_initialization.f90'. And the accumulation can be defined in 'clptur.f90'.

Best wishes,

Yu.

Yvan Fournier wrote:Hello,

In your code:

Code: Select all

f(iturb.eq.42.and.idries.eq.0) then
tau = romc*uet**2
tau0 = 0.0d0
uet0 = 0.0d0
if (ntcabs .gt. 3600) then
tau0 = tau0+tau
uet0 = uet0+uet
endif
usertau(ifac) = tau0
userutau(ifac) = uet0
endif
you are resetting tau0 at each time step, even when you are trying to accumulate things.
You need to accumulate in an array reserved for this in your user modules, then divide by the number of time steps (weighted if they are not constant) ipon usage.

In versions 3.3 and above, new functions have been added to easily handle time averages, provided the variable you want to average is defined (+ created) as a field object. In version 3.0, you need to do this yourself.

Regards,

Yvan

MartianDuan
Posts: 74
Joined: Fri Aug 02, 2013 4:26 pm

Re: Wall shear stress calculation

Post by MartianDuan » Fri Nov 28, 2014 3:14 pm

Hello Yvan,

Sorry for interrupting again.

Now I came across a problem on reusing the result of accumulation calculated previously. Can we save the results of user defined array into the 'checkpiont'? Or, do we had any other solution for this problem?

Thanks in advance,

Yu.
Yvan Fournier wrote:Hello,

In your code:

Code: Select all

f(iturb.eq.42.and.idries.eq.0) then
tau = romc*uet**2
tau0 = 0.0d0
uet0 = 0.0d0
if (ntcabs .gt. 3600) then
tau0 = tau0+tau
uet0 = uet0+uet
endif
usertau(ifac) = tau0
userutau(ifac) = uet0
endif
you are resetting tau0 at each time step, even when you are trying to accumulate things.
You need to accumulate in an array reserved for this in your user modules, then divide by the number of time steps (weighted if they are not constant) ipon usage.

In versions 3.3 and above, new functions have been added to easily handle time averages, provided the variable you want to average is defined (+ created) as a field object. In version 3.0, you need to do this yourself.

Regards,

Yvan

Post Reply