Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
petsc_ts.h
Go to the documentation of this file.
1//-----------------------------------------------------------
2//
3// Copyright (C) 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14//---------------------------------------------------------------
15
16#ifndef dealii_petsc_ts_h
17#define dealii_petsc_ts_h
18
19#include <deal.II/base/config.h>
20
21#ifdef DEAL_II_WITH_PETSC
22# include <deal.II/base/mpi.h>
25
29
30# include <petscts.h>
31
32# include <exception>
33
34# if defined(DEAL_II_HAVE_CXX20)
35# include <concepts>
36# endif
37
39
40namespace PETScWrappers
41{
46 {
47 public:
53 using real_type = PetscReal;
54
89 // Running parameters
90 const std::string &options_prefix = "",
91 const std::string &ts_type = "",
92 const real_type initial_time = 0.0,
93 const real_type final_time = 0.0,
94 const real_type initial_step_size = 0.0,
95 const int max_steps = -1,
96 const bool match_step = false,
97 // Error parameters
98 const std::string &ts_adapt_type = "none",
99 const real_type minimum_step_size = -1.0,
100 const real_type maximum_step_size = -1.0,
101 const real_type absolute_tolerance = -1.0,
102 const real_type relative_tolerance = -1.0,
103 const bool ignore_algebraic_lte = true)
117 {}
118
122 void
124
128 std::string options_prefix;
129
133 std::string ts_type;
134
139
144
151
158
163
167 std::string ts_adapt_type;
168
175
182
189
196
201 };
202
304 template <typename VectorType = PETScWrappers::VectorBase,
305 typename PMatrixType = PETScWrappers::MatrixBase,
306 typename AMatrixType = PMatrixType>
307# if defined(DEAL_II_HAVE_CXX20) && \
308 !defined(DEAL_II_DOXYGEN_DO_NOT_PARSE_REQUIRES_CLAUSES)
309 requires(
311 std::constructible_from<
312 VectorType,
314 std::constructible_from<
315 PMatrixType,
317 std::constructible_from<AMatrixType, Mat>))
318# endif
320 {
321 public:
327 using real_type = PetscReal;
328
333 const MPI_Comm mpi_comm = PETSC_COMM_WORLD);
334
339
345 operator TS() const;
346
350 TS
352
358
362 void
364
369 void
371
384 void
385 set_matrix(PMatrixType &P);
386
391 void
392 set_matrices(AMatrixType &A, PMatrixType &P);
393
399
405
413 unsigned int
414 solve(VectorType &y);
415
425 unsigned int
426 solve(VectorType &y, PMatrixType &P);
427
438 unsigned int
439 solve(VectorType &y, AMatrixType &A, PMatrixType &P);
440
449 std::function<void(const real_type t,
450 const VectorType &y,
451 const VectorType &y_dot,
452 VectorType & res)>
454
469 std::function<void(const real_type t,
470 const VectorType &y,
471 const VectorType &y_dot,
472 const real_type alpha,
473 AMatrixType & A,
474 PMatrixType & P)>
476
485 std::function<void(const real_type t, const VectorType &y, VectorType &res)>
487
497 std::function<void(const real_type t,
498 const VectorType &y,
499 AMatrixType & A,
500 PMatrixType & P)>
502
514 std::function<void(const real_type t,
515 const VectorType & y,
516 const unsigned int step_number)>
518
538 std::function<void(const real_type t,
539 const VectorType &y,
540 const VectorType &ydot,
541 const real_type alpha)>
543
555 std::function<void(const VectorType &src, VectorType &dst)>
557
567
568 private:
572 TS ts;
573
579
584
589
595 mutable std::exception_ptr pending_exception;
596
601 };
602
603} // namespace PETScWrappers
604
606
607#endif // DEAL_II_WITH_PETSC
608
609#endif
void add_parameters(ParameterHandler &prm)
void reinit(const TimeStepperData &data)
std::exception_ptr pending_exception
Definition petsc_ts.h:595
unsigned int solve(VectorType &y, PMatrixType &P)
std::function< void(const real_type t, const VectorType &y, const VectorType &y_dot, const real_type alpha, AMatrixType &A, PMatrixType &P)> implicit_jacobian
Definition petsc_ts.h:475
std::function< void(const real_type t, const VectorType &y, const unsigned int step_number)> monitor
Definition petsc_ts.h:517
MPI_Comm get_mpi_communicator() const
std::function< void(const real_type t, const VectorType &y, AMatrixType &A, PMatrixType &P)> explicit_jacobian
Definition petsc_ts.h:501
TimeStepper(const TimeStepperData &data=TimeStepperData(), const MPI_Comm mpi_comm=PETSC_COMM_WORLD)
SmartPointer< AMatrixType, TimeStepper > A
Definition petsc_ts.h:577
unsigned int solve(VectorType &y, AMatrixType &A, PMatrixType &P)
std::function< IndexSet()> algebraic_components
Definition petsc_ts.h:566
std::function< void(const real_type t, const VectorType &y, const VectorType &ydot, const real_type alpha)> setup_jacobian
Definition petsc_ts.h:542
SmartPointer< PMatrixType, TimeStepper > P
Definition petsc_ts.h:578
std::function< void(const real_type t, const VectorType &y, VectorType &res)> explicit_function
Definition petsc_ts.h:486
std::function< void(const real_type t, const VectorType &y, const VectorType &y_dot, VectorType &res)> implicit_function
Definition petsc_ts.h:453
unsigned int solve(VectorType &y)
std::function< void(const VectorType &src, VectorType &dst)> solve_with_jacobian
Definition petsc_ts.h:556
void set_matrices(AMatrixType &A, PMatrixType &P)
void set_matrix(PMatrixType &P)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
TimeStepperData(const std::string &options_prefix="", const std::string &ts_type="", const real_type initial_time=0.0, const real_type final_time=0.0, const real_type initial_step_size=0.0, const int max_steps=-1, const bool match_step=false, const std::string &ts_adapt_type="none", const real_type minimum_step_size=-1.0, const real_type maximum_step_size=-1.0, const real_type absolute_tolerance=-1.0, const real_type relative_tolerance=-1.0, const bool ignore_algebraic_lte=true)
Definition petsc_ts.h:88