1 #ifndef __CS_MESH_EXTRUDE_H__
2 #define __CS_MESH_EXTRUDE_H__
3 
4 /*============================================================================
5  * Mesh extrusion.
6  *============================================================================*/
7 
8 /*
9   This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11   Copyright (C) 1998-2021 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 
30 /*----------------------------------------------------------------------------
31  *  Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 #include "cs_mesh.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
39 BEGIN_C_DECLS
40 
41 /*============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /*============================================================================
46  * Type definitions
47  *============================================================================*/
48 
49 /*! Per face mesh extrusion settings;
50 
51  * This structure usually created or updated with utility functions, and may
52  * be modified by the user in case fine control is needed */
53 
54 typedef struct {
55 
56   cs_lnum_t   *n_layers;          /*!< number of layers for each boundary face;
57                                    *   (< 0 for non-extruded faces) */
58 
59   cs_real_t   *distance;          /*!< total distance for each boundary face
60                                     (if < 0, absolute value used as
61                                     multiplier for boundary cell thickness) */
62 
63   float       *expansion_factor;  /*!< expansion factor for each boundary face */
64 
65   cs_real_t   *thickness_s;       /*!< optional start thickness for each boundary
66                                    *   face; ignored if <= 0 */
67   cs_real_t   *thickness_e;       /*!< optional end thickness for each boundary
68                                    *   face; ignored if <= 0 */
69 
70 } cs_mesh_extrude_face_info_t;
71 
72 /*! Mesh extrusion vectors definition;
73 
74  * This structure defines local extrusion vectors; it is usually created
75  * or updated with utility functions, and may be modified by the user
76  * in case fine control is needed */
77 
78 typedef struct {
79 
80   cs_lnum_t       n_faces;           /*!< number of associated faces */
81   cs_lnum_t       n_vertices;        /*!< number of associated vertices */
82   cs_lnum_t      *face_ids;          /*!< ids of associated faces, or NULL */
83   cs_lnum_t      *vertex_ids;        /*!< ids of associated vertices, or NULL */
84   cs_lnum_t      *n_layers;          /*!< number of layers for each vertex */
85   cs_coord_3_t   *coord_shift;       /*!< extrusion vector for each vertex */
86   cs_lnum_t      *distribution_idx;  /*!< index of optional distribution */
87   float          *distribution;      /*!< optional distribution of resulting
88                                       *   vertices along each extrusion vector,
89                                       *   with values in range ]0, 1], or NULL
90                                       *   (size: distribution_idx[n_vertices]) */
91 
92 } cs_mesh_extrude_vectors_t;
93 
94 /*=============================================================================
95  * Public function prototypes
96  *============================================================================*/
97 
98 /*----------------------------------------------------------------------------*/
99 /*!
100  * \brief Extrude mesh boundary faces in the normal direction.
101  *
102  * Extrusion is defined on selected boundary faces, and the number of layers
103  * for each associated vertex may be (slightly) variable, to account for
104  * cluttered areas where extrusion may be constrained, or more complex
105  * extrusions.
106  *
107  * \param[in, out]  m             mesh
108  * \param[in]       e             extrusion vector definitions
109  * \param[in]       interior_gc   if true, maintain group classes of
110  *                                interior faces previously on boundary
111  */
112 /*----------------------------------------------------------------------------*/
113 
114 void
115 cs_mesh_extrude(cs_mesh_t                        *m,
116                 const cs_mesh_extrude_vectors_t  *e,
117                 bool                              interior_gc);
118 
119 /*----------------------------------------------------------------------------*/
120 /*!
121  * \brief Extrude mesh boundary faces in the normal direction by a constant
122  *        thickness.
123  *
124  * \param[in, out]  m                 mesh
125  * \param[in]       interior_gc       if true, maintain group classes of
126  *                                    interior faces previously on boundary
127  * \param[in]       n_layers          number of layers
128  * \param[in]       thickness         extrusion thickness
129  * \param[in]       expansion_factor  geometric expansion factor for
130  *                                    extrusion refinement
131  * \param[in]       n_faces           number of selected boundary faces
132  * \param[in]       faces             list of selected boundary faces (0 to n-1),
133  *                                    or NULL if no indirection is needed
134  */
135 /*----------------------------------------------------------------------------*/
136 
137 void
138 cs_mesh_extrude_constant(cs_mesh_t        *m,
139                          bool              interior_gc,
140                          cs_lnum_t         n_layers,
141                          double            thickness,
142                          double            expansion_factor,
143                          cs_lnum_t         n_faces,
144                          const cs_lnum_t   faces[]);
145 
146 /*----------------------------------------------------------------------------*/
147 /*!
148  * \brief Create a mesh extrusion face information structure.
149  *
150  * \param[in]  m  mesh
151  *
152  * \return pointer to new mesh extrusion face information structure.
153  */
154 /*----------------------------------------------------------------------------*/
155 
156 cs_mesh_extrude_face_info_t *
157 cs_mesh_extrude_face_info_create(const cs_mesh_t  *m);
158 
159 /*----------------------------------------------------------------------------*/
160 /*!
161  * \brief Destroy a mesh extrusion face information structure.
162  *
163  * \param[in, out]  efi  pointer to pointer to mesh extrusion face information.
164  */
165 /*----------------------------------------------------------------------------*/
166 
167 void
168 cs_mesh_extrude_face_info_destroy(cs_mesh_extrude_face_info_t **efi);
169 
170 /*----------------------------------------------------------------------------*/
171 /*!
172  * \brief Set face extrusion information by zone.
173  *
174  * \param[in, out]  efi               mesh extrusion face information
175  * \param[in]       n_layers          number of layers for selected faces
176  * \param[in]       distance          extrusion distance for selected faces
177  *                                    (if < 0, absolute value used as
178  *                                    multiplier for boundary cell thickness)
179  * \param[in]       expansion_factor  expansion factor for selected faces
180  * \param[in]       n_faces           number of selected faces
181  * \param[in]       face_ids          ids of selected faces, or NULL
182  */
183 /*----------------------------------------------------------------------------*/
184 
185 void
186 cs_mesh_extrude_set_info_by_zone(cs_mesh_extrude_face_info_t  *efi,
187                                  int                           n_layers,
188                                  double                        distance,
189                                  float                         expansion_factor,
190                                  const cs_lnum_t               n_faces,
191                                  const cs_lnum_t               face_ids[]);
192 
193 /*----------------------------------------------------------------------------*/
194 /*!
195  * \brief Create and build a mesh extrusion vectors definition.
196  *
197  * Extrusion vectors will be computed based on the provided extrusion
198  * face information structure. If no such structure is provided, an empty
199  * structure is returned.
200  *
201  * \param[in]  efi  mesh extrusion face information, or NULL
202  *
203  * \return pointer to created mesh extrusion vectors definition.
204  */
205 /*----------------------------------------------------------------------------*/
206 
207 cs_mesh_extrude_vectors_t *
208 cs_mesh_extrude_vectors_create(const cs_mesh_extrude_face_info_t  *efi);
209 
210 /*----------------------------------------------------------------------------*/
211 /*!
212  * \brief Destroy a mesh extrusion vectors definition.
213  *
214  *
215  * \param[in, out]  e  pointer to pointer to mesh extrusion vectors definition.
216  */
217 /*----------------------------------------------------------------------------*/
218 
219 void
220 cs_mesh_extrude_vectors_destroy(cs_mesh_extrude_vectors_t  **e);
221 
222 /*----------------------------------------------------------------------------*/
223 
224 END_C_DECLS
225 
226 #endif /* __CS_MESH_EXTRUDE_H__ */
227