Skip to content

Commit 4920c86

Browse files
committed
PetscCellMapping::extractEvolvingSubmatrix implementation
Passes unit tests
1 parent 65185d0 commit 4920c86

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/mesh/petsc_operators.cxx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ IS PetscCellMapping::makeEvolvingIS() const {
142142
return is;
143143
}
144144

145-
// Dummy implementation. Note: Result is owned by the caller.
146145
Mat PetscCellMapping::extractEvolvingSubmatrix(
147146
const PetscOperator<CellSpaceTag, CellSpaceTag>& op) const {
148-
Mat new_mat;
149-
BOUT_DO_PETSC(MatDuplicate(op.raw(), MAT_COPY_VALUES, &new_mat));
150-
return new_mat;
147+
IS is = makeEvolvingIS();
148+
149+
Mat sub;
150+
BOUT_DO_PETSC(MatCreateSubMatrix(op.raw(), is, is, MAT_INITIAL_MATRIX, &sub));
151+
152+
BOUT_DO_PETSC(ISDestroy(&is));
153+
154+
return sub;
151155
}
152156

153157
PetscLegMapping::PetscLegMapping(int total_legs, std::vector<int> local_leg_indices) {

0 commit comments

Comments
 (0)