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_flag.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 */
57 
59 
61 
62 /* Set of parameters attached to a property */
63 typedef struct {
64 
65  char *restrict name;
66  int id;
68 
69  /* The number of values to set depends on the type of property
70  isotropic = 1, orthotropic = 3, anisotropic = 9 */
72 
73  /* Property is up to now only defined on the whole domain (volume) */
74  int n_definitions; /* Current number of definitions used */
75  cs_xdef_t **defs; /* List of definitions */
76 
77  /* Store the definition id for each cell, NULL is only one
78  definition is set */
79  short int *def_ids;
80 
81  /* Function pointers to handle generic tasks related to a property. There
82  is one function related to each definition. Some functions may not be
83  allocated according to the kind of property */
84 
85  /* Retrieve the evaluation of the property at the cell center for each
86  definition */
88 
89  /* Same thing as the previous one but now with the usage of cellwise algo.
90  relying on a cs_cell_mesh_t structure */
92 
94 
95 /* List of available keys for setting an advection field */
96 typedef enum {
97 
100 
102 
103 /*============================================================================
104  * Global variables
105  *============================================================================*/
106 
107 /*============================================================================
108  * Public function prototypes
109  *============================================================================*/
110 
111 /*----------------------------------------------------------------------------*/
119 /*----------------------------------------------------------------------------*/
120 
121 void
123  const cs_cdo_connect_t *connect,
124  const cs_time_step_t *time_step);
125 
126 /*----------------------------------------------------------------------------*/
132 /*----------------------------------------------------------------------------*/
133 
134 int
136 
137 /*----------------------------------------------------------------------------*/
146 /*----------------------------------------------------------------------------*/
147 
149 cs_property_add(const char *name,
150  cs_property_type_t type);
151 
152 /*----------------------------------------------------------------------------*/
160 /*----------------------------------------------------------------------------*/
161 
163 cs_property_by_name(const char *name);
164 
165 /*----------------------------------------------------------------------------*/
173 /*----------------------------------------------------------------------------*/
174 
176 cs_property_by_id(int id);
177 
178 /*----------------------------------------------------------------------------*/
183 /*----------------------------------------------------------------------------*/
184 
185 void
187 
188 /*----------------------------------------------------------------------------*/
193 /*----------------------------------------------------------------------------*/
194 
195 void
197 
198 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
208 static inline bool
210 {
211  if (pty == NULL)
212  return false;
213 
215  return true;
216  else
217  return false;
218 }
219 
220 /*----------------------------------------------------------------------------*/
228 /*----------------------------------------------------------------------------*/
229 
230 static inline bool
232 {
233  if (pty == NULL)
234  return false;
235 
236  if (pty->type == CS_PROPERTY_ISO)
237  return true;
238  else
239  return false;
240 }
241 
242 /*----------------------------------------------------------------------------*/
250 /*----------------------------------------------------------------------------*/
251 
252 static inline const char *
254 {
255  if (pty == NULL)
256  return NULL;
257 
258  return pty->name;
259 }
260 
261 /*----------------------------------------------------------------------------*/
269 /*----------------------------------------------------------------------------*/
270 
271 static inline cs_property_type_t
273 {
274  if (pty == NULL)
275  return CS_PROPERTY_N_TYPES;
276 
277  return pty->type;
278 }
279 
280 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 cs_xdef_t *
296  const char *zname,
297  double val);
298 
299 /*----------------------------------------------------------------------------*/
311 /*----------------------------------------------------------------------------*/
312 
313 cs_xdef_t *
315  const char *zname,
316  double val[]);
317 
318 /*----------------------------------------------------------------------------*/
330 /*----------------------------------------------------------------------------*/
331 
332 cs_xdef_t *
334  const char *zname,
335  cs_real_t tens[3][3]);
336 
337 /*----------------------------------------------------------------------------*/
350 /*----------------------------------------------------------------------------*/
351 
352 cs_xdef_t *
354  const char *zname,
355  cs_analytic_func_t *func,
356  void *input);
357 
358 /*----------------------------------------------------------------------------*/
373 /*----------------------------------------------------------------------------*/
374 
375 cs_xdef_t *
377  const char *zname,
378  void *context,
379  cs_xdef_eval_t *get_eval_at_cell,
380  cs_xdef_eval_cw_t *get_eval_at_cell_cw);
381 
382 /*----------------------------------------------------------------------------*/
393 /*----------------------------------------------------------------------------*/
394 
395 cs_xdef_t *
397  cs_flag_t loc,
398  cs_real_t *array,
399  cs_lnum_t *index);
400 
401 /*----------------------------------------------------------------------------*/
408 /*----------------------------------------------------------------------------*/
409 
410 void
412  cs_field_t *field);
413 
414 /*----------------------------------------------------------------------------*/
422 /*----------------------------------------------------------------------------*/
423 
424 void
426  cs_real_t *array);
427 
428 /*----------------------------------------------------------------------------*/
438 /*----------------------------------------------------------------------------*/
439 
440 void
442  const cs_property_t *pty,
443  bool do_inversion,
444  cs_real_3_t *tensor);
445 
446 /*----------------------------------------------------------------------------*/
455 /*----------------------------------------------------------------------------*/
456 
457 cs_real_t
459  const cs_property_t *pty);
460 
461 /*----------------------------------------------------------------------------*/
472 /*----------------------------------------------------------------------------*/
473 
474 void
476  const cs_property_t *pty,
477  bool do_inversion,
478  cs_real_3_t *tensor);
479 
480 /*----------------------------------------------------------------------------*/
490 /*----------------------------------------------------------------------------*/
491 
492 cs_real_t
494  const cs_property_t *pty);
495 
496 /*----------------------------------------------------------------------------*/
504 /*----------------------------------------------------------------------------*/
505 
506 void
508  double dt,
509  cs_real_t fourier[]);
510 
511 /*----------------------------------------------------------------------------*/
516 /*----------------------------------------------------------------------------*/
517 
518 void
520 
521 /*----------------------------------------------------------------------------*/
522 
524 
525 #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:1234
time step descriptor
Definition: cs_time_step.h:51
#define restrict
Definition: cs_defs.h:122
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.h:66
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:320
cs_property_t * cs_property_by_name(const char *name)
Find the related property definition from its name.
Definition: cs_property.c:363
#define CS_FLAG_STATE_UNIFORM
Definition: cs_flag.h:73
Field descriptor.
Definition: cs_field.h:124
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:605
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_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:711
Definition: cs_property.h:55
char *restrict name
Definition: cs_property.h:65
cs_property_type_t
Definition: cs_property.h:52
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:284
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
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:133
void cs_property_destroy_all(void)
Free all cs_property_t structures and the array storing all the structures.
Definition: cs_property.c:408
int n_definitions
Definition: cs_property.h:74
int id
Definition: cs_property.h:66
Definition: cs_cdo_connect.h:69
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:561
static cs_property_type_t cs_property_get_type(const cs_property_t *pty)
Retrieve the type of a property.
Definition: cs_property.h:272
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:913
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:447
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:821
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:94
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:1134
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:517
Definition: cs_property.h:54
cs_property_type_t type
Definition: cs_property.h:71
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:253
static int input(void)
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:1058
cs_flag_t state_flag
Definition: cs_property.h:67
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:122
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:1169
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
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:658
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
#define END_C_DECLS
Definition: cs_defs.h:462
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:390
Definition: cs_property.h:99
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:1010
short int * def_ids
Definition: cs_property.h:79
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:756
cs_xdef_t ** defs
Definition: cs_property.h:75
Definition: cs_property.h:58
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:231
cs_property_key_t
Definition: cs_property.h:96
cs_xdef_eval_cw_t ** get_eval_at_cell_cw
Definition: cs_property.h:91
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:209
int cs_property_get_n_properties(void)
Retrieve the number of properties.
Definition: cs_property.c:303
Definition: cs_property.h:63
Definition: cs_property.h:98
cs_xdef_eval_t ** get_eval_at_cell
Definition: cs_property.h:87
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:876