deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2017 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_sundials_kinsol_h
15#define dealii_sundials_kinsol_h
16
17#include <deal.II/base/config.h>
18
19#ifdef DEAL_II_WITH_SUNDIALS
20
21
26
27# include <deal.II/lac/vector.h>
29
31
32# include <boost/signals2.hpp>
33
34# include <kinsol/kinsol.h>
35# include <nvector/nvector_serial.h>
36# include <sundials/sundials_math.h>
37
38# include <exception>
39# include <memory>
40
41#endif
42
44
45#ifdef DEAL_II_WITH_SUNDIALS
46namespace SUNDIALS
47{
179 template <typename VectorType = Vector<double>>
180 class KINSOL
181 {
182 public:
187 {
188 public:
194 {
198 newton = KIN_NONE,
202 linesearch = KIN_LINESEARCH,
206 fixed_point = KIN_FP,
210 picard = KIN_PICARD,
211 };
212
213
258
290 const unsigned int maximum_non_linear_iterations = 200,
291 const double function_tolerance = 0.0,
292 const double step_tolerance = 0.0,
293 const bool no_init_setup = false,
294 const unsigned int maximum_setup_calls = 0,
295 const double maximum_newton_step = 0.0,
296 const double dq_relative_error = 0.0,
297 const unsigned int maximum_beta_failures = 0,
298 const unsigned int anderson_subspace_size = 0,
301
340 void
342
351
356
364
372
382
392
399
408
415
423
429 };
430
441
449 KINSOL(const AdditionalData &data, const MPI_Comm mpi_comm);
450
454 ~KINSOL();
455
461 unsigned int
462 solve(VectorType &initial_guess_and_solution);
463
478 std::function<void(VectorType &)> reinit_vector;
479
493 std::function<void(const VectorType &src, VectorType &dst)> residual;
494
508 std::function<void(const VectorType &src, VectorType &dst)>
510
556 std::function<void(const VectorType &current_u,
557 const VectorType &current_f)>
559
599 std::function<
600 void(const VectorType &rhs, VectorType &dst, const double tolerance)>
602
648 std::function<VectorType &()> get_solution_scaling;
649
671 std::function<VectorType &()> get_function_scaling;
672
673
702 std::function<void(void *kinsol_mem)> custom_setup;
703
704 private:
710 std::string,
711 << "Please provide an implementation for the function \""
712 << arg1 << "\"");
713
719 void
721
726
731
736
737# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
742# endif
743
744
749
755 mutable std::exception_ptr pending_exception;
756 };
757
762 int,
763 << "One of the SUNDIALS KINSOL internal functions "
764 << "returned a negative error code: " << arg1
765 << ". Please consult SUNDIALS manual.");
766
767} // namespace SUNDIALS
768
769#endif
770
772
773#endif
SolutionStrategy strategy
Definition kinsol.h:350
unsigned int maximum_beta_failures
Definition kinsol.h:414
OrthogonalizationStrategy anderson_qr_orthogonalization
Definition kinsol.h:428
void add_parameters(ParameterHandler &prm)
Definition kinsol.cc:97
unsigned int maximum_non_linear_iterations
Definition kinsol.h:355
unsigned int anderson_subspace_size
Definition kinsol.h:422
std::function< VectorType &()> get_solution_scaling
Definition kinsol.h:648
std::function< void(const VectorType &current_u, const VectorType &current_f)> setup_jacobian
Definition kinsol.h:558
void set_functions_to_trigger_an_assert()
Definition kinsol.cc:597
MPI_Comm mpi_communicator
Definition kinsol.h:730
unsigned int solve(VectorType &initial_guess_and_solution)
Definition kinsol.cc:231
SUNContext kinsol_ctx
Definition kinsol.h:741
std::function< void(const VectorType &src, VectorType &dst)> residual
Definition kinsol.h:493
std::function< void(const VectorType &src, VectorType &dst)> iteration_function
Definition kinsol.h:509
GrowingVectorMemory< VectorType > mem
Definition kinsol.h:748
std::exception_ptr pending_exception
Definition kinsol.h:755
std::function< void(const VectorType &rhs, VectorType &dst, const double tolerance)> solve_with_jacobian
Definition kinsol.h:601
std::function< VectorType &()> get_function_scaling
Definition kinsol.h:671
std::function< void(VectorType &)> reinit_vector
Definition kinsol.h:478
std::function< void(void *kinsol_mem)> custom_setup
Definition kinsol.h:702
AdditionalData data
Definition kinsol.h:725
void * kinsol_mem
Definition kinsol.h:735
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
static ::ExceptionBase & ExcKINSOLError(int arg1)
static ::ExceptionBase & ExcFunctionNotProvided(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)