Code_Saturne
CFD tool
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-2012 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 "fvm_defs.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #if 0
41 } /* Fake brace to force back Emacs auto-indentation back to column 0 */
42 #endif
43 #endif /* __cplusplus */
44 
45 /*=============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 /*----------------------------------------------------------------------------
54  * Periodicity types
55  *----------------------------------------------------------------------------*/
56 
57 typedef enum {
58 
63 
65 
66 /*============================================================================
67  * Structure definitions
68  *============================================================================*/
69 
71 
72 /*=============================================================================
73  * Static global variables
74  *============================================================================*/
75 
76 /* Names of periodicity type */
77 
78 extern const char *fvm_periodicity_type_name[];
79 
80 /*=============================================================================
81  * Public function prototypes
82  *============================================================================*/
83 
84 /*----------------------------------------------------------------------------
85  * Create an empty periodicity definition structure.
86  *
87  * To create a composed periodicity, use fvm_periodicity_compose().
88  *
89  * parameters:
90  * equiv_tolerance <-- relative tolerance for identification of
91  * possibly equivalent directions
92  *
93  * returns:
94  * pointer to the created fvm_periodicity_t structure.
95  *---------------------------------------------------------------------------*/
96 
99 
100 /*----------------------------------------------------------------------------
101  * Destroy an fvm_periodicity_t structure.
102  *
103  * parameters:
104  * this_periodicity <-> pointer to structure that should be destroyed
105  *
106  * returns:
107  * NULL pointer
108  *---------------------------------------------------------------------------*/
109 
111 fvm_periodicity_destroy(fvm_periodicity_t *this_periodicity);
112 
113 /*----------------------------------------------------------------------------
114  * Return number of transformations associated with peridocity.
115  *
116  * parameters:
117  * this_periodicity <-- pointer to the periodicity structure
118  *
119  * returns:
120  * number of periodicity transformations
121  *---------------------------------------------------------------------------*/
122 
123 int
124 fvm_periodicity_get_n_transforms(const fvm_periodicity_t *this_periodicity);
125 
126 /*----------------------------------------------------------------------------
127  * Return number of periodicity combination levels.
128  *
129  * Combination level is 0 for single periodicity, and 1 or 2 for
130  * combinations of periodicities (2 max in 3d).
131  *
132  * parameters:
133  * this_periodicity <-- pointer to the periodicity structure
134  *
135  * returns:
136  * number of periodicity combination levels (1 to 3)
137  *---------------------------------------------------------------------------*/
138 
139 int
140 fvm_periodicity_get_n_levels(const fvm_periodicity_t *this_periodicity);
141 
142 /*----------------------------------------------------------------------------
143  * Return index of periodicity transform combination levels.
144  *
145  * Combination level is 0 for single periodicity, and 1 or 2 for
146  * combinations of periodicities (2 max in 3d).
147  *
148  * parameters:
149  * this_periodicity <-- pointer to the periodicity structure
150  * tr_level_index --> start index of first transform of each level
151  * (size: 3 + 1)
152  *---------------------------------------------------------------------------*/
153 
154 void
156  int tr_level_index[4]);
157 
158 /*----------------------------------------------------------------------------
159  * Add a general periodicity direction.
160  *
161  * For each direction defined, two transformations are defined: direct
162  * and reverse. The id of the reverse transformation is equal to the
163  * id of the direct transformation + 1.
164  *
165  * parameters:
166  * this_periodicity <-- pointer to the periodicity structure
167  * external_num <-- external number (1 to n) associated with direction
168  * type <-- transformation type (translation or rotation)
169  * matrix <-- transformation matrix (3x4 matrix, 3 first rows
170  * of a homogeneous coordinates transformation
171  * matrix, with last row = [0 0 0 1])
172  *
173  * returns:
174  * id of the associated direct transformation.
175  *---------------------------------------------------------------------------*/
176 
177 int
179  int external_num,
181  double matrix[3][4]);
182 
183 /*----------------------------------------------------------------------------
184  * Add a translation-type periodicity direction.
185  *
186  * For each direction defined, two transformations are defined: direct
187  * and reverse. The id of the reverse transformation is equal to the
188  * id of the direct transformation + 1.
189  *
190  * parameters:
191  * this_periodicity <-- pointer to the periodicity structure
192  * external_num <-- external number (1 to n) associated with direction
193  * translation <-- components of translation vector (3)
194  *
195  * returns:
196  * id of the associated direct transformation.
197  *---------------------------------------------------------------------------*/
198 
199 int
201  int external_num,
202  const double translation[3]);
203 
204 /*----------------------------------------------------------------------------
205  * Add a rotation type periodicity direction.
206  *
207  * For each direction defined, two transformations are defined: direct
208  * and reverse. The id of the reverse transformation is equal to the
209  * id of the direct transformation + 1.
210  *
211  * parameters:
212  * this_periodicity <-- pointer to the periodicity structure
213  * external_num <-- external number (1 to n) associated with direction
214  * angle <-- rotation angle in degrees
215  * axis <-- components of rotation axis direction vector (3)
216  * invariant_point <-- components of invariant point (3)
217  *
218  * returns:
219  * id of the associated direct transformation.
220  *---------------------------------------------------------------------------*/
221 
222 int
224  int external_num,
225  double angle,
226  const double axis[3],
227  const double invariant_point[3]);
228 
229 /*----------------------------------------------------------------------------
230  * Return the periodicity transform id associated with an external number.
231  *
232  * parameters:
233  * this_periodicity <-- pointer to periodicity structure
234  * external_num <-- external number (1 to n) associated with direction
235  * direction <-- 1 for direct transformation, -1 for reverse
236  *
237  * returns:
238  * transformation id (0 to n-1), or -1 if not found.
239  *---------------------------------------------------------------------------*/
240 
241 int
243  int external_num,
244  int direction);
245 
246 /*----------------------------------------------------------------------------
247  * Return a periodicity transformation's type.
248  *
249  * parameters:
250  * this_periodicity <-- pointer to periodicity structure
251  * tr_id <-- id of transformation we are interested in
252  *
253  * returns:
254  * periodicity transform's type
255  *---------------------------------------------------------------------------*/
256 
258 fvm_periodicity_get_type(const fvm_periodicity_t *this_periodicity,
259  int tr_id);
260 
261 /*----------------------------------------------------------------------------
262  * Return the periodicity transform reverse's id.
263  *
264  * parameters:
265  * this_periodicity <-- pointer to periodicity structure
266  * tr_id <-- id of transformation we are interested in
267  *
268  * returns:
269  * reverse transformation id (0 to n-1), or -1 if not found.
270  *---------------------------------------------------------------------------*/
271 
272 int
273 fvm_periodicity_get_reverse_id(const fvm_periodicity_t *this_periodicity,
274  int tr_id);
275 
276 /*----------------------------------------------------------------------------
277  * Return a periodicity transformation's parents.
278  *
279  * A standard transformation has combination level 0, and no parents.
280  * Transformations built from combination of 2 parents have combination
281  * level 1, and those built from the combination of 3 parents have
282  * combination level 2.
283  *
284  * Level 2 transformations are built from a combination of a level 0
285  * transformation with a level 1 transformation (itself a combination of
286  * 2 level 0 transformations).
287  *
288  * parameters:
289  * this_periodicity <-- pointer to periodicity structure
290  * tr_id <-- id of transformation we are interested in
291  * parent_ids --> parent ids, or -1 (size: 2)
292  *---------------------------------------------------------------------------*/
293 
294 void
295 fvm_periodicity_get_parent_ids(const fvm_periodicity_t *this_periodicity,
296  int tr_id,
297  int parent_ids[2]);
298 
299 /*----------------------------------------------------------------------------
300  * Return a periodicity transformation's component ids.
301  *
302  * A standard transformation has combination level 0, and no parents.
303  * Transformations built from combination of 2 parents have combination
304  * level 1, and those built from the combination of 3 parents have
305  * combination level 2.
306  *
307  * Level 2 transformations are built from a combination of a level 0
308  * transformation with a level 1 transformation (itself a combination of
309  * 2 level 0 transformations). Component ids allow direct access to the 3
310  * corresponding level 0 combinations.
311  *
312  * parameters:
313  * this_periodicity <-- pointer to periodicity structure
314  * tr_id <-- id of transformation we are interested in
315  * component_ids --> component ids, or -1 (size: 3)
316  *---------------------------------------------------------------------------*/
317 
318 void
319 fvm_periodicity_get_components(const fvm_periodicity_t *this_periodicity,
320  int tr_id,
321  int component_ids[3]);
322 
323 /*----------------------------------------------------------------------------
324  * Return a periodicity transformation's first equivalent transform id.
325  *
326  * If multiple transformations are equivalent, each will point to
327  * the previous equivalent transformation, defining a reversed linked list.
328  *
329  * parameters:
330  * this_periodicity <-- pointer to periodicity structure
331  * tr_id <-- id of transformation we are interested in
332  *
333  * returns:
334  * id of first equivalent transformation
335  *---------------------------------------------------------------------------*/
336 
337 int
338 fvm_periodicity_get_equiv_id(const fvm_periodicity_t *this_periodicity,
339  int tr_id);
340 
341 /*----------------------------------------------------------------------------
342  * Return a periodicity transformation's matrix.
343  *
344  * parameters:
345  * this_periodicity <-- pointer to periodicity structure
346  * tr_id <-- id of transformation we are interested in
347  * matrix --> coefficients of transformation matrix
348  *
349  * returns:
350  * periodicity transform's matrix
351  *---------------------------------------------------------------------------*/
352 
353 void
354 fvm_periodicity_get_matrix(const fvm_periodicity_t *this_periodicity,
355  int tr_id,
356  double matrix[3][4]);
357 
358 /*----------------------------------------------------------------------------
359  * Complete periodicity information with combined transformations.
360  *
361  * This function should only be called once, after all base periodicity
362  * transforms have been defined. It returns immediately if combined
363  * transforms are already defined.
364  *
365  * parameters:
366  * this_periodicity <-> pointer to the periodicity structure
367  * abort_on_error <-- 0: non-commuting combinations are discarded
368  * 1: abort in presence of non-commuting combinations
369  *---------------------------------------------------------------------------*/
370 
371 void
373  int abort_on_error);
374 
375 /*----------------------------------------------------------------------------
376  * Dump fvm_periodicity_t structure
377  *
378  * parameters:
379  * this_periodicity <-- pointer to the periodicity structure
380  *---------------------------------------------------------------------------*/
381 
382 void
383 fvm_periodicity_dump(const fvm_periodicity_t *this_periodicity);
384 
385 /*----------------------------------------------------------------------------*/
386 
387 #ifdef __cplusplus
388 }
389 #endif /* __cplusplus */
390 
391 #endif /* __FVM_PERIODICITY_H__ */
Definition: fvm_periodicity.c:123
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.c:824
void fvm_periodicity_get_matrix(const fvm_periodicity_t *this_periodicity, int tr_id, double matrix[3][4])
Definition: fvm_periodicity.c:1160
fvm_periodicity_type_t
Definition: fvm_periodicity.h:57
int fvm_periodicity_get_n_transforms(const fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.c:598
int fvm_periodicity_get_n_levels(const fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.c:622
void fvm_periodicity_get_tr_level_idx(const fvm_periodicity_t *this_periodicity, int tr_level_index[4])
Definition: fvm_periodicity.c:645
int fvm_periodicity_get_reverse_id(const fvm_periodicity_t *this_periodicity, int tr_id)
Definition: fvm_periodicity.c:984
double equiv_tolerance
Definition: fvm_periodicity.c:133
int fvm_periodicity_get_transform_id(const fvm_periodicity_t *this_periodicity, int external_num, int direction)
Definition: fvm_periodicity.c:921
Definition: fvm_periodicity.h:61
Definition: fvm_periodicity.h:62
Definition: fvm_periodicity.h:60
void fvm_periodicity_get_components(const fvm_periodicity_t *this_periodicity, int tr_id, int component_ids[3])
Definition: fvm_periodicity.c:1066
subroutine matrix(ncelet, ncel, nfac, nfabor, iconvp, idiffp, ndircp, isym, nfecra, thetap, imucpp, ifacel, ifabor, coefbp, cofbfp, rovsdt, flumas, flumab, viscf, viscb, xcpp, da, xa)
Definition: matrix.f90:94
Definition: fvm_periodicity.h:59
fvm_periodicity_t * fvm_periodicity_destroy(fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.c:570
fvm_periodicity_type_t fvm_periodicity_get_type(const fvm_periodicity_t *this_periodicity, int tr_id)
Definition: fvm_periodicity.c:960
int fvm_periodicity_get_equiv_id(const fvm_periodicity_t *this_periodicity, int tr_id)
Definition: fvm_periodicity.c:1132
void fvm_periodicity_combine(fvm_periodicity_t *this_periodicity, int abort_on_error)
Definition: fvm_periodicity.c:1200
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.c:679
fvm_periodicity_t * fvm_periodicity_create(double equiv_tolerance)
Definition: fvm_periodicity.c:539
void fvm_periodicity_dump(const fvm_periodicity_t *this_periodicity)
Definition: fvm_periodicity.c:1337
void fvm_periodicity_get_parent_ids(const fvm_periodicity_t *this_periodicity, int tr_id, int parent_ids[2])
Definition: fvm_periodicity.c:1018
int fvm_periodicity_add_translation(fvm_periodicity_t *this_periodicity, int external_num, const double translation[3])
Definition: fvm_periodicity.c:787
const char * fvm_periodicity_type_name[]
Definition: fvm_periodicity.c:144