~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to include/base/cs_grid.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*============================================================================
2
 
 *
3
 
 *     This file is part of the Code_Saturne Kernel, element of the
4
 
 *     Code_Saturne CFD tool.
5
 
 *
6
 
 *     Copyright (C) 1998-2009 EDF S.A., France
7
 
 *
8
 
 *     contact: saturne-support@edf.fr
9
 
 *
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.
14
 
 *
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.
19
 
 *
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
25
 
 *
26
 
 *============================================================================*/
27
 
 
28
 
#ifndef __CS_GRID_H__
29
 
#define __CS_GRID_H__
30
 
 
31
 
/*============================================================================
32
 
 * Grid connectivity and data used for multgrid coarsening
33
 
 * and associated matrix construction.
34
 
 *============================================================================*/
35
 
 
36
 
/*----------------------------------------------------------------------------
37
 
 * FVM library headers
38
 
 *----------------------------------------------------------------------------*/
39
 
 
40
 
#include <fvm_defs.h>
41
 
 
42
 
/*----------------------------------------------------------------------------
43
 
 * Local headers
44
 
 *----------------------------------------------------------------------------*/
45
 
 
46
 
#include "cs_base.h"
47
 
 
48
 
#include "cs_halo.h"
49
 
#include "cs_matrix.h"
50
 
 
51
 
/*----------------------------------------------------------------------------*/
52
 
 
53
 
BEGIN_C_DECLS
54
 
 
55
 
/*============================================================================
56
 
 * Macro definitions
57
 
 *============================================================================*/
58
 
 
59
 
/*============================================================================
60
 
 * Type definitions
61
 
 *============================================================================*/
62
 
 
63
 
/* Structure associated with opaque grid object */
64
 
 
65
 
typedef struct _cs_grid_t cs_grid_t;
66
 
 
67
 
/*============================================================================
68
 
 *  Global variables
69
 
 *============================================================================*/
70
 
 
71
 
/*=============================================================================
72
 
 * Public function prototypes
73
 
 *============================================================================*/
74
 
 
75
 
/*----------------------------------------------------------------------------
76
 
 * Create base grid by mapping from shared mesh values.
77
 
 *
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.
81
 
 *
82
 
 * parameters:
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)
96
 
 *
97
 
 * returns:
98
 
 *   base grid structure
99
 
 *----------------------------------------------------------------------------*/
100
 
 
101
 
cs_grid_t *
102
 
cs_grid_create_from_shared(fvm_lnum_t             n_cells,
103
 
                           fvm_lnum_t             n_cells_ext,
104
 
                           fvm_lnum_t             n_faces,
105
 
                           cs_bool_t              symmetric,
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,
112
 
                           const cs_real_t       *da,
113
 
                           const cs_real_t       *xa);
114
 
 
115
 
/*----------------------------------------------------------------------------
116
 
 * Destroy a grid structure.
117
 
 *
118
 
 * parameters:
119
 
 *   grid <-> Pointer to grid structure pointer
120
 
 *----------------------------------------------------------------------------*/
121
 
 
122
 
void
123
 
cs_grid_destroy(cs_grid_t **grid);
124
 
 
125
 
/*----------------------------------------------------------------------------
126
 
 * Get grid information.
127
 
 *
128
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
137
 
 
138
 
void
139
 
cs_grid_get_info(const cs_grid_t  *g,
140
 
                 int              *level,
141
 
                 cs_bool_t        *symmetric,
142
 
                 fvm_lnum_t       *n_cells,
143
 
                 fvm_lnum_t       *n_cells_ext,
144
 
                 fvm_lnum_t       *n_faces,
145
 
                 fvm_gnum_t       *n_g_cells);
146
 
 
147
 
/*----------------------------------------------------------------------------
148
 
 * Get number of cells corresponding to a grid.
149
 
 *
150
 
 * parameters:
151
 
 *   g <-- Grid structure
152
 
 *
153
 
 * returns:
154
 
 *   number of cells of grid structure
155
 
 *----------------------------------------------------------------------------*/
156
 
 
157
 
fvm_lnum_t
158
 
cs_grid_get_n_cells(const cs_grid_t  *g);
159
 
 
160
 
/*----------------------------------------------------------------------------
161
 
 * Get number of extended (local + ghost) cells corresponding to a grid.
162
 
 *
163
 
 * parameters:
164
 
 *   g <-- Grid structure
165
 
 *
166
 
 * returns:
167
 
 *   number of extended cells of grid structure
168
 
 *----------------------------------------------------------------------------*/
169
 
 
170
 
fvm_lnum_t
171
 
cs_grid_get_n_cells_ext(const cs_grid_t  *g);
172
 
 
173
 
/*----------------------------------------------------------------------------
174
 
 * Get global number of cells corresponding to a grid.
175
 
 *
176
 
 * parameters:
177
 
 *   g <-- Grid structure
178
 
 *
179
 
 * returns:
180
 
 *   global number of cells of grid structure
181
 
 *----------------------------------------------------------------------------*/
182
 
 
183
 
fvm_gnum_t
184
 
cs_grid_get_n_g_cells(const cs_grid_t  *g);
185
 
 
186
 
/*----------------------------------------------------------------------------
187
 
 * Get grid's associated matrix information.
188
 
 *
189
 
 * parameters:
190
 
 *   g           <-- Grid structure
191
 
 *   da          --> Diagonal matrix coefficients
192
 
 *   xa          --> Non-diagonal matrix coefficients
193
 
 *   m           --> Associated matrix structure
194
 
 *----------------------------------------------------------------------------*/
195
 
 
196
 
void
197
 
cs_grid_get_matrix(const cs_grid_t  *g,
198
 
                   const cs_real_t  **da,
199
 
                   const cs_real_t  **xa,
200
 
                   cs_matrix_t      **m);
201
 
 
202
 
/*----------------------------------------------------------------------------
203
 
 * Create coarse grid from fine grid.
204
 
 *
205
 
 * parameters:
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
210
 
 *
211
 
 * returns:
212
 
 *   coarse grid structure
213
 
 *----------------------------------------------------------------------------*/
214
 
 
215
 
cs_grid_t *
216
 
cs_grid_coarsen(const cs_grid_t  *f,
217
 
                int               verbosity,
218
 
                int               agglomeration_limit,
219
 
                int              *max_agglomeration);
220
 
 
221
 
/*----------------------------------------------------------------------------
222
 
 * Compute coarse cell variable values from fine cell values
223
 
 *
224
 
 * parameters:
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
229
 
 *
230
 
 * returns:
231
 
 *   coarse grid structure
232
 
 *----------------------------------------------------------------------------*/
233
 
 
234
 
void
235
 
cs_grid_restrict_cell_var(const cs_grid_t  *f,
236
 
                          const cs_grid_t  *c,
237
 
                          const cs_real_t  *f_var,
238
 
                          cs_real_t        *c_var);
239
 
 
240
 
/*----------------------------------------------------------------------------
241
 
 * Compute fine cell variable values from coarse cell values
242
 
 *
243
 
 * parameters:
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
248
 
 *
249
 
 * returns:
250
 
 *   coarse grid structure
251
 
 *----------------------------------------------------------------------------*/
252
 
 
253
 
void
254
 
cs_grid_prolong_cell_var(const cs_grid_t  *c,
255
 
                         const cs_grid_t  *f,
256
 
                         const cs_real_t  *c_var,
257
 
                         cs_real_t        *f_var);
258
 
 
259
 
/*----------------------------------------------------------------------------
260
 
 * Project coarse grid cell numbers to base grid.
261
 
 *
262
 
 * If a global coarse grid cell number is larger than max_num, its
263
 
 * value modulo max_num is used.
264
 
 *
265
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
271
 
 
272
 
void
273
 
cs_grid_project_cell_num(const cs_grid_t  *g,
274
 
                         fvm_lnum_t        n_base_cells,
275
 
                         int               max_num,
276
 
                         int               c_cell_num[]);
277
 
 
278
 
/*----------------------------------------------------------------------------
279
 
 * Project variable from coarse grid to base grid
280
 
 *
281
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
287
 
 
288
 
void
289
 
cs_grid_project_var(const cs_grid_t  *g,
290
 
                    fvm_lnum_t        n_base_cells,
291
 
                    const cs_real_t   c_var[],
292
 
                    cs_real_t         f_var[]);
293
 
 
294
 
/*----------------------------------------------------------------------------
295
 
 * Compute diagonal dominance metric and project it to base grid
296
 
 *
297
 
 * parameters:
298
 
 *   g            <-- Grid structure
299
 
 *   n_base_cells <-- Number of cells in base grid
300
 
 *   diag_dom     --> Diagonal dominance metric (on fine grid)
301
 
 *----------------------------------------------------------------------------*/
302
 
 
303
 
void
304
 
cs_grid_project_diag_dom(const cs_grid_t  *g,
305
 
                         fvm_lnum_t        n_base_cells,
306
 
                         cs_real_t         diag_dom[]);
307
 
 
308
 
/*----------------------------------------------------------------------------*/
309
 
 
310
 
END_C_DECLS
311
 
 
312
 
#endif /* __CS_GRID_H__ */