programmer's documentation
cs_field.h
Go to the documentation of this file.
1 #ifndef __CS_FIELD_H__
2 #define __CS_FIELD_H__
3 
4 /*============================================================================
5  * Field management.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2016 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_defs.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*=============================================================================
41  * Macro definitions
42  *============================================================================*/
43 
44 /*
45  * Field property type
46  */
47 
48 #define CS_FIELD_INTENSIVE (1 << 0)
49 #define CS_FIELD_EXTENSIVE (1 << 1)
50 
51 /* Field category */
52 
53 #define CS_FIELD_VARIABLE (1 << 2)
54 #define CS_FIELD_PROPERTY (1 << 3)
55 #define CS_FIELD_POSTPROCESS (1 << 4)
56 #define CS_FIELD_ACCUMULATOR (1 << 5)
57 
58 #define CS_FIELD_USER (1 << 6)
59 
60 /*============================================================================
61  * Type definitions
62  *============================================================================*/
63 
64 /* Field handling error types */
65 /*----------------------------*/
66 
67 typedef enum {
68 
75 
77 
78 /* Field boundary condition descriptor (for variables) */
79 /*-----------------------------------------------------*/
80 
81 typedef struct {
82 
83  int location_id; /* Id of matching location */
84 
85  cs_real_t *a; /* Explicit coefficient */
86  cs_real_t *b; /* Implicit coefficient */
87  cs_real_t *af; /* Explicit coefficient for flux */
88  cs_real_t *bf; /* Implicit coefficient for flux */
89  cs_real_t *ad; /* Explicit coefficient for divergence */
90  cs_real_t *bd; /* Implicit coefficient for divergence */
91  cs_real_t *ac; /* Explicit coefficient for convection */
92  cs_real_t *bc; /* Implicit coefficient for convection */
93 
95 
96 /* Field descriptor */
97 /*------------------*/
98 
99 typedef struct {
100 
101  const char *name; /* Canonical name */
102 
103  int id; /* Field id */
104  int type; /* Field type flag */
105 
106  int dim; /* Field dimension */
107  bool interleaved; /* is field interleaved ? */
108 
109  int location_id; /* Id of matching location */
110 
111  int n_time_vals; /* Number of time values */
112 
113  cs_real_t **vals; /* For each active location, pointer
114  to matching values arrays
115  vals[0][:] = val
116  vals[1][:] = val_pre
117  vals[p][:] = p ith previous field
118  p < n_time_vals */
119 
120 
121  cs_real_t *val; /* For each active location, pointer
122  to matching values array */
123 
124  cs_real_t *val_pre; /* For each active location, pointer
125  to matching previous values array
126  (if n_time_vals == 2) */
127 
128  cs_field_bc_coeffs_t *bc_coeffs; /* Boundary condition coefficients,
129  for variable type fields */
130 
131  bool is_owner; /* Ownership flag for values */
132 
133 } cs_field_t;
134 
135 /*----------------------------------------------------------------------------
136  * Function pointer for structure associated to field key
137  *
138  * parameters:
139  * t <-- pointer to structure
140  *----------------------------------------------------------------------------*/
141 
142 typedef void
143 (cs_field_log_key_struct_t) (const void *t);
144 
145 /*============================================================================
146  * Global variables
147  *============================================================================*/
148 
149 /* Names for components */
150 
151 extern const char *cs_glob_field_comp_name_3[];
152 extern const char *cs_glob_field_comp_name_6[];
153 extern const char *cs_glob_field_comp_name_9[];
154 
155 /*=============================================================================
156  * Public function prototypes
157  *============================================================================*/
158 
159 /*----------------------------------------------------------------------------
160  * Return the number of defined fields.
161  *
162  * returns:
163  * number of defined fields.
164  *----------------------------------------------------------------------------*/
165 
166 int
167 cs_field_n_fields(void);
168 
169 /*----------------------------------------------------------------------------
170  * Create a field descriptor.
171  *
172  * parameters:
173  * name <-- field name
174  * type_flag <-- mask of field property and category values
175  * location_id <-- id of associated location
176  * dim <-- field dimension (number of components)
177  * interleaved <-- indicate if values are interleaved
178  * (ignored if number of components < 2)
179  * has_previous <-- maintain values at the previous time step ?
180  *
181  * returns:
182  * pointer to new field.
183  *----------------------------------------------------------------------------*/
184 
185 cs_field_t *
186 cs_field_create(const char *name,
187  int type_flag,
188  int location_id,
189  int dim,
190  bool interleaved,
191  bool has_previous);
192 
193 /*----------------------------------------------------------------------------
194  * Change the number of time values managed by a field.
195  *
196  * The minimum will never be below 1, as the current time is always handled.
197  *
198  * parameters:
199  * f <-> pointer to field structure
200  * n_time_vals <-- number of time values to maintain
201  *----------------------------------------------------------------------------*/
202 
203 void
205  int n_time_vals);
206 
207 /*----------------------------------------------------------------------------
208  * Allocate arrays for field values.
209  *
210  * parameters:
211  * f <-- pointer to field structure
212  *----------------------------------------------------------------------------*/
213 
214 void
216 
217 /*----------------------------------------------------------------------------
218  * Map existing value arrays to field descriptor.
219  *
220  * parameters:
221  * f <-> pointer to field structure
222  * val <-- pointer to array of values
223  * val_pre <-- pointer to array of previous values, or NULL
224  *----------------------------------------------------------------------------*/
225 
226 void
228  cs_real_t *val,
229  cs_real_t *val_pre);
230 
231 /*----------------------------------------------------------------------------
232  * Allocate boundary condition coefficient arrays.
233  *
234  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
235  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
236  *
237  * Boundary condition coefficients are not currently supported for other
238  * locations (though support could be added by mapping a boundary->location
239  * indirection array in the cs_mesh_location_t structure).
240  *
241  * For multidimensional fields, arrays are assumed to have the same
242  * interleaving behavior as the field, unless components are coupled.
243  *
244  * For multidimensional fields with coupled components, interleaving
245  * is the norm, and implicit b and bf coefficient arrays are arrays of
246  * block matrices, not vectors, so the number of entries for each boundary
247  * face is dim*dim instead of dim.
248  *
249  * parameters:
250  * f <-- pointer to field structure
251  * have_flux_bc <-- if true, flux BC coefficients (af and bf) are added
252  * have_mom_bc <-- if true, div BC coefficients (ad and bd) are added
253  * have_conv_bc <-- if true, convection BC coefficients (ac and bc) are added
254  *----------------------------------------------------------------------------*/
255 
256 void
258  bool have_flux_bc,
259  bool have_mom_bc,
260  bool have_conv_bc);
261 
262 /*----------------------------------------------------------------------------*/
263 /* Initialize boundary condition coefficients arrays.
264  *
265  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
266  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
267  *
268  * Boundary condition coefficients are not currently supported for other
269  * locations (though support could be added by mapping a boundary->location
270  * indirection array in the cs_mesh_location_t structure).
271  *
272  * For multidimensional fields, arrays are assumed to have the same
273  * interleaving behavior as the field, unless components are coupled.
274  *
275  * For multidimensional fields with coupled components, interleaving
276  * is the norm, and implicit b and bf coefficient arrays are arrays of
277  * block matrices, not vectors, so the number of entries for each boundary
278  * face is dim*dim instead of dim.
279  *
280  * parameters:
281  * f <-> pointer to field structure
282  *----------------------------------------------------------------------------*/
283 
284 void
286 
287 /*----------------------------------------------------------------------------
288  * Copy current field values to previous values if applicable.
289  *
290  * For fields with only one time value, or values not allocated yet,
291  * this is a no-op.
292  *
293  * parameters:
294  * f <-> pointer to field structure
295  *----------------------------------------------------------------------------*/
296 
297 void
299 
300 /*----------------------------------------------------------------------------
301  * Destroy all defined fields.
302  *----------------------------------------------------------------------------*/
303 
304 void
306 
307 /*----------------------------------------------------------------------------
308  * Allocate arrays for all defined fields based on their location.
309  *
310  * Location sized must thus be known.
311  *
312  * Fields that do not own their data should all have been mapped at this
313  * stage, and are checked.
314  *----------------------------------------------------------------------------*/
315 
316 void
318 
319 /*----------------------------------------------------------------------------
320  * Return a pointer to a field based on its id.
321  *
322  * This function requires that a field of the given id is defined.
323  *
324  * parameters:
325  * id <-- field id
326  *
327  * returns:
328  * pointer to the field structure
329  *----------------------------------------------------------------------------*/
330 
331 cs_field_t *
332 cs_field_by_id(int id);
333 
334 /*----------------------------------------------------------------------------
335  * Return a pointer to a field based on its name.
336  *
337  * This function requires that a field of the given name is defined.
338  *
339  * parameters:
340  * name <-- field name
341  *
342  * returns:
343  * pointer to the field structure
344  *----------------------------------------------------------------------------*/
345 
346 cs_field_t *
347 cs_field_by_name(const char *name);
348 
349 /*----------------------------------------------------------------------------
350  * Return a pointer to a field based on its name if present.
351  *
352  * If no field of the given name is defined, NULL is returned.
353  *
354  * parameters:
355  * name <-- field name
356  *
357  * returns:
358  * pointer to the field structure, or NULL
359  *----------------------------------------------------------------------------*/
360 
361 cs_field_t *
362 cs_field_by_name_try(const char *name);
363 
364 /*----------------------------------------------------------------------------
365  * Return the id of a defined field based on its name.
366  *
367  * If no field with the given name exists, -1 is returned.
368  *
369  * parameters:
370  * name <-- field name
371  *
372  * returns:
373  * id the field, or -1 if not found
374  *----------------------------------------------------------------------------*/
375 
376 int
377 cs_field_id_by_name(const char *name);
378 
379 /*----------------------------------------------------------------------------
380  * Return the id of a defined field and an associated component
381  * based on a component name.
382  *
383  * If no field with the given name exists, -1 is returned.
384  *
385  * parameters:
386  * name <-- field or field+component name
387  * f_id --> field id, or -1 if no match was found
388  * c_id --> component id, or -1 for all components
389  *----------------------------------------------------------------------------*/
390 
391 void
392 cs_field_component_id_by_name(const char *name,
393  int *f_id,
394  int *c_id);
395 
396 /*----------------------------------------------------------------------------
397  * Return an id associated with a given key name.
398  *
399  * The key must have been defined previously.
400  *
401  * parameters:
402  * name <-- key name
403  *
404  * returns:
405  * id associated with key
406  *----------------------------------------------------------------------------*/
407 
408 int
409 cs_field_key_id(const char *name);
410 
411 /*----------------------------------------------------------------------------
412  * Return an id associated with a given key name if present.
413  *
414  * If the key has not been defined previously, -1 is returned.
415  *
416  * parameters:
417  * name <-- key name
418  *
419  * returns:
420  * id associated with key, or -1
421  *----------------------------------------------------------------------------*/
422 
423 int
424 cs_field_key_id_try(const char *name);
425 
426 /*----------------------------------------------------------------------------
427  * Define a key for an integer value by its name and return an associated id.
428  *
429  * If the key has already been defined, its previous default value is replaced
430  * by the current value, and its id is returned.
431  *
432  * parameters:
433  * name <-- key name
434  * default_value <-- default value associated with key
435  * type flag <-- mask associated with field types with which the
436  * key may be associated, or 0
437  *
438  * returns:
439  * id associated with key
440  *----------------------------------------------------------------------------*/
441 
442 int
443 cs_field_define_key_int(const char *name,
444  int default_value,
445  int type_flag);
446 
447 /*----------------------------------------------------------------------------
448  * Define a key for an floating point value by its name and return an
449  * associated id.
450  *
451  * If the key has already been defined, its previous default value is replaced
452  * by the current value, and its id is returned.
453  *
454  * parameters:
455  * name <-- key name
456  * default_value <-- default value associated with key
457  * type flag <-- mask associated with field types with which the
458  * key may be associated, or 0
459  *
460  * returns:
461  * id associated with key
462  *----------------------------------------------------------------------------*/
463 
464 int
465 cs_field_define_key_double(const char *name,
466  double default_value,
467  int type_flag);
468 
469 /*----------------------------------------------------------------------------
470  * Define a key for an string point value by its name and return an
471  * associated id.
472  *
473  * If the key has already been defined, its previous default value is replaced
474  * by the current value, and its id is returned.
475  *
476  * parameters:
477  * name <-- key name
478  * default_value <-- default value associated with key
479  * type flag <-- mask associated with field types with which the
480  * key may be associated, or 0
481  *
482  * returns:
483  * id associated with key
484  *----------------------------------------------------------------------------*/
485 
486 int
487 cs_field_define_key_str(const char *name,
488  const char *default_value,
489  int type_flag);
490 
491 /*----------------------------------------------------------------------------
492  * Define a key for a structure value by its name and return an
493  * associated id.
494  *
495  * If the key has already been defined, its previous default value is replaced
496  * by the current value, and its id is returned.
497  *
498  * parameters:
499  * name <-- key name
500  * default_value <-- pointer to default value associated with key
501  * log_funct <-- pointer to logging function
502  * size <-- sizeof structure
503  * type_flag <-- mask associated with field types with which
504  * the key may be associated, or 0
505  *
506  * returns:
507  * id associated with key
508  *----------------------------------------------------------------------------*/
509 
510 int
511 cs_field_define_key_struct(const char *name,
512  const void *default_value,
513  cs_field_log_key_struct_t *log_func,
514  size_t size,
515  int type_flag);
516 
517 /*----------------------------------------------------------------------------
518  * Define a sub key.
519  *
520  * The sub key is the same type as the parent key.
521  *
522  * For a given field, when querying a sub key's value and that value has not
523  * been set, the query will return the value of the parent key.
524  *
525  * parameters:
526  * name <-- key name
527  * parent_id <-- parent key id
528  *
529  * returns:
530  * id associated with key
531  *----------------------------------------------------------------------------*/
532 
533 int
534 cs_field_define_sub_key(const char *name,
535  int parent_id);
536 
537 /*----------------------------------------------------------------------------
538  * Destroy all defined field keys and associated values.
539  *----------------------------------------------------------------------------*/
540 
541 void
543 
544 /*----------------------------------------------------------------------------
545  * Get the type flag associated with a given key id.
546  *
547  * If the key has not been defined previously, -1 is returned.
548  *
549  * parameters:
550  * key_id <-- id of associated key
551  *
552  * returns:
553  * type flag associated with key, or -1
554  *----------------------------------------------------------------------------*/
555 
556 int
557 cs_field_key_flag(int key_id);
558 
559 /*----------------------------------------------------------------------------
560  * Disable logging setup values associated with a given key.
561  *
562  * This is useful when a key is used not for setup purposes, but to track
563  * values associated with a field, such as convergence or performance data.
564  *
565  * parameters:
566  * key_id <-- id of associated key
567  *----------------------------------------------------------------------------*/
568 
569 void
571 
572 /*----------------------------------------------------------------------------
573  * Query if a given key has been set for a field.
574  *
575  * If the key id is not valid, or the field category is not
576  * compatible, a fatal error is provoked.
577  *
578  * parameters:
579  * f <-- pointer to field structure
580  * key_id <-- id of associated key
581  *
582  * returns:
583  * true if the key has been set for this field, false otherwise
584  *----------------------------------------------------------------------------*/
585 
586 bool
588  int key_id);
589 
590 /*----------------------------------------------------------------------------
591  * Query if a given key has been locked for a field.
592  *
593  * If the key id is not valid, or the field category is not
594  * compatible, a fatal error is provoked.
595  *
596  * parameters:
597  * f <-- pointer to field structure
598  * key_id <-- id of associated key
599  *
600  * returns:
601  * true if the key has been locked for this field, false otherwise
602  *----------------------------------------------------------------------------*/
603 
604 bool
606  int key_id);
607 
608 /*----------------------------------------------------------------------------
609  * Lock a field relative to a given key.
610  *
611  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
612  * If the field category is not compatible with the key (as defined
613  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
614  *
615  * parameters:
616  * f <-- pointer to field structure
617  * key_id <-- id of associated key
618  * value <-- value associated with key
619  *
620  * returns:
621  * 0 in case of success, > 1 in case of error
622  *----------------------------------------------------------------------------*/
623 
624 int
626  int key_id);
627 
628 /*----------------------------------------------------------------------------
629  * Assign a integer value for a given key to a field.
630  *
631  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
632  * If the field category is not compatible with the key (as defined
633  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
634  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
635  * If the key value has been locked, CS_FIELD_LOCKED is returned.
636  *
637  * parameters:
638  * f <-- pointer to field structure
639  * key_id <-- id of associated key
640  * value <-- value associated with key
641  *
642  * returns:
643  * 0 in case of success, > 1 in case of error
644  *----------------------------------------------------------------------------*/
645 
646 int
648  int key_id,
649  int value);
650 
651 /*----------------------------------------------------------------------------
652  * Return a integer value for a given key associated with a field.
653  *
654  * If the key id is not valid, or the value type or field category is not
655  * compatible, a fatal error is provoked.
656  *
657  * parameters:
658  * f <-- pointer to field structure
659  * key_id <-- id of associated key
660  *
661  * returns:
662  * integer value associated with the key id for this field
663  *----------------------------------------------------------------------------*/
664 
665 int
667  int key_id);
668 
669 /*----------------------------------------------------------------------------
670  * Assign a floating point value for a given key to a field.
671  *
672  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
673  * If the field category is not compatible with the key (as defined
674  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
675  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
676  * If the key value has been locked, CS_FIELD_LOCKED is returned.
677  *
678  * parameters:
679  * f <-- pointer to field structure
680  * key_id <-- id of associated key
681  * value <-- value associated with key
682  *
683  * returns:
684  * 0 in case of success, > 1 in case of error
685  *----------------------------------------------------------------------------*/
686 
687 int
689  int key_id,
690  double value);
691 
692 /*----------------------------------------------------------------------------
693  * Return a floating point value for a given key associated with a field.
694  *
695  * If the key id is not valid, or the value type or field category is not
696  * compatible, a fatal error is provoked.
697  *
698  * parameters:
699  * f <-- pointer to field structure
700  * key_id <-- id of associated key
701  *
702  * returns:
703  * floating point value associated with the key id for this field
704  *----------------------------------------------------------------------------*/
705 
706 double
708  int key_id);
709 
710 /*----------------------------------------------------------------------------
711  * Assign a character string value for a given key to a field.
712  *
713  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
714  * If the field category is not compatible with the key (as defined
715  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
716  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
717  * If the key value has been locked, CS_FIELD_LOCKED is returned.
718  *
719  * parameters:
720  * f <-- pointer to field structure
721  * key_id <-- id of associated key
722  * str <-- string associated with key
723  *
724  * returns:
725  * 0 in case of success, > 1 in case of error
726  *----------------------------------------------------------------------------*/
727 
728 int
730  int key_id,
731  const char *str);
732 
733 /*----------------------------------------------------------------------------
734  * Return a string for a given key associated with a field.
735  *
736  * If the key id is not valid, or the value type or field category is not
737  * compatible, a fatal error is provoked.
738  *
739  * parameters:
740  * f <-- pointer to field structure
741  * key_id <-- id of associated key
742  *
743  * returns:
744  * pointer to character string associated with the key id for this field
745  *----------------------------------------------------------------------------*/
746 
747 const char *
749  int key_id);
750 
751 
752 /*----------------------------------------------------------------------------
753  * Assign a simple structure for a given key to a field.
754  *
755  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
756  * If the field category is not compatible with the key (as defined
757  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
758  * If the key value has been locked, CS_FIELD_LOCKED is returned.
759  *
760  * parameters:
761  * f <-- pointer to field structure
762  * key_id <-- id of associated key
763  * s <-- structure associated with key
764  *
765  * returns:
766  * 0 in case of success, > 1 in case of error
767  *----------------------------------------------------------------------------*/
768 
769 int
771  int key_id,
772  void *s);
773 
774 /*----------------------------------------------------------------------------
775  * Return a structure for a given key associated with a field.
776  *
777  * If the key id is not valid, or the value type or field category is not
778  * compatible, a fatal error is provoked.
779  *
780  * parameters:
781  * f <-- pointer to field structure
782  * key_id <-- id of associated key
783  * s <-- structure associated with key
784  *
785  * returns:
786  * pointer to structure associated with the key id for this field
787  * (same as s)
788  *----------------------------------------------------------------------------*/
789 
790 const void *
792  int key_id,
793  void *s);
794 
795 /*----------------------------------------------------------------------------
796  * Print info relative to all field definitions to log file.
797  *----------------------------------------------------------------------------*/
798 
799 void
800 cs_field_log_defs(void);
801 
802 /*----------------------------------------------------------------------------
803  * Print info relative to a given field to log file.
804  *
805  * parameters:
806  * f <-- pointer to field structure
807  * log_keywords <-- log level for keywords (0: do not log,
808  * 1: log non-default values, 2: log all)
809  *----------------------------------------------------------------------------*/
810 
811 void
813  int log_keywords);
814 
815 /*----------------------------------------------------------------------------
816  * Print info relative to all defined fields to log file.
817  *
818  * parameters:
819  * log_keywords <-- log level for keywords (0: do not log,
820  * 1: log non-default values, 2: log all)
821  *----------------------------------------------------------------------------*/
822 
823 void
824 cs_field_log_fields(int log_keywords);
825 
826 /*----------------------------------------------------------------------------
827  * Print info relative to all key definitions to log file.
828  *----------------------------------------------------------------------------*/
829 
830 void
832 
833 /*----------------------------------------------------------------------------
834  * Print info relative to a given field key to log file.
835  *
836  * parameters:
837  * int key_id <-- id of associated key
838  * log_defaults <-- if true, log default field values in addition to
839  * defined field values
840  *----------------------------------------------------------------------------*/
841 
842 void
843 cs_field_log_key_vals(int key_id,
844  bool log_defaults);
845 
846 /*----------------------------------------------------------------------------
847  * Print info relative to all given field keys to log file.
848  *
849  * parameters:
850  * log_defaults <-- if true, log default field values in addition to
851  * defined field values
852  *----------------------------------------------------------------------------*/
853 
854 void
855 cs_field_log_all_key_vals(bool log_defaults);
856 
857 /*----------------------------------------------------------------------------
858  * Define base keys.
859  *
860  * Keys defined by this function are:
861  * "label" (string)
862  * "log" (integer)
863  * "post_vis" (integer)
864  * "post_probes" (integer)
865  * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
866  * "moment_id" (integer, restricted to
867  * CS_FIELD_ACCUMULATOR | CS_FIELD_POSTPROCESS);
868  *
869  * A recommened practice for different submodules would be to use
870  * "cs_<module>_key_init() functions to define keys specific to those modules.
871  *----------------------------------------------------------------------------*/
872 
873 void
875 
876 /*----------------------------------------------------------------------------
877  * Return a label associated with a field.
878  *
879  * If the "label" key has been set for this field, its associated string
880  * is returned. Otherwise, the field's name is returned.
881  *
882  * parameters:
883  * f <-- pointer to field structure
884  *
885  * returns:
886  * pointer to character string associated with label for this field
887  *----------------------------------------------------------------------------*/
888 
889 const char *
891 
892 /*----------------------------------------------------------------------------*/
893 
895 
896 #endif /* __CS_FIELD_H__ */
int cs_field_get_key_int(const cs_field_t *f, int key_id)
Return a integer value for a given key associated with a field.
Definition: cs_field.c:2644
const char * cs_field_get_key_str(const cs_field_t *f, int key_id)
Return a string for a given key associated with a field.
Definition: cs_field.c:2874
int cs_field_set_key_int(cs_field_t *f, int key_id, int value)
Assign a integer value for a given key to a field.
Definition: cs_field.c:2598
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:128
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2161
void cs_field_init_bc_coeffs(cs_field_t *f)
Initialize boundary condition coefficients arrays.
Definition: cs_field.c:1697
cs_real_t * b
Definition: cs_field.h:86
int location_id
Definition: cs_field.h:109
Field descriptor.
Definition: cs_field.h:99
const char * cs_glob_field_comp_name_6[]
void cs_field_log_defs(void)
Print info relative to all field definitions to log file.
Definition: cs_field.c:3050
int cs_field_define_key_str(const char *name, const char *default_value, int type_flag)
Define a key for a string value by its name and return an associated id.
Definition: cs_field.c:2290
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.c:2447
int dim
Definition: cs_field.h:106
const char * cs_glob_field_comp_name_3[]
void cs_field_map_values(cs_field_t *f, cs_real_t *val, cs_real_t *val_pre)
Map existing value arrays to field descriptor.
Definition: cs_field.c:1511
const void * cs_field_get_key_struct(const cs_field_t *f, int key_id, void *s)
Return a structure for a given key associated with a field.
Definition: cs_field.c:2991
#define BEGIN_C_DECLS
Definition: cs_defs.h:419
cs_field_t * cs_field_create(const char *name, int type_flag, int location_id, int dim, bool interleaved, bool has_previous)
Create a field descriptor.
Definition: cs_field.c:1385
bool cs_field_is_key_set(const cs_field_t *f, int key_id)
Query if a given key has been set for a field.
Definition: cs_field.c:2493
cs_real_t * val_pre
Definition: cs_field.h:124
void cs_field_allocate_values(cs_field_t *f)
Allocate arrays for field values.
Definition: cs_field.c:1480
int cs_field_define_key_struct(const char *name, const void *default_value, cs_field_log_key_struct_t *log_func, size_t size, int type_flag)
Define a key for a structure value by its name and return an associated id.
Definition: cs_field.c:2340
Definition: cs_field.h:69
void cs_field_log_all_key_vals(bool log_defaults)
Print info relative to all given field keys to log file.
Definition: cs_field.c:3632
int cs_field_lock_key(cs_field_t *f, int key_id)
Lock a field relative to a given key.
Definition: cs_field.c:2556
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.c:2389
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.c:1947
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:2188
cs_real_t * val
Definition: cs_field.h:121
const char * cs_glob_field_comp_name_9[]
void cs_field_define_keys_base(void)
Define base keys.
Definition: cs_field.c:3664
int cs_field_set_key_double(cs_field_t *f, int key_id, double value)
Assign a floating point value for a given key to a field.
Definition: cs_field.c:2711
Field boundary condition descriptor (for variables)
Definition: cs_field.h:81
void cs_field_component_id_by_name(const char *name, int *f_id, int *c_id)
Return the id of a defined field and an associated component based on a component name...
Definition: cs_field.c:2072
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.c:1892
const char * name
Definition: cs_field.h:101
Definition: cs_field.h:73
void cs_field_key_disable_setup_log(int key_id)
Disable logging setup values associated with a given key.
Definition: cs_field.c:2471
void cs_field_log_key_vals(int key_id, bool log_defaults)
Print info relative to a given field key to log file.
Definition: cs_field.c:3508
cs_real_t * bd
Definition: cs_field.h:90
cs_real_t ** vals
Definition: cs_field.h:113
Definition: cs_field.h:70
Definition: cs_field.h:74
cs_real_t * bf
Definition: cs_field.h:88
int type
Definition: cs_field.h:104
int cs_field_set_key_str(cs_field_t *f, int key_id, const char *str)
Assign a character string for a given key to a field.
Definition: cs_field.c:2824
bool cs_field_is_key_locked(const cs_field_t *f, int key_id)
Query if a given key has been locked for a field.
Definition: cs_field.c:2524
Definition: cs_field.h:71
int cs_field_id_by_name(const char *name)
Return the id of a defined field based on its name.
Definition: cs_field.c:2051
int id
Definition: cs_field.h:103
cs_real_t * ad
Definition: cs_field.h:89
void cs_field_destroy_all_keys(void)
Destroy all defined field keys and associated values.
Definition: cs_field.c:2415
int cs_field_define_key_double(const char *name, double default_value, int type_flag)
Define a key for an floating point value by its name and return an associated id. ...
Definition: cs_field.c:2253
cs_real_t * bc
Definition: cs_field.h:92
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.c:2002
int n_time_vals
Definition: cs_field.h:111
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.c:1363
bool interleaved
Definition: cs_field.h:107
const char * cs_field_get_label(const cs_field_t *f)
Return a label associated with a field.
Definition: cs_field.c:3691
#define END_C_DECLS
Definition: cs_defs.h:420
double cs_real_t
Definition: cs_defs.h:296
cs_real_t * ac
Definition: cs_field.h:91
int cs_field_set_key_struct(cs_field_t *f, int key_id, void *s)
Assign a simple structure for a given key to a field.
Definition: cs_field.c:2941
void cs_field_set_n_time_vals(cs_field_t *f, int n_time_vals)
Change the number of time values managed by a field.
Definition: cs_field.c:1421
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.c:3390
cs_real_t * af
Definition: cs_field.h:87
Definition: cs_field_pointer.h:92
int location_id
Definition: cs_field.h:83
void cs_field_log_fields(int log_keywords)
Print info relative to all defined fields to log file.
Definition: cs_field.c:3329
void cs_field_log_info(const cs_field_t *f, int log_keywords)
Print info relative to a given field to log file.
Definition: cs_field.c:3190
void cs_field_current_to_previous(cs_field_t *f)
Copy current field values to previous values if applicable.
Definition: cs_field.c:1834
cs_field_t * cs_field_by_name_try(const char *name)
Return a pointer to a field based on its name if present.
Definition: cs_field.c:2028
Definition: cs_field.h:72
bool is_owner
Definition: cs_field.h:131
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:1978
double cs_field_get_key_double(const cs_field_t *f, int key_id)
Return a floating point value for a given key associated with a field.
Definition: cs_field.c:2757
int cs_field_define_key_int(const char *name, int default_value, int type_flag)
Define a key for an integer value by its name and return an associated id.
Definition: cs_field.c:2216
cs_field_error_type_t
Definition: cs_field.h:67
cs_real_t * a
Definition: cs_field.h:85
void() cs_field_log_key_struct_t(const void *t)
Definition: cs_field.h:143
void cs_field_allocate_bc_coeffs(cs_field_t *f, bool have_flux_bc, bool have_mom_bc, bool have_conv_bc)
Allocate boundary condition coefficients arrays.
Definition: cs_field.c:1564