Page 1 of 1

Define usclim to collect scalar data in cells (v2)

Posted: Tue Jul 31, 2018 2:46 pm
by VincentM
Hi everyone.
Actually have some issues with a case i try to run.

I try to modelling some air streams in a room with some hot surfaces at some place.
I have some inlet and outlet of air and i want to know temperature of extracted air.
My case is running but listing give me wrong value of temperature.

Code: Select all

! Conditions aux limites sur les aspirations
!====================!
! SELECTION DES FACES!
!====================!

debit_Four_1_aspi_1 = 0.77160d0
call getfbr('Four_1_aspi_1',nlelt, lstelt) 
! BOUCLE SUR LES FACES SELECTIONNEES
do ilelt = 1,nlelt
  !face
  ifac = lstelt(ilelt)
  !cellule adjacente a la face
  iel = ifabor(ifac)
  !Boucle sur les differentes phases (specificite CS V2) 
  do iphas = 1,nphas
    ! Affectation du type de CL 
    !itypfb(ifac,iphas)   = ientre ! On fixe la valeur des variables..
    !Calcul de la surface
    ns = dsqrt(surfbo(1,ifac)**2 + surfbo(2,ifac)**2 + surfbo(3,ifac)**2)
    ! Calcul des coordonnees du vecteur normal sortant (convention saturne)
    sx = surfbo(1,ifac)/ns
    sy = surfbo(2,ifac)/ns
    sz = surfbo(3,ifac)/ns

    itypfb(ifac,iphas) = iindef

    icodcl(ifac,iu(iphas))  = 1
    rcodcl(ifac,iu(iphas),1) = sx*debit_Four_1_aspi_1
    rcodcl(ifac,iu(iphas),2) = rinfin
    rcodcl(ifac,iu(iphas),3) = 0.d0

    icodcl(ifac,iv(iphas))  = 1
    rcodcl(ifac,iv(iphas),1) = sy*debit_Four_1_aspi_1
    rcodcl(ifac,iv(iphas),2) = rinfin
    rcodcl(ifac,iv(iphas),3) = 0.d0

    icodcl(ifac,iw(iphas))  = 1
    rcodcl(ifac,iw(iphas),1) = sz*debit_Four_1_aspi_1
    rcodcl(ifac,iw(iphas),2) = rinfin
    rcodcl(ifac,iw(iphas),3) = 0.d0

    icodcl(ifac,ipr(iphas))  = 3
    rcodcl(ifac,ipr(iphas),1) = 0.0d0
    rcodcl(ifac,ipr(iphas),2) = rinfin
    rcodcl(ifac,ipr(iphas),3) = 0.d0

    icodcl(ifac,ik(iphas))  = 3
    rcodcl(ifac,ik(iphas),1) = 0.0d0
    rcodcl(ifac,ik(iphas),2) = rinfin
    rcodcl(ifac,ik(iphas),3) = 0.d0    

    icodcl(ifac,iep(iphas))  = 3
    rcodcl(ifac,iep(iphas),1) = 0.0d0
    rcodcl(ifac,iep(iphas),2) = rinfin
    rcodcl(ifac,iep(iphas),3) = 0.d0

    flufac_isortie = flufac_isortie + debit_Four_1_aspi_1

    ! --- Handle scalars attached to the current phase
    if(nscal.gt.0) then
      do ii = 1, nscal
        if(iphsca(ii).eq.iphas) then
          icodcl(ifac,isca(ii))  = 3
          rcodcl(ifac,isca(ii),1) = 0.0d0
          rcodcl(ifac,isca(ii),2) = rinfin
          rcodcl(ifac,isca(ii),3) = 0.d0
        endif
      enddo
	  Temp_Air_Four_1_aspi_1 = Temp_Air_Four_1_aspi_1 + rtp(iel,isca(iscalt(iphas)))*volume(iel)/volume_out_Four_1_aspi_1
      icodcl(ifac,isca(iscalt))  = 1
      rcodcl(ifac,isca(iscalt),1) = Temp_Air_Four_1_aspi_1
      rcodcl(ifac,isca(iscalt),2) = rinfin
      rcodcl(ifac,isca(iscalt),3) = 0.0d0
    endif
  enddo
enddo

[...]

write(nfecra,*) 'Temp_Air_Four_1_aspi_1 =',Temp_Air_Four_1_aspi_1 

I tried different configuration (with "parsom", with rcodcl(ifac,isca(iscalt),1) = Temp_Air_Four_1_aspi_1+ rtp(iel,isca(iscalt(iphas)))*volume(iel)/volume_out_Four_1_aspi_1) but listing still give me wrong value.


Did someone have an idea/tool for me?


Thanks

Re: Define usclim to collect scalar data in cells (v2)

Posted: Tue Jul 31, 2018 3:16 pm
by Yvan Fournier
Hello,

We need more information to be of any help. Did you read this first ? viewtopic.php?f=2&t=7

Regards,

Yvan

Re: Define usclim to collect scalar data in cells (v2)

Posted: Tue Jul 31, 2018 4:01 pm
by VincentM
Hi,
yes i read this post ;).

Since it seemed to me that it was a syntax problem, I only indicated the incriminated piece of code. But I can provide the additional items. (mesh is too heavy to be send)


Thanks

Re: Define usclim to collect scalar data in cells (v2)

Posted: Tue Jul 31, 2018 4:36 pm
by Yvan Fournier
Hello,

I do not recommend doing postprocessing in the boundary conditions settings, as everything you compute is based on the values of the previous time step.

Calls to parsom should be done at the end, just before printing values, but you can ignore those and test your code in serial mode first.

Did you test your code on a debug build (code configured with --enable-debug) ? As version 2.0 was a bit tricky due to the loops on "iphas", this allows checking array accesses are correct in the Fortran part.

And in any case, I recommend upgrading to a more recent version. Version 2.0 has been deprecated in 2013 (when 3.0) was released, and is unsupported since 2015 (when 4.0 was released). Newer versions have more complete examples in the documentation for many postprocessing tasks and printing balances.

Regards,

Yvan

Re: Define usclim to collect scalar data in cells (v2)

Posted: Wed Aug 01, 2018 6:44 am
by VincentM
Thanks for your answer.

-> updating to a more recent version is planned
-> i didnt test code on a debug build. Actually i'm a rookie CDF/code user so i try to solve problems by myself.

Regards

Vincent

Re: Define usclim to collect scalar data in cells (v2)

Posted: Wed Aug 01, 2018 10:42 am
by Yvan Fournier
Hello,

OK. You should find quite a few improvements (especially in the postprocessing you need) in more recent versions. The code should also be faster, as for most cases, we have better performance in the pressure correction step using the multigrid as a preconditonner (available since 5.0 if I remember correctly) then as a solver as in 2.0.

In any case, installing a "debug" build along with the "production" build is recommended. Computations usually run about 3x slower, so you do not want tu use a debug build once your computation is set up, but when you are preparing a case, the additional checks in the debug build can help you catch subtle errors (especially if you are using user subroutines) much earlier, and so save you a lot of time in the long run. So when you move to a newer version, I recommend installng both a standard/production build and a debug build (the installation manual provides a few recommendations for naming).

This is a reminder to all users who do not use debug builds...

Best regards,

Yvan

Re: Define usclim to collect scalar data in cells (v2)

Posted: Wed Aug 01, 2018 1:43 pm
by VincentM
Yvan Fournier wrote: Tue Jul 31, 2018 4:36 pm Hello,

I do not recommend doing postprocessing in the boundary conditions settings, as everything you compute is based on the values of the previous time step.
So maybe it's better to call/print value i'm looking for (i.e. cells temperature) via usproj.f90 ?

Re: Define usclim to collect scalar data in cells (v2)

Posted: Wed Aug 01, 2018 1:50 pm
by Yvan Fournier
Hello,

Yes, usproj (renamed cs_user_extra_operations in recent versions) is a better place for this sort of thing. Especially if you are checking the code examples...

Regards,

Yvan