1
/*============================================================================
3
* This file is part of the Code_Saturne Kernel, element of the
4
* Code_Saturne CFD tool.
6
* Copyright (C) 1998-2009 EDF S.A., France
8
* contact: saturne-support@edf.fr
10
* The Code_Saturne Kernel is free software; you can redistribute it
11
* and/or modify it under the terms of the GNU General Public License
12
* as published by the Free Software Foundation; either version 2 of
13
* the License, or (at your option) any later version.
15
* The Code_Saturne Kernel is distributed in the hope that it will be
16
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with the Code_Saturne Kernel; if not, write to the
22
* Free Software Foundation, Inc.,
23
* 51 Franklin St, Fifth Floor,
24
* Boston, MA 02110-1301 USA
26
*============================================================================*/
31
/*============================================================================
32
* Grid connectivity and data used for multgrid coarsening
33
* and associated matrix construction.
34
*============================================================================*/
36
/*----------------------------------------------------------------------------
38
*----------------------------------------------------------------------------*/
42
/*----------------------------------------------------------------------------
44
*----------------------------------------------------------------------------*/
49
#include "cs_matrix.h"
51
/*----------------------------------------------------------------------------*/
55
/*============================================================================
57
*============================================================================*/
59
/*============================================================================
61
*============================================================================*/
63
/* Structure associated with opaque grid object */
65
typedef struct _cs_grid_t cs_grid_t;
67
/*============================================================================
69
*============================================================================*/
71
/*=============================================================================
72
* Public function prototypes
73
*============================================================================*/
75
/*----------------------------------------------------------------------------
76
* Create base grid by mapping from shared mesh values.
78
* Note that as arrays given as arguments are shared by the created grid
79
* (which can only access them, not modify them), the grid should be
80
* destroyed before those arrays.
83
* n_cells <-- Local number of cells
84
* n_cells_ext <-- Local number of cells + ghost cells
85
* n_faces <-- Local number of faces
86
* symmetric <-- True if xam is symmetric, false otherwise
87
* face_cell <-- Face -> cells connectivity (1 to n)
88
* halo <-- Halo structure associated with this level, or NULL.
89
* numbering <-- vectorization or thread-related numbering info, or NULL
90
* cell_cen <-- Cell center (size: 3.n_cells_ext)
91
* cell_vol <-- Cell volume (size: n_cells_ext)
92
* face_normal <-- Internal face normals (size: 3.n_faces)
93
* da <-- Matrix diagonal (size: n_cell_ext)
94
* xa <-- Matrix extra-diagonal terms
95
* (size: n_faces if symmetric, 2.n_faces otherwise)
99
*----------------------------------------------------------------------------*/
102
cs_grid_create_from_shared(fvm_lnum_t n_cells,
103
fvm_lnum_t n_cells_ext,
106
const fvm_lnum_t *face_cell,
107
const cs_halo_t *halo,
108
const cs_numbering_t *numbering,
109
const cs_real_t *cell_cen,
110
const cs_real_t *cell_vol,
111
const cs_real_t *face_normal,
113
const cs_real_t *xa);
115
/*----------------------------------------------------------------------------
116
* Destroy a grid structure.
119
* grid <-> Pointer to grid structure pointer
120
*----------------------------------------------------------------------------*/
123
cs_grid_destroy(cs_grid_t **grid);
125
/*----------------------------------------------------------------------------
126
* Get grid information.
129
* g <-- Grid structure
130
* level --> Level in multigrid hierarchy (or NULL)
131
* symmetric --> Symmetric matrix coefficients indicator (or NULL)
132
* n_cells_ext --> Number of local cells (or NULL)
133
* n_cells_ext --> Number of cells including ghosts (or NULL)
134
* n_cells_ext --> Number of faces (or NULL)
135
* n_g_cells --> Number of global cells (or NULL)
136
*----------------------------------------------------------------------------*/
139
cs_grid_get_info(const cs_grid_t *g,
141
cs_bool_t *symmetric,
143
fvm_lnum_t *n_cells_ext,
145
fvm_gnum_t *n_g_cells);
147
/*----------------------------------------------------------------------------
148
* Get number of cells corresponding to a grid.
151
* g <-- Grid structure
154
* number of cells of grid structure
155
*----------------------------------------------------------------------------*/
158
cs_grid_get_n_cells(const cs_grid_t *g);
160
/*----------------------------------------------------------------------------
161
* Get number of extended (local + ghost) cells corresponding to a grid.
164
* g <-- Grid structure
167
* number of extended cells of grid structure
168
*----------------------------------------------------------------------------*/
171
cs_grid_get_n_cells_ext(const cs_grid_t *g);
173
/*----------------------------------------------------------------------------
174
* Get global number of cells corresponding to a grid.
177
* g <-- Grid structure
180
* global number of cells of grid structure
181
*----------------------------------------------------------------------------*/
184
cs_grid_get_n_g_cells(const cs_grid_t *g);
186
/*----------------------------------------------------------------------------
187
* Get grid's associated matrix information.
190
* g <-- Grid structure
191
* da --> Diagonal matrix coefficients
192
* xa --> Non-diagonal matrix coefficients
193
* m --> Associated matrix structure
194
*----------------------------------------------------------------------------*/
197
cs_grid_get_matrix(const cs_grid_t *g,
198
const cs_real_t **da,
199
const cs_real_t **xa,
202
/*----------------------------------------------------------------------------
203
* Create coarse grid from fine grid.
206
* f <-- Fine grid structure
207
* verbosity <-- Verbosity level
208
* agglomeration_limit <-- Maximum allowed fine cells per coarse cell
209
* max_agglomeration <-> Maximum fine cells per coarse cell
212
* coarse grid structure
213
*----------------------------------------------------------------------------*/
216
cs_grid_coarsen(const cs_grid_t *f,
218
int agglomeration_limit,
219
int *max_agglomeration);
221
/*----------------------------------------------------------------------------
222
* Compute coarse cell variable values from fine cell values
225
* f <-- Fine grid structure
226
* c <-- Fine grid structure
227
* f_var <-- Variable defined on fine grid cells
228
* c_var --> Variable defined on coarse grid cells
231
* coarse grid structure
232
*----------------------------------------------------------------------------*/
235
cs_grid_restrict_cell_var(const cs_grid_t *f,
237
const cs_real_t *f_var,
240
/*----------------------------------------------------------------------------
241
* Compute fine cell variable values from coarse cell values
244
* c <-- Fine grid structure
245
* f <-- Fine grid structure
246
* c_var --> Variable defined on coarse grid cells
247
* f_var <-- Variable defined on fine grid cells
250
* coarse grid structure
251
*----------------------------------------------------------------------------*/
254
cs_grid_prolong_cell_var(const cs_grid_t *c,
256
const cs_real_t *c_var,
259
/*----------------------------------------------------------------------------
260
* Project coarse grid cell numbers to base grid.
262
* If a global coarse grid cell number is larger than max_num, its
263
* value modulo max_num is used.
266
* g <-- Grid structure
267
* n_base_cells <-- Number of cells in base grid
268
* max_num <-- Values of c_cell_num = global_num % max_num
269
* c_cell_num --> Global coarse cell number (modulo max_num)
270
*----------------------------------------------------------------------------*/
273
cs_grid_project_cell_num(const cs_grid_t *g,
274
fvm_lnum_t n_base_cells,
278
/*----------------------------------------------------------------------------
279
* Project variable from coarse grid to base grid
282
* g <-- Grid structure
283
* n_base_cells <-- Number of cells in base grid
284
* c_var <-- Cell variable on coarse grid
285
* f_var --> Cell variable projected to fine grid
286
*----------------------------------------------------------------------------*/
289
cs_grid_project_var(const cs_grid_t *g,
290
fvm_lnum_t n_base_cells,
291
const cs_real_t c_var[],
294
/*----------------------------------------------------------------------------
295
* Compute diagonal dominance metric and project it to base grid
298
* g <-- Grid structure
299
* n_base_cells <-- Number of cells in base grid
300
* diag_dom --> Diagonal dominance metric (on fine grid)
301
*----------------------------------------------------------------------------*/
304
cs_grid_project_diag_dom(const cs_grid_t *g,
305
fvm_lnum_t n_base_cells,
306
cs_real_t diag_dom[]);
308
/*----------------------------------------------------------------------------*/
312
#endif /* __CS_GRID_H__ */