Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: prescribe flowrate at liquid boundaries by programming functions

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15421

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
I need to prescribe the flowrate at liquid boundaries as a function of time, water level and several other external parameters. As far as I understand, I need to modify de function Q in file souces/telemac2d/q.f., somewhere like in the file in attachment.

Then, I need to access the values of the time and the water level (the mean value along the boundary at previous time step should be OK for the water level).

To be honest, I'm a bit lost before starting this work, because it's my first real implementation experience in TELEMAC (and in Fortran actually, though I have experience in C/C++).

So, I would really appreciate if someone could help me, either by providing files of a similar case, or by giving some clues to start with.

Thank you in advance.
Attachments:
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15422

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

There is many possibilities to adapt the code to your needs...
In Q.f you could program the discharge for all the boundary. But as I know, you cannot have a direct access to the mean water level on the boundary.

Maybe you could have a look on bord.f which manage the boundary conditions. It's more complex but you could have an access to all the nodes of the boundary...

Hope this helps
Christophe
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15424

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Actually, in the user manual v6p2 (the most recent to my knowledge), it is mentioned that:
Functions Q, VIT and SL are programmed in the same way. In each case, the user has the time, the boundary rank (for determining, for example, whether the first or second boundary with a prescribed flowrate is being processed), the global number of the boundary point (useful in case of parallel computing) and in the case of Q, information on the depth of water at the previous time step.

If I have access to the global number of the boundary point as well, isn't it possible to get the value of the bathymetry there and then deduce the water level?

Thank you for your help.
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15427

  • jmhervouet
  • jmhervouet's Avatar
Hello,

Yes, for a point N the water level will be ZF%R(N)+H%R(N).

ZF (bottom) and H (depth) are bief_obj structures (see the guide for programming in the Telemac system), and the component %R contains the double precision array of values.

However here I is the liquid boundary number, because Q is the total discharge of an open boundary. So if you have one global number of a point of this boundary Q may depend on the elevation at this very point.

Have a good week-end,

Jean-Michel Hervouet
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15470

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Thank you Jean-Michel, that is exactly what I need.

It works perfectly in serial.

However, as far as I understand, in parallel, the N from your formula should be the number of the node on the local subdomain. How is it possible to obtain N from the global node number, i.e. its row on the XYZ array of the SLF file?

Thank you for your help.
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15471

  • jmhervouet
  • jmhervouet's Avatar
Hello,

I looked at the call to functions SL and VIT in bord.f and we intentedly send the global number by using MESH%KNOLG%I, to go back to the local number, you would have to use the function global_to_local_point.f (if not seen add USE BIEF in the subroutine), but this functions hides an akward loop on all points. In your case I wonder if it would not be easier to change bord.f and send the local N, this would be obtained by removing the lines IF(NCSIZE.GT.1) N=MESH%KNOLG%I(N) before calling the functions SL, VIT, etc.

With best regards,

Jean-Michel Hervouet
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15474

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
Thank you for your answer Jean-Michel.

However, I might be missing something, but I am not sure removing the lines

IF(NCSIZE.GT.1) N=MESH%KNOLG%I(N)

before calling SL and VIT will change something, as it is the discharge Q that I want to prescribe as a function of the mean water level along the liquid boundary, and it does not take N as an argument.

Actually, for the moment, I am hard coding the global node numbers for each liquid boundary (in the future, it could be read from an external file) and computing the mean water level along it.

Therefore, I tried your second solution by calling the function GLOBAL_TO_LOCAL_POINT (I'll figure out a way to call it only once at start later), but I got a segmentation fault... Could you explain me why?

I only attached my modified Q function. I will send the other files if needed.

Thank you in advance!
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15476

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

Just a quick reply since I also had to program some parts involving the global node number for parallel runs.

You need to make a test on the value returned by GLOBAL_TO_LOCAL_POINT since it can be 0 if the current global node number is not part of the submesh treated by the processor doing the job (this is an example from T3D):

IF(NCSIZE.GT.1) THEN
  N = BRIDGE1(I) !2D mesh numbering
  NLOC = GLOBAL_TO_LOCAL_POINT(N,MESH3D)
  IF(NLOC.NE.0) THEN
    N = NLOC + NPOIN2*(IPLAN-1) !3D mesh numbering
!   Do something here   
  ENDIF
ELSE
! the scalar implementation here
ENDIF

The segmentation fault can also be due to the fact that the global_to_local_point subroutine needs to be recompiled. Just add it in your fortran file, that did the trick for me...

Good luck!

Best regards
PL
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15477

  • o.gourgue
  • o.gourgue's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 155
  • Thank you received: 11
I added the function to the fortran file, but I still got a segmentation fault at the following line:

KLOC(J) = GLOBAL_TO_LOCAL_POINT(K(J), MESH)

It should work even if the result is 0...

:(
The administrator has disabled public write access.

prescribe flowrate at liquid boundaries by programming functions 9 years 10 months ago #15478

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

Humm...
Hard to say without seing what you want to do...
I understand that in GLOBAL_TO_LOCAL_POINT(N, MESH), N should be an integer with a value comprised between 1 and NPOIN. Does your K Array satisfy this for all the J values?

Good luck!

Best regards and have a nice weekend!
PL
The administrator has disabled public write access.
The following user(s) said Thank You: o.gourgue
  • Page:
  • 1
  • 2
Moderators: pham

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