[Trilinos-Users] [EXTERNAL] EpetraVector, BlockMap, GID and LID

Rizzi, Francesco NMN fnrizzi at sandia.gov
Mon May 13 06:58:09 EDT 2019


Hi Patrick,


Sorry, in my previous email I shared the wrong version of the code :)

The main_revised.cc is the right one.

Running with 1 and 3 MPI ranks gives the outputs below. I hope I interpreted correctly what you intended to do.

I am printing the vector twice, after it is constructed and right after it is modified.

Please let me know if this is not right and/or some things are not clear.


Thanks.

Best,

Francesco Rizzi





------------------------------------

OUTPUT for 3 MPI ranks

------------------------------------
1: Test timeout computed to be: 10000000
1: 1 3
1: 0 3
1: 2 3
1:
1: Number of Global Elements  = 6
1: Number of Global Points    = 18
1: Maximum of all GIDs        = 5
1: Minimum of all GIDs        = 0
1: Index Base                 = 0
1: Constant Element Size      = 3
1:
1: Number of Local Elements   = 2
1: Number of Local Points     = 6
1: Maximum of my GIDs         = 1
1: Minimum of my GIDs         = 0
1:
1:          MyPID           Local Index        Global Index
1:              0                 0                 0
1:              0                 1                 1
1:
1: Number of Local Elements   = 2
1: Number of Local Points     = 6
1: Maximum of my GIDs         = 3
1: Minimum of my GIDs         = 2
1:
1:          MyPID           Local Index        Global Index
1:              1                 0                 2
1:              1                 1                 3
1:
1: Number of Local Elements   = 2
1: Number of Local Points     = 6
1: Maximum of my GIDs         = 5
1: Minimum of my GIDs         = 4
1:
1:          MyPID           Local Index        Global Index
1:              2                 0                 4
1:              2                 1                 5
1:      MyPID         GID/Point             Value
1:          0             0/0                       0
1:          0             0/1                       0
1:          0             0/2                       0
1:          0             1/0                       0
1:          0             1/1                       0
1:          0             1/2                       0
1:          1             2/0                       0
1:          1             2/1                       0
1:          1             2/2                       0
1:          1             3/0                       0
1:          1             3/1                       0
1:          1             3/2                       0
1:          2             4/0                       0
1:          2             4/1                       0
1:          2             4/2                       0
1:          2             5/0                       0
1:          2             5/1                       0
1:          2             5/2                       0
1:      MyPID         GID/Point             Value
1:          0             0/0                       0
1:          0             0/1                       0
1:          0             0/2                       0
1:          0             1/0                       0
1:          0             1/1                       0
1:          0             1/2                       0
1:          1             2/0                       0
1:          1             2/1                       0
1:          1             2/2                       0
1:          1             3/0                       1
1:          1             3/1                     0.5
1:          1             3/2                       0
1:          2             4/0                       0
1:          2             4/1                       0
1:          2             4/2                       0
1:          2             5/0                       0
1:          2             5/1                       0
1:          2             5/2                       0



------------------------------------

OUTPUT for 1 MPI rank

------------------------------------
1: Test timeout computed to be: 10000000
1: 0 1
1:
1: Number of Global Elements  = 6
1: Number of Global Points    = 18
1: Maximum of all GIDs        = 5
1: Minimum of all GIDs        = 0
1: Index Base                 = 0
1: Constant Element Size      = 3
1:
1: Number of Local Elements   = 6
1: Number of Local Points     = 18
1: Maximum of my GIDs         = 5
1: Minimum of my GIDs         = 0
1:
1:          MyPID           Local Index        Global Index
1:              0                 0                 0
1:              0                 1                 1
1:              0                 2                 2
1:              0                 3                 3
1:              0                 4                 4
1:              0                 5                 5
1:      MyPID         GID/Point             Value
1:          0             0/0                       0
1:          0             0/1                       0
1:          0             0/2                       0
1:          0             1/0                       0
1:          0             1/1                       0
1:          0             1/2                       0
1:          0             2/0                       0
1:          0             2/1                       0
1:          0             2/2                       0
1:          0             3/0                       0
1:          0             3/1                       0
1:          0             3/2                       0
1:          0             4/0                       0
1:          0             4/1                       0
1:          0             4/2                       0
1:          0             5/0                       0
1:          0             5/1                       0
1:          0             5/2                       0
1:      MyPID         GID/Point             Value
1:          0             0/0                       0
1:          0             0/1                       0
1:          0             0/2                       0
1:          0             1/0                       0
1:          0             1/1                       0
1:          0             1/2                       0
1:          0             2/0                       0
1:          0             2/1                       0
1:          0             2/2                       0
1:          0             3/0                       1
1:          0             3/1                     0.5
1:          0             3/2                       0
1:          0             4/0                       0
1:          0             4/1                       0
1:          0             4/2                       0
1:          0             5/0                       0
1:          0             5/1                       0
1:          0             5/2                       0









________________________________
From: Trilinos-Users <trilinos-users-bounces at trilinos.org> on behalf of Amstad Patrick <pamstad at student.ethz.ch>
Sent: Sunday, May 12, 2019 3:41 AM
To: trilinos-users at trilinos.org
Subject: [EXTERNAL] [Trilinos-Users] EpetraVector, BlockMap, GID and LID

Hi everbody

I think I have a general problem with the understanding of BlockMaps, and EpetraVector and my last hope is this mailing list. My Goal is (as a simplified example):


  *   Let's assume I have a beam, discretised in a way that it has six nodes. Each node has two degrees of freedom (DOF); one in the x-direction and anotherone in the y-direction (I assume a cartesian coordinate system)

  *   My goal is now, that I can specify for each node a desired displacement. So let's say I want to displace node 3 by one unit in the x-direction and by 0.5 units in the y-direction. This information, by how much each node gets displaced, I want to store in the EpetraVector and want to access it later.
  *   My Problem is now; I have no idea how I can access these individual DOF from the BlockMap; any idea?

How do I get these informations from the BlockMap and how can fill my EpetraVector? A code snippet below, how I wanted to do this:

         // Create P1 VectorEpetra
        VectorEpetra p1PositionVector (p1dFESpace.map());


        Int p1nCompLocalDof = p1PositionVector.epetraVector().MyLength() / 3; //My Length returns length of EpetraVector on calling processor
        for (int j (0); j < p1nCompLocalDof; j++)
        {
            UInt iGID = p1PositionVector.blockMap().GID (j);
            UInt jGID = p1PositionVector.blockMap().GID (j + p1nCompLocalDof);
            UInt kGID = p1PositionVector.blockMap().GID (j + 2 * p1nCompLocalDof);

            p1PositionVector[iGID] = 1.0 ;
            p1PositionVector[jGID] = 0.5 ; //Here I want to specify the displacements of the nodes; for example displacement of 1.0 in x-direction; 0.5 in y-direction
            p1PositionVector[kGID] = 0.0 ;
        }


The result I get from this, is that for example node 5 instead of node 3 gets the displacement specified; so I have problems to access specific nodes.

Thanks for an answer.

Best regards
Patrick Amstad



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20190513/9c5cca42/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main_revised.cc
Type: application/octet-stream
Size: 1122 bytes
Desc: main_revised.cc
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20190513/9c5cca42/attachment-0001.obj>


More information about the Trilinos-Users mailing list