9.2
general documentation
cs_sles.h
Go to the documentation of this file.
1#ifndef CS_SLES_H
2#define CS_SLES_H
3
4/*============================================================================
5 * Sparse Linear Equation Solver driver
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "base/cs_base.h"
35#include "base/cs_log.h"
36#include "base/cs_halo_perio.h"
37#include "alge/cs_matrix.h"
38#include "alge/cs_matrix.h"
39
40/*----------------------------------------------------------------------------*/
41
43
44/*============================================================================
45 * Macro definitions
46 *============================================================================*/
47
48/*============================================================================
49 * Type definitions
50 *============================================================================*/
51
52/*----------------------------------------------------------------------------
53 * Convergence status
54 *----------------------------------------------------------------------------*/
55
57typedef enum {
58
69
70/* General linear solver context (opaque) */
71
72typedef struct _cs_sles_t cs_sles_t;
73
74/*----------------------------------------------------------------------------
75 * Function pointer for pre-resolution setup of a linear system solvers's
76 * context.
77 *
78 * This setup may include building a multigrid hierarchy, or a preconditioner.
79 *
80 * Use of this type of function is optional: the context is expected to
81 * maintain state, so that if a cs_sles_solve_t function is called before a
82 * cs_sles_setup_t function, the latter will be called automatically.
83 *
84 * parameters:
85 * context <-> pointer to solver context
86 * name <-- pointer to name of linear system
87 * a <-- matrix
88 * verbosity <-- associated verbosity
89 *----------------------------------------------------------------------------*/
90
91typedef void
92(cs_sles_setup_t) (void *context,
93 const char *name,
94 const cs_matrix_t *a,
95 int verbosity);
96
97/*----------------------------------------------------------------------------
98 * Function pointer for resolution of a linear system.
99 *
100 * If the associated cs_sles_setup_t function has not been called before
101 * this function, it will be called automatically.
102 *
103 * The solution context setup by this call (or that of the matching setup
104 * function) will be maintained until the matching cs_sles_free_t function
105 * is called.
106 *
107 * The matrix is not expected to change between successive calls, although
108 * the right hand side may. If the matrix changes, the associated
109 * cs_sles_setup_t or cs_sles_free_t function must be called between
110 * solves.
111 *
112 * The system is considered to have converged when
113 * residual/r_norm <= precision, residual being the L2 norm of a.vx-rhs.
114 *
115 * parameters:
116 * context <-> pointer to solver context
117 * name <-- pointer to name of linear system
118 * a <-- matrix
119 * verbosity <-- associated verbosity
120 * precision <-- solver precision
121 * r_norm <-- residual normalization
122 * n_iter --> number of "equivalent" iterations
123 * residual --> residual
124 * rhs <-- right hand side
125 * vx_ini <-- initial solution (vx if nonzero, nullptr if zero)
126 * vx --> system solution
127 * aux_size <-- number of elements in aux_vectors
128 * aux_vectors <-- optional working area (internal allocation if NULL)
129 *
130 * returns:
131 * convergence status
132 *----------------------------------------------------------------------------*/
133
135(cs_sles_solve_t) (void *context,
136 const char *name,
137 const cs_matrix_t *a,
138 int verbosity,
139 double precision,
140 double r_norm,
141 int *n_iter,
142 double *residual,
143 const cs_real_t *rhs,
144 cs_real_t *vx_ini,
145 cs_real_t *vx,
146 size_t aux_size,
147 void *aux_vectors);
148
149/*----------------------------------------------------------------------------
150 * Function pointer for freeing of a linear system's context data.
151 *
152 * Note that this function should free resolution-related data, such as
153 * multigrid hierarchy, preconditioning, and any other temporary arrays or
154 * objects required for resolution, but should not free the whole context,
155 * as info used for logging (especially performance data) should be
156 * maintained.
157 *
158 * parameters:
159 * context <-> pointer to solver context
160 *----------------------------------------------------------------------------*/
161
162typedef void
163(cs_sles_free_t) (void *context);
164
165/*----------------------------------------------------------------------------
166 * Function pointer for logging of linear solver setup,
167 * history and performance data.
168 *
169 * This function will be called for each solver when cs_sles_finalize()
170 * is called.
171 *
172 * parameters:
173 * context <-- pointer to solver context
174 * log_type <-- log type
175 *----------------------------------------------------------------------------*/
176
177typedef void
178(cs_sles_log_t) (const void *context,
179 cs_log_t log_type);
180
181/*----------------------------------------------------------------------------
182 * Function pointer for creation of a solver context based on the copy
183 * of another.
184 *
185 * The new context copies the settings of the copied context, but not
186 * its setup data and logged info, such as performance data.
187 *
188 * This type of function is optional, but enables associating different
189 * solvers to related systems (to differentiate logging) while using
190 * the same settings by default.
191 *
192 * parameters:
193 * context <-- source context
194 *
195 * returns:
196 * pointer to newly created context
197 *----------------------------------------------------------------------------*/
198
199typedef void *
200(cs_sles_copy_t) (const void *context);
201
202/*----------------------------------------------------------------------------
203 * Function pointer for destruction of a linear system solver context.
204 *
205 * This function should free all context data, and will be called for each
206 * system when cs_sles_finalize() is called.
207 *
208 * parameters:
209 * context <-> pointer to solver context
210 *----------------------------------------------------------------------------*/
211
212typedef void
213(cs_sles_destroy_t) (void **context);
214
215/*----------------------------------------------------------------------------
216 * Function pointer for handling of non-convegence when solving
217 * a linear system.
218 *
219 * Such a function is optional, and may be used for a variety of purposes,
220 * such as logging, postprocessing, re-trying with different parameters,
221 * aborting the run, or any combination thereof.
222 *
223 * An error handler may be associated with a given solver using
224 * cs_sles_set_error_handler(), in which case it will be called whenever
225 * convergence fails.
226 *
227 * parameters:
228 * sles <-> pointer to solver object
229 * state <-- convergence status
230 * a <-- matrix
231 * rhs <-- Right hand side
232 * vx <-- System solution
233 *
234 * returns:
235 * true if solve should be re-executed, false otherwise
236 *----------------------------------------------------------------------------*/
237
238typedef bool
241 const cs_matrix_t *a,
242 const cs_real_t *rhs,
243 cs_real_t *vx);
244
245/*----------------------------------------------------------------------------
246 * Function pointer for the default definition of a sparse
247 * linear equation solver
248 *
249 * The function may be associated using cs_sles_set_default_define(), so
250 * that it may provide a definition that will be used when
251 * cs_sles_setup() or cs_sles_solve() is used for a system for which
252 * no matching call to cs_sles_define() has been done.
253 *
254 * The function should call cs_sles_define() with arguments f_id
255 * and name, and appropriately chosen function pointers.
256 *
257 * A pointer to the matrix of the system to be solved is also provided,
258 * so that the corresponding information may be used to better choose
259 * defaults.
260 *
261 * parameters:
262 * f_id <-- associated field id, or < 0
263 * name <-- associated name if f_id < 0, or NULL
264 * a <-- Matrix
265 *----------------------------------------------------------------------------*/
266
267typedef void
268(cs_sles_define_t) (int f_id,
269 const char *name,
270 const cs_matrix_t *a);
271
272/*----------------------------------------------------------------------------
273 * Function pointer for the default definition of a sparse
274 * linear equation solver's verbosity
275 *
276 * The function may be associated using cs_sles_set_default_verbosity(), so
277 * that it may provide a definition that will be used when
278 * cs_sles_default_verbosity() is called.
279 *
280 * parameters:
281 * f_id <-- associated field id, or < 0
282 * name <-- associated name if f_id < 0, or NULL
283 *
284 * returns:
285 * default verbosity value
286 *----------------------------------------------------------------------------*/
287
288typedef int
289(cs_sles_verbosity_t) (int f_id,
290 const char *name);
291
292/*============================================================================
293 * Global variables
294 *============================================================================*/
295
296/*=============================================================================
297 * Public function prototypes for Fortran API
298 *============================================================================*/
299
300/*=============================================================================
301 * Public function prototypes
302 *============================================================================*/
303
304/*----------------------------------------------------------------------------*/
308/*----------------------------------------------------------------------------*/
309
310void
311cs_sles_set_epzero(double new_value);
312
313/*----------------------------------------------------------------------------*/
320/*----------------------------------------------------------------------------*/
321
322double
324
325/*----------------------------------------------------------------------------
326 * \brief Initialize sparse linear equation solver API.
327 *----------------------------------------------------------------------------*/
328
329void
331
332/*----------------------------------------------------------------------------
333 * \brief Finalize sparse linear equation solver API.
334 *----------------------------------------------------------------------------*/
335
336void
337cs_sles_finalize(void);
338
339/*----------------------------------------------------------------------------*/
345/*----------------------------------------------------------------------------*/
346
347void
348cs_sles_log(cs_log_t log_type);
349
350/*----------------------------------------------------------------------------*/
351/*
352 * \brief Return pointer to linear system object, based on matching field id or
353 * system name.
354 *
355 * If this system did not previously exist, nullptr is returned.
356 *
357 * \param[in] f_id associated field id, or < 0
358 * \param[in] name associated name if f_id < 0, or NULL
359 *
360 * \return pointer to associated linear system object, or NULL
361 */
362/*----------------------------------------------------------------------------*/
363
364cs_sles_t *
365cs_sles_find(int f_id,
366 const char *name);
367
368/*----------------------------------------------------------------------------*/
369/*
370 * \brief Return pointer to linear system object, based on matching field id or
371 * system name.
372 *
373 * If this system did not previously exist, it is created and added to
374 * to the list of "known" systems. In this case, it will be usable
375 * only if cs_sles_define() is called for the same field id and name
376 * (in which case calling the present function is redundant), or if
377 * cs_sles_set_sefault_define() has been previously used to define
378 * the default solver policy.
379 *
380 * \param[in] f_id associated field id, or < 0
381 * \param[in] name associated name if f_id < 0, or NULL
382 *
383 * \return pointer to associated linear system object, or NULL
384 */
385/*----------------------------------------------------------------------------*/
386
387cs_sles_t *
388cs_sles_find_or_add(int f_id,
389 const char *name);
390
391/*----------------------------------------------------------------------------*/
392/*
393 * \brief Temporarily replace field id with name for matching calls
394 * to \ref cs_sles_setup, \ref cs_sles_solve, \ref cs_sles_free, and other
395 * operations involving access through a field id.
396 *
397 * This function is provided to allow some peculiar calling sequences,
398 * in which \ref cs_equation_iterative_solve_scalar is called with a given
399 * field id, but specific solver options must still be set.
400 * In the future, a cleaner method to handle those exceptional cases
401 * would be preferred. As such, only a stack depth of 1 is allowed.
402 *
403 * \param[in] f_id associated field id, or < 0
404 * \param[in] name associated name if f_id < 0, or NULL
405 */
406/*----------------------------------------------------------------------------*/
407
408[[deprecated]] void
409cs_sles_push(int f_id,
410 const char *name);
411
412/*----------------------------------------------------------------------------*/
413/*
414 * \brief Restore behavior temporarily modified by \ref cs_sles_push.
415 *
416 * \deprecated This function matches \ref cs_sles_push, which is deprecated.
417 *
418 * \param[in] f_id associated field id, or < 0
419 */
420/*----------------------------------------------------------------------------*/
421
422[[deprecated]] void
423cs_sles_pop(int f_id);
424
425/*----------------------------------------------------------------------------*/
460/*----------------------------------------------------------------------------*/
461
462cs_sles_t *
463cs_sles_define(int f_id,
464 const char *name,
465 void *context,
466 const char *type_name,
467 cs_sles_setup_t *setup_func,
468 cs_sles_solve_t *solve_func,
469 cs_sles_free_t *free_func,
470 cs_sles_log_t *log_func,
471 cs_sles_copy_t *copy_func,
472 cs_sles_destroy_t *destroy_func);
473
474/*----------------------------------------------------------------------------*/
486/*----------------------------------------------------------------------------*/
487
488void
490 int verbosity);
491
492/*----------------------------------------------------------------------------*/
502/*----------------------------------------------------------------------------*/
503
504int
506
507/*----------------------------------------------------------------------------*/
508/*
509 * \brief Activate postprocessing output for a given linear equation solver.
510 *
511 * This allows the output of the residual at the end of each solution
512 * series, using a single postprocessing writer.
513 * By default, no output is activated.
514 *
515 * \param[in, out] sles pointer to solver object
516 * \param[in] writer_id id of the writer
517 */
518/*----------------------------------------------------------------------------*/
519
520void
522 int writer_id);
523
524/*----------------------------------------------------------------------------*/
525/*
526 * \brief Return the id of the associated writer if postprocessing output
527 * is active for a given linear equation solver.
528 *
529 * \param[in] sles pointer to solver object
530 *
531 * \return id od associated writer, or 0
532 */
533/*----------------------------------------------------------------------------*/
534
535int
537
538/*----------------------------------------------------------------------------*/
539/*
540 * \brief Return type name of solver context.
541 *
542 * The returned string is intended to help determine which type is associated
543 * with the void * pointer returned by \ref cs_sles_get_context for a given
544 * solver definition, so as to be able to call additional specific functions
545 * beyond the generic functions assigned to a cs_sles_t object.
546 *
547 * If no type_name string was associated to the solver upon its definition by
548 * \ref cs_sles_define, or it has not been defined yet, the string returned
549 * is "<undefined>". It is recommended the type name provided
550 * \ref cs_sles_define directly relate to the associated structure type
551 * (for example, "cs_sles_it_t" or "cs_multigrid_t").
552 *
553 * \param[in] sles pointer to solver object
554 *
555 * \return pointer to linear system solver specific type name
556 */
557/*----------------------------------------------------------------------------*/
558
559const char *
561
562/*----------------------------------------------------------------------------*/
563/*
564 * \brief Return pointer to solver context structure pointer.
565 *
566 * The context structure depends on the type of solver used, which may in
567 * turn be determined by the string returned by cs_sles_get_type().
568 * If may be used by appropriate functions specific to that type.
569 *
570 * \param[in] sles pointer to solver object
571 *
572 * \return pointer to solver-specific linear system info and context
573 */
574/*----------------------------------------------------------------------------*/
575
576void *
578
579/*----------------------------------------------------------------------------*/
580/*
581 * \brief Return field id associated with a given sparse linear equation solver.
582 *
583 * \param[in] sles pointer to solver object
584 *
585 * \return associated field id (or -1 if defined by name)
586 */
587/*----------------------------------------------------------------------------*/
588
589int
590cs_sles_get_f_id(const cs_sles_t *sles);
591
592/*----------------------------------------------------------------------------*/
593/*
594 * \brief Return name associated with a given sparse linear equation solver.
595 *
596 * This is simply a utility function which will return its name argument
597 * if f_id < 0, and the associated field's name otherwise.
598 *
599 * \param[in] sles pointer to solver object
600 *
601 * \return pointer to associated linear system object name
602 */
603/*----------------------------------------------------------------------------*/
604
605const char *
606cs_sles_get_name(const cs_sles_t *sles);
607
608/*----------------------------------------------------------------------------*/
609/*
610 * \brief Query if immediate_return ("no-op") is allowed when initial
611 * guess is zero (solve by increments) and the RHS is already zero within the
612 * normalized tolerance criteria.
613 *
614 * \param[in] sles pointer to solver object
615 *
616 * \return true if immediate return is allowed, false if at least one
617 * iteration is required
618 */
619/*----------------------------------------------------------------------------*/
620
621bool
623
624/*----------------------------------------------------------------------------*/
625/*
626 * \brief Indicate if immediate_return ("no-op") is allowed when initial
627 * guess is zero (solve by increments) and the RHS is already zero within the
628 * normalized tolerance criteria.
629 *
630 * \param[in, out] sles pointer to solver object
631 * \param[in] allow_no_op true if immediate return is allowed,
632 * false if at least one iteration is required
633 */
634/*----------------------------------------------------------------------------*/
635
636void
638 bool allow_no_op);
639
640/*----------------------------------------------------------------------------*/
641/*
642 * \brief Setup sparse linear equation solver.
643 *
644 * Use of this function is optional: if a \ref cs_sles_solve is called
645 * for the same system before this function is called, the latter will be
646 * called automatically.
647 *
648 * If no options were previously provided for the matching system,
649 * default options will be used.
650 *
651 * \param[in, out] sles pointer to solver object
652 * \param[in] a matrix
653 */
654/*----------------------------------------------------------------------------*/
655
656void
658 const cs_matrix_t *a);
659
660/*----------------------------------------------------------------------------*/
661/*
662 * \brief General sparse linear system resolution.
663 *
664 * If no options were previously provided for the matching system,
665 * default options will be used.
666 *
667 * Note that if \ref cs_sles_setup was previously called for this
668 * system, and \ref cs_sles_free has not been called since, the matrix
669 * provided should be the same. The optional separation between the
670 * two stages is intended to allow amortizing the cost of setup
671 * over multiple solutions.
672 *
673 * If the initial solution iz zero, setting vx_ini_0 to true may
674 * allow extra optimizations with some solvers, and avoids
675 * requiring an upstream initialization.
676 *
677 * The system is considered to have converged when
678 * residual/r_norm <= precision, residual being the L2 norm of a.vx-rhs.
679 *
680 * \param[in, out] sles pointer to solver object
681 * \param[in] a matrix
682 * \param[in] precision solver precision
683 * \param[in] r_norm residual normalization
684 * \param[in] vx_ini_0 if true, initialize solution to 0
685 * \param[out] n_iter number of "equivalent" iterations
686 * \param[out] residual residual
687 * \param[in] rhs right hand side
688 * \param[in, out] vx system solution
689 * \param[in] aux_size size of aux_vectors (in bytes)
690 * \param aux_vectors optional working area
691 * (internal allocation if NULL)
692 *
693 * \return convergence state
694 */
695/*----------------------------------------------------------------------------*/
696
699 const cs_matrix_t *a,
700 double precision,
701 double r_norm,
702 bool vx_ini_0,
703 int *n_iter,
704 double *residual,
705 const cs_real_t *rhs,
706 cs_real_t *vx,
707 size_t aux_size,
708 void *aux_vectors);
709
710/*----------------------------------------------------------------------------*/
711/*
712 * \brief Free sparse linear equation solver setup.
713 *
714 * This function frees resolution-related data, such as multigrid hierarchy,
715 * preconditioning, and any other temporary arrays or objects required for
716 * resolution, but maintains context information such as that used for
717 * logging (especially performance data).
718 *
719 * \param[in, out] sles pointer to solver object
720 */
721/*----------------------------------------------------------------------------*/
722
723void
725
726/*----------------------------------------------------------------------------*/
727/*
728 * \brief Copy the definition of a sparse linear equation solver to another.
729 *
730 * The intended use of this function is to allow associating different
731 * solvers to related systems, so as to differentiate logging, while using
732 * the same settings by default.
733 *
734 * If the source solver does not provide a \ref cs_sles_copy_t function,
735 * No modification is done to the solver. If the copy function is available,
736 * the context is copied, as are the matching function pointers.
737 *
738 * If previous settings have been defined and used, they are saved as
739 * per \ref cs_sles_define.
740 *
741 * \param[in, out] dest pointer to destination solver object
742 * \param[in] src pointer to source solver object
743 *
744 * \return 0 in case of success, 1 in case of failure
745 */
746/*----------------------------------------------------------------------------*/
747
748int
750 const cs_sles_t *src);
751
752/*----------------------------------------------------------------------------*/
753/*
754 * \brief Associate a convergence error handler to a given sparse linear
755 * equation solver.
756 *
757 * The error will be called whenever convergence fails. To dissassociate
758 * the error handler, this function may be called with \p handler = NULL.
759 *
760 * The association will only be successful if the matching solver
761 * has already been defined.
762 *
763 * \param[in, out] sles pointer to solver object
764 * \param[in] error_handler_func pointer to convergence error
765 * handler function
766 */
767/*----------------------------------------------------------------------------*/
768
769void
771 cs_sles_error_handler_t *error_handler_func);
772
773/*----------------------------------------------------------------------------*/
774/*
775 * \brief Return pointer to default sparse linear solver definition function.
776 *
777 * The associated function will be used to provide a definition when
778 * \ref cs_sles_setup or \ref cs_sles_solve is used for a system for which no
779 * matching call to \ref cs_sles_define has been done.
780 *
781 * \return define_func pointer to default definition function
782 */
783/*----------------------------------------------------------------------------*/
784
787
788/*----------------------------------------------------------------------------*/
789/*
790 * \brief Set default sparse linear solver definition function.
791 *
792 * The provided function will be used to provide a definition when
793 * \ref cs_sles_setup or \ref cs_sles_solve is used for a system for which no
794 * matching call to \ref cs_sles_define has been done.
795 *
796 * \param[in] define_func pointer to default definition function
797 */
798/*----------------------------------------------------------------------------*/
799
800void
802
803/*----------------------------------------------------------------------------*/
804/*
805 * \brief Set default verbosity definition function.
806 *
807 * The provided function will be used to define the verbosity when
808 * \ref cs_sles_find_or_add is called.
809 *
810 * \param[in] verbosity_func pointer to default verbosity function
811 */
812/*----------------------------------------------------------------------------*/
813
814void
816
817/*----------------------------------------------------------------------------*/
818/*
819 * \brief Output default post-processing data for failed system convergence.
820 *
821 * \param[in] name variable name
822 * \param[in] mesh_id id of error output mesh, or 0 if none
823 * \param[in] a linear equation matrix
824 * \param[in] rhs right hand side
825 * \param[in, out] vx current system solution
826 */
827/*----------------------------------------------------------------------------*/
828
829void
830cs_sles_post_error_output_def(const char *name,
831 int mesh_id,
832 const cs_matrix_t *a,
833 const cs_real_t *rhs,
834 cs_real_t *vx);
835
836/*----------------------------------------------------------------------------*/
837/*
838 * \brief Output post-processing variable related to system convergence.
839 *
840 * \param[in] name variable name
841 * \param[in] mesh_id id of error output mesh, or 0 if none
842 * \param[in] location_id mesh location id (cells or vertices)
843 * \param[in] writer_id id of specified associated writer, or
844 * \ref CS_POST_WRITER_ALL_ASSOCIATED for all
845 * \param[in] diag_block_size block size for diagonal
846 * \param[in, out] var variable values
847 */
848/*----------------------------------------------------------------------------*/
849
850void
851cs_sles_post_output_var(const char *name,
852 int mesh_id,
853 int location_id,
854 int writer_id,
855 int diag_block_size,
856 cs_real_t var[]);
857
858/*----------------------------------------------------------------------------*/
859/*
860 * \brief Return base name associated to a field id, name couple.
861 *
862 * This is simply a utility function which will return its name argument
863 * if f_id < 0, and the associated field's name otherwise.
864 *
865 * \param[in] f_id associated field id, or < 0
866 * \param[in] name associated name if f_id < 0, or NULL
867 *
868 * \return pointer to associated linear system object, or NULL
869 */
870/*----------------------------------------------------------------------------*/
871
872const char *
873cs_sles_base_name(int f_id,
874 const char *name);
875
876/*----------------------------------------------------------------------------*/
877/*
878 * \brief Return name associated to a field id, name couple.
879 *
880 * \param[in] f_id associated field id, or < 0
881 * \param[in] name associated name if f_id < 0, or NULL
882 *
883 * \return pointer to name associated to the field id, name couple
884 */
885/*----------------------------------------------------------------------------*/
886
887const char *
888cs_sles_name(int f_id,
889 const char *name);
890
891/*----------------------------------------------------------------------------*/
892
894
895#endif /* CS_SLES_H */
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
#define END_C_DECLS
Definition: cs_defs.h:529
cs_log_t
Definition: cs_log.h:44
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:108
void() cs_sles_destroy_t(void **context)
Definition: cs_sles.h:213
cs_sles_convergence_state_t cs_sles_solve(cs_sles_t *sles, const cs_matrix_t *a, double precision, double r_norm, bool vx_ini_0, int *n_iter, double *residual, const cs_real_t *rhs, cs_real_t *vx, size_t aux_size, void *aux_vectors)
General sparse linear system resolution.
Definition: cs_sles.cpp:1726
void * cs_sles_get_context(cs_sles_t *sles)
Return pointer to solver context structure pointer.
Definition: cs_sles.cpp:1557
void cs_sles_set_default_define(cs_sles_define_t *define_func)
Set default sparse linear solver definition function.
Definition: cs_sles.cpp:2002
cs_sles_convergence_state_t
Definition: cs_sles.h:57
@ CS_SLES_ITERATING
Definition: cs_sles.h:65
@ CS_SLES_MAX_ITERATION
Definition: cs_sles.h:62
@ CS_SLES_DIVERGED
Definition: cs_sles.h:59
@ CS_SLES_CONVERGED
Definition: cs_sles.h:66
@ CS_SLES_BREAKDOWN
Definition: cs_sles.h:60
void() cs_sles_log_t(const void *context, cs_log_t log_type)
Function pointer for logging of linear solver history and performance data.
Definition: cs_sles.h:178
int cs_sles_copy(cs_sles_t *dest, const cs_sles_t *src)
Copy the definition of a sparse linear equation solver to another.
Definition: cs_sles.cpp:1907
void cs_sles_setup(cs_sles_t *sles, const cs_matrix_t *a)
Setup sparse linear equation solver.
Definition: cs_sles.cpp:1652
void cs_sles_log(cs_log_t log_type)
Log sparse linear equation solver info.
Definition: cs_sles.cpp:1021
double cs_sles_get_epzero(void)
Get the current threshold value used in the detection of immediate exit.
Definition: cs_sles.cpp:949
void cs_sles_post_output_var(const char *name, int mesh_id, int location_id, int writer_id, int diag_block_size, cs_real_t var[])
Output post-processing variable related to system convergence.
Definition: cs_sles.cpp:2150
void *() cs_sles_copy_t(const void *context)
Function pointer for creation of a solver context based on the copy of another.
Definition: cs_sles.h:200
const char * cs_sles_get_name(const cs_sles_t *sles)
Return name associated with a given sparse linear equation solver.
Definition: cs_sles.cpp:1592
int cs_sles_get_verbosity(cs_sles_t *sles)
Get the verbosity for a given linear equation solver.
Definition: cs_sles.cpp:1458
int() cs_sles_verbosity_t(int f_id, const char *name)
Function pointer for the default definition of a sparse linear equation solver's verbosity.
Definition: cs_sles.h:289
void() cs_sles_setup_t(void *context, const char *name, const cs_matrix_t *a, int verbosity)
Function pointer for pre-resolution setup of a linear system's context.
Definition: cs_sles.h:92
void cs_sles_pop(int f_id)
Restore behavior temporarily modified by cs_sles_push.
Definition: cs_sles.cpp:1333
cs_sles_t * cs_sles_define(int f_id, const char *name, void *context, const char *type_name, cs_sles_setup_t *setup_func, cs_sles_solve_t *solve_func, cs_sles_free_t *free_func, cs_sles_log_t *log_func, cs_sles_copy_t *copy_func, cs_sles_destroy_t *destroy_func)
Define sparse linear equation solver for a given field or equation name.
Definition: cs_sles.cpp:1385
void cs_sles_push(int f_id, const char *name)
Temporarily replace field id with name for matching calls to cs_sles_setup, cs_sles_solve,...
Definition: cs_sles.cpp:1297
void cs_sles_free(cs_sles_t *sles)
Free sparse linear equation solver setup.
Definition: cs_sles.cpp:1876
const char * cs_sles_name(int f_id, const char *name)
Return name associated to a field id, name couple.
Definition: cs_sles.cpp:2291
int cs_sles_get_post_output(cs_sles_t *sles)
Return the id of the associated writer if postprocessing output is active for a given linear equation...
Definition: cs_sles.cpp:1505
cs_sles_convergence_state_t() cs_sles_solve_t(void *context, const char *name, const cs_matrix_t *a, int verbosity, double precision, double r_norm, int *n_iter, double *residual, const cs_real_t *rhs, cs_real_t *vx_ini, cs_real_t *vx, size_t aux_size, void *aux_vectors)
Function pointer for resolution of a linear system.
Definition: cs_sles.h:135
cs_sles_define_t * cs_sles_get_default_define(void)
Return pointer to default sparse linear solver definition function.
Definition: cs_sles.cpp:1984
void cs_sles_set_verbosity(cs_sles_t *sles, int verbosity)
Set the verbosity for a given linear equation solver.
Definition: cs_sles.cpp:1439
const char * cs_sles_base_name(int f_id, const char *name)
Return base name associated to a field id, name couple.
Definition: cs_sles.cpp:2266
bool cs_sles_get_allow_no_op(const cs_sles_t *sles)
Query if immediate_return ("no-op") is allowed when initial guess is zero (solve by increments) and t...
Definition: cs_sles.cpp:1611
cs_sles_t * cs_sles_find_or_add(int f_id, const char *name)
Return pointer to linear system object, based on matching field id or system name.
Definition: cs_sles.cpp:1262
void cs_sles_set_epzero(double new_value)
Set the threshold value used in the detection of immediate exit.
Definition: cs_sles.cpp:934
cs_sles_t * cs_sles_find(int f_id, const char *name)
Return pointer to linear system object, based on matching field id or system name.
Definition: cs_sles.cpp:1197
int cs_sles_get_f_id(const cs_sles_t *sles)
Return field id associated with a given sparse linear equation solver.
Definition: cs_sles.cpp:1573
void cs_sles_finalize(void)
Finalize sparse linear equation solver API.
Definition: cs_sles.cpp:981
void cs_sles_post_error_output_def(const char *name, int mesh_id, const cs_matrix_t *a, const cs_real_t *rhs, cs_real_t *vx)
Output default post-processing data for failed system convergence.
Definition: cs_sles.cpp:2037
const char * cs_sles_get_type(cs_sles_t *sles)
Return type name of solver context.
Definition: cs_sles.cpp:1537
void() cs_sles_free_t(void *context)
Function pointer for freeing of a linear system's context data.
Definition: cs_sles.h:163
void cs_sles_set_default_verbosity(cs_sles_verbosity_t *verbosity_func)
Set default verbosity definition function.
Definition: cs_sles.cpp:2019
void cs_sles_set_error_handler(cs_sles_t *sles, cs_sles_error_handler_t *error_handler_func)
Associate a convergence error handler to a given sparse linear equation solver.
Definition: cs_sles.cpp:1964
bool() cs_sles_error_handler_t(cs_sles_t *sles, cs_sles_convergence_state_t state, const cs_matrix_t *a, const cs_real_t *rhs, cs_real_t *vx)
Function pointer for handling of non-convergence when solving a linear system.
Definition: cs_sles.h:239
struct _cs_sles_t cs_sles_t
Definition: cs_sles.h:72
void cs_sles_initialize(void)
Initialize sparse linear equation solver API.
Definition: cs_sles.cpp:961
void cs_sles_set_post_output(cs_sles_t *sles, int writer_id)
Activate postprocessing output for a given linear equation solver.
Definition: cs_sles.cpp:1477
void() cs_sles_define_t(int f_id, const char *name, const cs_matrix_t *a)
Function pointer for the default definition of a sparse linear equation solver.
Definition: cs_sles.h:268
void cs_sles_set_allow_no_op(cs_sles_t *sles, bool allow_no_op)
Indicate if immediate_return ("no-op") is allowed when initial guess is zero (solve by increments) an...
Definition: cs_sles.cpp:1629