From feb909a20dfce083abd7ed7e9a1898eab2613d4a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 23 Apr 2023 16:05:12 -0600 Subject: [PATCH] Also annotate the implementation of functions with 'requires' clauses. --- include/deal.II/lac/petsc_snes.templates.h | 62 ++++++++++++------- include/deal.II/lac/petsc_ts.templates.h | 70 +++++++++++++++------- 2 files changed, 87 insertions(+), 45 deletions(-) diff --git a/include/deal.II/lac/petsc_snes.templates.h b/include/deal.II/lac/petsc_snes.templates.h index dff02f5623..9d272094b9 100644 --- a/include/deal.II/lac/petsc_snes.templates.h +++ b/include/deal.II/lac/petsc_snes.templates.h @@ -51,6 +51,8 @@ DEAL_II_NAMESPACE_OPEN namespace PETScWrappers { template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) NonlinearSolver::NonlinearSolver( const NonlinearSolverData &data, const MPI_Comm & mpi_comm) @@ -63,6 +65,8 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) NonlinearSolver::operator SNES() const { return snes; @@ -71,8 +75,9 @@ namespace PETScWrappers template - SNES - NonlinearSolver::petsc_snes() + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + SNES NonlinearSolver::petsc_snes() { return snes; } @@ -80,9 +85,10 @@ namespace PETScWrappers template - MPI_Comm - NonlinearSolver::get_mpi_communicator() - const + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + MPI_Comm NonlinearSolver:: + get_mpi_communicator() const { return PetscObjectComm(reinterpret_cast(snes)); } @@ -90,6 +96,8 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) NonlinearSolver::~NonlinearSolver() { AssertPETSc(SNESDestroy(&snes)); @@ -98,8 +106,9 @@ namespace PETScWrappers template - void - NonlinearSolver::reinit() + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void NonlinearSolver::reinit() { AssertPETSc(SNESReset(snes)); } @@ -107,8 +116,9 @@ namespace PETScWrappers template - void - NonlinearSolver::reinit( + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void NonlinearSolver::reinit( const NonlinearSolverData &data) { reinit(); @@ -154,8 +164,9 @@ namespace PETScWrappers template - void - NonlinearSolver::set_matrix( + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void NonlinearSolver::set_matrix( PMatrixType &P) { this->A = nullptr; @@ -165,8 +176,9 @@ namespace PETScWrappers template - void - NonlinearSolver::set_matrices( + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void NonlinearSolver::set_matrices( AMatrixType &A, PMatrixType &P) { @@ -177,8 +189,10 @@ namespace PETScWrappers template - unsigned int - NonlinearSolver::solve(VectorType &x) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + unsigned int NonlinearSolver::solve( + VectorType &x) { const auto snes_function = [](SNES, Vec x, Vec f, void *ctx) -> PetscErrorCode { @@ -393,9 +407,11 @@ namespace PETScWrappers template - unsigned int - NonlinearSolver::solve(VectorType & x, - PMatrixType &P) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + unsigned int NonlinearSolver::solve( + VectorType & x, + PMatrixType &P) { set_matrix(P); return solve(x); @@ -404,10 +420,12 @@ namespace PETScWrappers template - unsigned int - NonlinearSolver::solve(VectorType & x, - AMatrixType &A, - PMatrixType &P) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + unsigned int NonlinearSolver::solve( + VectorType & x, + AMatrixType &A, + PMatrixType &P) { set_matrices(A, P); return solve(x); diff --git a/include/deal.II/lac/petsc_ts.templates.h b/include/deal.II/lac/petsc_ts.templates.h index 91d3268c64..75ae0bb2fd 100644 --- a/include/deal.II/lac/petsc_ts.templates.h +++ b/include/deal.II/lac/petsc_ts.templates.h @@ -51,6 +51,8 @@ DEAL_II_NAMESPACE_OPEN namespace PETScWrappers { template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) TimeStepper::TimeStepper( const TimeStepperData &data, const MPI_Comm & mpi_comm) @@ -63,6 +65,8 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) TimeStepper::~TimeStepper() { AssertPETSc(TSDestroy(&ts)); @@ -71,6 +75,8 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) TimeStepper::operator TS() const { return ts; @@ -79,8 +85,9 @@ namespace PETScWrappers template - TS - TimeStepper::petsc_ts() + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + TS TimeStepper::petsc_ts() { return ts; } @@ -88,9 +95,11 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) inline MPI_Comm - TimeStepper::get_mpi_communicator() - const + TimeStepper::get_mpi_communicator() + const { return PetscObjectComm(reinterpret_cast(ts)); } @@ -98,8 +107,10 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) typename TimeStepper::real_type - TimeStepper::get_time() + TimeStepper::get_time() { PetscReal t; PetscErrorCode ierr = TSGetTime(ts, &t); @@ -110,8 +121,10 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) typename TimeStepper::real_type - TimeStepper::get_time_step() + TimeStepper::get_time_step() { PetscReal dt; PetscErrorCode ierr = TSGetTimeStep(ts, &dt); @@ -122,8 +135,9 @@ namespace PETScWrappers template - void - TimeStepper::reinit() + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void TimeStepper::reinit() { AssertPETSc(TSReset(ts)); } @@ -131,8 +145,9 @@ namespace PETScWrappers template - void - TimeStepper::reinit( + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void TimeStepper::reinit( const TimeStepperData &data) { reinit(); @@ -199,8 +214,10 @@ namespace PETScWrappers template - void - TimeStepper::set_matrix(PMatrixType &P) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void TimeStepper::set_matrix( + PMatrixType &P) { this->A = nullptr; this->P = &P; @@ -209,8 +226,9 @@ namespace PETScWrappers template - void - TimeStepper::set_matrices( + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + void TimeStepper::set_matrices( AMatrixType &A, PMatrixType &P) { @@ -221,8 +239,10 @@ namespace PETScWrappers template - unsigned int - TimeStepper::solve(VectorType &y) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + unsigned int TimeStepper::solve( + VectorType &y) { const auto ts_ifunction = [](TS, PetscReal t, Vec x, Vec xdot, Vec f, void *ctx) -> PetscErrorCode { @@ -529,9 +549,11 @@ namespace PETScWrappers template - unsigned int - TimeStepper::solve(VectorType & y, - PMatrixType &P) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + unsigned int TimeStepper::solve( + VectorType & y, + PMatrixType &P) { set_matrix(P); return solve(y); @@ -540,10 +562,12 @@ namespace PETScWrappers template - unsigned int - TimeStepper::solve(VectorType & y, - AMatrixType &A, - PMatrixType &P) + DEAL_II_CXX20_REQUIRES((concepts::is_dealii_petsc_vector_type || + std::constructible_from)) + unsigned int TimeStepper::solve( + VectorType & y, + AMatrixType &A, + PMatrixType &P) { set_matrices(A, P); return solve(y); -- 2.39.5