Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for https://github.com/dealii/dealii/issues/15882 #15912

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 23 additions & 2 deletions include/deal.II/lac/petsc_ts.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,28 @@ namespace PETScWrappers
PetscReal atol, rtol;
AssertPETSc(TSGetTolerances(ts, &atol, nullptr, &rtol, nullptr));

// Fill up vectors with individual tolerances, using -1 for the
// algebraic variables.
// We need to input them with the same vector type of our solution
// but we are not sure that the user's VectorType supports operator[]
// We thus first create standard vectors that we know support the
// operator, and then copy the values into the user's type operator.
Vec av, rv;
Vec py = const_cast<VectorType &>(y).petsc_vector();
AssertPETSc(VecDuplicate(py, &av));
AssertPETSc(VecDuplicate(py, &rv));

VectorType avdealii(av);
VectorType rvdealii(rv);
// Standard vectors
Vec avT, rvT;
PetscInt n, N;
AssertPETSc(VecGetLocalSize(py, &n));
AssertPETSc(VecGetSize(py, &N));
AssertPETSc(VecCreateMPI(this->get_mpi_communicator(), n, N, &avT));
AssertPETSc(VecDuplicate(avT, &rvT));

// Fill-up the vectors
VectorBase avdealii(avT);
VectorBase rvdealii(rvT);
avdealii = atol;
rvdealii = rtol;
for (auto i : algebraic_components())
Expand All @@ -1104,9 +1119,15 @@ namespace PETScWrappers
}
avdealii.compress(VectorOperation::insert);
rvdealii.compress(VectorOperation::insert);

// Copy, set and destroy
AssertPETSc(VecCopy(avT, av));
AssertPETSc(VecCopy(rvT, rv));
AssertPETSc(TSSetTolerances(ts, atol, av, rtol, rv));
AssertPETSc(VecDestroy(&av));
AssertPETSc(VecDestroy(&rv));
AssertPETSc(VecDestroy(&avT));
AssertPETSc(VecDestroy(&rvT));
}
}

Expand Down