Welcome, Guest
Username: Password: Remember me

TOPIC: Modifying roughness for every iteration with a fortran file

Modifying roughness for every iteration with a fortran file 11 years 1 month ago #10675

  • doeby
  • doeby's Avatar
Hi folks,

I would like to change the bed roughness of my BOTTOM_FRICTION for each iteration. The equation for each node is: Current_Water_Level**(1/6)*RoughnessValues = New_Roughness. The RoughnessValues are defined and extracted in Blue Kenue as: BOTTOM_FRICTION → save as → TriGrid Node File *.nod

So far, I have a kind of working code, but I have two questions:


! ***************** Part of the code START

unit = 20
Open (unit,file='test.txt',STATUS="old",ACTION="read")
read(unit,*) n ! ”read first line, this is the node number n needed for allocation...”
allocate(xx(n,1)) ! “Do some allocation, only rough will be needed.....”
allocate(yy(n,1))
allocate(zz(n,1))
allocate(rough(n,1))
write(*,*) "We have nodes: ", n , " Currenrt Iteration ", LT
do ii = 1, n ! ”get the values from my ascii file: 'RoughnessValue' and store it in rough(:,1)“
read(unit,*) xx(ii,1), yy(ii,1), zz(ii,1), rough(ii,1)
end do
close(unit)

DO I = 1 , NPOIN
CHESTR%R(I) = HN%R(I)**(1/6) * rough(I,1) !”Recalculate a new roughness, depending on water depth”
ENDDO

! ***************** Part of the code END

Question 1: Does this also work for a parallelized telemac2d run? If I print the value of NPOIN it tells me that not all points are used (e.g if PARALLEL PROCESSORS : 4 than size is: NPOIN/4). Nevertheless, if I check the roughness again in Blue Kenue the new CHESTR is recalculated for the hole domain, so obviously it is ok.

Question 2: How can I avoid to reload the ascii file for each iteration? With a simple IF Statement it's not working (scope); can I set a global variable or is there even a better way?

Thanks for your help!
Doeby
The administrator has disabled public write access.

Modifying roughness for every iteration with a fortran file 11 years 1 month ago #10676

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi

1) No it probably doesn't work in parallel!
In parallel, each subdomain known only its own NPOIN and it always use this value to calculate the new friction coefficient so it will just use the first NPOIN(local) value of the file...

2) Friction subroutine are called every time step in telemac 2d so you can directly use it in your code.
Something like CHESTR%R(I) = HN%R(I)**(1./6.) * CHESTR%R(I) should work!

I'm not sure about your objective but in my opinion, this iterative process should converge only if H could converge to 1! you should add some limit value otherwise you friction will tend to 0 or infinity

Regards
Christophe
The administrator has disabled public write access.

Modifying roughness for every iteration with a fortran file 11 years 1 month ago #10678

  • doeby
  • doeby's Avatar
Thanks for the quick reply!

Regarding: CHESTR%R(I) = HN%R(I)**(1./6.) * CHESTR%R(I) This is not exactly what I wanted. I need something like: CHESTR%R(I) = HN%R(I)**(1./6.) * ORIGINAL_ROUGHNESS_PARAMETER_AT_TIME=0

This data array (ORIGINAL_ROUGHNESS_PARAMETER_AT_TIME=0 or RoughnessValues from the prev. post) should be kept constant all the time. Multiplied with the current water depth should give me the REAL new roughness CHESTR for telemac2d (this varies over time of course).

Thanks!
The administrator has disabled public write access.

Modifying roughness for every iteration with a fortran file 11 years 1 month ago #10682

  • doeby
  • doeby's Avatar
No ideas so far?

Lets reshape the question: Is it possible to have a copy of the roughness data array (CHESTR%R) with the original values (lets say CHESTR_MY_COPY%R)? This would avoid reloading the original roughness value from the ascii file and there should also be no problem with parallelization. Am I right?

Thanks,
Doeby
The administrator has disabled public write access.

Modifying roughness for every iteration with a fortran file 11 years 1 month ago #10684

  • pilou1253
  • pilou1253's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 584
  • Thank you received: 106
Hi!

I guess this should work (but probably not in parallel though):
IF(LT.EQ.0) THEN
DO I = 1,NPOIN
CHESTR_MY_COPY%R(I) = CHESTR%R(I)
ENDDO
ENDIF

Provided that CHESTR_MY_COPY has same type (BIEF I assume) as CHESTR.

You can try to add CHESTR_MY_COPY%R in a user variable via PRIVATE ARRAYS to see if this parameter remains constant and equal to your original values through the whole simulation.

There is maybe a better test to do than IF(LT.EQ.0), something like IF(LT.LT.1D-6) for example (I got this tip from JMH once).

Good luck!
PL
The administrator has disabled public write access.
The following user(s) said Thank You: doeby

Modifying roughness for every iteration with a fortran file 11 years 1 month ago #10691

  • riadh
  • riadh's Avatar
Hi

yes the best way is to use private arrays that Telemac offers to users: you need to add the following keyword NUMBER OF PRIVATE ARRAYS = 1 and add the variable PRIVE%ADR(1)%P%R instead of CHESTR_MY_COPY in the code written by PILOU. You need also to add in the top of your routine
USE DECLARATION_TELEMAC2D

You can avoid the use of the ascii file by the use of a restart file. You said that you extract the friction file with BlueKenue, thus if you have a Selafin file that includes friction on all the domain, Telemac will load these data when starting computation with a restart file.
Otherwise, if you want to go on with your solution, you need to adapt what you've written in order to respect local and global numbering of nodes (for parallel runs).
With my best regards

Riadh ATA
The administrator has disabled public write access.

Modifying roughness for every iteration with a fortran file 11 years 3 weeks ago #10809

  • doeby
  • doeby's Avatar
Hi Riadh & Pilou!

So far your suggestions works perfectly fine, thanks!

Of course, there is always one last question:)

How do i loop over the nodes in parallel mode? Is there something like DO J=1,PARALLEL_PROCESSOR_NUMBERS....

IF(LT.EQ.1) THEN
DO I = 1,NPOIN
PRIVE%ADR(1)%P%R(I) = CHESTR%R(I)
ENDDO
ENDIF

DO I = 1 , NPOIN
CHESTR%R(I) = HN%R(I) * PRIVE%ADR(1)%P%R(I) ENDDO
The administrator has disabled public write access.
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.