Page 2 of 2

Re: How to access to the mass flow of a cross section?

Posted: Wed Dec 13, 2017 1:06 pm
by Luciano Garelli
Hello,

Yes...you can access with ntcabs ; Current absolute time step number. In case of restart, this is equal to ntpabs + number of new iterations.

Regards,

Luciano

Re: How to access to the mass flow of a cross section?

Posted: Wed Dec 13, 2017 4:43 pm
by Jundi He
Many thanks!

Re: How to access to the mass flow of a cross section?

Posted: Mon Dec 18, 2017 5:58 pm
by Jundi He
Hi Code Saturne develop team:

In the script I access the mass flow rate of a certain layer of internal faces, and obtain the summation of the mass flows, then output the total mass flow to a file:

call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)

do ifac = 1, nfac
z_coord=cdgfac(3,ifac)
if(z_coord .gt. 0.00424 .and. z_coord .lt. 0.00426)then
totalmassflow = totalmassflow + imasfl(ifac)
endif
enddo

OPEN(2,FILE='output_massflow.txt',status='replace')
write(2,*)totalmassflow
close(2)

There is a problem, 8 processors are used in the simulation, every time only the mass flow information of a single processor is output to the file. What should I do if I need to calculate the mass flow of this cross section when the simulation is using 8 processors. Thanks for the time.

Regards!
Jundi

Re: How to access to the mass flow of a cross section?

Posted: Mon Dec 18, 2017 6:39 pm
by Luciano Garelli
Hello,

If you have debug your script and it works in a serial run, the next step is to parallelize it. Each processor will have a set of cell, depending on the partition method used, wherewith each processor will compute a portion (local) of the total mass flow, then you have to do a parallel sum of this local values (parsom()). To do that you can check the following example scripts and documentation:

cs_user_extra_operations-global_efforts.f90
cs_user_extra_operations-parallel_operations.f90
https://www.code-saturne.org/doxygen/sr ... _8f90.html

Finally, if the processor rank=0 do the write operation

Regards,

Luciano

Re: How to access to the mass flow of a cross section?

Posted: Mon Dec 18, 2017 7:49 pm
by Jundi He
Luciano:

Thanks for the examples. It seems useful for me. I'll try if it works.

Regards!
Jundi

Re: How to access to the mass flow of a cross section?

Posted: Tue Dec 19, 2017 12:27 pm
by Jundi He
Luciano:

Should I obtain and output the total mass flow (of a cross section) like this:

call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)

do ifac = 1, nfac
z_coord=cdgfac(3,ifac)
if(z_coord .gt. 0.00424 .and. z_coord .lt. 0.00426)then
totalmassflow = totalmassflow + imasfl(ifac)
endif
enddo

if (irangp.ge.0) then
call parsom(totalmassflow)
endif

OPEN(2,FILE='output_massflow.txt',status='replace')
write(2,*)totalmassflow
close(2)


Thanks for the time.

Regards!
Jundi

Re: How to access to the mass flow of a cross section?

Posted: Tue Dec 19, 2017 12:57 pm
by Luciano Garelli
Hello,

I think that yes, but you have to modify the write operation and initialize to zero totalmassflow variable. Try with this modifications.

Code: Select all

call field_get_key_int(ivarfl(ivar), kimasf, iflmas)
call field_get_val_s(iflmas, imasfl)

totalmassflow = 0.0

do ifac = 1, nfac
z_coord=cdgfac(3,ifac)
if(z_coord .gt. 0.00424 .and. z_coord .lt. 0.00426)then
totalmassflow = totalmassflow + imasfl(ifac)
endif
enddo

if (irangp.ge.0) then
call parsom(totalmassflow)
endif

if (irangp.le.0) then     ! Serial run irangp=-1, parallel run irangp=0 -> Master write
 OPEN(2,FILE='output_massflow.txt',status='replace')
 write(2,*) totalmassflow 
 close(2)
endif
Regards,

Luciano

Re: How to access to the mass flow of a cross section?

Posted: Fri Dec 22, 2017 7:18 pm
by Jundi He
Luciano:

Thanks for the help! Yes I should initialize the total mass flow rate at the begin, and then calculate the summation. Many thanks!

Regards!
Jundi