1

I have initialized ts = PETSc.TS().create() and attempt to solve with some initial distribution with ts.setSolution(u) and get a type error.

It seems as though it would like the type Vec but is getting passed as a _DMDA_Vec_array.

The setup goes as follows:

  1. create dmda = PETSc.DMDA().create(<...>)
  2. create a global vector x = dmda.createGlobalVec()
  3. get our IC vector: ic = dmda.getVecArray(x)
  4. fill IC vector
  5. attempt ts.setSolution(ic) but it doesn't like that ic is a _DMDA_Vec_arrayobject

So far I have found two things:

  1. ic = dmda.getVecArray(x) is doing what it is supposed to do--create a _DMDA_Vec_array object
  2. in regular PETSc, the equivalent would be to use the function DMDAVecGetArray() and then once you've filled the values, you run the function DMDAVecRestoreArray() to convert the _DMDA_Vec_array object back to a usable Vec object for ts.

What is the equivalent protocol/workflow in Python for _DMDA_Vec_array to Vec type?

scottbaker
  • 153
  • 1
  • 6

0 Answers0