9.2
general documentation
cs_multigrid_smoother.h
Go to the documentation of this file.
1#ifndef CS_MULTIGRID_SMOOTHER_H
2#define CS_MULTIGRID_SMOOTHER_H
3
4/*============================================================================
5 * Sparse Linear Equation Solvers
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_halo_perio.h"
36#include "alge/cs_matrix.h"
37#include "alge/cs_sles.h"
38#include "alge/cs_sles_it.h"
39
40/*============================================================================
41 * Macro definitions
42 *============================================================================*/
43
44/*============================================================================
45 * Type definitions
46 *============================================================================*/
47
48/* Iterative linear solver context (opaque) */
49
50typedef struct _cs_multigrid_smoother_t cs_multigrid_smoother_t;
51
52/*============================================================================
53 * Global variables
54 *============================================================================*/
55
56/*=============================================================================
57 * Public function prototypes
58 *============================================================================*/
59
60/*----------------------------------------------------------------------------*/
61/*
62 * \brief Create iterative sparse linear system solver info and context used as
63 * a smoother in a multigrid solver
64 *
65 * parameters:
66 * \param[in] smoother_type type of smoother (CG, Jacobi, ...)
67 * \param[in] poly_degree preconditioning polynomial degree
68 * (0: diagonal; -1: non-preconditioned;
69 * see \ref sles_it for details)
70 * \param[in] n_iter number of iterations to perform
71 *
72 * \return a pointer to newly created smoother info object, or NULL
73 * if not available for this solver type.
74 */
75/*----------------------------------------------------------------------------*/
76
77extern "C" cs_sles_it_t *
79 int poly_degree,
80 int n_iter);
81
82/*----------------------------------------------------------------------------*/
83/*
84 * \brief Destroy iterative sparse linear system solver info and context used
85 * as a smoother in a multigrid solver
86 *
87 * \param[in, out] context pointer to iterative sparse linear solver info
88 * (actual type: cs_sles_it_t **)
89 */
90/*----------------------------------------------------------------------------*/
91
92extern "C" void
94
95/*----------------------------------------------------------------------------
96 * Setup iterative sparse linear equation solver.
97 *
98 * parameters:
99 * context <-> pointer to iterative sparse linear solver info
100 * (actual type: cs_multigrid_smoother_t *)
101 * name <-- pointer to system name
102 * a <-- associated matrix
103 * verbosity <-- verbosity level
104 *----------------------------------------------------------------------------*/
105
106extern "C" void
107cs_multigrid_smoother_setup(void *context,
108 const char *name,
109 const cs_matrix_t *a,
110 int verbosity);
111
112/*----------------------------------------------------------------------------
113 * Call iterative sparse linear equation solver.
114 *
115 * parameters:
116 * context <-> pointer to iterative sparse linear solver info
117 * (actual type: cs_multigrid_smoother_t *)
118 * name <-- pointer to system name
119 * a <-- matrix
120 * verbosity <-- verbosity level
121 * precision <-- solver precision
122 * r_norm <-- residual normalization
123 * n_iter --> number of iterations
124 * residual --> residual
125 * rhs <-- right hand side
126 * vx_ini <-- initial solution (vx if nonzero, nullptr if zero)
127 * vx <-> system solution
128 * aux_size <-- number of elements in aux_vectors (in bytes)
129 * aux_vectors --- optional working area (internal allocation if NULL)
130 *
131 * returns:
132 * convergence state
133 *----------------------------------------------------------------------------*/
134
136cs_multigrid_smoother_solve(void *context,
137 const char *name,
138 const cs_matrix_t *a,
139 int verbosity,
140 double precision,
141 double r_norm,
142 int *n_iter,
143 double *residual,
144 const cs_real_t *rhs,
145 cs_real_t *vx_ini,
146 cs_real_t *vx,
147 size_t aux_size,
148 void *aux_vectors);
149
150/*----------------------------------------------------------------------------
151 * Free iterative sparse linear equation solver setup context.
152 *
153 * This function frees resolution-related data, such as
154 * buffers and preconditioning but does not free the whole context,
155 * as info used for logging (especially performance data) is maintained.
156
157 * parameters:
158 * context <-> pointer to iterative sparse linear solver info
159 * (actual type: cs_multigrid_smoother_t *)
160 *----------------------------------------------------------------------------*/
161
162extern "C" void
164
165/*----------------------------------------------------------------------------
166 * Log sparse linear equation solver info.
167 *
168 * parameters:
169 * context <-> pointer to iterative sparse linear solver info
170 * (actual type: cs_multigrid_smoother_t *)
171 * log_type <-- log type
172 *----------------------------------------------------------------------------*/
173
174extern "C" void
175cs_multigrid_smoother_log(const void *context,
176 cs_log_t log_type);
177
178/*----------------------------------------------------------------------------
179 * Return iterative solver type.
180 *
181 * parameters:
182 * context <-- pointer to iterative solver info and context
183 *
184 * returns:
185 * selected solver type
186 *----------------------------------------------------------------------------*/
187
188extern "C" cs_sles_it_type_t
190
191/*----------------------------------------------------------------------------*/
192
193#endif /* CS_MULTIGRID_SMOOTHER_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_log_t
Definition: cs_log.h:44
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:108
cs_sles_it_t * cs_multigrid_smoother_create(cs_sles_it_type_t smoother_type, int poly_degree, int n_iter)
Create iterative sparse linear system solver info and context used as a smoother in a multigrid solve...
Definition: cs_multigrid_smoother.cpp:1726
struct _cs_multigrid_smoother_t cs_multigrid_smoother_t
Definition: cs_multigrid_smoother.h:50
cs_sles_it_type_t cs_multigrid_smoother_get_type(const cs_multigrid_smoother_t *context)
void cs_multigrid_smoother_free(void *context)
void cs_multigrid_smoother_destroy(void **context)
void cs_multigrid_smoother_setup(void *context, const char *name, const cs_matrix_t *a, int verbosity)
Setup iterative sparse linear equation solver in case of used as a multigrid smoother.
Definition: cs_multigrid_smoother.cpp:1825
cs_sles_convergence_state_t cs_multigrid_smoother_solve(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)
Call iterative sparse linear equation solver.
Definition: cs_multigrid_smoother.cpp:2008
void cs_multigrid_smoother_log(const void *context, cs_log_t log_type)
cs_sles_convergence_state_t
Definition: cs_sles.h:57
struct _cs_sles_it_t cs_sles_it_t
Definition: cs_sles_it.h:95
cs_sles_it_type_t
Definition: cs_sles_it.h:55