programmer's documentation
cs_source_term.h
Go to the documentation of this file.
1 #ifndef __CS_SOURCE_TERM_H__
2 #define __CS_SOURCE_TERM_H__
3 
4 /*============================================================================
5  * Functions and structures to deal with source term computation
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 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_cdo.h"
36 #include "cs_cdo_quantities.h"
37 #include "cs_cdo_local.h"
38 #include "cs_param.h"
39 #include "cs_quadrature.h"
40 #include "cs_time_step.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 #define CS_N_MAX_SOURCE_TERMS 8 // Max number of source terms in an equation
51 
52 /*============================================================================
53  * Type definitions
54  *============================================================================*/
55 
56 typedef struct {
57 
58  char *restrict name; // short description of the source term
59  int ml_id; // id of the related mesh location structure
60 
61  /* Specification related to the way of computing the source term */
62  cs_flag_t flag; // Metadata
63  cs_quadra_type_t quad_type; // barycentric, higher, highest
64  cs_param_def_type_t def_type; // by value, by function...
66 
67  /* Useful buffers to deal with more complex definitions */
68  cs_desc_t array_desc; // short description of the related array
69  cs_real_t *array; // if the source term hinges on an array
70  const void *struc; // if one needs a structure. Only shared
71 
73 
74 /*----------------------------------------------------------------------------*/
84 /*----------------------------------------------------------------------------*/
85 
86 typedef void
88  const cs_cell_mesh_t *cm,
90  double *values);
91 
92 
93 /*============================================================================
94  * Public function prototypes
95  *============================================================================*/
96 
97 /*----------------------------------------------------------------------------*/
105 /*----------------------------------------------------------------------------*/
106 
107 void
109  const cs_cdo_connect_t *connect,
110  const cs_time_step_t *time_step);
111 
112 /*----------------------------------------------------------------------------*/
121 /*----------------------------------------------------------------------------*/
122 
124 cs_source_term_destroy(int n_source_terms,
125  cs_source_term_t *source_terms);
126 
127 /*----------------------------------------------------------------------------*/
139 /*----------------------------------------------------------------------------*/
140 
141 void
143  int st_id,
144  const char *name,
145  cs_param_var_type_t var_type,
146  int ml_id,
147  cs_flag_t flag,
148  const char *val);
149 
150 /*----------------------------------------------------------------------------*/
162 /*----------------------------------------------------------------------------*/
163 
164 void
166  int st_id,
167  const char *name,
168  cs_param_var_type_t var_type,
169  int ml_id,
170  cs_flag_t flag,
171  cs_analytic_func_t *func);
172 
173 /*----------------------------------------------------------------------------*/
186 /*----------------------------------------------------------------------------*/
187 
188 void
190  int st_id,
191  const char *name,
192  cs_param_var_type_t var_type,
193  int ml_id,
194  cs_flag_t flag,
195  cs_desc_t desc,
196  cs_real_t *array);
197 
198 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
207 void
209  cs_quadra_type_t quad_type);
210 
211 /*----------------------------------------------------------------------------*/
220 /*----------------------------------------------------------------------------*/
221 
222 cs_flag_t
224 
225 /*----------------------------------------------------------------------------*/
233 /*----------------------------------------------------------------------------*/
234 
235 void
237  cs_flag_t flag);
238 
239 /*----------------------------------------------------------------------------*/
247 /*----------------------------------------------------------------------------*/
248 
249 cs_flag_t
251 
252 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 const char *
264 
265 /*----------------------------------------------------------------------------*/
272 /*----------------------------------------------------------------------------*/
273 
274 void
275 cs_source_term_summary(const char *eqname,
276  const cs_source_term_t *st);
277 
278 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 cs_flag_t
296  const int n_source_terms,
297  const cs_source_term_t *source_terms,
298  cs_source_term_cellwise_t *compute_source[],
299  cs_flag_t *sys_flag,
300  cs_mask_t *source_mask[]);
301 
302 /*----------------------------------------------------------------------------*/
310 /*----------------------------------------------------------------------------*/
311 
312 void
314  const cs_source_term_t *source,
315  double *p_values[]);
316 
317 /*----------------------------------------------------------------------------*/
331 /*----------------------------------------------------------------------------*/
332 
333 void
334 cs_source_term_compute_cellwise(const int n_source_terms,
335  const cs_source_term_t *source_terms,
336  const cs_cell_mesh_t *cm,
337  const cs_flag_t sys_flag,
338  const cs_mask_t *source_mask,
339  cs_source_term_cellwise_t *compute_source[],
340  cs_cell_builder_t *cb,
341  cs_cell_sys_t *csys);
342 
343 /*----------------------------------------------------------------------------*/
357 /*----------------------------------------------------------------------------*/
358 
359 void
361  const cs_cell_mesh_t *cm,
362  cs_cell_builder_t *cb,
363  double *values);
364 
365 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 void
383  const cs_cell_mesh_t *cm,
384  cs_cell_builder_t *cb,
385  double *values);
386 
387 /*----------------------------------------------------------------------------*/
398 /*----------------------------------------------------------------------------*/
399 
400 void
402  const cs_cell_mesh_t *cm,
403  cs_cell_builder_t *cb,
404  double *values);
405 
406 /*----------------------------------------------------------------------------*/
420 /*----------------------------------------------------------------------------*/
421 
422 void
424  const cs_cell_mesh_t *cm,
425  cs_cell_builder_t *cb,
426  double *values);
427 
428 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 
444 void
446  const cs_cell_mesh_t *cm,
447  cs_cell_builder_t *cb,
448  double *values);
449 
450 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 void
468  const cs_cell_mesh_t *cm,
469  cs_cell_builder_t *cb,
470  double *values);
471 
472 /*----------------------------------------------------------------------------*/
488 /*----------------------------------------------------------------------------*/
489 
490 void
492  const cs_cell_mesh_t *cm,
493  cs_cell_builder_t *cb,
494  double *values);
495 
496 /*----------------------------------------------------------------------------*/
510 /*----------------------------------------------------------------------------*/
511 
512 void
514  const cs_cell_mesh_t *cm,
515  cs_cell_builder_t *cb,
516  double *values);
517 
518 /*----------------------------------------------------------------------------*/
532 /*----------------------------------------------------------------------------*/
533 
534 void
536  const cs_cell_mesh_t *cm,
537  cs_cell_builder_t *cb,
538  double *values);
539 
540 /*----------------------------------------------------------------------------*/
541 
543 
544 #endif /* __CS_SOURCE_TERM_H__ */
void() cs_analytic_func_t(cs_real_t time, cs_lnum_t n_points, const cs_real_t *xyz, cs_real_t *retval)
Generic analytic function.
Definition: cs_cdo.h:170
time step descriptor
Definition: cs_time_step.h:51
#define restrict
Definition: cs_defs.h:122
void cs_source_term_dcsd_q5o3_by_analytic(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1439
cs_param_def_type_t def_type
Definition: cs_source_term.h:64
Definition: cs_cdo.h:131
void cs_source_term_compute(cs_desc_t dof_desc, const cs_source_term_t *source, double *p_values[])
Compute the contribution related to a source term.
Definition: cs_source_term.c:889
const void * struc
Definition: cs_source_term.h:70
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
void cs_source_term_compute_cellwise(const int n_source_terms, const cs_source_term_t *source_terms, const cs_cell_mesh_t *cm, const cs_flag_t sys_flag, const cs_mask_t *source_mask, cs_source_term_cellwise_t *compute_source[], cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Compute the local contributions of source terms in a cell.
Definition: cs_source_term.c:831
unsigned char cs_mask_t
Definition: cs_cdo.h:126
void cs_source_term_dcsd_q1o1_by_analytic(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1192
Definition: cs_cdo_local.h:132
void cs_source_term_dcsd_bary_by_analytic(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1110
void cs_source_term_set_reduction(cs_source_term_t *st, cs_flag_t flag)
Set advanced parameters which are defined by default in a source term structure.
Definition: cs_source_term.c:488
Definition: cs_cdo_connect.h:56
cs_real_t * array
Definition: cs_source_term.h:69
void cs_source_term_summary(const char *eqname, const cs_source_term_t *st)
Summarize the content of a cs_source_term_t structure.
Definition: cs_source_term.c:580
void cs_source_term_def_by_value(cs_source_term_t *st, int st_id, const char *name, cs_param_var_type_t var_type, int ml_id, cs_flag_t flag, const char *val)
Generic way to define a cs_source_term_t structure by value.
Definition: cs_source_term.c:228
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:102
Definition: cs_cdo_local.h:90
void cs_source_term_vcsp_by_value(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1524
void cs_source_term_vcsp_by_analytic(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1569
cs_space_scheme_t
Definition: cs_cdo.h:148
void cs_source_term_set_shared_pointers(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_time_step_t *time_step)
Set shared pointers to main domain members.
Definition: cs_source_term.c:168
cs_quadra_type_t quad_type
Definition: cs_source_term.h:63
cs_desc_t array_desc
Definition: cs_source_term.h:68
int ml_id
Definition: cs_source_term.h:59
void cs_source_term_dcsd_q10o2_by_analytic(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1264
const char * cs_source_term_get_name(const cs_source_term_t *st)
Get the name related to a cs_source_term_t structure.
Definition: cs_source_term.c:562
cs_flag_t cs_source_term_init(cs_space_scheme_t space_scheme, const int n_source_terms, const cs_source_term_t *source_terms, cs_source_term_cellwise_t *compute_source[], cs_flag_t *sys_flag, cs_mask_t *source_mask[])
Initialize data to build the source terms.
Definition: cs_source_term.c:624
void cs_source_term_def_by_array(cs_source_term_t *st, int st_id, const char *name, cs_param_var_type_t var_type, int ml_id, cs_flag_t flag, cs_desc_t desc, cs_real_t *array)
Define a cs_source_term_t structure thanks to an array of values.
Definition: cs_source_term.c:366
Definition: cs_cdo_local.h:67
void cs_source_term_set_quadrature(cs_source_term_t *st, cs_quadra_type_t quad_type)
Set the type of quadrature to use for computing the source term.
Definition: cs_source_term.c:429
cs_quadra_type_t
Definition: cs_quadrature.h:47
Definition: cs_param.h:72
void() cs_source_term_cellwise_t(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.h:87
cs_flag_t flag
Definition: cs_source_term.h:62
char *restrict name
Definition: cs_source_term.h:58
#define END_C_DECLS
Definition: cs_defs.h:452
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_source_term_dcsd_by_value(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1074
cs_def_t def
Definition: cs_source_term.h:65
cs_param_var_type_t
Definition: cs_param.h:120
cs_flag_t cs_source_term_set_default_flag(cs_space_scheme_t scheme)
Set the default flag related to a source term according to the numerical scheme chosen for discretizi...
Definition: cs_source_term.c:450
void cs_source_term_pvsp_by_value(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:988
cs_source_term_t * cs_source_term_destroy(int n_source_terms, cs_source_term_t *source_terms)
Destroy an array of cs_source_term_t structures.
Definition: cs_source_term.c:190
void cs_source_term_def_by_analytic(cs_source_term_t *st, int st_id, const char *name, cs_param_var_type_t var_type, int ml_id, cs_flag_t flag, cs_analytic_func_t *func)
Define a cs_source_term_t structure thanks to an analytic function.
Definition: cs_source_term.c:298
void cs_source_term_pvsp_by_analytic(const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.c:1033
cs_param_def_type_t
Definition: cs_param.h:94
Definition: cs_source_term.h:56
cs_flag_t cs_source_term_get_flag(const cs_source_term_t *st)
Get metadata related to the given source term structure.
Definition: cs_source_term.c:543