Wrapper unrestricted to restricted #42
-
|
As far as I understand the wrappers (e.g. VecSubVectorWrapper) take a restricted vector and give you an unrestricted one. Is there a way to go in the opposite direction? In particular, I want to take this product: and I am looking for a clean and efficient way to go about this. EDIT: So far the solution I found looks like this indices = np.array(tuple(restriction.restricted_to_unrestricted.values())[:restriction.index_map.size_local],dtype=np.int32)
indices = restriction.dofmap.index_map.local_to_global(indices).astype(np.int32)
iset = PETSc.IS().createGeneral(indices, MPI.COMM_WORLD)
restricted_f = f.x.petsc_vec.getSubVector(iset)
...
f.x.petsc_vec.restoreSubVector(iset, restricted_f ) The costliest line here is the first one although not by a big margin. Let me know if you find something better. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi, |
Beta Was this translation helpful? Give feedback.
Hi,
creating a PETSc index set and then getting the sub vector/sub matrix (although not necessarily with
getSubVector) is whatVecSubVectorWrapperand the other wrappers do, so it seems to me that your solution is close enough to what the library does.