File: cs_cdo_local.h

package info (click to toggle)
code-saturne 4.3.3%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 77,992 kB
  • sloc: ansic: 281,257; f90: 122,305; python: 56,490; makefile: 3,915; xml: 3,285; cpp: 3,183; sh: 1,139; lex: 176; yacc: 101; sed: 16
file content (346 lines) | stat: -rw-r--r-- 13,522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#ifndef __CS_CDO_LOCAL_H__
#define __CS_CDO_LOCAL_H__

/*============================================================================
 * Routines to handle low-level routines related to CDO local quantities:
 * - local matrices (stored in dense format),
 * - local quantities related to a cell.
 *============================================================================*/

/*
  This file is part of Code_Saturne, a general-purpose CFD tool.

  Copyright (C) 1998-2016 EDF S.A.

  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

/*----------------------------------------------------------------------------
 *  Local headers
 *----------------------------------------------------------------------------*/

#include "cs_cdo.h"
#include "cs_cdo_connect.h"
#include "cs_cdo_quantities.h"
#include "cs_cdo_toolbox.h"

/*----------------------------------------------------------------------------*/

BEGIN_C_DECLS

/*============================================================================
 * Macro definitions
 *============================================================================*/

#define CS_CDO_LOCAL_V   (1 << 0) //  1: local information related to vertices
#define CS_CDO_LOCAL_E   (1 << 1) //  2: local information related to edges
#define CS_CDO_LOCAL_F   (1 << 2) //  4: local information related to faces
#define CS_CDO_LOCAL_EV  (1 << 3) //  8: cell-wise edge --> vertices connect.
#define CS_CDO_LOCAL_FE  (1 << 4) // 16: cell-wise face --> edges connect.
#define CS_CDO_LOCAL_EF  (1 << 5) // 32: cell-wise edge --> faces connect.

/*============================================================================
 * Type definitions
 *============================================================================*/

/* Structure used to store a local system (cell-wise for instance) */
typedef struct {

  cs_locmat_t  *mat;      // cell-wise view of the system matrix
  double       *rhs;      // cell-wise view of the right-hand side
  double       *dir_bc;   // Dirichlet values for boundary degrees of freedom

} cs_cdo_locsys_t;

/* Structure used to get a better memory locality. Map existing structure
   into a more compact one dedicated to a cell.
   Arrays are allocated to n_max_vbyc or to n_max_ebyc.
   Cell-wise numbering is based on the c2e and c2v connectivity.
*/

typedef struct {

  short int    n_max_vbyc;
  short int    n_max_ebyc;
  short int    n_max_fbyc;

  cs_flag_t    flag;   // indicate which quantities are defined
  cs_lnum_t    c_id;   // id of related cell
  cs_real_t   *xc;     // pointer to the coordinates of the cell center
  double       vol_c;  // volume of the current cell

  /* Vertex information */
  short int    n_vc;   // local number of vertices in a cell
  cs_lnum_t   *v_ids;  // vertex ids on this rank
  double      *xv;     // local vertex coordinates (copy)
  short int   *vtag;   // link between mesh and cell-wise numbering (-1 not set)
  double      *wvc;    // weight |vol_dc(v) cap vol_c|/|vol_c for each cell vtx

  /* Edge information */
  short int    n_ec;   // local number of edges in a cell
  cs_lnum_t   *e_ids;  // edge ids on this rank
  short int   *etag;   // link between mesh and cell-wise numbering (-1 not set)
  cs_quant_t  *edge;   // local edge quantities (xe, length and unit vector)
  cs_nvec3_t  *dface;  // local dual face quantities (area and unit normal)

  /* Face information */
  short int    n_fc;   // local number of faces in a cell
  cs_lnum_t   *f_ids;  // face ids on this rank
  short int   *f_sgn;  // incidence number between f and c
  cs_quant_t  *face;   // local face quantities (xf, area and unit normal)
  cs_nvec3_t  *dedge;  // local dual edge quantities (length and unit vector)

  /* Local e2v connectivity: size 2*n_ec (allocated to 2*n_max_ebyc) */
  short int   *e2v_ids;  // cell-wise edge -> vertices connectivity
  short int   *e2v_sgn;  // cell-wise edge -> vertices orientation (-1 or +1)

  /* Local f2e connectivity: size = n_fc*n_max_ebyf */
  short int   *f2e_idx;  // size n_fc + 1
  short int   *f2e_ids;  // size f2e_idx[n_fc]

  /* Local e2f connectivity: size 2*n_ec (allocated to 2*n_max_ebyc) */
  short int   *e2f_ids;  // cell-wise edge -> faces connectivity
  short int   *e2f_sgn;  // cell-wise edge -> faces orientation (-1 or +1)

} cs_cell_mesh_t;

/* Structure used to get a better memory locality. Map existing structure
   into a more compact one dedicated to a face.
   Arrays are allocated to n_max_vbyf (= n_max_ebyf).
   Face-wise numbering is based on the f2e connectivity.
*/

typedef struct {

  short int    n_max_vbyf; // = n_max_ebyf

  cs_lnum_t    c_id;    // id of related cell
  cs_real_t   *xc;      // pointer to the coordinates of the cell center

  /* Face information */
  cs_lnum_t    f_id;    // local mesh face id
  short int    f_sgn;   // incidence number between f and c
  cs_quant_t   face;    // local face quantities (xf, area and unit normal)
  cs_nvec3_t   dedge;   // local dual edge quantities (length and unit vector)

  /* Vertex information */
  short int    n_vf;    // local number of vertices on this face
  cs_lnum_t   *v_ids;   // vertex ids on this rank or in the cellwise numbering
  double      *xv;      // local vertex coordinates (copy)
  double      *wvf;     // weight related to each vertex

  /* Edge information */
  short int    n_ef;    // local number of edges in on this face (= n_vf)
  cs_lnum_t   *e_ids;   // edge ids on this rank or in the cellwise numbering
  cs_quant_t  *edge;    // local edge quantities (xe, length and unit vector)
  double      *tef;     // area of the triangle of base e and apex xf

  /* Local e2v connectivity: size 2*n_ec (allocated to 2*n_max_ebyf) */
  short int   *e2v_ids;  // face-wise edge -> vertices connectivity

} cs_face_mesh_t;

/*============================================================================
 *  Global variables
 *============================================================================*/

extern cs_cell_mesh_t  **cs_cdo_local_cell_meshes       ;
extern cs_face_mesh_t  **cs_cdo_local_face_meshes;

/*============================================================================
 * Public function prototypes
 *============================================================================*/

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Allocate a cs_cdo_locsys_t structure
 *
 * \param[in]   n_max_ent    max number of entries
 *
 * \return a pointer to a new allocated cs_cdo_locsys_t structure
 */
/*----------------------------------------------------------------------------*/

cs_cdo_locsys_t *
cs_cdo_locsys_create(int    n_max_ent);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Free a cs_cdo_locsys_t structure
 *
 * \param[in, out]  p_ls   pointer of pointer to a cs_cdo_locsys_t structure
 */
/*----------------------------------------------------------------------------*/

void
cs_cdo_locsys_free(cs_cdo_locsys_t     **p_ls);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Allocate global structures related to a cs_cell_mesh_t and
 *         cs_face_mesh_t structures
 *
 * \param[in]   connect   pointer to a cs_cdo_connect_t structure
 */
/*----------------------------------------------------------------------------*/

void
cs_cdo_local_initialize(const cs_cdo_connect_t     *connect);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Free global structures related to cs_cell_mesh_t and cs_face_mesh_t
 *         structures
 */
/*----------------------------------------------------------------------------*/

void
cs_cdo_local_finalize(void);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Get a pointer to a cs_cell_mesh_t structure corresponding to mesh id
 *
 * \param[in]   mesh_id   id in the array of pointer to cs_cell_mesh_t struct.
 *
 * \return a pointer to a cs_cell_mesh_t structure
 */
/*----------------------------------------------------------------------------*/

cs_cell_mesh_t *
cs_cdo_local_get_cell_mesh(int    mesh_id);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Get a pointer to a cs_face_mesh_t structure corresponding to mesh id
 *
 * \param[in]   mesh_id   id in the array of pointer to cs_face_mesh_t struct.
 *
 * \return a pointer to a cs_face_mesh_t structure
 */
/*----------------------------------------------------------------------------*/

cs_face_mesh_t *
cs_cdo_local_get_face_mesh(int    mesh_id);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Allocate a cs_cell_mesh_t structure
 *
 * \param[in]      connect   pointer to a cs_cdo_connect_t structure
 *
 * \return a pointer to a new allocated cs_cell_mesh_t structure
 */
/*----------------------------------------------------------------------------*/

cs_cell_mesh_t *
cs_cell_mesh_create(const cs_cdo_connect_t     *connect);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Free a cs_cell_mesh_t structure
 *
 * \param[in, out]  p_cm   pointer of pointer to a cs_cell_mesh_t structure
 */
/*----------------------------------------------------------------------------*/

void
cs_cell_mesh_free(cs_cell_mesh_t     **p_cm);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Define a cs_cell_mesh_t structure for a given cell id. According
 *         to the requested level, some quantities may not be defined;
 *
 * \param[in]       c_id      cell id
 * \param[in]       level     indicate which members are really defined
 * \param[in]       connect   pointer to a cs_cdo_connect_t structure
 * \param[in]       quant     pointer to a cs_cdo_quantities_t structure
 * \param[in, out]  cm        pointer to a cs_cell_mesh_t structure to set
 */
/*----------------------------------------------------------------------------*/

void
cs_cell_mesh_build(cs_lnum_t                    c_id,
                   cs_flag_t                    level,
                   const cs_cdo_connect_t      *connect,
                   const cs_cdo_quantities_t   *quant,
                   cs_cell_mesh_t              *cm);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Allocate a cs_face_mesh_t structure
 *
 * \param[in]      connect   pointer to a cs_cdo_connect_t structure
 *
 * \return a pointer to a new allocated cs_face_mesh_t structure
 */
/*----------------------------------------------------------------------------*/

cs_face_mesh_t *
cs_face_mesh_create(const cs_cdo_connect_t     *connect);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Free a cs_face_mesh_t structure
 *
 * \param[in, out]  p_fm   pointer of pointer to a cs_face_mesh_t structure
 */
/*----------------------------------------------------------------------------*/

void
cs_face_mesh_free(cs_face_mesh_t     **p_fm);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Define a cs_face_mesh_t structure for a given face/cell id.
 *
 * \param[in]       c_id      cell id
 * \param[in]       f_id      face id in the mesh structure
 * \param[in]       connect   pointer to a cs_cdo_connect_t structure
 * \param[in]       quant     pointer to a cs_cdo_quantities_t structure
 * \param[in, out]  fm        pointer to a cs_face_mesh_t structure to set
 */
/*----------------------------------------------------------------------------*/

void
cs_face_mesh_build(cs_lnum_t                    c_id,
                   cs_lnum_t                    f_id,
                   const cs_cdo_connect_t      *connect,
                   const cs_cdo_quantities_t   *quant,
                   cs_face_mesh_t              *fm);

/*----------------------------------------------------------------------------*/
/*!
 * \brief  Define a cs_face_mesh_t structure for a given cell from a
 *         cs_cell_mesh_t structure.
 *         v_ids and e_ids are defined in the cell numbering given by cm
 *
 * \param[in]       cm        pointer to the reference cs_cell_mesh_t structure
 * \param[in]       f         face id in the cs_cell_mesh_t structure
 * \param[in, out]  fm        pointer to a cs_face_mesh_t structure to set
 */
/*----------------------------------------------------------------------------*/

void
cs_face_mesh_build_from_cell_mesh(const cs_cell_mesh_t    *cm,
                                  short int                f,
                                  cs_face_mesh_t          *fm);

/*----------------------------------------------------------------------------*/

END_C_DECLS

#endif /* __CS_CDO_LOCAL_H__ */