1 #ifndef __CS_CDO_LOCAL_H__
2 #define __CS_CDO_LOCAL_H__
3 
4 /*============================================================================
5  * Functions to handle low-level functions related to CDO local quantities:
6  * - local matrices (stored in dense format),
7  * - local quantities related to a cell.
8  *============================================================================*/
9 
10 /*
11   This file is part of Code_Saturne, a general-purpose CFD tool.
12 
13   Copyright (C) 1998-2021 EDF S.A.
14 
15   This program is free software; you can redistribute it and/or modify it under
16   the terms of the GNU General Public License as published by the Free Software
17   Foundation; either version 2 of the License, or (at your option) any later
18   version.
19 
20   This program is distributed in the hope that it will be useful, but WITHOUT
21   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
23   details.
24 
25   You should have received a copy of the GNU General Public License along with
26   this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27   Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 /*----------------------------------------------------------------------------
31  *  Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_cdo_connect.h"
35 #include "cs_cdo_quantities.h"
36 #include "cs_flag.h"
37 #include "cs_param_cdo.h"
38 #include "cs_sdm.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
42 BEGIN_C_DECLS
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /*! \struct cs_cell_builder_t
53  *  \brief Set of local and temporary buffers
54  *
55  *  This set of data is useful for building the algebraic system with a
56  *  cellwise process. This structure belongs to one thread and so enable to
57  *  build the local systems in a multi-threaded environnement.
58  */
59 
60 typedef struct {
61 
62   /*!
63    * @name Evaluation times
64    * @{
65    *
66    * \var t_pty_eval
67    * Time at which one evaluates the properties
68    *
69    * \var t_bc_eval
70    * Time at which one evaluates the boundary conditions
71    *
72    * \var t_st_eval
73    * Time at which one evaluates the source terms
74    *
75    * @}
76    */
77 
78   cs_real_t     t_pty_eval;
79   cs_real_t     t_bc_eval;
80   cs_real_t     t_st_eval;
81 
82   cs_flag_t     cell_flag;    /*!< Metadata related to the current cell */
83 
84   /*!
85    * @name Scaling coefficients
86    * @{
87    *
88    * \var gpty_val
89    * Store the cellwise coefficient value scaling the grad-div term since the
90    * associated Hodge operator is linked to the unity property
91    *
92    * \var tpty_val
93    * Store the cellwise coefficient value scaling the unsteady term since the
94    * associated Hodge operator is linked to the unity property
95    *
96    * \var rpty_vals
97    * Set of coefficient values for each reaction term. The maximum number of
98    * reaction terms associated to an equation is limited to
99    * CS_CDO_N_MAX_REACTIONS
100    *
101    * \var rpty_val
102    * Sum of all coefficient values associated to a reaction term
103    *
104    * @}
105    */
106 
107   double        gpty_val;
108   double        tpty_val;
109   double        rpty_vals[CS_CDO_N_MAX_REACTIONS];
110   double        rpty_val;
111 
112   double       *adv_fluxes;  /*!< Values of the advection flux */
113 
114   /*!
115    * @name Temporary buffers
116    * @{
117    *
118    * \var loc
119    * Small dense matrix storing one term like the diffusion term or the
120    * advection term. This local matrix is a square matrix of size n_cell_dofs.
121    * This buffer is erased and updated several times during the system build.
122    *
123    * \var aux
124    * Additional small dense square matrix of size n_cell_dofs.
125    * This buffer is erased and updated several times during the system build.
126    */
127 
128   int          *ids;     /*!< local ids */
129   double       *values;  /*!< local values */
130   cs_real_3_t  *vectors; /*!< local 3-dimensional vectors */
131 
132   cs_sdm_t     *loc;
133   cs_sdm_t     *aux;
134 
135   /*!
136    * @}
137    */
138 
139 } cs_cell_builder_t;
140 
141 /*! \struct cs_cell_sys_t
142  *  \brief Set of arrays and local (small) dense matrices related to a mesh cell
143  *  This is a key structure for building the local algebraic system.
144  *  This structure belongs to one thread and only.
145  */
146 typedef struct {
147 
148   cs_lnum_t   c_id;       /*!< cell id  */
149 
150   int         n_dofs;   /*!< Number of Degrees of Freedom (DoFs) in this cell */
151   cs_lnum_t  *dof_ids;  /*!< DoF ids */
152   cs_flag_t  *dof_flag; /*!< size = number of DoFs */
153 
154   cs_sdm_t   *mat;      /*!< cellwise view of the system matrix */
155   double     *rhs;      /*!< cellwise view of the right-hand side */
156   double     *source;   /*!< cellwise view of the source term array */
157   double     *val_n;    /*!< values of the unkown at previous time t_n */
158   double     *val_nm1;  /*!< values of the unkown at previous time t_{n-1} */
159 
160   /*!
161    * @name Boundary conditions for the local system
162    * @{
163    */
164 
165   short int   n_bc_faces;  /*!< Number of border faces associated to a cell */
166   short int  *_f_ids;      /*!< List of face ids in the cell numbering */
167   cs_lnum_t  *bf_ids;      /*!< List of face ids in the border face numbering */
168   cs_flag_t  *bf_flag;     /*!< Boundary face flag; size n_bc_faces */
169 
170   bool        has_dirichlet; /*!< Dirichlet BCs ?*/
171   double     *dir_values;    /*!< Values of the Dirichlet BCs (size = n_dofs) */
172 
173   bool        has_nhmg_neumann; /*!< Non-homogeneous Neumann BCs ? */
174   double     *neu_values;       /*!< Neumann BCs values; size = n_dofs */
175 
176   bool        has_robin;      /*!< Robin BCs ? */
177   double     *rob_values;     /*!< Robin BCs values; size = 3*n_dofs */
178 
179   bool        has_sliding;    /*!< Sliding BCs ? */
180 
181   bool        has_internal_enforcement; /*<! At least one DoF enforced */
182   bool       *dof_is_forced;  /*!< Is enforced (array of size n_dofs) */
183 
184   /*!
185    * @}
186    */
187 
188 } cs_cell_sys_t;
189 
190 /*! \struct cs_cell_mesh_t
191  *  \brief Set of local quantities and connectivities related to a mesh cell
192  *
193  *  This is a key structure for all cellwise processes. This structure belongs
194  *  to one thread and only.
195  *  This structure used allows one to get a better memory locality.
196  *  It maps the existing global mesh and other related structures into a more
197  *  compact one dedicated to a cell. Arrays are allocated to the max number of
198  *  related entities (e.g. n_max_vbyc or to n_max_ebyc).
199  *  The cell-wise numbering is based on the c2v, c2e and c2f connectivity.
200  */
201 
202 typedef struct {
203 
204   cs_eflag_t     flag;    /*!< indicate which quantities have to be computed */
205   fvm_element_t  type;    /*!< type of element related to this cell */
206 
207   /* Sizes used to allocate buffers */
208   short int      n_max_vbyc;
209   short int      n_max_ebyc;
210   short int      n_max_fbyc;
211 
212   /* Cell information */
213   cs_lnum_t      c_id;    /*!< id of related cell */
214   cs_real_3_t    xc;      /*!< coordinates of the cell center */
215   double         vol_c;   /*!< volume of the current cell */
216   double         diam_c;  /*!< diameter of the current cell */
217 
218   /* Vertex information */
219   short int    n_vc;  /*!< number of vertices in a cell */
220   cs_lnum_t   *v_ids; /*!< vertex ids on this rank */
221   double      *xv;    /*!< local vertex coordinates (copy) */
222   double      *wvc;   /*!< weight |dualvol(v) cap vol_c|/|vol_c|, size: n_vc */
223 
224   /* Edge information */
225   short int    n_ec;   /*!< number of edges in a cell */
226   cs_lnum_t   *e_ids;  /*!< edge ids on this rank */
227   cs_quant_t  *edge;   /*!< edge quantities (xe, length and unit vector) */
228   cs_nvec3_t  *dface;  /*!< dual face quantities (area and unit normal) */
229   cs_real_t   *pvol_e; /*!< volume associated to an edge in the cell */
230 
231   /* Face information */
232   short int    n_fc;        /*!< number of faces in a cell */
233   cs_lnum_t    bface_shift; /*!< shift to get the boundary face numbering */
234   cs_lnum_t   *f_ids;       /*!< face ids on this rank */
235   short int   *f_sgn;       /*!< incidence number between f and c */
236   double      *f_diam;      /*!< diameters of local faces */
237   double      *hfc;         /*!< height of the pyramid of basis f and apex c */
238   cs_quant_t  *face;        /*!< face quantities (xf, area and unit normal) */
239   cs_nvec3_t  *dedge;      /*!< dual edge quantities (length and unit vector) */
240   cs_real_t   *pvol_f;      /*!< volume associated to a face in the cell */
241 
242   /* Local e2v connectivity: size 2*n_ec (allocated to 2*n_max_ebyc) */
243   short int   *e2v_ids;  /*!< cell-wise edge->vertices connectivity */
244   short int   *e2v_sgn;  /*!< cell-wise edge->vertices orientation (-1 or +1) */
245 
246   /* Local f2v connectivity: size = 2*n_max_ebyc */
247   short int   *f2v_idx;  /*!< size n_fc + 1 */
248   short int   *f2v_ids;  /*!< size 2*n_max_ebyc */
249 
250   /* Local f2e connectivity: size = 2*n_max_ebyc */
251   short int   *f2e_idx;  /*!< cellwise face->edges connectivity (size n_fc+1) */
252   short int   *f2e_ids;  /*!< cellwise face->edges ids (size 2*n_max_ebyc) */
253   short int   *f2e_sgn;  /*!< cellwise face->edges orientation (-1 or +1) */
254   double      *tef;      /*!< area of the triangle of base |e| and apex xf */
255 
256   /* Local e2f connectivity: size 2*n_ec (allocated to 2*n_max_ebyc) */
257   short int   *e2f_ids;  /*!< cell-wise edge -> faces connectivity */
258   cs_nvec3_t  *sefc;     /*!< portion of dual faces (2 triangles by edge) */
259 
260 } cs_cell_mesh_t;
261 
262 /*! \struct cs_face_mesh_t
263     \brief Set of local quantities and connectivities related to a mesh face
264     Structure used to get a better memory locality. Map existing structure
265     into a more compact one dedicated to a face.
266     Arrays are allocated to n_max_vbyf (= n_max_ebyf).
267     Face-wise numbering is based on the f2e connectivity.
268 */
269 
270 typedef struct {
271 
272   short int    n_max_vbyf; /*!< = n_max_ebyf */
273 
274   cs_lnum_t    c_id;    /*!< id of related cell */
275   cs_real_3_t  xc;      /*!< pointer to the coordinates of the cell center */
276 
277   /* Face information */
278   cs_lnum_t    f_id;   /*!< local mesh face id */
279   short int    f_sgn;  /*!< incidence number between f and c */
280   cs_quant_t   face;   /*!< face quantities (xf, area and unit normal) */
281   cs_nvec3_t   dedge;  /*!< its dual edge quantities (length and unit vector) */
282   double       pvol;   /*!< volume of the pyramid of base f and apex x_c */
283   double       hfc;    /*!< height of the pyramid of base f and apex x_c */
284 
285   /* Vertex information */
286   short int    n_vf;    /*!< local number of vertices on this face */
287   cs_lnum_t   *v_ids;   /*!< vertex ids (in the mesh or cellwise numbering) */
288   double      *xv;      /*!< local vertex coordinates (copy) */
289   double      *wvf;     /*!< weight related to each vertex */
290 
291   /* Edge information */
292   short int    n_ef;    /*!< local number of edges in on this face (= n_vf) */
293   cs_lnum_t   *e_ids;   /*!< edge ids (in the mesh or cellwise numbering) */
294   cs_quant_t  *edge;    /*!< edge quantities (xe, length and unit vector) */
295   double      *tef;     /*!< area of the triangle of base e and apex xf */
296 
297   /* Local e2v connectivity: size 2*n_ec (allocated to 2*n_max_ebyf) */
298   short int   *e2v_ids;  /*!< face-wise edge -> vertices connectivity */
299 
300 } cs_face_mesh_t;
301 
302 /*
303    A cs_face_mesh_light_t structure is close to a cs_face_mesh_t structure
304    There are less members to be buildt quicker.
305    Such structure is always associated to a cs_cell_mesh_t structure
306 */
307 
308 typedef struct {
309 
310   short int    n_max_vbyf;  /* Max number of vertices belonging to a face
311                                (= n_max_ebyf) */
312 
313   cs_lnum_t    c_id;    /* id of related cell in the mesh numbering */
314   short int    f;       /* id of the face in the cell mesh numbering */
315 
316   /* Vertex information */
317   short int    n_vf;    /* local number of vertices on this face */
318   short int   *v_ids;   /* vertex ids in the cellwise numbering */
319   double      *wvf;     /* weights related to each vertex */
320 
321   /* Edge information */
322   short int    n_ef;    /* local number of edges on this face (= n_vf) */
323   short int   *e_ids;   /* edge ids in the cellwise numbering */
324   double      *tef;     /* area of the triangle of base e and apex xf */
325 
326 } cs_face_mesh_light_t;
327 
328 /*============================================================================
329  *  Global variables
330  *============================================================================*/
331 
332 /* Auxiliary buffers for extra-operations related to local problems. These
333  * buffers are also used for computing quantities related to a cs_cell_mesh_t
334  * (there are as many buffers as threads since a call to these buffers can be
335  * inside an OpenMP directive */
336 extern int                     cs_cdo_local_d_buffer_size;
337 extern double                **cs_cdo_local_d_buffer;
338 
339 /* Pointer of pointers to global structures */
340 extern cs_cell_mesh_t        **cs_cdo_local_cell_meshes;
341 extern cs_face_mesh_t        **cs_cdo_local_face_meshes;
342 extern cs_face_mesh_light_t  **cs_cdo_local_face_meshes_light;
343 
344 /*============================================================================
345  * Static inline function prototypes
346  *============================================================================*/
347 
348 /*----------------------------------------------------------------------------*/
349 /*!
350  * \brief   Retrieve the size of the auxiliary buffer of double
351  *
352  * \return the number of allocated entries
353  */
354 /*----------------------------------------------------------------------------*/
355 
356 static inline int
cs_cdo_local_get_d_buffer_size(void)357 cs_cdo_local_get_d_buffer_size(void)
358 {
359   return cs_cdo_local_d_buffer_size;
360 }
361 
362 /*----------------------------------------------------------------------------*/
363 /*!
364  * \brief  Retrieve the buffer associated to the current thread. If there is
365  *         no openMP then one should give 0 as parameter.
366  *
367  * \param[in]  thr_id   thread_id
368  *
369  * \return a pointer to an allocated auxiliary buffer of double
370  */
371 /*----------------------------------------------------------------------------*/
372 
373 static inline double *
cs_cdo_local_get_d_buffer(int thr_id)374 cs_cdo_local_get_d_buffer(int   thr_id)
375 {
376   assert(thr_id > -1 && thr_id < cs_glob_n_threads);
377   return cs_cdo_local_d_buffer[thr_id];
378 }
379 
380 /*----------------------------------------------------------------------------*/
381 /*!
382  * \brief   Check if at least one entity of the cell belongs to the boundary
383  *
384  * \param[in]       cm      pointer to a cs_cell_mesh_t structure
385  *
386  * \return true or false
387  */
388 /*----------------------------------------------------------------------------*/
389 
390 static inline bool
cs_cell_has_boundary_elements(const cs_cell_builder_t * const cb)391 cs_cell_has_boundary_elements(const cs_cell_builder_t  *const cb)
392 {
393   if ((cb->cell_flag & (CS_FLAG_BOUNDARY_CELL_BY_FACE   |
394                         CS_FLAG_BOUNDARY_CELL_BY_VERTEX |
395                         CS_FLAG_BOUNDARY_CELL_BY_EDGE)) > 0)
396     return true;
397   else
398     return false;
399 }
400 
401 /*----------------------------------------------------------------------------*/
402 /*!
403  * \brief   Retrieve the vertex id in the cellwise numbering associated to the
404  *          given vertex id in the mesh numbering
405  *
406  * \param[in]       v_id    vertex id in the mesh numbering
407  * \param[in]       cm      pointer to a cs_cell_mesh_t structure
408  *
409  * \return the vertex id in the cell numbering or -1 if not found
410  */
411 /*----------------------------------------------------------------------------*/
412 
413 static inline short int
cs_cell_mesh_get_v(const cs_lnum_t v_id,const cs_cell_mesh_t * const cm)414 cs_cell_mesh_get_v(const cs_lnum_t              v_id,
415                    const cs_cell_mesh_t  *const cm)
416 {
417   if (cm == NULL)
418     return -1;
419   for (short int v = 0; v < cm->n_vc; v++)
420     if (cm->v_ids[v] == v_id)
421       return v;
422   return -1;
423 }
424 
425 /*----------------------------------------------------------------------------*/
426 /*!
427  * \brief   Retrieve the edge id in the cellwise numbering associated to the
428  *          given edge id in the mesh numbering
429  *
430  * \param[in]       e_id    vertex id in the mesh numbering
431  * \param[in]       cm      pointer to a cs_cell_mesh_t structure
432  *
433  * \return the edge id in the cell numbering or -1 if not found
434  */
435 /*----------------------------------------------------------------------------*/
436 
437 static inline short int
cs_cell_mesh_get_e(const cs_lnum_t e_id,const cs_cell_mesh_t * const cm)438 cs_cell_mesh_get_e(const cs_lnum_t              e_id,
439                    const cs_cell_mesh_t  *const cm)
440 {
441   if (cm == NULL)
442     return -1;
443   for (short int e = 0; e < cm->n_ec; e++)
444     if (cm->e_ids[e] == e_id)
445       return e;
446   return -1;
447 }
448 
449 /*----------------------------------------------------------------------------*/
450 /*!
451  * \brief   Retrieve the face id in the cellwise numbering associated to the
452  *          given face id in the mesh numbering
453  *
454  * \param[in]       f_id    face id in the mesh numbering
455  * \param[in]       cm      pointer to a cs_cell_mesh_t structure
456  *
457  * \return the face id in the cell numbering or -1 if not found
458  */
459 /*----------------------------------------------------------------------------*/
460 
461 static inline short int
cs_cell_mesh_get_f(const cs_lnum_t f_id,const cs_cell_mesh_t * const cm)462 cs_cell_mesh_get_f(const cs_lnum_t              f_id,
463                    const cs_cell_mesh_t  *const cm)
464 {
465   if (cm == NULL)
466     return -1;
467   for (short int f = 0; f < cm->n_fc; f++)
468     if (cm->f_ids[f] == f_id)
469       return f;
470   return -1;
471 }
472 
473 /*----------------------------------------------------------------------------*/
474 /*!
475  * \brief   Retrieve the list of vertices attached to a face
476  *
477  * \param[in]       f       face id in the cell numbering
478  * \param[in]       cm      pointer to a cs_cell_mesh_t structure
479  * \param[in, out]  n_vf    pointer of pointer to a cellwise view of the mesh
480  * \param[in, out]  v_ids   list of vertex ids in the cell numbering
481  */
482 /*----------------------------------------------------------------------------*/
483 
484 static inline void
cs_cell_mesh_get_f2v(short int f,const cs_cell_mesh_t * cm,short int * n_vf,short int * v_ids)485 cs_cell_mesh_get_f2v(short int                    f,
486                      const cs_cell_mesh_t        *cm,
487                      short int                   *n_vf,
488                      short int                   *v_ids)
489 {
490   /* Reset */
491   *n_vf = 0;
492   for (short int v = 0; v < cm->n_vc; v++) v_ids[v] = -1;
493 
494   /* Tag vertices belonging to the current face f */
495   for (short int i = cm->f2e_idx[f]; i < cm->f2e_idx[f+1]; i++) {
496 
497     const int  shift_e = 2*cm->f2e_ids[i];
498     v_ids[cm->e2v_ids[shift_e]] = 1;
499     v_ids[cm->e2v_ids[shift_e+1]] = 1;
500 
501   } /* Loop on face edges */
502 
503   for (short int v = 0; v < cm->n_vc; v++) {
504     if (v_ids[v] > 0)
505       v_ids[*n_vf] = v, *n_vf += 1;
506   }
507 
508 }
509 
510 /*----------------------------------------------------------------------------*/
511 /*!
512  * \brief  Get the next three vertices in a row from a face to edge connectivity
513  *         and a edge to vertex connectivity
514  *
515  * \param[in]       f2e_ids     face-edge connectivity
516  * \param[in]       e2v_ids     edge-vertex connectivity
517  * \param[in, out]  v0          id of the first vertex
518  * \param[in, out]  v1          id of the second vertex
519  * \param[in, out]  v2          id of the third vertex
520  */
521 /*----------------------------------------------------------------------------*/
522 
523 static inline void
cs_cell_mesh_get_next_3_vertices(const short int * f2e_ids,const short int * e2v_ids,short int * v0,short int * v1,short int * v2)524 cs_cell_mesh_get_next_3_vertices(const short int   *f2e_ids,
525                                  const short int   *e2v_ids,
526                                  short int         *v0,
527                                  short int         *v1,
528                                  short int         *v2)
529 {
530   const short int e0  = f2e_ids[0];
531   const short int e1  = f2e_ids[1];
532   const short int tmp = e2v_ids[2*e1];
533 
534   *v0 = e2v_ids[2*e0];
535   *v1 = e2v_ids[2*e0+1];
536   *v2 = ((tmp != *v0) && (tmp != *v1)) ? tmp : e2v_ids[2*e1+1];
537 }
538 
539 /*----------------------------------------------------------------------------*/
540 /*!
541  * \brief  Is the face a boundary one ?
542  *
543  * \param[in]  cm     pointer to a \ref cs_cell_mesh_t structure
544  * \param[in]  f      id of the face in the cellwise numbering
545  *
546  * \return true if this is a boundary face otherwise false
547  */
548 /*----------------------------------------------------------------------------*/
549 
550 static inline bool
cs_cell_mesh_is_boundary_face(const cs_cell_mesh_t * cm,const short int f)551 cs_cell_mesh_is_boundary_face(const cs_cell_mesh_t    *cm,
552                               const short int          f)
553 {
554   if (cm->f_ids[f] - cm->bface_shift > -1)
555     return true;
556   else
557     return false;
558 }
559 
560 /*============================================================================
561  * Public function prototypes
562  *============================================================================*/
563 
564 /*----------------------------------------------------------------------------*/
565 /*!
566  * \brief  Allocate global structures used for build system with a cellwise or
567  *         facewise process
568  *
569  * \param[in]   connect   pointer to a \ref cs_cdo_connect_t structure
570  */
571 /*----------------------------------------------------------------------------*/
572 
573 void
574 cs_cdo_local_initialize(const cs_cdo_connect_t     *connect);
575 
576 /*----------------------------------------------------------------------------*/
577 /*!
578  * \brief  Free global structures related to \ref cs_cell_mesh_t and
579  *         \ref cs_face_mesh_t structures
580  */
581 /*----------------------------------------------------------------------------*/
582 
583 void
584 cs_cdo_local_finalize(void);
585 
586 /*----------------------------------------------------------------------------*/
587 /*!
588  * \brief  Allocate a \ref cs_cell_sys_t structure
589  *
590  * \param[in]   n_max_dofbyc    max number of entries
591  * \param[in]   n_max_fbyc      max number of faces in a cell
592  * \param[in]   n_blocks        number of blocks in a row/column
593  * \param[in]   block_sizes     size of each block or NULL if n_blocks = 1
594  *                              Specific treatment n_blocks = 1.
595  *
596  * \return a pointer to a new allocated \ref cs_cell_sys_t structure
597  */
598 /*----------------------------------------------------------------------------*/
599 
600 cs_cell_sys_t *
601 cs_cell_sys_create(int    n_max_dofbyc,
602                    int    n_max_fbyc,
603                    int    n_blocks,
604                    int   *block_sizes);
605 
606 /*----------------------------------------------------------------------------*/
607 /*!
608  * \brief  Reset all members related to BC and some other ones in a
609  *         \ref cs_cell_sys_t structure
610  *
611  * \param[in]      n_fbyc     number of faces in a cell
612  * \param[in, out] csys       pointer to the \ref cs_cell_sys_t struct to reset
613  */
614 /*----------------------------------------------------------------------------*/
615 
616 void
617 cs_cell_sys_reset(int              n_fbyc,
618                   cs_cell_sys_t   *csys);
619 
620 /*----------------------------------------------------------------------------*/
621 /*!
622  * \brief  Free a \ref cs_cell_sys_t structure
623  *
624  * \param[in, out]  p_csys   pointer of pointer to a \ref cs_cell_sys_t struct.
625  */
626 /*----------------------------------------------------------------------------*/
627 
628 void
629 cs_cell_sys_free(cs_cell_sys_t     **p_csys);
630 
631 /*----------------------------------------------------------------------------*/
632 /*!
633  * \brief   Dump a local system for debugging purpose
634  *
635  * \param[in]       msg     associated message to print
636  * \param[in]       csys    pointer to a \ref cs_cell_sys_t structure
637  */
638 /*----------------------------------------------------------------------------*/
639 
640 void
641 cs_cell_sys_dump(const char              msg[],
642                  const cs_cell_sys_t    *csys);
643 
644 /*----------------------------------------------------------------------------*/
645 /*!
646  * \brief  Allocate \ref cs_cell_builder_t structure
647  *
648  * \return a pointer to the new allocated \ref cs_cell_builder_t structure
649  */
650 /*----------------------------------------------------------------------------*/
651 
652 cs_cell_builder_t *
653 cs_cell_builder_create(void);
654 
655 /*----------------------------------------------------------------------------*/
656 /*!
657  * \brief  Free a \ref cs_cell_builder_t structure
658  *
659  * \param[in, out]  p_cb  pointer of pointer to a \ref cs_cell_builder_t struct
660  */
661 /*----------------------------------------------------------------------------*/
662 
663 void
664 cs_cell_builder_free(cs_cell_builder_t     **p_cb);
665 
666 /*----------------------------------------------------------------------------*/
667 /*!
668  * \brief  Allocate and initialize a cs_cell_mesh_t structure
669  *
670  * \param[in]  connect        pointer to a cs_cdo_connect_t structure
671  *
672  * \return a pointer to a new allocated cs_cell_mesh_t structure
673  */
674 /*----------------------------------------------------------------------------*/
675 
676 cs_cell_mesh_t *
677 cs_cell_mesh_create(const cs_cdo_connect_t   *connect);
678 
679 /*----------------------------------------------------------------------------*/
680 /*!
681  * \brief  Get a pointer to a cs_cell_mesh_t structure corresponding to mesh id
682  *
683  * \param[in]   mesh_id   id in the array of pointer to cs_cell_mesh_t struct.
684  *
685  * \return a pointer to a cs_cell_mesh_t structure
686  */
687 /*----------------------------------------------------------------------------*/
688 
689 cs_cell_mesh_t *
690 cs_cdo_local_get_cell_mesh(int    mesh_id);
691 
692 /*----------------------------------------------------------------------------*/
693 /*!
694  * \brief  Initialize to invalid values a cs_cell_mesh_t structure
695  *
696  * \param[in]  cm         pointer to a cs_cell_mesh_t structure
697  */
698 /*----------------------------------------------------------------------------*/
699 
700 void
701 cs_cell_mesh_reset(cs_cell_mesh_t   *cm);
702 
703 /*----------------------------------------------------------------------------*/
704 /*!
705  * \brief  Dump a cs_cell_mesh_t structure
706  *
707  * \param[in]    cm    pointer to a cs_cell_mesh_t structure
708  */
709 /*----------------------------------------------------------------------------*/
710 
711 void
712 cs_cell_mesh_dump(const cs_cell_mesh_t     *cm);
713 
714 /*----------------------------------------------------------------------------*/
715 /*!
716  * \brief  Free a cs_cell_mesh_t structure
717  *
718  * \param[in, out]  p_cm   pointer of pointer to a cs_cell_mesh_t structure
719  */
720 /*----------------------------------------------------------------------------*/
721 
722 void
723 cs_cell_mesh_free(cs_cell_mesh_t     **p_cm);
724 
725 /*----------------------------------------------------------------------------*/
726 /*!
727  * \brief  Define a cs_cell_mesh_t structure for a given cell id. According
728  *         to the requested level, some quantities may not be defined;
729  *
730  * \param[in]       c_id        cell id
731  * \param[in]       build_flag  indicate which members are really built
732  * \param[in]       connect     pointer to a cs_cdo_connect_t structure
733  * \param[in]       quant       pointer to a cs_cdo_quantities_t structure
734  * \param[in, out]  cm          pointer to a cs_cell_mesh_t structure to set
735  */
736 /*----------------------------------------------------------------------------*/
737 
738 void
739 cs_cell_mesh_build(cs_lnum_t                    c_id,
740                    cs_eflag_t                   build_flag,
741                    const cs_cdo_connect_t      *connect,
742                    const cs_cdo_quantities_t   *quant,
743                    cs_cell_mesh_t              *cm);
744 
745 /*----------------------------------------------------------------------------*/
746 /*!
747  * \brief  Allocate a cs_face_mesh_t structure
748  *
749  * \param[in]  n_max_vbyf    max. number of vertices for a face
750  *
751  * \return a pointer to a new allocated cs_face_mesh_t structure
752  */
753 /*----------------------------------------------------------------------------*/
754 
755 cs_face_mesh_t *
756 cs_face_mesh_create(short int   n_max_vbyf);
757 
758 /*----------------------------------------------------------------------------*/
759 /*!
760  * \brief  Get a pointer to a cs_face_mesh_t structure corresponding to mesh id
761  *
762  * \param[in]   mesh_id   id in the array of pointer to cs_face_mesh_t struct.
763  *
764  * \return a pointer to a cs_face_mesh_t structure
765  */
766 /*----------------------------------------------------------------------------*/
767 
768 cs_face_mesh_t *
769 cs_cdo_local_get_face_mesh(int    mesh_id);
770 
771 /*----------------------------------------------------------------------------*/
772 /*!
773  * \brief  Free a cs_face_mesh_t structure
774  *
775  * \param[in, out]  p_fm   pointer of pointer to a cs_face_mesh_t structure
776  */
777 /*----------------------------------------------------------------------------*/
778 
779 void
780 cs_face_mesh_free(cs_face_mesh_t     **p_fm);
781 
782 /*----------------------------------------------------------------------------*/
783 /*!
784  * \brief  Define a cs_face_mesh_t structure for a given face/cell id.
785  *
786  * \param[in]       c_id      cell id
787  * \param[in]       f_id      face id in the mesh structure
788  * \param[in]       connect   pointer to a cs_cdo_connect_t structure
789  * \param[in]       quant     pointer to a cs_cdo_quantities_t structure
790  * \param[in, out]  fm        pointer to a cs_face_mesh_t structure to set
791  */
792 /*----------------------------------------------------------------------------*/
793 
794 void
795 cs_face_mesh_build(cs_lnum_t                    c_id,
796                    cs_lnum_t                    f_id,
797                    const cs_cdo_connect_t      *connect,
798                    const cs_cdo_quantities_t   *quant,
799                    cs_face_mesh_t              *fm);
800 
801 /*----------------------------------------------------------------------------*/
802 /*!
803  * \brief  Define a cs_face_mesh_t structure for a given cell from a
804  *         cs_cell_mesh_t structure.
805  *         v_ids and e_ids are defined in the cell numbering given by cm
806  *
807  * \param[in]       cm        pointer to the reference cs_cell_mesh_t structure
808  * \param[in]       f         face id in the cs_cell_mesh_t structure
809  * \param[in, out]  fm        pointer to a cs_face_mesh_t structure to set
810  */
811 /*----------------------------------------------------------------------------*/
812 
813 void
814 cs_face_mesh_build_from_cell_mesh(const cs_cell_mesh_t    *cm,
815                                   short int                f,
816                                   cs_face_mesh_t          *fm);
817 
818 /*----------------------------------------------------------------------------*/
819 /*!
820  * \brief  Allocate a cs_face_mesh_light_t structure
821  *
822  * \param[in]  n_max_vbyf    max. number of vertices for a face
823  * \param[in]  n_max_vbyc    max. number of vertices for a cell
824  *
825  * \return a pointer to a new allocated cs_face_mesh_light_t structure
826  */
827 /*----------------------------------------------------------------------------*/
828 
829 cs_face_mesh_light_t *
830 cs_face_mesh_light_create(short int   n_max_vbyf,
831                           short int   n_max_vbyc);
832 
833 /*----------------------------------------------------------------------------*/
834 /*!
835  * \brief  Get a pointer to a cs_face_mesh_light_t structure corresponding to
836  *         mesh id
837  *
838  * \param[in]   mesh_id   id in the cs_face_mesh_light_t array
839  *
840  * \return a pointer to a cs_face_mesh_light_t structure
841  */
842 /*----------------------------------------------------------------------------*/
843 
844 cs_face_mesh_light_t *
845 cs_cdo_local_get_face_mesh_light(int    mesh_id);
846 
847 /*----------------------------------------------------------------------------*/
848 /*!
849  * \brief  Free a cs_face_mesh_light_t structure
850  *
851  * \param[in, out]  p_fm   pointer of pointer to a cs_face_mesh_light_t struct.
852  */
853 /*----------------------------------------------------------------------------*/
854 
855 void
856 cs_face_mesh_light_free(cs_face_mesh_light_t     **p_fm);
857 
858 /*----------------------------------------------------------------------------*/
859 /*!
860  * \brief  Define a cs_face_mesh_light_t structure starting from a
861  *         cs_cell_mesh_t structure.
862  *
863  * \param[in]       cm     pointer to the reference cs_cell_mesh_t structure
864  * \param[in]       f      face id in the cs_cell_mesh_t structure
865  * \param[in, out]  fm     pointer to a cs_face_mesh_light_t structure to set
866  */
867 /*----------------------------------------------------------------------------*/
868 
869 void
870 cs_face_mesh_light_build(const cs_cell_mesh_t    *cm,
871                          short int                f,
872                          cs_face_mesh_light_t    *fm);
873 
874 /*----------------------------------------------------------------------------*/
875 
876 END_C_DECLS
877 
878 #endif /* __CS_CDO_LOCAL_H__ */
879