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_cdo_connect.h"
36 #include "cs_cdo_local.h"
37 #include "cs_cdo_quantities.h"
38 #include "cs_param.h"
39 #include "cs_time_step.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 #define CS_PROPERTY_POST_FOURIER (1 << 1) // postprocess Fourier number
50 
51 /*============================================================================
52  * Type definitions
53  *============================================================================*/
54 
55 /* Type of property considered */
56 typedef enum {
57 
58  CS_PROPERTY_ISO, // isotropic
59  CS_PROPERTY_ORTHO, // orthotropic
60  CS_PROPERTY_ANISO, // anisotropic
62 
64 
65 /* Set of parameters attached to a property */
66 typedef struct {
67 
68  char *restrict name;
69  cs_flag_t post_flag; // Indicate what to postprocess
70 
71  /* Short descriptor to know where is defined the property and what kind of
72  property one considers (mask of bits) */
74 
75  /* The number of values to set depends on the type of property
76  - isotropic = 1 => CS_PARAM_VAR_SCAL
77  - orthotropic = 3 => CS_PARAM_VAR_VECT
78  - anisotropic = 9 => CS_PARAM_VAR_TENS
79  */
80 
81  cs_property_type_t type; // isotropic, anistotropic...
82 
83  /* Members to define the value of the property by subdomains (up to now,
84  only subdomains built from an union of cells are considered) */
85 
86  int n_max_subdomains; // requested number of subdomains
87  int n_subdomains; // current number of subddomains defined
88  cs_param_def_t *defs; // list of definitions for each subdomain
89  short int *def_ids; /* id of the definition related to each
90  cell.
91  NULL is only one definition is set */
92 
93  /* Useful buffers to deal with more complex definitions */
94 
95  cs_real_t *array1; // if the property hinges on an array
96  cs_desc_t desc1; // short description of the related array
97  cs_real_t *array2; // if the property hinges on a second array
98  cs_desc_t desc2; // short description of the related array
99 
100 } cs_property_t;
101 
102 /* List of available keys for setting an advection field */
103 typedef enum {
104 
107 
109 
110 /*============================================================================
111  * Global variables
112  *============================================================================*/
113 
114 /*============================================================================
115  * Public function prototypes
116  *============================================================================*/
117 
118 /*----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------*/
127 
128 void
130  const cs_cdo_connect_t *connect,
131  const cs_time_step_t *time_step);
132 
133 /*----------------------------------------------------------------------------*/
143 /*----------------------------------------------------------------------------*/
144 
146 cs_property_create(const char *name,
147  const char *key_type,
148  int n_subdomains);
149 
150 /*----------------------------------------------------------------------------*/
157 /*----------------------------------------------------------------------------*/
158 
159 void
161 
162 /*----------------------------------------------------------------------------*/
170 /*----------------------------------------------------------------------------*/
171 
174 
175 /*----------------------------------------------------------------------------*/
184 /*----------------------------------------------------------------------------*/
185 
186 bool
188  const char *ref_name);
189 
190 /*----------------------------------------------------------------------------*/
198 /*----------------------------------------------------------------------------*/
199 
200 bool
202 
203 /*----------------------------------------------------------------------------*/
211 /*----------------------------------------------------------------------------*/
212 
213 const char *
215 
216 /*----------------------------------------------------------------------------*/
224 /*----------------------------------------------------------------------------*/
225 
228 
229 /*----------------------------------------------------------------------------*/
235 /*----------------------------------------------------------------------------*/
236 
237 void
239 
240 /*----------------------------------------------------------------------------*/
248 /*----------------------------------------------------------------------------*/
249 
250 void
252  cs_property_key_t key,
253  const char *keyval);
254 
255 /*----------------------------------------------------------------------------*/
264 /*----------------------------------------------------------------------------*/
265 
266 void
268  const char *ml_name,
269  const char *key_val);
270 
271 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
282 void
284  const char *ml_name,
285  double val);
286 
287 /*----------------------------------------------------------------------------*/
296 /*----------------------------------------------------------------------------*/
297 
298 void
300  const char *ml_name,
301  const double val[]);
302 
303 /*----------------------------------------------------------------------------*/
312 /*----------------------------------------------------------------------------*/
313 
314 void
316  const char *ml_name,
317  const double tens[3][3]);
318 
319 /*----------------------------------------------------------------------------*/
328 /*----------------------------------------------------------------------------*/
329 
330 void
332  const char *ml_name,
333  cs_analytic_func_t *func);
334 
335 /*----------------------------------------------------------------------------*/
346 /*----------------------------------------------------------------------------*/
347 
348 void
350  const char *ml_name,
351  const void *context,
352  cs_onevar_law_func_t *func);
353 
354 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 void
369  const char *ml_name,
370  const void *context,
371  cs_twovar_law_func_t *func);
372 
373 /*----------------------------------------------------------------------------*/
381 /*----------------------------------------------------------------------------*/
382 
383 void
385  cs_desc_t desc,
386  cs_real_t *array);
387 
388 /*----------------------------------------------------------------------------*/
396 /*----------------------------------------------------------------------------*/
397 
398 void
400  cs_desc_t desc,
401  cs_real_t *array);
402 
403 /*----------------------------------------------------------------------------*/
411 /*----------------------------------------------------------------------------*/
412 
413 void
415  cs_desc_t desc,
416  cs_real_t *array);
417 
418 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
432  const cs_property_t *pty,
433  bool do_inversion,
434  cs_real_3_t *tensor);
435 
436 /*----------------------------------------------------------------------------*/
445 /*----------------------------------------------------------------------------*/
446 
447 cs_real_t
449  const cs_property_t *pty);
450 
451 /*----------------------------------------------------------------------------*/
462 /*----------------------------------------------------------------------------*/
463 
464 void
466  const cs_property_t *pty,
467  bool do_inversion,
468  cs_real_3_t *tensor);
469 
470 /*----------------------------------------------------------------------------*/
480 /*----------------------------------------------------------------------------*/
481 
482 cs_real_t
484  const cs_property_t *pty);
485 
486 /*----------------------------------------------------------------------------*/
494 /*----------------------------------------------------------------------------*/
495 
496 void
498  double dt,
499  cs_real_t fourier[]);
500 
501 /*----------------------------------------------------------------------------*/
502 
504 
505 #endif /* __CS_PROPERTY_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
cs_flag_t post_flag
Definition: cs_property.h:69
Definition: cs_cdo.h:131
void cs_property_def_by_array(cs_property_t *pty, cs_desc_t desc, cs_real_t *array)
Define a cs_property_t structure thanks to an array of values.
Definition: cs_property.c:893
int n_subdomains
Definition: cs_property.h:87
const char * cs_property_get_name(const cs_property_t *pty)
Retrieve the name of a property.
Definition: cs_property.c:586
cs_real_t * array2
Definition: cs_property.h:97
cs_desc_t desc2
Definition: cs_property.h:98
Definition: cs_property.h:59
cs_param_def_t * defs
Definition: cs_property.h:88
char *restrict name
Definition: cs_property.h:68
cs_property_t * cs_property_create(const char *name, const char *key_type, int n_subdomains)
Create and initialize a new property structure.
Definition: cs_property.c:385
cs_property_type_t
Definition: cs_property.h:56
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:362
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
int n_max_subdomains
Definition: cs_property.h:86
cs_property_type_t cs_property_get_type(const cs_property_t *pty)
Retrieve the type of a property.
Definition: cs_property.c:605
Definition: cs_cdo_local.h:132
cs_desc_t flag
Definition: cs_property.h:73
Definition: cs_cdo_connect.h:56
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:972
void() cs_onevar_law_func_t(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t var_values[], const void *law_param, cs_real_t res_array[])
Compute the value of a quantity according to a law depending only on one variable. This law is described by a set of parameters stored in a structure. result = law(var_value)
Definition: cs_cdo.h:207
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
cs_real_t * array1
Definition: cs_property.h:95
Definition: cs_cdo_quantities.h:102
bool cs_property_check_name(const cs_property_t *pty, const char *ref_name)
Check if the given property has the name ref_name.
Definition: cs_property.c:534
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:1435
void cs_property_set_array(cs_property_t *pty, cs_desc_t desc, cs_real_t *array)
Set the "array" member of a cs_property_t structure.
Definition: cs_property.c:924
void cs_property_summary(const cs_property_t *pty)
Print a summary of a cs_property_t structure.
Definition: cs_property.c:1606
Definition: cs_property.h:58
cs_property_type_t type
Definition: cs_property.h:81
void cs_property_last_definition_stage(cs_property_t *pty)
Last stage of the definition of a property based on several subdomains.
Definition: cs_property.c:446
Definition: cs_field_pointer.h:65
void cs_property_def_by_onevar_law(cs_property_t *pty, const char *ml_name, const void *context, cs_onevar_law_func_t *func)
Define a cs_property_t structure thanks to law depending on one scalar variable in a subdomain attach...
Definition: cs_property.c:844
void cs_property_def_by_value(cs_property_t *pty, const char *ml_name, const char *key_val)
Define a cs_property_t structure by value for entities attached to the mesh location named ml_name...
Definition: cs_property.c:668
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:1255
cs_desc_t desc1
Definition: cs_property.h:96
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:1540
Definition: cs_param.h:108
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
void() cs_twovar_law_func_t(cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const double var1_values[], const double var2_values[], const void *law_param, cs_real_t res_array[])
Compute the value of a quantity according to a law depending only on two variables. This law is described by a set of parameters stored in a structure. result = law(var1_value, var2_value)
Definition: cs_cdo.h:230
void cs_property_def_by_twovar_law(cs_property_t *pty, const char *ml_name, const void *context, cs_twovar_law_func_t *func)
Define a cs_property_t structure thanks to a law depending on two scalars variables in a subdomain at...
Definition: cs_property.c:870
void cs_property_iso_def_by_value(cs_property_t *pty, const char *ml_name, double val)
Define an isotropic cs_property_t structure by value for entities attached to the mesh location named...
Definition: cs_property.c:718
cs_property_t * cs_property_free(cs_property_t *pty)
Free a cs_property_t structure.
Definition: cs_property.c:500
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
#define END_C_DECLS
Definition: cs_defs.h:452
unsigned short int cs_flag_t
Definition: cs_defs.h:299
Definition: cs_property.h:106
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:1147
void cs_property_ortho_def_by_value(cs_property_t *pty, const char *ml_name, const double val[])
Define orthotropic cs_property_t structure by value for entities attached to the mesh location named ...
Definition: cs_property.c:747
short int * def_ids
Definition: cs_property.h:89
void cs_property_def_by_analytic(cs_property_t *pty, const char *ml_name, cs_analytic_func_t *func)
Define a cs_property_t structure thanks to an analytic function in a subdomain attached to the mesh l...
Definition: cs_property.c:820
Definition: cs_property.h:61
void cs_property_set_second_array(cs_property_t *pty, cs_desc_t desc, cs_real_t *array)
Set the second "array" member of a cs_property_t structure.
Definition: cs_property.c:947
cs_property_key_t
Definition: cs_property.h:103
Definition: cs_property.h:60
Definition: cs_property.h:66
void cs_property_aniso_def_by_value(cs_property_t *pty, const char *ml_name, const double tens[3][3])
Define an anisotropic cs_property_t structure by value for entities attached to the mesh location nam...
Definition: cs_property.c:779
Definition: cs_property.h:105
bool cs_property_is_uniform(const cs_property_t *pty)
returns true if the property is uniform, otherwise false
Definition: cs_property.c:564
void cs_property_set_option(cs_property_t *pty, cs_property_key_t key, const char *keyval)
Set optional parameters related to a cs_property_t structure.
Definition: cs_property.c:624