9.2
general documentation
fvm_periodicity.h
Go to the documentation of this file.
1#ifndef FVM_PERIODICITY_H
2#define FVM_PERIODICITY_H
3
4/*============================================================================
5 * Main structure for handling of periodicities
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 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#include "base/cs_defs.h"
31
32/*----------------------------------------------------------------------------
33 * Local headers
34 *----------------------------------------------------------------------------*/
35
36#include "fvm/fvm_defs.h"
37
38/*=============================================================================
39 * Macro definitions
40 *============================================================================*/
41
42/*============================================================================
43 * Type definitions
44 *============================================================================*/
45
46/*----------------------------------------------------------------------------
47 * Periodicity types
48 *----------------------------------------------------------------------------*/
49
50typedef enum {
51
56
58
59/*============================================================================
60 * Structure definitions
61 *============================================================================*/
62
63typedef struct _fvm_periodicity_t fvm_periodicity_t;
64
65/*=============================================================================
66 * Static global variables
67 *============================================================================*/
68
69/* Names of periodicity type */
70
71extern const char *fvm_periodicity_type_name[];
72
73/*=============================================================================
74 * Public function prototypes
75 *============================================================================*/
76
77/*----------------------------------------------------------------------------
78 * Create an empty periodicity definition structure.
79 *
80 * To create a composed periodicity, use fvm_periodicity_compose().
81 *
82 * parameters:
83 * equiv_tolerance <-- relative tolerance for identification of
84 * possibly equivalent directions
85 *
86 * returns:
87 * pointer to the created fvm_periodicity_t structure.
88 *---------------------------------------------------------------------------*/
89
91fvm_periodicity_create(double equiv_tolerance);
92
93/*----------------------------------------------------------------------------
94 * Destroy an fvm_periodicity_t structure.
95 *
96 * parameters:
97 * this_periodicity <-> pointer to structure that should be destroyed
98 *
99 * returns:
100 * null pointer
101 *---------------------------------------------------------------------------*/
102
105
106/*----------------------------------------------------------------------------
107 * Return number of transformations associated with peridocity.
108 *
109 * parameters:
110 * this_periodicity <-- pointer to the periodicity structure
111 *
112 * returns:
113 * number of periodicity transformations
114 *---------------------------------------------------------------------------*/
115
116int
118
119/*----------------------------------------------------------------------------
120 * Return number of periodicity combination levels.
121 *
122 * Combination level is 0 for single periodicity, and 1 or 2 for
123 * combinations of periodicities (2 max in 3d).
124 *
125 * parameters:
126 * this_periodicity <-- pointer to the periodicity structure
127 *
128 * returns:
129 * number of periodicity combination levels (1 to 3)
130 *---------------------------------------------------------------------------*/
131
132int
133fvm_periodicity_get_n_levels(const fvm_periodicity_t *this_periodicity);
134
135/*----------------------------------------------------------------------------
136 * Return index of periodicity transform combination levels.
137 *
138 * Combination level is 0 for single periodicity, and 1 or 2 for
139 * combinations of periodicities (2 max in 3d).
140 *
141 * parameters:
142 * this_periodicity <-- pointer to the periodicity structure
143 * tr_level_index --> start index of first transform of each level
144 * (size: 3 + 1)
145 *---------------------------------------------------------------------------*/
146
147void
149 int tr_level_index[4]);
150
151/*----------------------------------------------------------------------------
152 * Add a general periodicity direction.
153 *
154 * For each direction defined, two transformations are defined: direct
155 * and reverse. The id of the reverse transformation is equal to the
156 * id of the direct transformation + 1.
157 *
158 * parameters:
159 * this_periodicity <-- pointer to the periodicity structure
160 * external_num <-- external number (1 to n) associated with direction
161 * type <-- transformation type (translation or rotation)
162 * matrix <-- transformation matrix (3x4 matrix, 3 first rows
163 * of a homogeneous coordinates transformation
164 * matrix, with last row = [0 0 0 1])
165 *
166 * returns:
167 * id of the associated direct transformation.
168 *---------------------------------------------------------------------------*/
169
170int
172 int external_num,
174 double matrix[3][4]);
175
176/*----------------------------------------------------------------------------
177 * Add a translation-type periodicity direction.
178 *
179 * For each direction defined, two transformations are defined: direct
180 * and reverse. The id of the reverse transformation is equal to the
181 * id of the direct transformation + 1.
182 *
183 * parameters:
184 * this_periodicity <-- pointer to the periodicity structure
185 * external_num <-- external number (1 to n) associated with direction
186 * translation <-- components of translation vector (3)
187 *
188 * returns:
189 * id of the associated direct transformation.
190 *---------------------------------------------------------------------------*/
191
192int
194 int external_num,
195 const double translation[3]);
196
197/*----------------------------------------------------------------------------
198 * Add a rotation type periodicity direction.
199 *
200 * For each direction defined, two transformations are defined: direct
201 * and reverse. The id of the reverse transformation is equal to the
202 * id of the direct transformation + 1.
203 *
204 * parameters:
205 * this_periodicity <-- pointer to the periodicity structure
206 * external_num <-- external number (1 to n) associated with direction
207 * angle <-- rotation angle in degrees
208 * axis <-- components of rotation axis direction vector (3)
209 * invariant_point <-- components of invariant point (3)
210 *
211 * returns:
212 * id of the associated direct transformation.
213 *---------------------------------------------------------------------------*/
214
215int
217 int external_num,
218 double angle,
219 const double axis[3],
220 const double invariant_point[3]);
221
222/*----------------------------------------------------------------------------
223 * Return the periodicity transform id associated with an external number.
224 *
225 * parameters:
226 * this_periodicity <-- pointer to periodicity structure
227 * external_num <-- external number (1 to n) associated with direction
228 * direction <-- 1 for direct transformation, -1 for reverse
229 *
230 * returns:
231 * transformation id (0 to n-1), or -1 if not found.
232 *---------------------------------------------------------------------------*/
233
234int
236 int external_num,
237 int direction);
238
239/*----------------------------------------------------------------------------
240 * Return a periodicity transformation's type.
241 *
242 * parameters:
243 * this_periodicity <-- pointer to periodicity structure
244 * tr_id <-- id of transformation we are interested in
245 *
246 * returns:
247 * periodicity transform's type
248 *---------------------------------------------------------------------------*/
249
251fvm_periodicity_get_type(const fvm_periodicity_t *this_periodicity,
252 int tr_id);
253
254/*----------------------------------------------------------------------------
255 * Return the periodicity transform reverse's id.
256 *
257 * parameters:
258 * this_periodicity <-- pointer to periodicity structure
259 * tr_id <-- id of transformation we are interested in
260 *
261 * returns:
262 * reverse transformation id (0 to n-1), or -1 if not found.
263 *---------------------------------------------------------------------------*/
264
265int
267 int tr_id);
268
269/*----------------------------------------------------------------------------
270 * Return a periodicity transformation's parents.
271 *
272 * A standard transformation has combination level 0, and no parents.
273 * Transformations built from combination of 2 parents have combination
274 * level 1, and those built from the combination of 3 parents have
275 * combination level 2.
276 *
277 * Level 2 transformations are built from a combination of a level 0
278 * transformation with a level 1 transformation (itself a combination of
279 * 2 level 0 transformations).
280 *
281 * parameters:
282 * this_periodicity <-- pointer to periodicity structure
283 * tr_id <-- id of transformation we are interested in
284 * parent_ids --> parent ids, or -1 (size: 2)
285 *---------------------------------------------------------------------------*/
286
287void
289 int tr_id,
290 int parent_ids[2]);
291
292/*----------------------------------------------------------------------------
293 * Return a periodicity transformation's component ids.
294 *
295 * A standard transformation has combination level 0, and no parents.
296 * Transformations built from combination of 2 parents have combination
297 * level 1, and those built from the combination of 3 parents have
298 * combination level 2.
299 *
300 * Level 2 transformations are built from a combination of a level 0
301 * transformation with a level 1 transformation (itself a combination of
302 * 2 level 0 transformations). Component ids allow direct access to the 3
303 * corresponding level 0 combinations.
304 *
305 * parameters:
306 * this_periodicity <-- pointer to periodicity structure
307 * tr_id <-- id of transformation we are interested in
308 * component_ids --> component ids, or -1 (size: 3)
309 *---------------------------------------------------------------------------*/
310
311void
313 int tr_id,
314 int component_ids[3]);
315
316/*----------------------------------------------------------------------------
317 * Return a periodicity transformation's first equivalent transform id.
318 *
319 * If multiple transformations are equivalent, each will point to
320 * the previous equivalent transformation, defining a reversed linked list.
321 *
322 * parameters:
323 * this_periodicity <-- pointer to periodicity structure
324 * tr_id <-- id of transformation we are interested in
325 *
326 * returns:
327 * id of first equivalent transformation
328 *---------------------------------------------------------------------------*/
329
330int
331fvm_periodicity_get_equiv_id(const fvm_periodicity_t *this_periodicity,
332 int tr_id);
333
334/*----------------------------------------------------------------------------
335 * Return a periodicity transformation's matrix.
336 *
337 * parameters:
338 * this_periodicity <-- pointer to periodicity structure
339 * tr_id <-- id of transformation we are interested in
340 * matrix --> coefficients of transformation matrix
341 *
342 *---------------------------------------------------------------------------*/
343
344void
345fvm_periodicity_get_matrix(const fvm_periodicity_t *this_periodicity,
346 int tr_id,
347 double matrix[3][4]);
348
349/*----------------------------------------------------------------------------
350 * Return a periodicity transformation's matrix.
351 *
352 * parameters:
353 * this_periodicity <-- pointer to periodicity structure
354 * tr_id <-- id of transformation we are interested in
355 * matrix <-- coefficients of transformation matrix
356 *
357 *---------------------------------------------------------------------------*/
358
359void
360fvm_periodicity_set_matrix(const fvm_periodicity_t *this_periodicity,
361 int tr_id,
362 double matrix[3][4]);
363
364/*----------------------------------------------------------------------------
365 * Complete periodicity information with combined transformations.
366 *
367 * This function should only be called once, after all base periodicity
368 * transforms have been defined. It returns immediately if combined
369 * transforms are already defined.
370 *
371 * parameters:
372 * this_periodicity <-> pointer to the periodicity structure
373 * abort_on_error <-- 0: non-commuting combinations are discarded
374 * 1: abort in presence of non-commuting combinations
375 *---------------------------------------------------------------------------*/
376
377void
379 int abort_on_error);
380
381/*----------------------------------------------------------------------------
382 * Dump fvm_periodicity_t structure
383 *
384 * parameters:
385 * this_periodicity <-- pointer to the periodicity structure
386 *---------------------------------------------------------------------------*/
387
388void
389fvm_periodicity_dump(const fvm_periodicity_t *this_periodicity);
390
391/*----------------------------------------------------------------------------*/
392
393#endif /* FVM_PERIODICITY_H */
void fvm_periodicity_combine(fvm_periodicity_t *this_periodicity, int abort_on_error)
Definition: fvm_periodicity.cpp:1221
void fvm_periodicity_get_matrix(const fvm_periodicity_t *this_periodicity, int tr_id, double matrix[3][4])
Definition: fvm_periodicity.cpp:1151
int fvm_periodicity_get_n_transforms(const fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.cpp:591
int fvm_periodicity_get_equiv_id(const fvm_periodicity_t *this_periodicity, int tr_id)
Definition: fvm_periodicity.cpp:1125
fvm_periodicity_t * fvm_periodicity_destroy(fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.cpp:563
int fvm_periodicity_get_reverse_id(const fvm_periodicity_t *this_periodicity, int tr_id)
Definition: fvm_periodicity.cpp:977
void fvm_periodicity_get_parent_ids(const fvm_periodicity_t *this_periodicity, int tr_id, int parent_ids[2])
Definition: fvm_periodicity.cpp:1011
fvm_periodicity_type_t
Definition: fvm_periodicity.h:50
@ FVM_PERIODICITY_NULL
Definition: fvm_periodicity.h:52
@ FVM_PERIODICITY_TRANSLATION
Definition: fvm_periodicity.h:53
@ FVM_PERIODICITY_MIXED
Definition: fvm_periodicity.h:55
@ FVM_PERIODICITY_ROTATION
Definition: fvm_periodicity.h:54
void fvm_periodicity_dump(const fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.cpp:1358
struct _fvm_periodicity_t fvm_periodicity_t
Definition: fvm_periodicity.h:63
const char * fvm_periodicity_type_name[]
void fvm_periodicity_set_matrix(const fvm_periodicity_t *this_periodicity, int tr_id, double matrix[3][4])
Definition: fvm_periodicity.cpp:1188
fvm_periodicity_t * fvm_periodicity_create(double equiv_tolerance)
Definition: fvm_periodicity.cpp:532
int fvm_periodicity_get_n_levels(const fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.cpp:615
int fvm_periodicity_add_rotation(fvm_periodicity_t *this_periodicity, int external_num, double angle, const double axis[3], const double invariant_point[3])
Definition: fvm_periodicity.cpp:817
int fvm_periodicity_add_by_matrix(fvm_periodicity_t *this_periodicity, int external_num, fvm_periodicity_type_t type, double matrix[3][4])
Definition: fvm_periodicity.cpp:672
void fvm_periodicity_get_components(const fvm_periodicity_t *this_periodicity, int tr_id, int component_ids[3])
Definition: fvm_periodicity.cpp:1059
void fvm_periodicity_get_tr_level_idx(const fvm_periodicity_t *this_periodicity, int tr_level_index[4])
Definition: fvm_periodicity.cpp:638
fvm_periodicity_type_t fvm_periodicity_get_type(const fvm_periodicity_t *this_periodicity, int tr_id)
Definition: fvm_periodicity.cpp:953
int fvm_periodicity_add_translation(fvm_periodicity_t *this_periodicity, int external_num, const double translation[3])
Definition: fvm_periodicity.cpp:780
int fvm_periodicity_get_transform_id(const fvm_periodicity_t *this_periodicity, int external_num, int direction)
Definition: fvm_periodicity.cpp:914