My Project
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-2019 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_flag.h"
35 #include "cs_param.h"
36 #include "cs_xdef.h"
37 #include "cs_xdef_cw_eval.h"
38 #include "cs_xdef_eval.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
55 #define CS_PROPERTY_POST_FOURIER (1 << 0)
56 
59 /*============================================================================
60  * Type definitions
61  *============================================================================*/
62 
70 typedef enum {
71 
74 
76 
93 typedef enum {
94 
98 
100 
102 
103 /* Set of parameters attached to a property */
104 typedef struct {
105 
106  char *restrict name;
107  int id;
110 
111  /* The number of values to set depends on the type of property
112  isotropic = 1, orthotropic = 3, anisotropic = 9 */
114 
115  /* Property is up to now only defined on the whole domain (volume) */
116  int n_definitions; /* Current number of definitions used */
117  cs_xdef_t **defs; /* List of definitions */
118 
119  /* Store the definition id for each cell, NULL if there is only one
120  definition set */
121  short int *def_ids;
122 
123  /* Function pointers to handle generic tasks related to a property. There
124  is one function related to each definition. Some functions may not be
125  allocated according to the kind of property */
126 
127  /* Retrieve the evaluation of the property at the cell center for each
128  definition */
130 
131  /* Same thing as the previous one but now with the usage of cellwise algo.
132  relying on a cs_cell_mesh_t structure */
134 
135 } cs_property_t;
136 
137 /*============================================================================
138  * Global variables
139  *============================================================================*/
140 
141 /*============================================================================
142  * Public function prototypes
143  *============================================================================*/
144 
145 /*----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------*/
153 
154 void
156  const cs_cdo_connect_t *connect);
157 
158 /*----------------------------------------------------------------------------*/
164 /*----------------------------------------------------------------------------*/
165 
166 int
168 
169 /*----------------------------------------------------------------------------*/
178 /*----------------------------------------------------------------------------*/
179 
181 cs_property_add(const char *name,
183 
184 /*----------------------------------------------------------------------------*/
192 /*----------------------------------------------------------------------------*/
193 
195 cs_property_by_name(const char *name);
196 
197 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
208 cs_property_by_id(int id);
209 
210 /*----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------*/
218 
219 void
221  cs_property_key_t key);
222 
223 /*----------------------------------------------------------------------------*/
228 /*----------------------------------------------------------------------------*/
229 
230 void
232 
233 /*----------------------------------------------------------------------------*/
238 /*----------------------------------------------------------------------------*/
239 
240 void
242 
243 /*----------------------------------------------------------------------------*/
251 /*----------------------------------------------------------------------------*/
252 
253 static inline bool
255 {
256  if (pty == NULL)
257  return false;
258 
260  return true;
261  else
262  return false;
263 }
264 
265 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 static inline bool
277 {
278  if (pty == NULL)
279  return false;
280 
281  if (pty->type == CS_PROPERTY_ISO)
282  return true;
283  else
284  return false;
285 }
286 
287 /*----------------------------------------------------------------------------*/
295 /*----------------------------------------------------------------------------*/
296 
297 static inline const char *
299 {
300  if (pty == NULL)
301  return NULL;
302 
303  return pty->name;
304 }
305 
306 /*----------------------------------------------------------------------------*/
314 /*----------------------------------------------------------------------------*/
315 
316 static inline cs_property_type_t
318 {
319  if (pty == NULL)
320  return CS_PROPERTY_N_TYPES;
321 
322  return pty->type;
323 }
324 
325 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 cs_xdef_t *
341  const char *zname,
342  double val);
343 
344 /*----------------------------------------------------------------------------*/
356 /*----------------------------------------------------------------------------*/
357 
358 cs_xdef_t *
360  const char *zname,
361  double val[]);
362 
363 /*----------------------------------------------------------------------------*/
375 /*----------------------------------------------------------------------------*/
376 
377 cs_xdef_t *
379  const char *zname,
380  cs_real_t tens[3][3]);
381 
382 /*----------------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------------*/
396 
397 cs_xdef_t *
399  const char *zname,
400  cs_time_func_t *func,
401  void *input);
402 
403 /*----------------------------------------------------------------------------*/
416 /*----------------------------------------------------------------------------*/
417 
418 cs_xdef_t *
420  const char *zname,
421  cs_analytic_func_t *func,
422  void *input);
423 
424 /*----------------------------------------------------------------------------*/
439 /*----------------------------------------------------------------------------*/
440 
441 cs_xdef_t *
443  const char *zname,
444  void *context,
445  cs_xdef_eval_t *get_eval_at_cell,
446  cs_xdef_cw_eval_t *get_eval_at_cell_cw);
447 
448 /*----------------------------------------------------------------------------*/
461 /*----------------------------------------------------------------------------*/
462 
463 cs_xdef_t *
465  cs_flag_t loc,
466  cs_real_t *array,
467  bool is_owner,
468  cs_lnum_t *index);
469 
470 /*----------------------------------------------------------------------------*/
477 /*----------------------------------------------------------------------------*/
478 
479 void
481  cs_field_t *field);
482 
483 /*----------------------------------------------------------------------------*/
492 /*----------------------------------------------------------------------------*/
493 
494 void
496  const cs_property_t *pty,
497  cs_real_t *array);
498 
499 /*----------------------------------------------------------------------------*/
510 /*----------------------------------------------------------------------------*/
511 
512 void
514  cs_real_t t_eval,
515  const cs_property_t *pty,
516  bool do_inversion,
517  cs_real_3_t *tensor);
518 
519 /*----------------------------------------------------------------------------*/
529 /*----------------------------------------------------------------------------*/
530 
531 cs_real_t
533  cs_real_t t_eval,
534  const cs_property_t *pty);
535 
536 /*----------------------------------------------------------------------------*/
548 /*----------------------------------------------------------------------------*/
549 
550 void
552  const cs_property_t *pty,
553  cs_real_t t_eval,
554  bool do_inversion,
555  cs_real_3_t *tensor);
556 
557 /*----------------------------------------------------------------------------*/
568 /*----------------------------------------------------------------------------*/
569 
570 cs_real_t
572  const cs_property_t *pty,
573  cs_real_t t_eval);
574 
575 /*----------------------------------------------------------------------------*/
584 /*----------------------------------------------------------------------------*/
585 
586 void
588  cs_real_t t_eval,
589  double dt,
590  cs_real_t fourier[]);
591 
592 /*----------------------------------------------------------------------------*/
597 /*----------------------------------------------------------------------------*/
598 
599 void
601 
602 /*----------------------------------------------------------------------------*/
603 
605 
606 #endif /* __CS_PROPERTY_H__ */
input
static int input(void)
cs_property_def_by_analytic
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:764
cs_property_def_ortho_by_value
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:599
cs_xdef_cw_eval.h
cs_xdef_t
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:126
cs_property_add
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:293
field
Definition: field.f90:27
restrict
#define restrict
Definition: cs_defs.h:127
cs_property_get_n_properties
int cs_property_get_n_properties(void)
Retrieve the number of properties.
Definition: cs_property.c:276
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:315
cs_property_t::id
int id
Definition: cs_property.h:107
cs_property_type_t
cs_property_type_t
Type of property to consider.
Definition: cs_property.h:93
cs_property_set_option
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:383
cs_property_log_setup
void cs_property_log_setup(void)
Print a summary of the settings for all defined cs_property_t structures.
Definition: cs_property.c:1361
CS_FLAG_STATE_UNIFORM
#define CS_FLAG_STATE_UNIFORM
Definition: cs_flag.h:76
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_property_finalize_setup
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:451
cs_property_set_shared_pointers
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:259
cs_xdef_cw_eval_t
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
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_property_t::name
char *restrict name
Definition: cs_property.h:106
CS_PTYKEY_N_KEYS
Definition: cs_property.h:73
cs_property_t::process_flag
cs_flag_t process_flag
Definition: cs_property.h:109
cs_property_by_name
cs_property_t * cs_property_by_name(const char *name)
Find the related property definition from its name.
Definition: cs_property.c:336
cs_property_def_by_func
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:817
cs_property_t::type
cs_property_type_t type
Definition: cs_property.h:113
cs_property_destroy_all
void cs_property_destroy_all(void)
Free all cs_property_t structures and the array storing all the structures.
Definition: cs_property.c:412
cs_property_t::n_definitions
int n_definitions
Definition: cs_property.h:116
cs_property_t::state_flag
cs_flag_t state_flag
Definition: cs_property.h:108
cs_xdef.h
cs_time_func_t
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.h:88
cs_property_def_by_field
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:931
cs_property_eval_at_cells
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:987
cs_property_get_type
static cs_property_type_t cs_property_get_type(const cs_property_t *pty)
Retrieve the type of a property.
Definition: cs_property.h:317
cs_property_def_iso_by_value
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:555
cs_xdef_eval_t
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
CS_PROPERTY_ANISO
Definition: cs_property.h:97
cs_property_get_cell_tensor
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_3_t *tensor)
Compute the value of the tensor attached a property at the cell center.
Definition: cs_property.c:1026
cs_property_def_by_time_func
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:696
cs_cdo_quantities_t
Definition: cs_cdo_quantities.h:94
cs_property_t
Definition: cs_property.h:104
cs_property_by_id
cs_property_t * cs_property_by_id(int id)
Find the related property definition from its id.
Definition: cs_property.c:363
CS_PTYKEY_POST_FOURIER
Definition: cs_property.h:72
CS_PROPERTY_N_TYPES
Definition: cs_property.h:99
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_cdo_connect_t
Definition: cs_cdo_connect.h:74
cs_property_t::def_ids
short int * def_ids
Definition: cs_property.h:121
cs_property_is_uniform
static bool cs_property_is_uniform(const cs_property_t *pty)
returns true if the property is uniform, otherwise false
Definition: cs_property.h:254
cs_analytic_func_t
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,...
Definition: cs_param.h:66
cs_flag.h
cs_property_tensor_in_cell
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_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:1178
cs_xdef_eval.h
cs_property_get_cell_value
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:1126
cs_property_get_name
static const char * cs_property_get_name(const cs_property_t *pty)
Retrieve the name of a property.
Definition: cs_property.h:298
cs_property_t::defs
cs_xdef_t ** defs
Definition: cs_property.h:117
cs_property_def_aniso_by_value
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:643
cs_property_t::get_eval_at_cell
cs_xdef_eval_t ** get_eval_at_cell
Definition: cs_property.h:129
cs_property_t::get_eval_at_cell_cw
cs_xdef_cw_eval_t ** get_eval_at_cell_cw
Definition: cs_property.h:133
cs_property_key_t
cs_property_key_t
List of available keys for setting options on a property.
Definition: cs_property.h:70
cs_property_def_by_array
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:864
cs_flag_t
unsigned short int cs_flag_t
Definition: cs_defs.h:304
dt
Definition: cs_field_pointer.h:65
CS_PROPERTY_ISO
Definition: cs_property.h:95
cs_property_value_in_cell
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:1257
CS_PROPERTY_ORTHO
Definition: cs_property.h:96
cs_property_is_isotropic
static bool cs_property_is_isotropic(const cs_property_t *pty)
returns true if the property is isotropic, otherwise false
Definition: cs_property.h:276
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_cell_mesh_t
Set of local quantities and connectivities related to a mesh cell This is a key structure for all cel...
Definition: cs_cdo_local.h:146
type
void const cs_int_t * type
Definition: cs_measures_util.h:425
cs_param.h
cs_property_get_fourier
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:1296