6.2
general 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-2020 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_field.h"
35 #include "cs_flag.h"
36 #include "cs_param_types.h"
37 #include "cs_xdef.h"
38 #include "cs_xdef_cw_eval.h"
39 #include "cs_xdef_eval.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /* Common property names (property which is shared between different module) */
50 
51 #define CS_PROPERTY_MASS_DENSITY "mass_density"
52 
60 #define CS_PROPERTY_POST_FOURIER (1 << 0)
61 
73 #define CS_PROPERTY_ISO (1 << 0)
74 
78 #define CS_PROPERTY_ORTHO (1 << 1)
79 
84 #define CS_PROPERTY_ANISO (1 << 2)
85 
86 
90 #define CS_PROPERTY_BY_PRODUCT (1 << 3)
91 
94 /*============================================================================
95  * Type definitions
96  *============================================================================*/
97 
99 
107 typedef enum {
108 
111 
113 
114 /* ======================================== */
115 /* Set of parameters attached to a property */
116 /* ======================================== */
117 
124 typedef struct _cs_property_t cs_property_t;
125 
127 
128  char *restrict name;
129  int id;
133 
134  /* Reference value wich is used as default when nothing else is set. This
135  * value can also be used to renormalized quantities related to this property
136  * By default, this is set to 1
137  */
139 
140  /* Property is up to now only defined on the whole domain (volume) */
141  int n_definitions; /* Current number of definitions used */
142  cs_xdef_t **defs; /* List of definitions */
143 
144  /* Store the definition id for each cell, NULL if there is only one
145  definition set */
146  short int *def_ids;
147 
148  /* Function pointers to handle generic tasks related to a property. There
149  is one function related to each definition. Some functions may not be
150  allocated according to the kind of property */
151 
152  /* Retrieve the evaluation of the property at the cell center for each
153  definition */
155 
156  /* Same thing as the previous one but now with the usage of cellwise algo.
157  relying on a cs_cell_mesh_t structure */
159 
160  /* For properties relying on other properties for their definition, one
161  * stores the pointers to these related properties */
164 
165 };
166 
167 
174 typedef struct {
175 
176  const cs_property_t *property; /* shared pointer */
177 
178  bool is_iso; /* Detect if this an easier case */
179  bool is_unity; /* Detect if this a simple case */
180 
184 
186  cs_real_t tensor[3][3];
188 
190 
191 /*============================================================================
192  * Global variables
193  *============================================================================*/
194 
195 /*============================================================================
196  * Static inline public function prototypes
197  *============================================================================*/
198 
199 /*----------------------------------------------------------------------------*/
207 /*----------------------------------------------------------------------------*/
208 
209 static inline bool
210 cs_property_is_uniform(const cs_property_t *pty)
211 {
212  if (pty == NULL)
213  return true; /* Treated as the "unity" property */
214 
215  if (pty->state_flag & CS_FLAG_STATE_UNIFORM)
216  return true;
217  else
218  return false;
219 }
220 
221 /*----------------------------------------------------------------------------*/
229 /*----------------------------------------------------------------------------*/
230 
231 static inline bool
232 cs_property_is_isotropic(const cs_property_t *pty)
233 {
234  if (pty == NULL)
235  return false;
236 
237  if (pty->type & CS_PROPERTY_ISO)
238  return true;
239  else
240  return false;
241 }
242 
243 /*----------------------------------------------------------------------------*/
251 /*----------------------------------------------------------------------------*/
252 
253 static inline const char *
254 cs_property_get_name(const cs_property_t *pty)
255 {
256  if (pty == NULL)
257  return NULL;
258 
259  return pty->name;
260 }
261 
262 /*----------------------------------------------------------------------------*/
270 /*----------------------------------------------------------------------------*/
271 
272 static inline cs_property_type_t
273 cs_property_get_type(const cs_property_t *pty)
274 {
275  if (pty == NULL)
276  return 0; /* means undefined */
277 
278  return pty->type;
279 }
280 
281 /*============================================================================
282  * Public function prototypes
283  *============================================================================*/
284 
285 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 void
296  const cs_cdo_connect_t *connect);
297 
298 /*----------------------------------------------------------------------------*/
304 /*----------------------------------------------------------------------------*/
305 
306 int
308 
309 /*----------------------------------------------------------------------------*/
318 /*----------------------------------------------------------------------------*/
319 
321 cs_property_add(const char *name,
323 
324 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
341 cs_property_add_as_product(const char *name,
342  const cs_property_t *pty_a,
343  const cs_property_t *pty_b);
344 
345 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
356 cs_property_by_name(const char *name);
357 
358 /*----------------------------------------------------------------------------*/
366 /*----------------------------------------------------------------------------*/
367 
369 cs_property_by_id(int id);
370 
371 /*----------------------------------------------------------------------------*/
378 /*----------------------------------------------------------------------------*/
379 
380 void
382  cs_property_key_t key);
383 
384 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 void
396  double refval);
397 
398 /*----------------------------------------------------------------------------*/
403 /*----------------------------------------------------------------------------*/
404 
405 void
407 
408 /*----------------------------------------------------------------------------*/
413 /*----------------------------------------------------------------------------*/
414 
415 void
417 
418 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
431 cs_property_data_init(bool need_tensor,
432  bool need_eigen,
433  const cs_property_t *property,
434  cs_property_data_t *data);
435 
436 /*----------------------------------------------------------------------------*/
448 /*----------------------------------------------------------------------------*/
449 
450 cs_xdef_t *
452  const char *zname,
453  double val);
454 
455 /*----------------------------------------------------------------------------*/
467 /*----------------------------------------------------------------------------*/
468 
469 cs_xdef_t *
471  const char *zname,
472  double val[]);
473 
474 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 cs_xdef_t *
490  const char *zname,
491  cs_real_t tens[3][3]);
492 
493 /*----------------------------------------------------------------------------*/
506 /*----------------------------------------------------------------------------*/
507 
508 cs_xdef_t *
510  const char *zname,
511  cs_time_func_t *func,
512  void *input);
513 
514 /*----------------------------------------------------------------------------*/
527 /*----------------------------------------------------------------------------*/
528 
529 cs_xdef_t *
531  const char *zname,
532  cs_analytic_func_t *func,
533  void *input);
534 
535 /*----------------------------------------------------------------------------*/
550 /*----------------------------------------------------------------------------*/
551 
552 cs_xdef_t *
554  const char *zname,
555  void *context,
558 
559 /*----------------------------------------------------------------------------*/
572 /*----------------------------------------------------------------------------*/
573 
574 cs_xdef_t *
576  cs_flag_t loc,
577  cs_real_t *array,
578  bool is_owner,
579  cs_lnum_t *index);
580 
581 /*----------------------------------------------------------------------------*/
588 /*----------------------------------------------------------------------------*/
589 
590 void
592  cs_field_t *field);
593 
594 /*----------------------------------------------------------------------------*/
603 /*----------------------------------------------------------------------------*/
604 
605 void
607  const cs_property_t *pty,
608  cs_real_t *array);
609 
610 /*----------------------------------------------------------------------------*/
621 /*----------------------------------------------------------------------------*/
622 
623 void
625  cs_real_t t_eval,
626  const cs_property_t *pty,
627  bool do_inversion,
628  cs_real_t tensor[3][3]);
629 
630 /*----------------------------------------------------------------------------*/
640 /*----------------------------------------------------------------------------*/
641 
642 cs_real_t
644  cs_real_t t_eval,
645  const cs_property_t *pty);
646 
647 /*----------------------------------------------------------------------------*/
659 /*----------------------------------------------------------------------------*/
660 
661 void
663  const cs_property_t *pty,
664  cs_real_t t_eval,
665  bool do_inversion,
666  cs_real_t tensor[3][3]);
667 
668 /*----------------------------------------------------------------------------*/
679 /*----------------------------------------------------------------------------*/
680 
681 cs_real_t
683  const cs_property_t *pty,
684  cs_real_t t_eval);
685 
686 /*----------------------------------------------------------------------------*/
695 /*----------------------------------------------------------------------------*/
696 
697 void
699  cs_real_t t_eval,
700  double dt,
701  cs_real_t fourier[]);
702 
703 /*----------------------------------------------------------------------------*/
708 /*----------------------------------------------------------------------------*/
709 
710 void
712 
713 /*----------------------------------------------------------------------------*/
714 
716 
717 #endif /* __CS_PROPERTY_H__ */
int id
Definition: cs_property.h:129
void cs_property_log_setup(void)
Print a summary of the settings for all defined cs_property_t structures.
Definition: cs_property.c:1991
cs_xdef_t * cs_property_def_by_array(cs_property_t *pty, cs_flag_t loc, cs_real_t *array, bool is_owner, cs_lnum_t *index)
Define a cs_property_t structure thanks to an array of values.
Definition: cs_property.c:1417
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, cs_real_t time_eval, 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:66
#define restrict
Definition: cs_defs.h:127
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:662
cs_property_t * cs_property_by_name(const char *name)
Find the related property definition from its name.
Definition: cs_property.c:772
short int * def_ids
Definition: cs_property.h:146
cs_real_t eigen_ratio
Definition: cs_property.h:183
#define CS_FLAG_STATE_UNIFORM
Definition: cs_flag.h:87
void cs_property_set_shared_pointers(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect)
Set shared pointers to main domain members.
Definition: cs_property.c:628
cs_flag_t state_flag
Definition: cs_property.h:130
cs_real_t eigen_max
Definition: cs_property.h:182
Field descriptor.
Definition: cs_field.h:125
cs_xdef_t * cs_property_def_aniso_by_value(cs_property_t *pty, const char *zname, 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:1189
bool is_iso
Definition: cs_property.h:178
Structure storing the evaluation of a property and its related data.
Definition: cs_property.h:174
char *restrict name
Definition: cs_property.h:128
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
cs_flag_t process_flag
Definition: cs_property.h:131
cs_real_t ref_value
Definition: cs_property.h:138
Set of local quantities and connectivities related to a mesh cell This is a key structure for all cel...
Definition: cs_cdo_local.h:158
cs_real_t value
Definition: cs_property.h:187
cs_xdef_cw_eval_t ** get_eval_at_cell_cw
Definition: cs_property.h:158
void cs_property_destroy_all(void)
Free all cs_property_t structures and the array storing all the structures.
Definition: cs_property.c:869
Definition: cs_cdo_connect.h:76
cs_xdef_t * cs_property_def_ortho_by_value(cs_property_t *pty, const char *zname, double val[])
Define an orthotropic cs_property_t structure by value for entities related to a volume zone...
Definition: cs_property.c:1139
Definition: field.f90:27
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:911
void cs_property_set_reference_value(cs_property_t *pty, double refval)
Set the reference value associated to a cs_property_t structure This is a real number even whatever t...
Definition: cs_property.c:852
void cs_property_def_by_field(cs_property_t *pty, cs_field_t *field)
Define a cs_property_t structure thanks to a field structure.
Definition: cs_property.c:1488
cs_property_type_t type
Definition: cs_property.h:132
cs_xdef_eval_t ** get_eval_at_cell
Definition: cs_property.h:154
double cs_real_t
Floating-point value.
Definition: cs_defs.h:307
Definition: cs_cdo_quantities.h:124
#define CS_PROPERTY_ISO
Definition: cs_property.h:73
Definition: cs_property.h:109
bool need_eigen
Definition: cs_property.h:181
cs_xdef_t * cs_property_def_iso_by_value(cs_property_t *pty, const char *zname, double val)
Define an isotropic cs_property_t structure by value for entities related to a volume zone...
Definition: cs_property.c:1085
cs_xdef_t * cs_property_def_by_func(cs_property_t *pty, const char *zname, void *context, cs_xdef_eval_t *get_eval_at_cell, cs_xdef_cw_eval_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:1370
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_param_types.h:93
Definition: cs_property.h:126
const cs_property_t ** related_properties
Definition: cs_property.h:163
cs_real_t cs_property_value_in_cell(const cs_cell_mesh_t *cm, const cs_property_t *pty, cs_real_t t_eval)
Compute the value of a property at the cell center Version using a cs_cell_mesh_t structure...
Definition: cs_property.c:1888
cs_xdef_t ** defs
Definition: cs_property.h:142
Definition: cs_field_pointer.h:65
void() cs_time_func_t(int time_iter, double time, void *input, cs_real_t *retval)
Function which defines the evolution of a quantity according to the number of iteration already done...
Definition: cs_param_types.h:138
void cs_property_data_init(bool need_tensor, bool need_eigen, const cs_property_t *property, cs_property_data_t *data)
Initialize a cs_property_data_t structure. If property is NULL then one considers that this is a unit...
Definition: cs_property.c:1022
cs_real_t cs_property_get_cell_value(cs_lnum_t c_id, cs_real_t t_eval, const cs_property_t *pty)
Compute the value of a property at the cell center.
Definition: cs_property.c:1802
void cs_property_eval_at_cells(cs_real_t t_eval, 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:1547
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:136
cs_xdef_t * cs_property_def_by_time_func(cs_property_t *pty, const char *zname, cs_time_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:1248
void() cs_xdef_cw_eval_t(const cs_cell_mesh_t *cm, cs_real_t time_eval, 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_cw_eval.h:70
bool need_tensor
Definition: cs_property.h:185
void cs_property_set_option(cs_property_t *pty, cs_property_key_t key)
Set optional parameters related to a cs_property_t structure.
Definition: cs_property.c:819
cs_xdef_t * cs_property_def_by_analytic(cs_property_t *pty, const char *zname, 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:1317
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
int n_definitions
Definition: cs_property.h:141
void cs_property_get_cell_tensor(cs_lnum_t c_id, cs_real_t t_eval, const cs_property_t *pty, bool do_inversion, cs_real_t tensor[3][3])
Compute the value of the tensor attached to a property at the cell center.
Definition: cs_property.c:1762
void cs_property_get_fourier(const cs_property_t *pty, cs_real_t t_eval, double dt, cs_real_t fourier[])
Compute the Fourier number in each cell.
Definition: cs_property.c:1926
int n_related_properties
Definition: cs_property.h:162
#define END_C_DECLS
Definition: cs_defs.h:496
unsigned short int cs_flag_t
Definition: cs_defs.h:309
cs_property_t * cs_property_by_id(int id)
Find the related property definition from its id.
Definition: cs_property.c:799
bool is_unity
Definition: cs_property.h:179
const cs_property_t * property
Definition: cs_property.h:176
Definition: cs_property.h:110
void cs_property_tensor_in_cell(const cs_cell_mesh_t *cm, const cs_property_t *pty, cs_real_t t_eval, bool do_inversion, cs_real_t tensor[3][3])
Compute the value of the tensor attached to a property at the cell center Version using a cs_cell_mes...
Definition: cs_property.c:1846
cs_property_t * cs_property_add_as_product(const char *name, const cs_property_t *pty_a, const cs_property_t *pty_b)
Define a cs_property_t structure thanks to the product of two properties The type is infered from tha...
Definition: cs_property.c:711
cs_flag_t cs_property_type_t
Definition: cs_property.h:98
cs_property_key_t
List of available keys for setting options on a property.
Definition: cs_property.h:107
int cs_property_get_n_properties(void)
Retrieve the number of properties.
Definition: cs_property.c:645
Structure associated to the definition of a property relying on the cs_xdef_t structure.