From global ID to local ID

Dear LAMMPS-users,

First, I was wondering if there is a way of mapping back form global to local atom ID. Like the tag[i] gives the global ID of the local i ID I would like a way to do the opposite.
Second, is there a way of keeping the atom ID numbering as I set them in the input data file. For most of the cases the local-ID = global-ID minus 1, but this is not always the case.Is there a way to ensure such a pattern.

Thanks,
chris

Hi

there is a function map(global_id) which returns the local_id (belongs to atom, see atom.h).

Generally it can not be guaranteed to keep a certain pattern of global_id to local_id. The thing is that the local_id has to be seen as the array index. And since you might be running multiple MPI processes these local_ids go only to approximately natoms/num_procs and depending on your system the atoms can be randomly distributed over the processors since spatial decomposition is used (for a gas you would expect after a while a random ordering of atoms). So even if you would order the atoms on each process according to global_id in memory (which is actually a bad idea because for optimal cache usage you want them to be ordered spatially) these global_ids would not be continues on each processor.

Furthermore over the local_id the "ghost" atoms can be accessed. These do actually share global_ids with other atoms (both ghost and non-ghost).

Cheers
Christian

-------- Original-Nachricht --------

Dear LAMMPS-users,

First, I was wondering if there is a way of mapping back form global to
local atom ID. Like the tag[i] gives the global ID of the local i ID I would
like a way to do the opposite.
Second, is there a way of keeping the atom ID numbering as I set them in the
input data file. For most of the cases the local-ID = global-ID minus 1, but

this is only approximately true for serial execution.
global ids can be sparse, local ids must not.

this is not always the case.Is there a way to ensure such a pattern.

no. that is impossible.
atoms will move from MPI task to MPI task.

if you want that kind of behavior, you have to write your own MD code.

rather than asking questions about details, why don't
you explain what you are aiming to do. perhaps somebody
has a suggestion that will allow you to do that, without
having to tear down and rebuild the entire backbone of LAMMPS?

axel.

Date: Tue, 18 Oct 2011 11:14:08 -0400
Subject: Re: [lammps-users] From global ID to local ID
From: [email protected]
To: liopiri@…2160…
CC: lammps-users@…458…net

Dear LAMMPS-users,

First, I was wondering if there is a way of mapping back form global to
local atom ID. Like the tag[i] gives the global ID of the local i ID I would
like a way to do the opposite.
Second, is there a way of keeping the atom ID numbering as I set them in the
input data file. For most of the cases the local-ID = global-ID minus 1, but

this is only approximately true for serial execution.
global ids can be sparse, local ids must not.

this is not always the case.Is there a way to ensure such a pattern.

no. that is impossible.
atoms will move from MPI task to MPI task.

if you want that kind of behavior, you have to write your own MD code.

rather than asking questions about details, why don’t
you explain what you are aiming to do. perhaps somebody
has a suggestion that will allow you to do that, without
having to tear down and rebuild the entire backbone of LAMMPS?

That’s correct! I am calculating the force on an atom i (local ID) with tag[i] (global ID) in a routine (lets say pair_coul_cut). So I have in the loop over neighbors
for(ii=0;…){for(jj=0;…){ f[i][0]+=delxfpair;}}
I would like to assign this force to another atom x where tag[x]=tag[i]-2. So the problem becomes: if I know tag[x] how I could find x in order to say f[x][0]+=delx
fpair?

Date: Tue, 18 Oct 2011 17:08:07 +0200
From: ceearem@…116…
Subject: Re: [lammps-users] From global ID to local ID
To: liopiri@…2160…; [email protected]

Hi
Thanks for your reply.

there is a function map(global_id) which returns the local_id (belongs to atom, see atom.h).
Is there any way of using this function in a routine (like the pair_coul_cut.cpp for example). I would need to write in the routine something like s=map(t) where t=tag[s].

Generally it can not be guaranteed to keep a certain pattern of global_id to local_id. The thing is that the local_id has to be seen as the array index. And since you might be running multiple MPI processes these local_ids go only to approximately natoms/num_procs and depending on your system the atoms can be randomly distributed over the processors since spatial decomposition is used (for a gas you would expect after a while a random ordering of atoms). So even if you would order the atoms on each process according to global_id in memory (which is actually a bad idea because for optimal cache usage you want them to be ordered spatially) these global_ids would not be continues on each processor.

Furthermore over the local_id the “ghost” atoms can be accessed. These do actually share global_ids with other atoms (both ghost and non-ghost).

Cheers
Christian

Many Thanks,
Chris

Hi

Is there any way of using this function in a routine (like the
pair_coul_cut.cpp for example). I would need to write in the routine something like
s=map(t) where t=tag[s].

Yes you can do that (use atom->map()).

Christian

Date: Wed, 19 Oct 2011 11:11:45 +0200
From: ceearem@…116…
Subject: Re: RE: [lammps-users] From global ID to local ID
To: liopiri@…2160…; [email protected]

Hi

Is there any way of using this function in a routine (like the
pair_coul_cut.cpp for example). I would need to write in the routine something like
s=map(t) where t=tag[s].

Yes you can do that (use atom->map()).

Thanks for your quick reply and help

Christian

All best,
Chris