[petsc-users] How to pass the Matrices between functions in c++

ehsan sadrfaridpour it.sadr at gmail.com
Mon Jun 15 16:40:24 CDT 2015


Thanks a lot. So, I guess I shouldn't destroy it before I use it completely
in other functions. And in the end I just call a destroy functions.

Best,
Ehsan

On Mon, Jun 15, 2015 at 5:36 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Mon, Jun 15, 2015 at 4:12 PM, ehsan sadrfaridpour <it.sadr at gmail.com>
> wrote:
>
>> Hi,
>> Thanks for your great support.
>> I am developing my code in c++ and I have created 4 matrices in a
>> function and they are work fine.
>> In the end of the function I need to delete them to release the memory
>> space they occupied.
>>
>>    - My question:
>>
>> However, I need to pass these matrices to other functions (or another
>> class) and use their contents before I destroy them in the current function.
>>
>> (I need it because now I have a long function and I want to make it
>> smaller. Also I need to make a recursive function that gets matrices as
>> input.)
>>
>> I was thinking of using a pointer to the beginning of each of them, but I
>> am not very good at this. Also I am worried about how I destroy them.
>>
>> Would you please let me know what is the best approach for this?
>>
>
> You can just use "Mat A" since the PETSc type is a pointer.
>
>   Thanks,
>
>     Matt
>
>
>> Best,
>> Ehsan
>>
>>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150615/47786d28/attachment.html>


More information about the petsc-users mailing list