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

TOPIC: solve tracer equation without hydrodynamic process

solve tracer equation without hydrodynamic process 9 years 6 months ago #16940

  • zqzuoan
  • zqzuoan's Avatar
Hi, everyone,

I want to calculate a tracer using my velocity fields. So I refer to the example 'cone' under the version V7, but it has some error. But I donnot know if it can work. Attached my files below. Hope for help.

Thank you very much.

zqzuoan
Attachments:
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16941

  • jmhervouet
  • jmhervouet's Avatar
Hello,

One question is whether your files are formatted or unformatted (binary). You read them as if they were formatted, in free format. If they are unformatted the read(97,*) should be read(97). Moreover if you ask "read(98,*) tmp2" it will read all the array, not only one value. The problem to help you is that we do not know how are written the files.

If they are binary, we must know what is in every record, if they are formatted (ascii) we must know what is on every line.

For example:

To read a record of NPOIN values in a binary file :

READ(97,ERR=100,END=101) (U%R(KK),KK=1,NPOIN)
GO TO 102
100 CONTINUE
the program will go to tag 100 in case of error and you may write an error message there...
101 CONTINUE
the program will go to tag 100 in case of end of file and you may write an error message there...
102 CONTINUE


To read in a one value per line formatted file :

READ(97,*) U%R(KK)

In all cases, I doubt that you need arrays TMP1, 2 and 3, which are declared with a size that is not NPOIN...

Also note that INT(0.99) is 0, whereas NINT(0.99) is 1.

Last thing: u%r(kk)=-1.D0*tmp2(ixt+1)

is probably not what you want, as kk should be somewhere in the index of tmp2 otherwise all array U will have the same value. and -1.D0*tmp2(ixt+1) is more simply written -tmp2(ixt+1).


I hope this is helpful, with best regards,

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

solve tracer equation without hydrodynamic process 9 years 6 months ago #16942

  • zqzuoan
  • zqzuoan's Avatar
Dear JMH,
Thank you for your reply. I have to explain my purpose.I have three files store u, v, h respectively and they are free formatted. Each of the columns represent the data of all nodes in the mesh (npoin) at each time step. For example, the first column is the u/v/h at time=0, the second column is that at first time step, i.e. time=1800s. The sample is attached below.

I want to revert the velocity direction, that is to solve the tracer eauqtion
∂T/∂t + (-U)▽(T)=▽[K▽(T)] , so the data read at each time step is multiplied by -1.D0.

Wheather I can give the velocity field in the propag.f ?
Attachments:
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16945

  • jmhervouet
  • jmhervouet's Avatar
Hello,

My remark on -1.D0* is just that to change the sign you just have to put a minus sign, not multiplying by -1.D0.

So you have formatted files and you should open your files adding FORM='FORMATTED' in the list of arguments of the OPEN statement.

Your files are not properly written if they have h,u,v of the first time step in the first column. Fortran reads line by line. Suppose that h,u,v are written line by line, reading one time step would be reading NPOIN values in one line in every file.

With a declaration of tmp1 as REAL(NPOIN), with a hardcoded value of NPOIN, this would give:

READ(97,*) (tmp1(KK),KK=1,NPOIN)
DO KK=1,NPOIN
H%R(KK)=tmp1(KK)
ENDDO

and so on for u and v with files 98 and 99

The problem in your implementation is that propag is called at every time step, and this will cause a problem because you should not open the files at every time step. To avoid this use the following trick:

LOGICAL ALREADY
DATA ALREADY/.FALSE./

IF(.NOT.ALREADY) THEN
open the files here...
ALREADY=.TRUE.
ENDIF

then at every time step your read statement would progress of one line in the files.

With best regards,

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

solve tracer equation without hydrodynamic process 9 years 6 months ago #16950

  • zqzuoan
  • zqzuoan's Avatar
Dear JMH,
Thank you very much. I have modified the fortran file and the u/v/h data file and attached them below.Yes, you are right. The problem in my implementation is that propag is called at every time step, and I try to use ixt=int(at)/int(dt) to represent each time step.

But it show some error: Program exception—Access violation
Attachments:
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16951

  • jmhervouet
  • jmhervouet's Avatar
Hello,

Hum, I do not know, it looks good now. Try to see if the problem is really in propag.f :

add DEBUGGER = 1 in your steering file.

You can also put prints :

IF(.NOT.ALREADY) THEN
open(97,file='F:\OpenTelemac\tanya\h.TXT',form='FORMATTED)
open(98,file='F:\OpenTelemac\tanya\u.TXT',form='FORMATTED)
open(99,file='F:\OpenTelemac\tanya\v.TXT',form='FORMATTED)
PRINT*,'FILES OPENED'
ALREADY=.TRUE.
ENDIF
! should not be more than 1861, declared size of tmp1,...
PRINT*,'NPOIN=',NPOIN
! this is not useful
! CALL OS( 'X=C ' , U , U , U , 0.D0 )
! CALL OS( 'X=C ' , V , V , V , 0.D0 )
! CALL OS( 'X=C ' , H , H , H , 0.D0 )
READ(97,*) (tmp1(KK),KK=1,NPOIN)
PRINT*,'READ(97,*) OK'
READ(98,*) (tmp2(KK),KK=1,NPOIN)
PRINT*,'READ(98,*) OK'
READ(99,*) (tmp3(KK),KK=1,NPOIN)
PRINT*,'READ(99,*) OK'
DO KK=1,NPOIN
H%R(KK)=tmp1(KK)
U%R(KK)=-tmp2(KK)
V%R(KK)=tmp3(KK)
ENDDO

You should also check what is done in condin.f, because propag happens a bit late in the time loop, and maybe you have to initialise H, U and V also in condin.f (in this case if you copy part of what is in propag.f, do not forget to close the 3 files 97,98,99 at the end of condin.f).

regards,

JMH
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16954

  • zqzuoan
  • zqzuoan's Avatar
Dear JMH,
Thank you very much. I have done as you said but the same error accured.

But it can read line by line in every file at each time step by this way? I mean at first time step, reading the first line, at second time step,reading the second line...

In addition, my understanding of tracer transport. The tracer eauation is solved via CVDFTR.f by using the advection velocity UCONV/VONV or UDEL/VDEL, I want to use the velocity u/v to replace the udel/vdel, so I added

DO KK=1,NPOIN
udel%r(KK)=u%r(KK)
vdel%r(KK)=v%r(KK)
enddo
DO I=1,3*MESH%NELMAX
ZCONV%R(I)=0.D0
ENDDO

in the PROPAG.f.

I wonder if my understanding of how telemac2d.f solve the tracer equation is right?
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16956

  • jmhervouet
  • jmhervouet's Avatar
Hello,

Do you know where the crash segmentation fault occurs, in propag ?

I am just wondering what is the value of NPOIN and if it is that size that you give for tmp1,2 and 3.

Reading one line at every time step will work only if the first line is the first time step, not point 1 for all the time steps... this is why I asked about columns and lines. So every line should have NPOIN values, that's it ?

The rest is OK, it is the program that will build UCONV, VCONV, etc.,

Regards,

JMH
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16960

  • zqzuoan
  • zqzuoan's Avatar
Dear JMH,
Thank you very much. Yes. The error occures in propag, after 'READ(99,*) OK'.

The the value of NPOIN and size that I give for tmp1,2 and 3 are eaual to NUMBER OF POINTS: 1861.

Yes, the first line is the first time step, not point 1 for all the time steps...and every liine have 1861 values.

But it shows error: Program received signal SIGSEGU: Segmentation fault - invalid memory reference.
Attachments:
The administrator has disabled public write access.

solve tracer equation without hydrodynamic process 9 years 6 months ago #16967

  • jmhervouet
  • jmhervouet's Avatar
Hello,

So the error is perhaps elsewhere, add :

PRINT*,'EXITING PROPAG' before the return in propag.

and moreover you seem to have forgotten the line:

CALL OS('X=0 ',X=DM1)

that was in the original file, and this could be a good reason for a crash later.

Regards,

JMH
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: pham

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