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

TOPIC: Parallel compatibility: converting global to local IDs from text file

Parallel compatibility: converting global to local IDs from text file 6 years 6 months ago #30018

  • SDAC
  • SDAC's Avatar
Hello!

I have a code which I wish to use in parallel. I have a problem of compatibility: the code opens a .txt file to read global node IDs to which implicit source terms are then added. It would be easier to use an additional variable within the geometry file instead of the .txt file, however I had a lot of problems using the private variables method (as documented on the forum!) This is the workaround.

I tried to convert the global IDs provided by the .txt file into local IDs using local_node_number = GLOBAL_TO_LOCAL_POINT(global_node_number,MESH) , however reading deeper I don't think it's appropriate for what I'm trying to do.
I had assumed the KNOLG attribute array contained all the mesh global points and it was a matter of finding the relevant matching IDs. Questions:

1) Is GLOBAL_TO_LOCAL_POINT only appropriate when finding the local node IDs for the whole mesh, or can it be used to find the local node IDs for specific global IDs in an array?

e.g.
DO I = 1, N !from 1 - N number of IDs read from .txt file
 GLOBALN= NODEIDS(I)   !where the read NODEIDS match the global mesh IDs
 LOCALN=MESH3D%KNOLG%I(GLOBALN) !where the relevant local IDs are found for the global IDs

Where the global node IDs "NODEID"s that are read from the *.txt file are simply replaced with the local node IDs "LOCALN" used for parallel. I strongly suspect this is not the case and I'm missing out on some complexity I've not yet read.

2) Is it possible to convert specific global IDs to local IDs in the fortran file for use with parallel using any other method? For example, would using a formatted file such as SELAFIN to provide the global IDs - if Telemac internally handles the opening and closing of such files would it work fine in parallel mode?

The code I'm adapting:
OPEN(12,FILE='../0.1_SER.dat')
        DO I=1,8189
         READ(12,*) SEID(I), SEA(I)
!         write(*,*)I, SEID(I), SEA(I)
         END DO
       CLOSE(12)


      DO I = 1, 8189
       I1=SEID(I)       
!       write(*,*)I1
       A = 24.3816D0
       DO IPLAN = NPLAN-29,NPLAN !for layers at that node
         I3D = I1+NPOIN2*(IPLAN-1) !get the 3D node IDs
       
         NORM =SQRT(UN3%R(I3D)**2+VN3%R(I3D)**2+WN3%R(I3D)**2)
         S1U%R(I3D)=0.5D0*A*CD2*NORM
         S1V%R(I3D)=0.5D0*A*CD2*NORM
         S1W%R(I3D)=0.5D0*A*CD2*NORM
           
       END DO
      END DO


Thankyou!
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 6 months ago #30020

  • Leballeur
  • Leballeur's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 434
  • Thank you received: 163
Hello,

I'm not really sure to understand the issue, but these 2 reciprocal functions are useful for parallel computations.

GLOBAL_TO_LOCAL_POINT lets you to retrieve the local number of a point of your global mesh:
IF (NCSIZE.GT.1) THEN
LOCALN=GLOBAL_TO_LOCAL_POINT(GLOBALN,MESH)
ELSE
LOCALN=GLOBALN
ENDIF
0 is returned if the point not in the subdomain. In scalar mode, it should return GLOBALN, the "else" part of the above example is maybe useless.


And KNOLG let you finding the global number of a point in a local (partitioned) mesh :
IF(NCSIZE.GT.1) GLOBALN=MESH%KNOLG%I(LOCALN)


I hope it helps.

Regards,
Laurent
The administrator has disabled public write access.
The following user(s) said Thank You: SDAC

Parallel compatibility: converting global to local IDs from text file 6 years 6 months ago #30126

  • SDAC
  • SDAC's Avatar
Hello!

To clarify: I have a text file of specific global node IDs stored as a single column. I can assign source terms to these specific nodes in 3D in scalar but not in parallel. My query is: can this method be made compatible for parallel?

I tried the GLOBAL_TO_LOCAL_POINT and using a write command noticed the output is a matrix. I get results but the source terms are incorrectly assigned.

My question is: does the input to GLOBAL_TO_LOCAL_POINT need to be a matrix? I've not found anything in the programming guide that described GLOBAL_TO_LOCAL_POINT.

Currently, my code finds the specific node IDs which match those in the geometry file to select the nodes which I apply the source terms to:
DO I = 1, 8189 !loop for number of specific node Ids
       I1=ID(I)  !finds matching IDs
       DO IPLAN = NPLAN-29,NPLAN  !for these layers
       I3D = I1+NPOIN2*(IPLAN-1)   !at these 3D nodes
        ...

Can GLOBAL_TO_LOCAL_POINT be used to replace the IDs to be used in a code like the above (i.e. single column of specific nodes rather than a matrix)?
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 6 months ago #30128

  • Leballeur
  • Leballeur's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 434
  • Thank you received: 163
Hi,

Yes, I think it can be compatible with parallel mode.
GLOBAL_TO_LOCAL_POINT takes as input arguments:
- a first one that is an integer accounting for the global node number
- and a second one of type bief_mesh object (the local mesh).

I think you can't give directly an array of global points, you need to do a loop over this array.
Be careful to give as second argument the right mesh according to the 2D or 3D numbering (MESH2D or MESH3D).

I'm not sure to understand what you want to do in your example. It rather looks like you're dealing with 2D to 3D numbering, not from global to local meshes...

Regards,
Laurent
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 6 months ago #30129

  • Leballeur
  • Leballeur's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 434
  • Thank you received: 163
From your example, I1 should rather be:
I1=GLOBAL_TO_LOCAL_POINT(ID(I),MESH2D)
IF (I1.NE.0) THEN ...
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 6 months ago #30204

  • SDAC
  • SDAC's Avatar
Thankyou Leballeur.
I had looped through the conversion, but the zeroes seemed to be the problem.
I had another crack at it today and discovered that the code was working but when using the logical IF(ID.NE.0) the output "non-zero" array only contained one repeated value.
However, comparing the values in the converted array against the non-zero array using a write command, the value in the non-zero array doesn't match any value in the converted array!

i.e. the nodes are converted successfully. An array is produced with converted node IDs and zeroes. When a logical test is applied to index the on-zero values I get a value not-related to the converted values.

For example, sample of values from:

Converted array:
12176 Conversion
12173 Conversion
12181 Conversion
12184 Conversion
12183 Conversion
12191 Conversion
12196 Conversion

Non-zero array:
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node
12187 Node

I tried other approaches to removing zeroes such as IDSR1 = PACK(IDSR,IDSR /= 0) and using the logical test in its separate loop,but the result was the same.

Is there an obvious error in my code that might result in such an issue?

My code:
OPEN(12,FILE='../0.1_SER.txt')
        DO I=1,8189
         READ(12,*) SEID(I), SEA(I)
!         write(*,*)I, SEID(I), SEA(I)
         END DO
       CLOSE(12)

  DO I = 1,8189
        IDSE = GLOBAL_TO_LOCAL_POINT(SEID(I),MESH2D) !Convert global to local
        write(*,*)IDSE(I),'Conversion'
      ENDDO

    DO I = 1, 8189
      IF (IDSE(I).NE.0) THEN  !index non-zero values
        I1=IDSE(I)
       write(*,*)I1,'Node'
       A = 24.3816D0
       DO IPLAN = NPLAN-29,NPLAN !for layers at that node
         I3D = I11+NPOIN2*(IPLAN-1) !get the 3D node IDs
        ...
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 5 months ago #30232

  • Leballeur
  • Leballeur's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 434
  • Thank you received: 163
Hi,

Could you upload your case please ?

Regards,
Laurent
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 5 months ago #30259

  • SDAC
  • SDAC's Avatar
Hi,

I've attached the case file below.

If looking at the code for parallel, it is under SOURCE.f and is the final section of the *.f file.


File Attachment:

File Name: Parallel_test_2018-05-24.zip
File Size: 164 KB


Many thanks!
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 5 months ago #30261

  • SDAC
  • SDAC's Avatar
Please use this .f file. The one above was older.


File Attachment:

File Name: ptest.f
File Size: 22 KB
The administrator has disabled public write access.

Parallel compatibility: converting global to local IDs from text file 6 years 5 months ago #30262

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi
this line :
IDSE = GLOBAL_TO_LOCAL_POINT(SEID(I),MESH2D)
is wrong.
it should be:
IDSE(I) = GLOBAL_TO_LOCAL_POINT(SEID(I),MESH2D)

regards
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: SDAC
  • Page:
  • 1
  • 2
Moderators: pham

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