16 #ifndef _d2k_kinsol_interface_h 17 #define _d2k_kinsol_interface_h 19 #include <deal2lkit/config.h> 22 #ifdef D2K_WITH_SUNDIALS 24 #include <nvector/nvector_serial.h> 25 #include <sundials/sundials_math.h> 26 #include <sundials/sundials_types.h> 35 #ifdef DEAL_II_WITH_MPI 39 #include <kinsol/kinsol_impl.h> 59 template<
typename VEC=Vector<
double> >
64 #ifdef DEAL_II_WITH_MPI 72 const MPI_Comm mpi_comm = MPI_COMM_WORLD);
77 MPI_Comm get_comm()
const ;
104 void initialize_solver( VEC &initial_guess );
111 void set_scaling_vectors(
const VEC &uscale,
const VEC &fscale );
123 void set_constraint_vector(
const VEC &constraint );
128 int solve( VEC &solution );
134 std::function<shared_ptr<VEC>()> create_new_vector;
137 std::function<int(const VEC &y, VEC &res)>
residual;
153 void set_functions_to_trigger_an_assert();
227 #ifdef DEAL_II_WITH_MPI 231 unsigned int local_system_size;
236 MPI_Comm communicator;
N_Vector solution
KINSOL solution vector.
unsigned int system_size
dimension of the system
A parameter acceptor base class.
bool use_internal_solver
if true the internal direct solver of KINSOL is used.
double steptol
The Newton method will terminate when the scaled norm of the update is smaller than steptol...
std::function< int(const VEC &v, VEC &dst)> jacobian_vmult
standard function multiplying the Jacobian to a vector
std::function< int(const VEC &y, VEC &res)> residual
standard function computing residuals
void * kin_mem
Kinsol memory object.
unsigned int max_iterations
Maximum number of iterations.
double ftol
Input scalar tolerance for residuals.
Interface to SUNDIALS KINSOL library.
unsigned int verbosity
Level of verbosity of kinsol solver 0,1,2,3.
ConditionalOStream pcout
Output stream.
std::string strategy
Strategy used by the solver: newton = basic Newton iteration global_newton = Newton with line search ...
std::function< int(const VEC &y)> setup_jacobian
standard function computing the Jacobian
N_Vector f_scale
Internal scaling vector for the Jacobian.
std::function< int(const VEC &res, VEC &dst)> solve_linear_system
standard function solving linear system
bool scaling_is_set
scaling flag: if the scaling have been provided by the user calling the function set_scaling_vectors(...
bool is_initialized
Initialization flag.
N_Vector u_scale
Internal scaling vector for the solution.
double mbset
Maximum number of nonlinear iteration that can be done without a Jacobian update. ...