Wall shear stress calculation

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

Re: Wall shear stress calculation

Post by Yvan Fournier »

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 133 times
Loïc A.
Posts: 9
Joined: Mon Mar 10, 2014 7:56 pm

Re: Wall shear stress calculation

Post by Loïc A. »

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 »

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 95 times
cs_user_modules.f90
(2.66 KiB) Downloaded 98 times
compile.log
(16.45 KiB) Downloaded 99 times
Yvan Fournier
Posts: 3105
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier »

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 »

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: 3105
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier »

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 »

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 111 times
clptur.f90
(76.48 KiB) Downloaded 101 times
Yvan Fournier
Posts: 3105
Joined: Mon Feb 20, 2012 3:25 pm

Re: Wall shear stress calculation

Post by Yvan Fournier »

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 »

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 »

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