6.3
general documentation
cs_stl.h
Go to the documentation of this file.
1 #ifndef __CS_STL_H__
2 #define __CS_STL_H__
3 
4 /*============================================================================
5  * STL reader and writer.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2020 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_defs.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*=============================================================================
41  * Macro definitions
42  *============================================================================*/
43 
44 /*============================================================================
45  * Type definitions
46  *============================================================================*/
47 
48 /*----------------------------------------------------------------------------
49  * Structure defining an STL mesh
50  *----------------------------------------------------------------------------*/
51 
52 typedef struct {
53 
54  char name[10];
56  char header[80];
63  int n_seeds;
69  bool is_porous;
72  fvm_nodal_t *ext_mesh;
74 } cs_stl_mesh_t ;
75 
76 /*----------------------------------------------------------------------------
77  * Structure containing the number of STL meshes and their associated pointers
78  *----------------------------------------------------------------------------*/
79 
80 typedef struct {
81 
87  int writer_id;
90 
91 /*=============================================================================
92  * Static global variables
93  *============================================================================*/
94 
96 
97 /*=============================================================================
98  * Public function prototypes
99  *============================================================================*/
100 
101 /*-----------------------------------------------------------------------------
102  * Add a new STL mesh structure.
103  *
104  * parameters:
105  * path <-- path of the STL mesh
106  *
107  * returns:
108  * pointer to the new STL mesh structure
109  *----------------------------------------------------------------------------*/
110 
112 cs_stl_mesh_add(const char *path);
113 
114 /*----------------------------------------------------------------------------
115  * Return a pointer to a STL mesh based on its name if present.
116  *
117  * parameters:
118  * name <-- name of the STL mesh
119  *
120  * returns:
121  * pointer to the STL mesh structure, or NULL
122  *----------------------------------------------------------------------------*/
123 
125 cs_stl_mesh_get_by_name(const char *name);
126 
127 /*----------------------------------------------------------------------------
128  * Free all allocated STL mesh structures
129  *----------------------------------------------------------------------------*/
130 
131 void
133 
134 /*----------------------------------------------------------------------------
135  * Read a binary STL file and store its content in a STL mesh structure.
136  *
137  * parameters:
138  * stl_mesh <-- pointer to the associated STL mesh structure
139  * path <-- path to the STL file
140  *----------------------------------------------------------------------------*/
141 
142 void
144  const char *path);
145 
146 /*----------------------------------------------------------------------------
147  * Apply a transformation matrix to a STL mesh structure.
148  *
149  * parameters:
150  * stl_mesh <-- pointer to the associated STL mesh structure
151  * matrix <-- transformation matrix
152  *----------------------------------------------------------------------------*/
153 
154 void
156  double matrix[3][4]);
157 
158 /*----------------------------------------------------------------------------
159  * Apply a translation to a STL mesh structure.
160  *
161  * parameters:
162  * stl_mesh <-- pointer to the associated STL mesh structure
163  * vector <-- translation vector
164  *----------------------------------------------------------------------------*/
165 
166 void
168  double vector[3]);
169 
170 /*----------------------------------------------------------------------------
171  * Apply a rotation to a STL mesh structure.
172  *
173  * parameters:
174  * stl_mesh <-- pointer to the associated STL mesh structure
175  * tehta <-- rotation angle
176  * axis <-- rotation axis
177  * center <-- rotation center
178  *----------------------------------------------------------------------------*/
179 
180 void
182  double theta,
183  double axis[3],
184  double center[3]);
185 
186 /*----------------------------------------------------------------------------
187  * Apply a scaling to a STL mesh structure.
188  *
189  * parameters:
190  * stl_mesh <-- pointer to the associated STL mesh structure
191  * scale <-- scale factor
192  *----------------------------------------------------------------------------*/
193 
194 void
196  double scale);
197 
198 /*----------------------------------------------------------------------------
199  * Set the points outside he STL geometry. Those points will be used as seed
200  * to propagate porosity values outside the STL geometry.
201  *
202  * parameters:
203  * stl_mesh <-- pointer to the associated STL mesh structure
204  * n_points <-- number of points
205  * coords <-- coordinates (x1,y1,z1,...,xn,yn,zn)
206  * (size : 3*n_point)
207  *----------------------------------------------------------------------------*/
208 
209 void
211  int n_points,
212  cs_real_t *coords);
213 
214 /*----------------------------------------------------------------------------
215  * Create a new writer that will contains the STL mesh added by the user
216  * The writer_id is stored in the cs_glob_stl_meshes structure.
217  *
218  * case_name associated case name
219  * dir_name associated directory name
220  * fmt_name associated format name
221  * fmt_opts associated format options string
222  * time_dep FVM_WRITER_FIXED_MESH if mesh definitions
223  * are fixed, FVM_WRITER_TRANSIENT_COORDS if
224  * coordinates change, FVM_WRITER_TRANSIENT_CONNECT if
225  * connectivity changes
226  * output_at_start force output at calculation start if true
227  * output_at_end force output at calculation end if true
228  * frequency_n default output frequency in time-steps, or < 0
229  * frequency_t default output frequency in secon
230  *----------------------------------------------------------------------------*/
231 
232 void
233 cs_stl_post_init_writer(const char *case_name,
234  const char *dir_name,
235  const char *fmt_name,
236  const char *fmt_opts,
237  fvm_writer_time_dep_t time_dep,
238  bool output_at_start,
239  bool output_at_end,
240  int frequency_n,
241  double frequency_t);
242 
243 /*----------------------------------------------------------------------------
244  * Associate a STL mesh to the default writer
245  *
246  * stl_mesh <-- pointer to the associated STL mesh structure
247  *----------------------------------------------------------------------------*/
248 
249 void
251 
252 /*----------------------------------------------------------------------------
253  * Write a binary STL file according to a given STL mesh structure.
254  *
255  * parameters:
256  * stl_mesh <-- pointer to the associated STL mesh structure
257  * path <-- path to the STL file
258  *----------------------------------------------------------------------------*/
259 
260 void
262  const char *path);
263 
264 /*----------------------------------------------------------------------------
265  * Compute intersection between a STL mesh and the main mesh.
266  *
267  * parameters:
268  * stl_mesh <-- pointer to the associated STL mesh structure
269  * n_input <-- number of cells on which intersection is done
270  * input_index <-- index of input cells (size: n_input)
271  * n_selected_cells --> number of intersecting cells
272  * selected_cells --> index of output cells (size: n_output)
273  * tria_in_cell_idx --> start index of triangle intersecting each cell
274  * (size: n_output)
275  * tria_in_cell_lst --> list of triangles in intersecting cells
276  * max_size --> maximum size of tria_in_cell_lst array
277  *----------------------------------------------------------------------------*/
278 
279 void
281  cs_lnum_t n_input,
282  cs_lnum_t *input_idx,
283  cs_lnum_t *n_selected_cells,
284  cs_lnum_t *selected_cells,
285  cs_lnum_t *tria_in_cell_idx,
286  cs_lnum_t **tria_in_cell_lst,
287  cs_lnum_t *max_size);
288 
289 /*----------------------------------------------------------------------------
290  * Refine the mesh following a given STL mesh
291  *
292  * parameters:
293  * stl_mesh <-- pointer to the associated STL mesh structure
294  * n_ref <-- level of refinement
295  *----------------------------------------------------------------------------*/
296 
297 void
298 cs_stl_refine(cs_stl_mesh_t *stl_mesh,
299  int n_ref);
300 
301 /*----------------------------------------------------------------------------
302  * Compute porosity field according to a given STL mesh
303  *
304  * parameters:
305  * stl_mesh <-- pointer to the associated STL mesh structure
306  * n_ref_point <-- number of prescribed points outside the STL
307  * ref_coords <-- coordinates of the reference points :
308  * x1,y1,z1,...,xn,yn,zn (size : 3*n_ref_point)
309  * porosity --> interpolated porosity field
310  * indic --> indicator of the STL location (NULL if not needed)
311  *----------------------------------------------------------------------------*/
312 
313 void
315  cs_real_t *porosity,
316  int *indic);
317 
318 /*----------------------------------------------------------------------------*/
319 
321 
322 #endif /* __CS_STL_H__ */
cs_stl_mesh_t
Definition: cs_stl.h:52
cs_defs.h
cs_stl_mesh_t::n_faces
cs_lnum_t n_faces
Definition: cs_stl.h:58
cs_stl_mesh_t::coords
cs_real_3_t * coords
Definition: cs_stl.h:60
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:317
cs_stl_mesh_info_t::mesh_list
cs_stl_mesh_t ** mesh_list
Definition: cs_stl.h:82
cs_stl_file_read
void cs_stl_file_read(cs_stl_mesh_t *stl_mesh, const char *path)
Read a binary STL file and store its content in a STL mesh structure.
Definition: cs_stl.c:1136
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:493
cs_stl_post_init_writer
void cs_stl_post_init_writer(const char *case_name, const char *dir_name, const char *fmt_name, const char *fmt_opts, fvm_writer_time_dep_t time_dep, bool output_at_start, bool output_at_end, int frequency_n, double frequency_t)
Create a new writer that will contains the STL mesh added by the user.
Definition: cs_stl.c:1492
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
cs_stl_mesh_translate
void cs_stl_mesh_translate(cs_stl_mesh_t *stl_mesh, double vector[3])
Apply a translation to a STL mesh structure.
Definition: cs_stl.c:1399
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:492
cs_stl_refine
void cs_stl_refine(cs_stl_mesh_t *stl_mesh, int n_ref)
Refine the mesh following a given STL mesh.
Definition: cs_stl.c:1860
cs_stl_intersection
void cs_stl_intersection(cs_stl_mesh_t *stl_mesh, cs_lnum_t n_input, cs_lnum_t *input_idx, cs_lnum_t *n_selected_cells, cs_lnum_t *selected_cells, cs_lnum_t *tria_in_cell_idx, cs_lnum_t **tria_in_cell_lst, cs_lnum_t *max_size)
Compute intersection between a STL mesh and the main mesh.
Definition: cs_stl.c:1665
cs_stl_mesh_add
cs_stl_mesh_t * cs_stl_mesh_add(const char *path)
Add a new STL mesh structure.
Definition: cs_stl.c:1028
atimbr::theta
double precision, dimension(:,:,:), allocatable theta
Definition: atimbr.f90:123
cs_stl_mesh_t::seed_coords
cs_real_t * seed_coords
Definition: cs_stl.h:66
cs_stl_mesh_info_t
Definition: cs_stl.h:80
cs_stl_file_write
void cs_stl_file_write(cs_stl_mesh_t *stl_mesh, const char *path)
Write a binary STL file according to a given STL mesh structure.
Definition: cs_stl.c:1565
cs_stl_mesh_t::n_seeds
int n_seeds
Definition: cs_stl.h:63
cs_stl_mesh_t::ext_mesh
fvm_nodal_t * ext_mesh
Definition: cs_stl.h:72
cs_stl_post_add_mesh
void cs_stl_post_add_mesh(cs_stl_mesh_t *stl_mesh)
Associate a STL mesh to the default writer.
Definition: cs_stl.c:1535
cs_stl_mesh_get_by_name
cs_stl_mesh_t * cs_stl_mesh_get_by_name(const char *name)
Return a pointer to a STL mesh based on its name if present.
Definition: cs_stl.c:1081
fvm_writer_time_dep_t
fvm_writer_time_dep_t
Definition: fvm_writer.h:57
cs_stl_mesh_info_t::writer_id
int writer_id
Definition: cs_stl.h:87
cs_stl_set_porosity_seed
void cs_stl_set_porosity_seed(cs_stl_mesh_t *stl_mesh, int n_points, cs_real_t *coords)
Set the points outside he STL geometry. Those points will be used as.
Definition: cs_stl.c:1471
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_stl_mesh_destroy_all
void cs_stl_mesh_destroy_all(void)
Free all allocated STL mesh structures.
Definition: cs_stl.c:1102
cs_stl_mesh_transform
void cs_stl_mesh_transform(cs_stl_mesh_t *stl_mesh, double matrix[3][4])
Apply a transformation matrix to a STL mesh structure.
Definition: cs_stl.c:1366
cs_stl_mesh_scale
void cs_stl_mesh_scale(cs_stl_mesh_t *stl_mesh, double scale)
Apply a scaling to a STL mesh structure.
Definition: cs_stl.c:1446
cs_stl_mesh_t::is_porous
bool is_porous
Definition: cs_stl.h:69
cs_glob_stl_meshes
cs_stl_mesh_info_t * cs_glob_stl_meshes
matrix
void matrix(const int *iconvp, const int *idiffp, const int *ndircp, const int *isym, const cs_real_t *thetap, const int *imucpp, const cs_real_t coefbp[], const cs_real_t cofbfp[], const cs_real_t rovsdt[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t xcpp[], cs_real_t da[], cs_real_t xa[])
Definition: cs_matrix_building.c:112
cs_stl_mesh_info_t::n_meshes
cs_lnum_t n_meshes
Definition: cs_stl.h:85
cs_stl_mesh_rotate
void cs_stl_mesh_rotate(cs_stl_mesh_t *stl_mesh, double theta, double axis[3], double center[3])
Apply a rotation to a STL mesh structure.
Definition: cs_stl.c:1424
cs_stl_compute_porosity
void cs_stl_compute_porosity(cs_stl_mesh_t *stl_mesh, cs_real_t *porosity, int *indic)
Compute porosity field according to a given STL mesh.
Definition: cs_stl.c:1995