User_Defined_Script output issue

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
iorishx
Posts: 20
Joined: Fri Jun 19, 2015 11:33 am

User_Defined_Script output issue

Post by iorishx »

Hello, basically I was simulating an aerofoil in flowfield. I need to use scripts to generate instaneous lift and drag on different spanwise positions (Z direction) of the aerofoil and save to differenct files. As the spanwise positions could be more than 40, I wrote a loop as follows to output the data.

"if (ineedf.eq.1) then
do ioutput = 2, 3
do ii = 1, ndim
xfor(ii) = 0.d0
enddo
a1 = 0.1d0 * dble(ioutput-2) / 2.0d0
a2 = 0.1d0 * dble(ioutput-1) / 2.0d0
write(nfecra,*) a1, a2
call getfbr('AIRFOIL and z > a1 and z < a2', nlelt, lstelt)
!==========
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
do ii = 1, ndim
xfor(ii) = xfor(ii) + bfprp_for(ii, ifac)
enddo
enddo
if (irangp.ge.0) then
call parrsm(ndim,xfor)
endif
!Output Forces
if (irangp.le.0) then
write(impusr(ioutput),*)ntcabs,xfor(1),xfor(2),xfor(3)
endif
enddo
endif"

And the error is always:
"fvm_selector_postfix.c:1281: Fatal error.
Error parsing expression:
AIRFOIL and z > a1 and z < a2
.................^
Operator needs a floating point operand
on one side, x, y, or z on the other"

But when I change a1 and a2 to real numbers say 0.0 or 0.05, it works perfectly. And the correct values of a1 and a2 can be printed into listing file successfully. It seems to me that CodeSaturne cannot recognise a1 and a2 when I am using the function "getfbr".

Can someone help please? I don't want to copy and paste 40 times to make the function run. :?: :?:
Attachments
listing.txt
the error listing file
(37.46 KiB) Downloaded 318 times
cs_user_extra_operations.f90
extra operation file
(5.07 KiB) Downloaded 316 times
cs_user_initialization.f90
Initialization file
(4.93 KiB) Downloaded 312 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: User_Defined_Script output issue

Post by Yvan Fournier »

Hello,

The syntax of selection criteria such as getfbr are explained in the user manual, and no, there is no chance the selection criteria can understand fortran variables, as it uses a specific, minimalist interpreter.

The good news is the you do not need to use getfbr in a user subroutine, or you can combine it with a standard loop; for example, in the central part of your loop:

Code: Select all

...
call getfbr('AIRFOIL', nlelt, lstelt)
!==========
do ilelt = 1, nlelt
  ifac = lstelt(ilelt)
  if (cgdfbo(0,0,ifac) > a1 .and. cgdfbo(0,0,ifac) < a2)
    do ii = 1, ndim
      xfor(ii) = xfor(ii) + bfprp_for(ii, ifac)
    enddo
  endif
enddo
...
Regards,

Yvan
iorishx
Posts: 20
Joined: Fri Jun 19, 2015 11:33 am

Re: User_Defined_Script output issue

Post by iorishx »

Hello, Yvan.

Many thanks for your reply. Unfortunatly the script is still not running.

I modified code as you suggested, and the code says cgdfbo at (1) has no IMPLICIT type

I assume I need to declare the variable, so I declared that at the beginning of the code as follows:

"double precision, dimension(:,:,:), pointer :: cgdfbo"

Please see the file attached for the full script.

Then the script can be compiled (with a warning that cgdfbo not be initialized) but when the code is running, another error happened.
I got several error files called 'error_n003', 'error_n004' and so on, and says

"SIGSEGV signal (forbidden memory area access) intercepted!"

Sorry I am a rookie to CodeSaturne, is the way I declared wrong? or I missed some initialization steps? Please help.

Sean
Attachments
cs_user_initialization.f90
initialization file
(4.94 KiB) Downloaded 324 times
cs_user_extra_operations.f90
the script cannot be run
(5.29 KiB) Downloaded 337 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: User_Defined_Script output issue

Post by Yvan Fournier »

Hello,

Sorry, there was a typo in my post: it should be cdgfbo and not cgdfbo...

Regards,

Yvan
iorishx
Posts: 20
Joined: Fri Jun 19, 2015 11:33 am

Re: User_Defined_Script output issue

Post by iorishx »

Thanks for the reply.

Unfortunately the error carrys on...:

"/fs3/e01/e01/iorishx/CS/Re60k/E387/A12_noSRC/RESU/20150625-1426/src_saturne/cs_user_extra_operations.f90:180.46:

if (cdgfbo(0,0,ifac) > a1 .and. cdgfbo(0,0,ifac) < a2) then
1
Error: Rank mismatch in array reference at (1) (3/2)
"

I assume cdgfbo is 2 dimensional only??? Please let me know

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

Re: User_Defined_Script output issue

Post by Yvan Fournier »

Hello,

Sorry, missed a second typo. I must have been tired when I first answered.

You can check the documentation for cdgfbo using Doxygen, but basically,
cdgfbo(i,ifac) is the boundary face center for coordinate i (1 to 3) and face ifac.

So it should be 3 (for z-direction) instead of 0,0.

Hope I didn't miss anything this time...

Regards,

Yvan
iorishx
Posts: 20
Joined: Fri Jun 19, 2015 11:33 am

Re: User_Defined_Script output issue

Post by iorishx »

Thank you, Yvan.

I think the case is finally running. I appreciate your help.

Sean
Post Reply