Thanks, I will definitely try it.

Ignacio.

On Fri, Mar 24, 2017 at 1:50 AM, Jean-Paul Pelteret <jppelte...@gmail.com>
wrote:

> Dear Itomas,
>
> I would recommend going the route suggested in this recent post
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_forum_-23-21topic_dealii_kToGg5lNhFE&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=ihd-8rKZdGkf12UV9R7-pA&m=vXwEg0P0IkHcAecANEcqpdfWm7DS8YbChufy5v0CsGs&s=geXIi3kQ2mQALSRuqz3mdU0XT1V4__auq1W-uVxNPA4&e=>,
> namely creating a vector of shared pointers of PETSc vectors, i.e.
> std::vector<std::shared<PETScWrappers::MPI::Vector> >. Using shared
> pointers means that you safeguard against memory leaks, and can be stored
> as entries in a vector. That would give you the flexibility that you
> require with a minimal interface change to your code (apart from how you
> create the vectors initially, you would need to dereference these vector
> entries with the "->" operator instead of the "." operator).
>
> I hope that this helps.
> Best regards,
> Jean-Paul
>
> On Friday, March 24, 2017 at 2:37:07 AM UTC+1, ito...@tamu.edu wrote:
>>
>> Dear everybody:
>>
>> I don't have any particular problem, just trying to streamline a code. I
>> am have a mess with the interfaces of my code, in particular with the
>> functions and classes I have created, primarily because I have to handle a
>> ''packet'' of vectors, say
>>
>>     PETScWrappers::MPI::Vector  Vect1;
>>     PETScWrappers::MPI::Vector  Vect2;
>>     PETScWrappers::MPI::Vector  Vect3;
>>     PETScWrappers::MPI::Vector  Vect4;
>>     …
>>     PETScWrappers::MPI::Vector  Vect7;
>>
>> and use them either as input or output arguments of some functions,
>> solvers, complementary computations, etc. This is quite cumbersome, and as
>> solution I naively thought I could do the following
>>
>>     std::vector<PETScWrappers::MPI::Vector >  VectorPacket ;
>>     VectorPacket.resize(7) ;
>>     for (int i=0; i<7 ; ++i)
>>       VectorPacket[i].reinit (locally_owned_dofs, mpi_communicator ) ;
>>
>> So, now VectorPacket is really a packet, rather than seven isolated
>> vectors. It is almost needless to say that this is bad idea, std::vector
>> will demand quite a few things from the class PETScWrappers::MPI::Vector
>> which are just not there (in particular some operators). In reality the
>> size of the packet of vector is not always seven, which means that I really
>> need to use a proper container for which I can change it's size. Do you
>> have any suggestion (a.k.a. creative approach) on how to deal with an issue
>> like this one? Which container from the STL would be appropriate?
>>
>> Many thanks.
>>
> --
> The deal.II project is located at http://www.dealii.org/
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.dealii.org_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=ihd-8rKZdGkf12UV9R7-pA&m=vXwEg0P0IkHcAecANEcqpdfWm7DS8YbChufy5v0CsGs&s=BnA2TuiZyt6TTwla_oPMt9ygwFZ3pgcuPbqbiLgtI-E&e=>
> For mailing list/forum options, see https://groups.google.com/d/
> forum/dealii?hl=en
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_forum_dealii-3Fhl-3Den&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=ihd-8rKZdGkf12UV9R7-pA&m=vXwEg0P0IkHcAecANEcqpdfWm7DS8YbChufy5v0CsGs&s=kS559TWqee-h6dwoqNfQ-KSDgtFQ9b1eKFOe8Y8gEVk&e=>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "deal.II User Group" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/dealii/rFm-6ZMYoU4/unsubscribe
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_topic_dealii_rFm-2D6ZMYoU4_unsubscribe&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=ihd-8rKZdGkf12UV9R7-pA&m=vXwEg0P0IkHcAecANEcqpdfWm7DS8YbChufy5v0CsGs&s=Mhvv16_fMaou-5bsrd7i9e0dNMu-GY8eYS8ypmo9TC0&e=>
> .
> To unsubscribe from this group and all its topics, send an email to
> dealii+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_optout&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=ihd-8rKZdGkf12UV9R7-pA&m=vXwEg0P0IkHcAecANEcqpdfWm7DS8YbChufy5v0CsGs&s=tOLws4juCTBpyjF1gNWxKnIJAYYGCNKojmzAepeiAAg&e=>
> .
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to