deal.II version GIT relicensing-2947-g2b65dfb0bb 2025-03-26 20:50:00+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 - 2024 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
28
29# include <deal.II/lac/vector.h>
31
33
34# include <boost/signals2.hpp>
35
36# include <kinsol/kinsol.h>
37# include <nvector/nvector_serial.h>
38# include <sundials/sundials_math.h>
39
40# include <exception>
41# include <memory>
42
43
45
46
47namespace SUNDIALS
48{
180 template <typename VectorType = Vector<double>>
181 class KINSOL
182 {
183 public:
188 {
189 public:
195 {
199 newton = KIN_NONE,
203 linesearch = KIN_LINESEARCH,
207 fixed_point = KIN_FP,
211 picard = KIN_PICARD,
212 };
213
214
259
291 const unsigned int maximum_non_linear_iterations = 200,
292 const double function_tolerance = 0.0,
293 const double step_tolerance = 0.0,
294 const bool no_init_setup = false,
295 const unsigned int maximum_setup_calls = 0,
296 const double maximum_newton_step = 0.0,
297 const double dq_relative_error = 0.0,
298 const unsigned int maximum_beta_failures = 0,
299 const unsigned int anderson_subspace_size = 0,
302
341 void
343
352
357
365
373
383
393
400
409
416
424
430 };
431
442
450 KINSOL(const AdditionalData &data, const MPI_Comm mpi_comm);
451
455 ~KINSOL();
456
462 unsigned int
463 solve(VectorType &initial_guess_and_solution);
464
479 std::function<void(VectorType &)> reinit_vector;
480
494 std::function<void(const VectorType &src, VectorType &dst)> residual;
495
509 std::function<void(const VectorType &src, VectorType &dst)>
511
557 std::function<void(const VectorType &current_u,
558 const VectorType &current_f)>
560
600 std::function<
601 void(const VectorType &rhs, VectorType &dst, const double tolerance)>
603
649 std::function<VectorType &()> get_solution_scaling;
650
672 std::function<VectorType &()> get_function_scaling;
673
674
703 std::function<void(void *kinsol_mem)> custom_setup;
704
709 int,
710 << "One of the SUNDIALS KINSOL internal functions "
711 << "returned a negative error code: " << arg1
712 << ". Please consult SUNDIALS manual.");
713
714 private:
720 std::string,
721 << "Please provide an implementation for the function \""
722 << arg1 << "\"");
723
729 void
731
736
741
746
747# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
752# endif
753
754
759
765 mutable std::exception_ptr pending_exception;
766 };
767
768} // namespace SUNDIALS
769
770
772
773#endif
774
775#endif
SolutionStrategy strategy
Definition kinsol.h:351
unsigned int maximum_beta_failures
Definition kinsol.h:415
OrthogonalizationStrategy anderson_qr_orthogonalization
Definition kinsol.h:429
void add_parameters(ParameterHandler &prm)
Definition kinsol.cc:90
unsigned int maximum_non_linear_iterations
Definition kinsol.h:356
unsigned int anderson_subspace_size
Definition kinsol.h:423
std::function< VectorType &()> get_solution_scaling
Definition kinsol.h:649
std::function< void(const VectorType &current_u, const VectorType &current_f)> setup_jacobian
Definition kinsol.h:559
void set_functions_to_trigger_an_assert()
Definition kinsol.cc:580
MPI_Comm mpi_communicator
Definition kinsol.h:740
unsigned int solve(VectorType &initial_guess_and_solution)
Definition kinsol.cc:224
SUNContext kinsol_ctx
Definition kinsol.h:751
std::function< void(const VectorType &src, VectorType &dst)> residual
Definition kinsol.h:494
std::function< void(const VectorType &src, VectorType &dst)> iteration_function
Definition kinsol.h:510
GrowingVectorMemory< VectorType > mem
Definition kinsol.h:758
std::exception_ptr pending_exception
Definition kinsol.h:765
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
Definition kinsol.h:602
std::function< VectorType &()> get_function_scaling
Definition kinsol.h:672
std::function< void(VectorType &)> reinit_vector
Definition kinsol.h:479
std::function< void(void *kinsol_mem)> custom_setup
Definition kinsol.h:703
AdditionalData data
Definition kinsol.h:735
void * kinsol_mem
Definition kinsol.h:745
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:40
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:41
static ::ExceptionBase & ExcKINSOLError(int arg1)
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)