[Trilinos-Users] Problem extracting element from Epetra_FEVector

mlx82 mlx82 at fastwebnet.it
Tue Nov 4 04:33:06 MST 2008


Thank you Alan, it works fine!

   Cristiano

Williams, Alan B ha scritto:
> 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/20081104/ef3c8b82/attachment-0001.html 


More information about the Trilinos-Users mailing list