Reference documentation for deal.II version GIT relicensing-12-g89ba5bf9db 2024-02-24 00:00:03+00:00
\(\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// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_petsc_ts_h
16#define dealii_petsc_ts_h
17
18#include <deal.II/base/config.h>
19
20#ifdef DEAL_II_WITH_PETSC
21# include <deal.II/base/mpi.h>
24
28
29# include <petscts.h>
30
31# include <exception>
32
33# if defined(DEAL_II_HAVE_CXX20)
34# include <concepts>
35# endif
36
38
39namespace PETScWrappers
40{
45 {
46 public:
52 using real_type = PetscReal;
53
88 // Running parameters
89 const std::string &options_prefix = "",
90 const std::string &ts_type = "",
91 const real_type initial_time = 0.0,
92 const real_type final_time = 0.0,
93 const real_type initial_step_size = 0.0,
94 const int max_steps = -1,
95 const bool match_step = false,
96 // Error parameters
97 const std::string &ts_adapt_type = "none",
98 const real_type minimum_step_size = -1.0,
99 const real_type maximum_step_size = -1.0,
100 const real_type absolute_tolerance = -1.0,
101 const real_type relative_tolerance = -1.0,
102 const bool ignore_algebraic_lte = true)
116 {}
117
121 void
123
127 std::string options_prefix;
128
132 std::string ts_type;
133
138
143
150
157
162
166 std::string ts_adapt_type;
167
174
181
188
195
200 };
201
314 template <typename VectorType = PETScWrappers::VectorBase,
315 typename PMatrixType = PETScWrappers::MatrixBase,
316 typename AMatrixType = PMatrixType>
317# if defined(DEAL_II_HAVE_CXX20) && \
318 !defined(DEAL_II_DOXYGEN_DO_NOT_PARSE_REQUIRES_CLAUSES)
320 std::constructible_from<VectorType, Vec>) &&
322 std::constructible_from<PMatrixType, Mat>) &&
324 std::constructible_from<AMatrixType, Mat>))
325# endif
327 {
328 public:
334 using real_type = PetscReal;
335
340 const MPI_Comm mpi_comm = PETSC_COMM_WORLD);
341
346
352 operator TS() const;
353
357 TS
359
365
369 void
371
376 void
378
391 void
392 set_matrix(PMatrixType &P);
393
399 void
400 set_matrices(AMatrixType &A, PMatrixType &P);
401
407
413
417 unsigned int
419
427 unsigned int
428 solve(VectorType &y);
429
439 unsigned int
440 solve(VectorType &y, PMatrixType &P);
441
452 unsigned int
453 solve(VectorType &y, AMatrixType &A, PMatrixType &P);
454
463 std::function<void(const real_type t,
464 const VectorType &y,
465 const VectorType &y_dot,
466 VectorType &res)>
468
483 std::function<void(const real_type t,
484 const VectorType &y,
485 const VectorType &y_dot,
486 const real_type alpha,
487 AMatrixType &A,
488 PMatrixType &P)>
490
499 std::function<void(const real_type t, const VectorType &y, VectorType &res)>
501
511 std::function<void(const real_type t,
512 const VectorType &y,
513 AMatrixType &A,
514 PMatrixType &P)>
516
528 std::function<void(const real_type t,
529 const VectorType &y,
530 const unsigned int step_number)>
532
552 std::function<void(const real_type t,
553 const VectorType &y,
554 const VectorType &ydot,
555 const real_type alpha)>
557
569 std::function<void(const VectorType &src, VectorType &dst)>
571
581
595 std::function<void(const real_type t, VectorType &y)> distribute;
596
613 std::function<void(const real_type t,
614 const unsigned int step,
615 const VectorType &y,
616 bool &resize)>
618
633 std::function<void(const std::vector<VectorType> &all_in,
634 std::vector<VectorType> &all_out)>
636
637 private:
641 TS ts;
642
648
653
658
663
669 mutable std::exception_ptr pending_exception;
670
675
683 void
685
693 void
694 setup_algebraic_constraints(const VectorType &y);
695 };
696
697} // namespace PETScWrappers
698
700
701#endif // DEAL_II_WITH_PETSC
702
703#endif
void add_parameters(ParameterHandler &prm)
void reinit(const TimeStepperData &data)
std::exception_ptr pending_exception
Definition petsc_ts.h:669
unsigned int solve(VectorType &y, PMatrixType &P)
std::function< void(const real_type t, const unsigned int step, const VectorType &y, bool &resize)> decide_for_coarsening_and_refinement
Definition petsc_ts.h:617
void setup_algebraic_constraints(const VectorType &y)
std::function< void(const real_type t, const VectorType &y, const VectorType &y_dot, VectorType &res)> implicit_function
Definition petsc_ts.h:467
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:515
unsigned int get_step_number()
TimeStepper(const TimeStepperData &data=TimeStepperData(), const MPI_Comm mpi_comm=PETSC_COMM_WORLD)
SmartPointer< AMatrixType, TimeStepper > A
Definition petsc_ts.h:646
unsigned int solve(VectorType &y, AMatrixType &A, PMatrixType &P)
std::function< void(const real_type t, const VectorType &y, const unsigned int step_number)> monitor
Definition petsc_ts.h:531
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:489
std::function< IndexSet()> algebraic_components
Definition petsc_ts.h:580
std::function< void(const real_type t, VectorType &y)> distribute
Definition petsc_ts.h:595
std::function< void(const real_type t, const VectorType &y, const VectorType &ydot, const real_type alpha)> setup_jacobian
Definition petsc_ts.h:556
SmartPointer< PMatrixType, TimeStepper > P
Definition petsc_ts.h:647
std::function< void(const real_type t, const VectorType &y, VectorType &res)> explicit_function
Definition petsc_ts.h:500
unsigned int solve(VectorType &y)
std::function< void(const VectorType &src, VectorType &dst)> solve_with_jacobian
Definition petsc_ts.h:570
void set_matrices(AMatrixType &A, PMatrixType &P)
PreconditionShell solve_with_jacobian_pc
Definition petsc_ts.h:652
std::function< void(const std::vector< VectorType > &all_in, std::vector< VectorType > &all_out)> interpolate
Definition petsc_ts.h:635
void set_matrix(PMatrixType &P)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
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:87