Thanks Matt and Jed for the quick replies! That answers my immediate questions.

Best,

Samar

> On Feb 12, 2022, at 1:33 PM, Jed Brown <[email protected]> wrote:
> 
> VecDuplicateVecs isn't implemented in petsc4py, but it internally just loops 
> over VecDuplicate so you can use
> 
> qs = [x.duplicate() for i in range(4)]
> 
> y.maxpy(alphas, qs)
> 
> 
> where the Python binding here handles qs being a Python array.
> 
> Samar Khatiwala <[email protected]> writes:
> 
>> Hello,
>> 
>> I’d like to create an array of Vecs in petsc4py by calling VecDuplicateVecs 
>> but I can’t find the corresponding method (I’ve tried various iterations 
>> such as q = x.duplicateVecs(4), etc). 
>> Is this not implemented in petsc4py? One workaround I’ve come up with is 
>> something like:
>> 
>> q={}
>> for i in range(0, 3):
>>    q[i]=x.duplicate()
>> 
>> Is there another/better way? And how do I then use PETSc functions that 
>> operate on Vecs (e.g., VecMAXPY)? Would I just call VecAXPY in a loop as 
>> above?
>> 
>> Ultimately, what I really want to do is wrap my own C functions with Cython 
>> that take an array of Vecs as an argument and then operate on them. (The 
>> function needs the entire array 
>> of Vecs to do its thing so I can’t loop over the elements of the array.) For 
>> instance, I want to pass the q above to myCfunc(Vec *q, Vec *qout). How do I 
>> go about doing that?
>> 
>> Thanks very much!
>> 
>> Best,
>> 
>> Samar

Reply via email to