[Trilinos-Users] Problem extracting element from Epetra_FEVector

Williams, Alan B william at sandia.gov
Mon Nov 3 07:59:12 MST 2008


Hi Cristiano,
The square-bracket operators are kind of confusing in this case.
Here is what you need to do:


//X is a Epetra_FEVector pointer. It is sometimes easier to
//work with a reference rather than a pointer:

Epetra_FEVector& X_reference = *X;

double* x_values = X_reference[0];

for(int i=0; i<Xdof; ++i)
   cout << i << " " << x_values[i] << " " << endl;


Alan


________________________________
From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf Of mlx82
Sent: Friday, October 31, 2008 5:37 AM
To: trilinos-users at software.sandia.gov
Subject: [Trilinos-Users] Problem extracting element from Epetra_FEVector

Good evening,

I have a problem with EpetraFEVector. I initialize two vectors with this syntax:

Xold = new Epetra_FEVector(*mapX);
X    = new Epetra_FEVector(*Xold);

Now, after some computation, I want to extract one-by-one each element from X. Notice that I am working on a single process in this code, so I have only one vector inside the "multivector".

The command which I use is this (here I use a cout because it is a test):

for (int i=0 ; i < Xdof ; ++i)
        cout << i << "  " << (*(X[0])[i]) << " " << endl;

It works only for i = 0. Then it gives me a segmentation fault.

Can you give me the correct syntax to extract all the element one-by-one?

Thank you for any help.
Best regards,

   Cristiano Malossi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://software.sandia.gov/mailman/private/trilinos-users/attachments/20081103/306f3a23/attachment.html 


More information about the Trilinos-Users mailing list