9.2
general documentation
cs_dbg.h
Go to the documentation of this file.
1#ifndef CS_DBG_H
2#define CS_DBG_H
3
4/*============================================================================
5 * General functions or variables for the INNOV module
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 * Local headers
30 *----------------------------------------------------------------------------*/
31
32#include "alge/cs_matrix.h"
33#include "base/cs_base.h"
34#include "base/cs_defs.h"
35#include "base/cs_math.h"
36#include "cdo/cs_cdo_bc.h"
37#include "cdo/cs_cdo_local.h"
39
40/*============================================================================
41 * Macro definitions
42 *============================================================================*/
43
44/*============================================================================
45 * Type definitions
46 *============================================================================*/
47
48/*============================================================================
49 * Global variables
50 *============================================================================*/
51
52/*============================================================================
53 * Static inline function prototypes
54 *============================================================================*/
55
56/*----------------------------------------------------------------------------*/
63/*----------------------------------------------------------------------------*/
64
65static inline void
67 const cs_cell_sys_t *csys)
68{
69 for (short int i = 0; i < csys->n_dofs; i++) {
70 if (csys->dof_flag[i] & CS_CDO_BC_HMG_DIRICHLET)
71 if (cs::abs(csys->dir_values[i]) > 100. * cs_dbl_min)
72 bft_error(__FILE__, __LINE__, 0,
73 " %s: Invalid value for a homogeneous Dirichlet condition",
74 fname);
75 }
76}
77
78/*============================================================================
79 * Public function prototypes
80 *============================================================================*/
81
82/*----------------------------------------------------------------------------*/
91/*----------------------------------------------------------------------------*/
92
93bool
95 const cs_cell_mesh_t *cm,
96 const cs_cell_sys_t *csys);
97
98/*----------------------------------------------------------------------------*/
113/*----------------------------------------------------------------------------*/
114
115void
116cs_dbg_array_fprintf(FILE *fp,
117 const char *fname,
118 cs_real_t thd,
119 cs_lnum_t n_elts,
120 const cs_real_t array[],
121 int n_cols);
122
123/*----------------------------------------------------------------------------*/
135/*----------------------------------------------------------------------------*/
136
137void
138cs_dbg_fprintf_system(const char *eqname,
139 int id,
140 int level,
141 const cs_real_t *sol,
142 const cs_real_t *rhs,
143 cs_lnum_t size);
144
145/*----------------------------------------------------------------------------*/
154/*----------------------------------------------------------------------------*/
155
156void
157cs_dbg_darray_to_listing(const char *header,
158 const cs_lnum_t size,
159 const cs_real_t array[],
160 int n_cols);
161
162/*----------------------------------------------------------------------------*/
171/*----------------------------------------------------------------------------*/
172
173void
174cs_dbg_iarray_to_listing(const char *header,
175 const cs_lnum_t size,
176 const cs_lnum_t array[],
177 int n_cols);
178
179/*----------------------------------------------------------------------------*/
186/*----------------------------------------------------------------------------*/
187
188void
190 const cs_matrix_t *matrix);
191
192/*----------------------------------------------------------------------------*/
199/*----------------------------------------------------------------------------*/
200
201void
203 const cs_matrix_t *matrix);
204
205/*----------------------------------------------------------------------------*/
220/*----------------------------------------------------------------------------*/
221
222void
223cs_dbg_dump_msr_system(const char *eqname,
224 cs_lnum_t size,
225 int verbosity,
226 const cs_real_t x[],
227 const cs_real_t b[],
228 const cs_lnum_t row_index[],
229 const cs_lnum_t col_id[],
230 const cs_real_t xval[],
231 const cs_real_t dval[]);
232
233/*----------------------------------------------------------------------------*/
243/*----------------------------------------------------------------------------*/
244
245void
246cs_dbg_binary_dump_system(const char *basename,
247 const cs_matrix_t *matrix,
248 const cs_real_t *rhs,
249 const cs_real_t *sol);
250
251#endif /* CS_DBG_H */
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:187
void cs_dbg_dump_msr_system(const char *eqname, cs_lnum_t size, int verbosity, const cs_real_t x[], const cs_real_t b[], const cs_lnum_t row_index[], const cs_lnum_t col_id[], const cs_real_t xval[], const cs_real_t dval[])
In debug mode, dump a linear system stored in a MSR format into the listing file (should be a small s...
Definition: cs_dbg.cpp:387
void cs_dbg_dump_local_scalar_msr_matrix(const char *name, const cs_matrix_t *matrix)
In debug mode, dump a linear system. Case of scalar-valued entries.
Definition: cs_dbg.cpp:305
static void cs_dbg_check_hmg_dirichlet_cw(const char *fname, const cs_cell_sys_t *csys)
Check if there is no invalid setting for a homogeneous Dirichlet.
Definition: cs_dbg.h:66
void cs_dbg_array_fprintf(FILE *fp, const char *fname, cs_real_t thd, cs_lnum_t n_elts, const cs_real_t array[], int n_cols)
Print an array. Print into the file f if given otherwise open a new file named fname if given otherwi...
Definition: cs_dbg.cpp:138
void cs_dbg_print_local_scalar_msr_matrix(const char *name, const cs_matrix_t *matrix)
Print a linear system. Case of scalar-valued entries.
Definition: cs_dbg.cpp:342
void cs_dbg_iarray_to_listing(const char *header, const cs_lnum_t size, const cs_lnum_t array[], int n_cols)
In debug mode, dump an array of integer into the log.
Definition: cs_dbg.cpp:271
void cs_dbg_darray_to_listing(const char *header, const cs_lnum_t size, const cs_real_t array[], int n_cols)
In debug mode, dump an array of double into the log.
Definition: cs_dbg.cpp:235
bool cs_dbg_cw_test(const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, const cs_cell_sys_t *csys)
Function used to select which element deserves a dump or specific treatment during a debugging stage.
Definition: cs_dbg.cpp:76
void cs_dbg_fprintf_system(const char *eqname, int id, int level, const cs_real_t *sol, const cs_real_t *rhs, cs_lnum_t size)
In debug mode, print into a file the solution and its right-hand side.
Definition: cs_dbg.cpp:200
void cs_dbg_binary_dump_system(const char *basename, const cs_matrix_t *matrix, const cs_real_t *rhs, const cs_real_t *sol)
Binary dump (matrix, rhs and solution) of a matrix, its right-hand side and the solution array.
Definition: cs_dbg.cpp:484
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
static constexpr double cs_dbl_min
Definition: cs_math.h:96
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:108
#define CS_CDO_BC_HMG_DIRICHLET
Definition: cs_cdo_bc.h:73
CS_F_HOST_DEVICE T abs(const T a)
Definition: cs_defs.h:690
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:242
Set of arrays and local (small) dense matrices related to a mesh cell This is a key structure for bui...
Definition: cs_cdo_local.h:163
double * dir_values
Definition: cs_cdo_local.h:188
cs_flag_t * dof_flag
Definition: cs_cdo_local.h:169
int n_dofs
Definition: cs_cdo_local.h:167
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190