programmer's documentation
cs_property.h
Go to the documentation of this file.
1 #ifndef __CS_PROPERTY_H__
2 #define __CS_PROPERTY_H__
3 
4 /*============================================================================
5  * Manage the definition/setting of properties
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_cdo.h"
35 #include "cs_param.h"
36 #include "cs_xdef.h"
37 #include "cs_xdef_eval.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
47 /*============================================================================
48  * Type definitions
49  *============================================================================*/
50 
51 /* Type of property considered */
52 typedef enum {
53 
54  CS_PROPERTY_ISO, // isotropic
55  CS_PROPERTY_ORTHO, // orthotropic
56  CS_PROPERTY_ANISO, // anisotropic
58 
60 
61 /* Set of parameters attached to a property */
62 typedef struct {
63 
64  char *restrict name;
65  int id;
67 
68  /* The number of values to set depends on the type of property
69  isotropic = 1, orthotropic = 3, anisotropic = 9 */
71 
72  /* Property is up to now only defined on the whole domain (volume) */
73  int n_definitions; /* Current number of definions used */
74  cs_xdef_t **defs; /* List of definitions */
75  short int *def_ids; /* Store the definition id for each cell,
76  NULL is only one definition is set */
77 
78  /* Function pointers to handle generic tasks related to a property. There
79  is one function related to each definition. Some functions may not be
80  allocated according to the kind of property */
81 
82  /* Retrieve the evaluation of the property at the cell center for each
83  definition */
85 
86  /* Same thing as the previous one but now with the usage of cellwise algo.
87  relying on a cs_cell_mesh_t structure */
89 
91 
92 /* List of available keys for setting an advection field */
93 typedef enum {
94 
97 
99 
100 /*============================================================================
101  * Global variables
102  *============================================================================*/
103 
104 /*============================================================================
105  * Public function prototypes
106  *============================================================================*/
107 
108 /*----------------------------------------------------------------------------*/
116 /*----------------------------------------------------------------------------*/
117 
118 void
120  const cs_cdo_connect_t *connect,
121  const cs_time_step_t *time_step);
122 
123 /*----------------------------------------------------------------------------*/
129 /*----------------------------------------------------------------------------*/
130 
131 int
133 
134 /*----------------------------------------------------------------------------*/
144 /*----------------------------------------------------------------------------*/
145 
147 cs_property_add(const char *name,
148  cs_property_type_t type);
149 
150 /*----------------------------------------------------------------------------*/
158 /*----------------------------------------------------------------------------*/
159 
161 cs_property_by_name(const char *name);
162 
163 /*----------------------------------------------------------------------------*/
171 /*----------------------------------------------------------------------------*/
172 
174 cs_property_by_id(int id);
175 
176 /*----------------------------------------------------------------------------*/
181 /*----------------------------------------------------------------------------*/
182 
183 void
185 
186 /*----------------------------------------------------------------------------*/
191 /*----------------------------------------------------------------------------*/
192 
193 void
195 
196 /*----------------------------------------------------------------------------*/
204 /*----------------------------------------------------------------------------*/
205 
206 static inline bool
208 {
209  if (pty == NULL)
210  return false;
211 
213  return true;
214  else
215  return false;
216 }
217 
218 /*----------------------------------------------------------------------------*/
226 /*----------------------------------------------------------------------------*/
227 
228 static inline bool
230 {
231  if (pty == NULL)
232  return false;
233 
234  if (pty->type == CS_PROPERTY_ISO)
235  return true;
236  else
237  return false;
238 }
239 
240 /*----------------------------------------------------------------------------*/
248 /*----------------------------------------------------------------------------*/
249 
250 static inline const char *
252 {
253  if (pty == NULL)
254  return NULL;
255 
256  return pty->name;
257 }
258 
259 /*----------------------------------------------------------------------------*/
267 /*----------------------------------------------------------------------------*/
268 
269 static inline cs_property_type_t
271 {
272  if (pty == NULL)
273  return CS_PROPERTY_N_TYPES;
274 
275  return pty->type;
276 }
277 
278 /*----------------------------------------------------------------------------*/
289 /*----------------------------------------------------------------------------*/
290 
291 cs_xdef_t *
293  const char *zone_name,
294  double val);
295 
296 /*----------------------------------------------------------------------------*/
307 /*----------------------------------------------------------------------------*/
308 
309 cs_xdef_t *
311  const char *zone_name,
312  double val[]);
313 
314 /*----------------------------------------------------------------------------*/
325 /*----------------------------------------------------------------------------*/
326 
327 cs_xdef_t *
329  const char *zone_name,
330  cs_real_t tens[3][3]);
331 
332 /*----------------------------------------------------------------------------*/
344 /*----------------------------------------------------------------------------*/
345 
346 cs_xdef_t *
348  const char *zone_name,
349  cs_analytic_func_t *func,
350  void *input);
351 
352 /*----------------------------------------------------------------------------*/
366 /*----------------------------------------------------------------------------*/
367 
368 cs_xdef_t *
370  const char *zone_name,
371  void *context,
372  cs_xdef_eval_t *get_eval_at_cell,
373  cs_xdef_eval_cw_t *get_eval_at_cell_cw);
374 
375 /*----------------------------------------------------------------------------*/
386 /*----------------------------------------------------------------------------*/
387 
388 cs_xdef_t *
390  cs_flag_t loc,
391  cs_real_t *array,
392  cs_lnum_t *index);
393 
394 /*----------------------------------------------------------------------------*/
401 /*----------------------------------------------------------------------------*/
402 
403 void
405  cs_field_t *field);
406 
407 /*----------------------------------------------------------------------------*/
415 /*----------------------------------------------------------------------------*/
416 
417 void
419  cs_real_t *array);
420 
421 /*----------------------------------------------------------------------------*/
431 /*----------------------------------------------------------------------------*/
432 
433 void
435  const cs_property_t *pty,
436  bool do_inversion,
437  cs_real_3_t *tensor);
438 
439 /*----------------------------------------------------------------------------*/
448 /*----------------------------------------------------------------------------*/
449 
450 cs_real_t
452  const cs_property_t *pty);
453 
454 /*----------------------------------------------------------------------------*/
465 /*----------------------------------------------------------------------------*/
466 
467 void
469  const cs_property_t *pty,
470  bool do_inversion,
471  cs_real_3_t *tensor);
472 
473 /*----------------------------------------------------------------------------*/
483 /*----------------------------------------------------------------------------*/
484 
485 cs_real_t
487  const cs_property_t *pty);
488 
489 /*----------------------------------------------------------------------------*/
497 /*----------------------------------------------------------------------------*/
498 
499 void
501  double dt,
502  cs_real_t fourier[]);
503 
504 /*----------------------------------------------------------------------------*/
509 /*----------------------------------------------------------------------------*/
510 
511 void
513 
514 /*----------------------------------------------------------------------------*/
515 
517 
518 #endif /* __CS_PROPERTY_H__ */
void cs_property_log_setup(void)
Print a summary of the settings for all defined cs_property_t structures.
Definition: cs_property.c:1196
time step descriptor
Definition: cs_time_step.h:51
#define restrict
Definition: cs_defs.h:122
cs_property_t * cs_property_add(const char *name, cs_property_type_t type)
Create and initialize a new property structure.
Definition: cs_property.c:292
cs_property_t * cs_property_by_name(const char *name)
Find the related property definition from its name.
Definition: cs_property.c:335
cs_xdef_t * cs_property_def_by_func(cs_property_t *pty, const char *zone_name, void *context, cs_xdef_eval_t *get_eval_at_cell, cs_xdef_eval_cw_t *get_eval_at_cell_cw)
Define a cs_property_t structure thanks to law depending on one scalar variable in a subdomain attach...
Definition: cs_property.c:674
Field descriptor.
Definition: cs_field.h:124
cs_xdef_t * cs_property_def_by_analytic(cs_property_t *pty, const char *zone_name, cs_analytic_func_t *func, void *input)
Define a cs_property_t structure thanks to an analytic function in a subdomain attached to the mesh l...
Definition: cs_property.c:622
Definition: cs_property.h:55
char *restrict name
Definition: cs_property.h:64
cs_property_type_t
Definition: cs_property.h:52
cs_xdef_t * cs_property_def_iso_by_value(cs_property_t *pty, const char *zone_name, double val)
Define an isotropic cs_property_t structure by value for entities related to a volume zone...
Definition: cs_property.c:484
void cs_property_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_property.c:255
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
void() cs_xdef_eval_cw_t(const cs_cell_mesh_t *cm, const cs_time_step_t *ts, void *input, cs_real_t *eval)
Function pointer for evaluating a quantity defined through a descriptor (cs_xdef_t structure) by a ce...
Definition: cs_xdef_eval.h:92
Definition: cs_cdo_local.h:138
void cs_property_destroy_all(void)
Free all cs_property_t structures and the array storing all the structures.
Definition: cs_property.c:380
int n_definitions
Definition: cs_property.h:73
int id
Definition: cs_property.h:65
Definition: cs_cdo_connect.h:55
static cs_property_type_t cs_property_get_type(const cs_property_t *pty)
Retrieve the type of a property.
Definition: cs_property.h:270
Definition: field.f90:27
void cs_property_get_cell_tensor(cs_lnum_t c_id, const cs_property_t *pty, bool do_inversion, cs_real_3_t *tensor)
Compute the value of the tensor attached a property at the cell center.
Definition: cs_property.c:875
void cs_property_finalize_setup(void)
Last stage of the definition of a property based on several definitions (i.e. definition by subdomain...
Definition: cs_property.c:419
void cs_property_def_by_field(cs_property_t *pty, cs_field_t *field)
Define a cs_property_t structure thanks to an array of values.
Definition: cs_property.c:783
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:89
cs_real_t cs_property_value_in_cell(const cs_cell_mesh_t *cm, const cs_property_t *pty)
Compute the value of a property at the cell center Version using a cs_cell_mesh_t structure...
Definition: cs_property.c:1096
#define CS_FLAG_STATE_UNIFORM
Definition: cs_cdo.h:60
void() cs_analytic_func_t(cs_real_t time, cs_lnum_t n_elts, const cs_lnum_t *elt_ids, const cs_real_t *coords, bool compact, void *input, cs_real_t *retval)
Generic function pointer for an analytic function elt_ids is optional. If not NULL, it enables to access in coords at the right location and the same thing to fill retval if compact is set to false.
Definition: cs_cdo.h:169
Definition: cs_property.h:54
cs_property_type_t type
Definition: cs_property.h:70
Definition: cs_field_pointer.h:65
static const char * cs_property_get_name(const cs_property_t *pty)
Retrieve the name of a property.
Definition: cs_property.h:251
void cs_property_tensor_in_cell(const cs_cell_mesh_t *cm, const cs_property_t *pty, bool do_inversion, cs_real_3_t *tensor)
Compute the value of the tensor attached a property at the cell center Version using a cs_cell_mesh_t...
Definition: cs_property.c:1020
cs_flag_t state_flag
Definition: cs_property.h:66
Definition: cs_xdef.h:72
void cs_property_get_fourier(const cs_property_t *pty, double dt, cs_real_t fourier[])
Compute the Fourier number in each cell.
Definition: cs_property.c:1131
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
#define END_C_DECLS
Definition: cs_defs.h:454
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_property_t * cs_property_by_id(int id)
Find the related property definition from its id.
Definition: cs_property.c:362
Definition: cs_property.h:96
cs_real_t cs_property_get_cell_value(cs_lnum_t c_id, const cs_property_t *pty)
Compute the value of a property at the cell center.
Definition: cs_property.c:972
short int * def_ids
Definition: cs_property.h:75
cs_xdef_t * cs_property_def_aniso_by_value(cs_property_t *pty, const char *zone_name, cs_real_t tens[3][3])
Define an anisotropic cs_property_t structure by value for entities related to a volume zone...
Definition: cs_property.c:570
cs_xdef_t * cs_property_def_by_array(cs_property_t *pty, cs_flag_t loc, cs_real_t *array, cs_lnum_t *index)
Define a cs_property_t structure thanks to an array of values.
Definition: cs_property.c:718
cs_xdef_t ** defs
Definition: cs_property.h:74
Definition: cs_property.h:57
void() cs_xdef_eval_t(cs_lnum_t n_elts, const cs_lnum_t *elt_ids, bool compact, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *ts, void *input, cs_real_t *eval)
Function pointer for evaluating a quantity defined through a descriptor (cs_xdef_t structure) ...
Definition: cs_xdef_eval.h:68
static bool cs_property_is_isotropic(const cs_property_t *pty)
returns true if the property is isotropic, otherwise false
Definition: cs_property.h:229
cs_property_key_t
Definition: cs_property.h:93
cs_xdef_eval_cw_t ** get_eval_at_cell_cw
Definition: cs_property.h:88
Definition: cs_property.h:56
static bool cs_property_is_uniform(const cs_property_t *pty)
returns true if the property is uniform, otherwise false
Definition: cs_property.h:207
int cs_property_get_n_properties(void)
Retrieve the number of properties.
Definition: cs_property.c:274
Definition: cs_property.h:62
cs_xdef_t * cs_property_def_ortho_by_value(cs_property_t *pty, const char *zone_name, double val[])
Define an orthotropic cs_property_t structure by value for entities related to a volume zone...
Definition: cs_property.c:527
Definition: cs_property.h:95
cs_xdef_eval_t ** get_eval_at_cell
Definition: cs_property.h:84
void cs_property_eval_at_cells(const cs_property_t *pty, cs_real_t *array)
Evaluate the value of the property at each cell. Store the evaluation in the given array...
Definition: cs_property.c:838