Reference documentation for deal.II version GIT relicensing-218-g1f873f3929 2024-03-28 15:00:02+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
kinsol.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2017 - 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
16#ifndef dealii_sundials_kinsol_h
17#define dealii_sundials_kinsol_h
18
19#include <deal.II/base/config.h>
20
21#ifdef DEAL_II_WITH_SUNDIALS
22
23
29
30# include <deal.II/lac/vector.h>
32
34
35# include <boost/signals2.hpp>
36
37# include <kinsol/kinsol.h>
38# include <nvector/nvector_serial.h>
39# include <sundials/sundials_math.h>
40
41# include <exception>
42# include <memory>
43
44
46
47// Shorthand notation for KINSOL error codes.
48# define AssertKINSOL(code) Assert(code >= 0, ExcKINSOLError(code))
49
50namespace SUNDIALS
51{
183 template <typename VectorType = Vector<double>>
184 class KINSOL
185 {
186 public:
191 {
192 public:
198 {
202 newton = KIN_NONE,
206 linesearch = KIN_LINESEARCH,
210 fixed_point = KIN_FP,
214 picard = KIN_PICARD,
215 };
216
217
262
294 const unsigned int maximum_non_linear_iterations = 200,
295 const double function_tolerance = 0.0,
296 const double step_tolerance = 0.0,
297 const bool no_init_setup = false,
298 const unsigned int maximum_setup_calls = 0,
299 const double maximum_newton_step = 0.0,
300 const double dq_relative_error = 0.0,
301 const unsigned int maximum_beta_failures = 0,
302 const unsigned int anderson_subspace_size = 0,
305
344 void
346
355
360
368
376
386
396
403
412
419
427
433 };
434
445
453 KINSOL(const AdditionalData &data, const MPI_Comm mpi_comm);
454
458 ~KINSOL();
459
465 unsigned int
466 solve(VectorType &initial_guess_and_solution);
467
482 std::function<void(VectorType &)> reinit_vector;
483
497 std::function<void(const VectorType &src, VectorType &dst)> residual;
498
512 std::function<void(const VectorType &src, VectorType &dst)>
514
560 std::function<void(const VectorType &current_u,
561 const VectorType &current_f)>
563
603 std::function<
604 void(const VectorType &rhs, VectorType &dst, const double tolerance)>
606
652 std::function<VectorType &()> get_solution_scaling;
653
675 std::function<VectorType &()> get_function_scaling;
676
677
706 std::function<void(void *kinsol_mem)> custom_setup;
707
712 int,
713 << "One of the SUNDIALS KINSOL internal functions "
714 << "returned a negative error code: " << arg1
715 << ". Please consult SUNDIALS manual.");
716
717 private:
723 std::string,
724 << "Please provide an implementation for the function \""
725 << arg1 << "\"");
726
732 void
734
739
744
749
750# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
755# endif
756
757
762
768 mutable std::exception_ptr pending_exception;
769 };
770
771} // namespace SUNDIALS
772
773
775
776#endif
777
778#endif
SolutionStrategy strategy
Definition kinsol.h:354
unsigned int maximum_beta_failures
Definition kinsol.h:418
OrthogonalizationStrategy anderson_qr_orthogonalization
Definition kinsol.h:432
void add_parameters(ParameterHandler &prm)
Definition kinsol.cc:85
unsigned int maximum_non_linear_iterations
Definition kinsol.h:359
unsigned int anderson_subspace_size
Definition kinsol.h:426
std::function< VectorType &()> get_solution_scaling
Definition kinsol.h:652
std::function< void(const VectorType &current_u, const VectorType &current_f)> setup_jacobian
Definition kinsol.h:562
void set_functions_to_trigger_an_assert()
Definition kinsol.cc:558
MPI_Comm mpi_communicator
Definition kinsol.h:743
unsigned int solve(VectorType &initial_guess_and_solution)
Definition kinsol.cc:212
SUNContext kinsol_ctx
Definition kinsol.h:754
std::function< void(const VectorType &src, VectorType &dst)> residual
Definition kinsol.h:497
std::function< void(const VectorType &src, VectorType &dst)> iteration_function
Definition kinsol.h:513
GrowingVectorMemory< VectorType > mem
Definition kinsol.h:761
std::exception_ptr pending_exception
Definition kinsol.h:768
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
Definition kinsol.h:605
std::function< VectorType &()> get_function_scaling
Definition kinsol.h:675
std::function< void(VectorType &)> reinit_vector
Definition kinsol.h:482
std::function< void(void *kinsol_mem)> custom_setup
Definition kinsol.h:706
AdditionalData data
Definition kinsol.h:738
void * kinsol_mem
Definition kinsol.h:748
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
static ::ExceptionBase & ExcKINSOLError(int arg1)
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:516