8.0
general documentation
Loading...
Searching...
No Matches
cs_coupling.h
Go to the documentation of this file.
1#ifndef __CS_COUPLING_H__
2#define __CS_COUPLING_H__
3
4/*============================================================================
5 * Common functionnality for various coupling types.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2023 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 * Standard C library headers
32 *----------------------------------------------------------------------------*/
33
34/*----------------------------------------------------------------------------
35 * PLE library headers
36 *----------------------------------------------------------------------------*/
37
38#include <ple_coupling.h>
39
40/*----------------------------------------------------------------------------
41 * Local headers
42 *----------------------------------------------------------------------------*/
43
44#include "cs_base.h"
45
46/*----------------------------------------------------------------------------*/
47
49
50/*=============================================================================
51 * Macro definitions
52 *============================================================================*/
53
54/*============================================================================
55 * Type definitions
56 *============================================================================*/
57
58/*=============================================================================
59 * Global variable definitions
60 *============================================================================*/
61
62/*============================================================================
63 * Public function prototypes for Fortran API
64 *============================================================================*/
65
66/*----------------------------------------------------------------------------
67 * Synchronize with applications in the same PLE coupling group.
68 *
69 * This function should be called before starting a new time step. The
70 * current time step id is that of the last finished time step, or 0 at
71 * initialization.
72 *
73 * Fortran Interface:
74 *
75 * subroutine cplsyn (ntcmabs, ntcabs, dtref)
76 * *****************
77 *
78 * integer ntmabs : <-> : maximum iteration number
79 * integer ntcabs : <-- : current iteration number
80 * double precision dtref : <-> : reference time step value
81 *----------------------------------------------------------------------------*/
82
83void CS_PROCF(cplsyn, CPLSYN)
84(
85 int *ntmabs,
86 const int *ntcabs,
88 );
89
90/*----------------------------------------------------------------------------
91 * Indicate if there are synchronized applications in the same
92 * PLE coupling group.
93 *
94 * Fortran Interface:
95 *
96 * subroutine cplact (isync)
97 * *****************
98 *
99 * integer isync : <-- : 1 if synchronized, 0 otherwise
100 *----------------------------------------------------------------------------*/
101
102void CS_PROCF(cplact, CPLACT)
103(
104 int *isync
105);
106
107/*============================================================================
108 * Public function prototypes
109 *============================================================================*/
110
111#if defined(HAVE_MPI)
112
113/*----------------------------------------------------------------------------
114 * Discover other applications in the same MPI root communicator.
115 *
116 * parameters:
117 * app_name <-- name of this instance of code_saturne.
118 * forced_app_type <-- name of app type, or NULL
119 *----------------------------------------------------------------------------*/
120
121void
122cs_coupling_discover_mpi_apps(const char *app_name,
123 const char *forced_app_type);
124
125/*----------------------------------------------------------------------------
126 * Finalize MPI coupling helper structures.
127 *----------------------------------------------------------------------------*/
128
129void
131
132/*----------------------------------------------------------------------------
133 * Return info on other applications in the same MPI root communicator.
134 *
135 * returns:
136 * info on other applications structure.
137 *----------------------------------------------------------------------------*/
138
139const ple_coupling_mpi_set_t *
141
142#endif /* HAVE_MPI */
143
144/*----------------------------------------------------------------------------
145 * Return the optional synchronization flag for external couplings.
146 *
147 * See cs_coupling_set_sync_flag() for details.
148 *
149 * returns:
150 * synchronization flag to apply to couplings
151 *----------------------------------------------------------------------------*/
152
153int
155
156/*----------------------------------------------------------------------------
157 * Define an optional synchronization flag for external couplings.
158 *
159 * This flag is used by all couplings based on the PLE (Parallel Location
160 * and Exchange) group synchronization mechanism, which include couplings
161 * with SYRTHES, code_saturne, and neptune_cfd.
162 *
163 * It is defined by a mask, so for example flags f1, f2, and f3 may be
164 * combined using the "f1 | f2 | f2" syntax.
165 *
166 * Note also that for code_saturne, in the case of a variable time step,
167 * the reference time step is synchronized at the beginning of each
168 * iteration, but the actual time step is recomputed later.
169 *
170 * Possible flags are:
171 * PLE_COUPLING_TS_MIN Use smallest time step
172 * PLE_COUPLING_TS_LEADER Prescribe time step for the group
173 * (only one member may set this flag)
174 * PLE_COUPLING_UNSTEADY Inform others that this instance is
175 * using an unsteady solution approach
176 * PLE_COUPLING_STEADY Inform others that this instance is
177 * using a steady solution approach
178 * PLE_COUPLING_USER_1 User definable flag
179 * PLE_COUPLING_USER_2 User definable flag
180 * PLE_COUPLING_USER_3 User definable flag
181 * PLE_COUPLING_USER_4 User definable flag
182 *
183 * To force stopping, PLE_COUPLING_STOP may be set. In this case,
184 * the calculation will stop at the first synchronization, even if
185 * this function is called again with another flag.
186 *
187 * parameters:
188 * flag <-- synchronization flag to apply to couplings
189 *----------------------------------------------------------------------------*/
190
191void
193
194/*----------------------------------------------------------------------------
195 * Return the time step multiplier for external couplings.
196 *
197 * See cs_coupling_set_ts_multiplier() for details.
198 *
199 * returns:
200 * time step multiplier for external couplings
201 *----------------------------------------------------------------------------*/
202
203double
205
206/*----------------------------------------------------------------------------
207 * Define a time step multiplier for external couplings.
208 *
209 * The apparent time step for the current instance times (as viewed by
210 * coupled codes) is equal to the true time step times this multiplier.
211 *
212 * If the synchronization flag contains "time step min" (PLE_COUPLING_TS_MIN),
213 * the apparent time step is used to determine which code has the smallest
214 * time step.
215 *
216 * parameters:
217 * m <-- time step multipier to aply to couplings
218 *----------------------------------------------------------------------------*/
219
220void
222
223/*----------------------------------------------------------------------------
224 * Synchronize with applications in the same PLE coupling group.
225 *
226 * This function should be called before starting a new time step. The
227 * current time step id is that of the last finished time step, or 0 at
228 * initialization.
229 *
230 * Default synchronization flags indicating a new iteration or end of
231 * calculation are set automatically, but the user may set additional flags
232 * to this function if necessary.
233 *
234 * parameters:
235 * flags <-- optional additional synchronization flags
236 * current_ts_id <-- current time step id
237 * max_ts_id <-> maximum time step id
238 * ts <-> suggested time step value
239 *----------------------------------------------------------------------------*/
240
241void
242cs_coupling_sync_apps(int flags,
243 int current_ts_id,
244 int *max_ts_id,
245 double *ts);
246
247/*----------------------------------------------------------------------------
248 * Indicate is synchronization with applications in the same
249 * PLE group is active.
250 *
251 * return:
252 * true if synchronization is required, false otherwise
253 *----------------------------------------------------------------------------*/
254
255bool
257
258/*----------------------------------------------------------------------------
259 * Compute extents of a mesh representation
260 *
261 * parameters:
262 * mesh <-- pointer to mesh representation structure
263 * n_max_extents <-- maximum number of sub-extents (such as element extents)
264 * to compute, or -1 to query
265 * tolerance <-- addition to local extents of each element:
266 * extent = base_extent * (1 + tolerance)
267 * extents <-> extents associated with mesh:
268 * x_min, y_min, ..., x_max, y_max, ... (size: 2*dim)
269 *
270 * returns:
271 * the number of extents computed
272 *----------------------------------------------------------------------------*/
273
276 ple_lnum_t n_max_extents,
277 double tolerance,
278 double extents[]);
279
280/*----------------------------------------------------------------------------
281 * Find elements in a given mesh containing points: updates the
282 * location[] and distance[] arrays associated with a set of points
283 * for points that are in an element of this mesh, or closer to one
284 * than to previously encountered elements.
285 *
286 * Location is relative to the id of a given element + 1 in
287 * concatenated sections of same element dimension.
288 *
289 * parameters:
290 * mesh <-- pointer to mesh representation structure
291 * tolerance_base <-- associated base tolerance (used for bounding
292 * box check only, not for location test)
293 * tolerance_fraction <-- associated fraction of element bounding boxes
294 * added to tolerance
295 * n_points <-- number of points to locate
296 * point_coords <-- point coordinates
297 * point_tag <-- optional point tag (size: n_points)
298 * location <-> number of element containing or closest to each
299 * point (size: n_points)
300 * distance <-> distance from point to element indicated by
301 * location[]: < 0 if unlocated, 0 - 1 if inside,
302 * and > 1 if outside a volume element, or absolute
303 * distance to a surface element (size: n_points)
304 *----------------------------------------------------------------------------*/
305
306void
308 float tolerance_base,
309 float tolerance_fraction,
310 ple_lnum_t n_points,
311 const ple_coord_t point_coords[],
312 const int point_tag[],
313 ple_lnum_t location[],
314 float distance[]);
315
316/*----------------------------------------------------------------------------
317 * Find elements in a given mesh containing points: updates the
318 * location[] and distance[] arrays associated with a set of points
319 * for points that are in an element of this mesh, or closer to one
320 * than to previously encountered elements.
321 *
322 * Location is relative to parent element numbers.
323 *
324 * parameters:
325 * mesh <-- pointer to mesh representation structure
326 * tolerance_base <-- associated base tolerance (used for bounding
327 * box check only, not for location test)
328 * tolerance_fraction <-- associated fraction of element bounding boxes
329 * added to tolerance
330 * n_points <-- number of points to locate
331 * point_coords <-- point coordinates
332 * point_tag <-- optional point tag (size: n_points)
333 * location <-> number of element containing or closest to each
334 * point (size: n_points)
335 * distance <-> distance from point to element indicated by
336 * location[]: < 0 if unlocated, 0 - 1 if inside,
337 * and > 1 if outside a volume element, or absolute
338 * distance to a surface element (size: n_points)
339 *----------------------------------------------------------------------------*/
340
341void
343 float tolerance_base,
344 float tolerance_fraction,
345 ple_lnum_t n_points,
346 const ple_coord_t point_coords[],
347 const int point_tag[],
348 ple_lnum_t location[],
349 float distance[]);
350
351/*----------------------------------------------------------------------------*/
352
354
355#endif /* __CS_COUPLING_H__ */
void cplact(int *isync)
Definition cs_coupling.c:154
void cplsyn(int *ntmabs, const int *ntcabs, cs_real_t *dtref)
Definition cs_coupling.c:122
ple_lnum_t cs_coupling_mesh_extents(const void *mesh, ple_lnum_t n_max_extents, double tolerance, double extents[])
Compute extents of a mesh representation.
Definition cs_coupling.c:611
void cs_coupling_point_in_mesh(const void *mesh, float tolerance_base, float tolerance_fraction, ple_lnum_t n_points, const ple_coord_t point_coords[], const int point_tag[], ple_lnum_t location[], float distance[])
Find elements in a given mesh containing points: updates the location[] and distance[] arrays associa...
Definition cs_coupling.c:667
void cs_coupling_set_ts_multiplier(double m)
Define a time step multiplier for external couplings.
Definition cs_coupling.c:388
void cs_coupling_set_sync_flag(int flag)
Define an optional synchronization flag for external couplings.
Definition cs_coupling.c:349
void cs_coupling_sync_apps(int flags, int current_ts_id, int *max_ts_id, double *ts)
Synchronize with applications in the same PLE coupling group.
Definition cs_coupling.c:413
const ple_coupling_mpi_set_t * cs_coupling_get_mpi_apps(void)
Return info on other applications in the same MPI root communicator.
Definition cs_coupling.c:289
void cs_coupling_point_in_mesh_p(const void *mesh, float tolerance_base, float tolerance_fraction, ple_lnum_t n_points, const ple_coord_t point_coords[], const int point_tag[], ple_lnum_t location[], float distance[])
Find elements in a given mesh containing points: updates the location[] and distance[] arrays associa...
Definition cs_coupling.c:715
int cs_coupling_get_sync_flag(void)
Return the optional synchronization flag for external couplings.
Definition cs_coupling.c:307
void cs_coupling_discover_mpi_apps(const char *app_name, const char *forced_app_type)
Discover other applications in the same MPI root communicator.
Definition cs_coupling.c:180
double cs_coupling_get_ts_multiplier(void)
Return the time step multiplier for external couplings.
Definition cs_coupling.c:367
bool cs_coupling_is_sync_active(void)
Indicate is synchronization with applications in the same PLE group is active.
Definition cs_coupling.c:548
void cs_coupling_finalize(void)
Finalize MPI coupling helper structures.
Definition cs_coupling.c:274
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define CS_PROCF(x, y)
Definition cs_defs.h:523
#define END_C_DECLS
Definition cs_defs.h:510
integer(c_int), pointer, save ntmabs
Maximum absolute time step number.
Definition optcal.f90:205
real(c_double), pointer, save dtref
Reference time step.
Definition optcal.f90:273
integer(c_int), pointer, save ntcabs
Current absolute time step number. In case of restart, this is equal to ntpabs + number of new iterat...
Definition optcal.f90:196
Definition mesh.f90:26
int ple_lnum_t
double ple_coord_t