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-2015 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  * Return a field matching a given name and attributes,
195  * creating it if necessary.
196  *
197  * If a field with the same name but different attributes is present,
198  * this is considered an error.
199  *
200  * The default number of time values associated with a field created through
201  * this function is 1. To modify it, use cs_field_set_n_time_vals().
202  *
203  * parameters:
204  * name <-- field name
205  * type_flag <-- mask of field property and category values
206  * location_id <-- id of associated location
207  * dim <-- field dimension (number of components)
208  * interleaved <-- indicate if values ar interleaved
209  * (ignored if number of components < 2)
210  *
211  * returns:
212  * pointer to field
213  *----------------------------------------------------------------------------*/
214 
215 cs_field_t *
216 cs_field_find_or_create(const char *name,
217  int type_flag,
218  int location_id,
219  int dim,
220  bool interleaved);
221 
222 /*----------------------------------------------------------------------------
223  * Change the number of time values managed by a field.
224  *
225  * The minimum will never be below 1, as the current time is always handled.
226  *
227  * parameters:
228  * f <-> pointer to field structure
229  * n_time_vals <-- number of time values to maintain
230  *----------------------------------------------------------------------------*/
231 
232 void
234  int n_time_vals);
235 
236 /*----------------------------------------------------------------------------
237  * Allocate arrays for field values.
238  *
239  * parameters:
240  * f <-- pointer to field structure
241  *----------------------------------------------------------------------------*/
242 
243 void
245 
246 /*----------------------------------------------------------------------------
247  * Map existing value arrays to field descriptor.
248  *
249  * parameters:
250  * f <-> pointer to field structure
251  * val <-- pointer to array of values
252  * val_pre <-- pointer to array of previous values, or NULL
253  *----------------------------------------------------------------------------*/
254 
255 void
257  cs_real_t *val,
258  cs_real_t *val_pre);
259 
260 /*----------------------------------------------------------------------------
261  * Allocate boundary condition coefficient arrays.
262  *
263  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
264  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
265  *
266  * Boundary condition coefficients are not currently supported for other
267  * locations (though support could be added by mapping a boundary->location
268  * indirection array in the cs_mesh_location_t structure).
269  *
270  * For multidimensional fields, arrays are assumed to have the same
271  * interleaving behavior as the field, unless components are coupled.
272  *
273  * For multidimensional fields with coupled components, interleaving
274  * is the norm, and implicit b and bf coefficient arrays are arrays of
275  * block matrices, not vectors, so the number of entries for each boundary
276  * face is dim*dim instead of dim.
277  *
278  * parameters:
279  * f <-- pointer to field structure
280  * have_flux_bc <-- if true, flux BC coefficients (af and bf) are added
281  * have_mom_bc <-- if true, div BC coefficients (ad and bd) are added
282  * have_conv_bc <-- if true, convection BC coefficients (ac and bc) are added
283  *----------------------------------------------------------------------------*/
284 
285 void
287  bool have_flux_bc,
288  bool have_mom_bc,
289  bool have_conv_bc);
290 
291 /*----------------------------------------------------------------------------*/
292 /* Initialize boundary condition coefficients arrays.
293  *
294  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
295  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
296  *
297  * Boundary condition coefficients are not currently supported for other
298  * locations (though support could be added by mapping a boundary->location
299  * indirection array in the cs_mesh_location_t structure).
300  *
301  * For multidimensional fields, arrays are assumed to have the same
302  * interleaving behavior as the field, unless components are coupled.
303  *
304  * For multidimensional fields with coupled components, interleaving
305  * is the norm, and implicit b and bf coefficient arrays are arrays of
306  * block matrices, not vectors, so the number of entries for each boundary
307  * face is dim*dim instead of dim.
308  *
309  * parameters:
310  * f <-> pointer to field structure
311  *----------------------------------------------------------------------------*/
312 
313 void
315 
316 /*----------------------------------------------------------------------------
317  * Copy current field values to previous values if applicable.
318  *
319  * For fields with only one time value, or values not allocated yet,
320  * this is a no-op.
321  *
322  * parameters:
323  * f <-> pointer to field structure
324  *----------------------------------------------------------------------------*/
325 
326 void
328 
329 /*----------------------------------------------------------------------------
330  * Destroy all defined fields.
331  *----------------------------------------------------------------------------*/
332 
333 void
335 
336 /*----------------------------------------------------------------------------
337  * Allocate arrays for all defined fields based on their location.
338  *
339  * Location sized must thus be known.
340  *
341  * Fields that do not own their data should all have been mapped at this
342  * stage, and are checked.
343  *----------------------------------------------------------------------------*/
344 
345 void
347 
348 /*----------------------------------------------------------------------------
349  * Return a pointer to a field based on its id.
350  *
351  * This function requires that a field of the given id is defined.
352  *
353  * parameters:
354  * id <-- field id
355  *
356  * returns:
357  * pointer to the field structure
358  *----------------------------------------------------------------------------*/
359 
360 cs_field_t *
361 cs_field_by_id(int id);
362 
363 /*----------------------------------------------------------------------------
364  * Return a pointer to a field based on its name.
365  *
366  * This function requires that a field of the given name is defined.
367  *
368  * parameters:
369  * name <-- field name
370  *
371  * returns:
372  * pointer to the field structure
373  *----------------------------------------------------------------------------*/
374 
375 cs_field_t *
376 cs_field_by_name(const char *name);
377 
378 /*----------------------------------------------------------------------------
379  * Return a pointer to a field based on its name if present.
380  *
381  * If no field of the given name is defined, NULL is returned.
382  *
383  * parameters:
384  * name <-- field name
385  *
386  * returns:
387  * pointer to the field structure, or NULL
388  *----------------------------------------------------------------------------*/
389 
390 cs_field_t *
391 cs_field_by_name_try(const char *name);
392 
393 /*----------------------------------------------------------------------------
394  * Return the id of a defined field based on its name.
395  *
396  * If no field with the given name exists, -1 is returned.
397  *
398  * parameters:
399  * name <-- field name
400  *
401  * returns:
402  * id the field, or -1 if not found
403  *----------------------------------------------------------------------------*/
404 
405 int
406 cs_field_id_by_name(const char *name);
407 
408 /*----------------------------------------------------------------------------
409  * Return the id of a defined field and an associated component
410  * based on a component name.
411  *
412  * If no field with the given name exists, -1 is returned.
413  *
414  * parameters:
415  * name <-- field or field+component name
416  * f_id --> field id, or -1 if no match was found
417  * c_id --> component id, or -1 for all components
418  *----------------------------------------------------------------------------*/
419 
420 void
421 cs_field_component_id_by_name(const char *name,
422  int *f_id,
423  int *c_id);
424 
425 /*----------------------------------------------------------------------------
426  * Return an id associated with a given key name.
427  *
428  * The key must have been defined previously.
429  *
430  * parameters:
431  * name <-- key name
432  *
433  * returns:
434  * id associated with key
435  *----------------------------------------------------------------------------*/
436 
437 int
438 cs_field_key_id(const char *name);
439 
440 /*----------------------------------------------------------------------------
441  * Return an id associated with a given key name if present.
442  *
443  * If the key has not been defined previously, -1 is returned.
444  *
445  * parameters:
446  * name <-- key name
447  *
448  * returns:
449  * id associated with key, or -1
450  *----------------------------------------------------------------------------*/
451 
452 int
453 cs_field_key_id_try(const char *name);
454 
455 /*----------------------------------------------------------------------------
456  * Define a key for an integer value by its name and return an associated id.
457  *
458  * If the key has already been defined, its previous default value is replaced
459  * by the current value, and its id is returned.
460  *
461  * parameters:
462  * name <-- key name
463  * default_value <-- default value associated with key
464  * type flag <-- mask associated with field types with which the
465  * key may be associated, or 0
466  *
467  * returns:
468  * id associated with key
469  *----------------------------------------------------------------------------*/
470 
471 int
472 cs_field_define_key_int(const char *name,
473  int default_value,
474  int type_flag);
475 
476 /*----------------------------------------------------------------------------
477  * Define a key for an floating point value by its name and return an
478  * associated id.
479  *
480  * If the key has already been defined, its previous default value is replaced
481  * by the current value, and its id is returned.
482  *
483  * parameters:
484  * name <-- key name
485  * default_value <-- default value associated with key
486  * type flag <-- mask associated with field types with which the
487  * key may be associated, or 0
488  *
489  * returns:
490  * id associated with key
491  *----------------------------------------------------------------------------*/
492 
493 int
494 cs_field_define_key_double(const char *name,
495  double default_value,
496  int type_flag);
497 
498 /*----------------------------------------------------------------------------
499  * Define a key for an string point value by its name and return an
500  * associated id.
501  *
502  * If the key has already been defined, its previous default value is replaced
503  * by the current value, and its id is returned.
504  *
505  * parameters:
506  * name <-- key name
507  * default_value <-- default value associated with key
508  * type flag <-- mask associated with field types with which the
509  * key may be associated, or 0
510  *
511  * returns:
512  * id associated with key
513  *----------------------------------------------------------------------------*/
514 
515 int
516 cs_field_define_key_str(const char *name,
517  const char *default_value,
518  int type_flag);
519 
520 /*----------------------------------------------------------------------------
521  * Define a key for a structure value by its name and return an
522  * associated id.
523  *
524  * If the key has already been defined, its previous default value is replaced
525  * by the current value, and its id is returned.
526  *
527  * parameters:
528  * name <-- key name
529  * default_value <-- pointer to default value associated with key
530  * log_funct <-- pointer to logging function
531  * size <-- sizeof structure
532  * type_flag <-- mask associated with field types with which
533  * the key may be associated, or 0
534  *
535  * returns:
536  * id associated with key
537  *----------------------------------------------------------------------------*/
538 
539 int
540 cs_field_define_key_struct(const char *name,
541  const void *default_value,
542  cs_field_log_key_struct_t *log_func,
543  size_t size,
544  int type_flag);
545 
546 /*----------------------------------------------------------------------------
547  * Define a sub key.
548  *
549  * The sub key is the same type as the parent key.
550  *
551  * For a given field, when querying a sub key's value and that value has not
552  * been set, the query will return the value of the parent key.
553  *
554  * parameters:
555  * name <-- key name
556  * parent_id <-- parent key id
557  *
558  * returns:
559  * id associated with key
560  *----------------------------------------------------------------------------*/
561 
562 int
563 cs_field_define_sub_key(const char *name,
564  int parent_id);
565 
566 /*----------------------------------------------------------------------------
567  * Destroy all defined field keys and associated values.
568  *----------------------------------------------------------------------------*/
569 
570 void
572 
573 /*----------------------------------------------------------------------------
574  * Get the type flag associated with a given key id.
575  *
576  * If the key has not been defined previously, -1 is returned.
577  *
578  * parameters:
579  * key_id <-- id of associated key
580  *
581  * returns:
582  * type flag associated with key, or -1
583  *----------------------------------------------------------------------------*/
584 
585 int
586 cs_field_key_flag(int key_id);
587 
588 /*----------------------------------------------------------------------------
589  * Disable logging setup values associated with a given key.
590  *
591  * This is useful when a key is used not for setup purposes, but to track
592  * values associated with a field, such as convergence or performance data.
593  *
594  * parameters:
595  * key_id <-- id of associated key
596  *----------------------------------------------------------------------------*/
597 
598 void
600 
601 /*----------------------------------------------------------------------------
602  * Query if a given key has been set for a field.
603  *
604  * If the key id is not valid, or the field category is not
605  * compatible, a fatal error is provoked.
606  *
607  * parameters:
608  * f <-- pointer to field structure
609  * key_id <-- id of associated key
610  *
611  * returns:
612  * true if the key has been set for this field, false otherwise
613  *----------------------------------------------------------------------------*/
614 
615 bool
617  int key_id);
618 
619 /*----------------------------------------------------------------------------
620  * Query if a given key has been locked for a field.
621  *
622  * If the key id is not valid, or the field category is not
623  * compatible, a fatal error is provoked.
624  *
625  * parameters:
626  * f <-- pointer to field structure
627  * key_id <-- id of associated key
628  *
629  * returns:
630  * true if the key has been locked for this field, false otherwise
631  *----------------------------------------------------------------------------*/
632 
633 bool
635  int key_id);
636 
637 /*----------------------------------------------------------------------------
638  * Lock a field relative to a given key.
639  *
640  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
641  * If the field category is not compatible with the key (as defined
642  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
643  *
644  * parameters:
645  * f <-- pointer to field structure
646  * key_id <-- id of associated key
647  * value <-- value associated with key
648  *
649  * returns:
650  * 0 in case of success, > 1 in case of error
651  *----------------------------------------------------------------------------*/
652 
653 int
655  int key_id);
656 
657 /*----------------------------------------------------------------------------
658  * Assign a integer value for a given key to a field.
659  *
660  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
661  * If the field category is not compatible with the key (as defined
662  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
663  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
664  * If the key value has been locked, CS_FIELD_LOCKED is returned.
665  *
666  * parameters:
667  * f <-- pointer to field structure
668  * key_id <-- id of associated key
669  * value <-- value associated with key
670  *
671  * returns:
672  * 0 in case of success, > 1 in case of error
673  *----------------------------------------------------------------------------*/
674 
675 int
677  int key_id,
678  int value);
679 
680 /*----------------------------------------------------------------------------
681  * Return a integer value for a given key associated with a field.
682  *
683  * If the key id is not valid, or the value type or field category is not
684  * compatible, a fatal error is provoked.
685  *
686  * parameters:
687  * f <-- pointer to field structure
688  * key_id <-- id of associated key
689  *
690  * returns:
691  * integer value associated with the key id for this field
692  *----------------------------------------------------------------------------*/
693 
694 int
696  int key_id);
697 
698 /*----------------------------------------------------------------------------
699  * Assign a floating point value for a given key to a field.
700  *
701  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
702  * If the field category is not compatible with the key (as defined
703  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
704  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
705  * If the key value has been locked, CS_FIELD_LOCKED is returned.
706  *
707  * parameters:
708  * f <-- pointer to field structure
709  * key_id <-- id of associated key
710  * value <-- value associated with key
711  *
712  * returns:
713  * 0 in case of success, > 1 in case of error
714  *----------------------------------------------------------------------------*/
715 
716 int
718  int key_id,
719  double value);
720 
721 /*----------------------------------------------------------------------------
722  * Return a floating point value for a given key associated with a field.
723  *
724  * If the key id is not valid, or the value type or field category is not
725  * compatible, a fatal error is provoked.
726  *
727  * parameters:
728  * f <-- pointer to field structure
729  * key_id <-- id of associated key
730  *
731  * returns:
732  * floating point value associated with the key id for this field
733  *----------------------------------------------------------------------------*/
734 
735 double
737  int key_id);
738 
739 /*----------------------------------------------------------------------------
740  * Assign a character string value for a given key to a field.
741  *
742  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
743  * If the field category is not compatible with the key (as defined
744  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
745  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
746  * If the key value has been locked, CS_FIELD_LOCKED is returned.
747  *
748  * parameters:
749  * f <-- pointer to field structure
750  * key_id <-- id of associated key
751  * str <-- string associated with key
752  *
753  * returns:
754  * 0 in case of success, > 1 in case of error
755  *----------------------------------------------------------------------------*/
756 
757 int
759  int key_id,
760  const char *str);
761 
762 /*----------------------------------------------------------------------------
763  * Return a string for a given key associated with a field.
764  *
765  * If the key id is not valid, or the value type or field category is not
766  * compatible, a fatal error is provoked.
767  *
768  * parameters:
769  * f <-- pointer to field structure
770  * key_id <-- id of associated key
771  *
772  * returns:
773  * pointer to character string associated with the key id for this field
774  *----------------------------------------------------------------------------*/
775 
776 const char *
778  int key_id);
779 
780 
781 /*----------------------------------------------------------------------------
782  * Assign a simple structure for a given key to a field.
783  *
784  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
785  * If the field category is not compatible with the key (as defined
786  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
787  * If the key value has been locked, CS_FIELD_LOCKED is returned.
788  *
789  * parameters:
790  * f <-- pointer to field structure
791  * key_id <-- id of associated key
792  * s <-- structure associated with key
793  *
794  * returns:
795  * 0 in case of success, > 1 in case of error
796  *----------------------------------------------------------------------------*/
797 
798 int
800  int key_id,
801  void *s);
802 
803 /*----------------------------------------------------------------------------
804  * Return a structure for a given key associated with a field.
805  *
806  * If the key id is not valid, or the value type or field category is not
807  * compatible, a fatal error is provoked.
808  *
809  * parameters:
810  * f <-- pointer to field structure
811  * key_id <-- id of associated key
812  * s <-- structure associated with key
813  *
814  * returns:
815  * pointer to structure associated with the key id for this field
816  * (same as s)
817  *----------------------------------------------------------------------------*/
818 
819 const void *
821  int key_id,
822  void *s);
823 
824 /*----------------------------------------------------------------------------
825  * Print info relative to all field definitions to log file.
826  *----------------------------------------------------------------------------*/
827 
828 void
829 cs_field_log_defs(void);
830 
831 /*----------------------------------------------------------------------------
832  * Print info relative to a given field to log file.
833  *
834  * parameters:
835  * f <-- pointer to field structure
836  * log_keywords <-- log level for keywords (0: do not log,
837  * 1: log non-default values, 2: log all)
838  *----------------------------------------------------------------------------*/
839 
840 void
842  int log_keywords);
843 
844 /*----------------------------------------------------------------------------
845  * Print info relative to all defined fields to log file.
846  *
847  * parameters:
848  * log_keywords <-- log level for keywords (0: do not log,
849  * 1: log non-default values, 2: log all)
850  *----------------------------------------------------------------------------*/
851 
852 void
853 cs_field_log_fields(int log_keywords);
854 
855 /*----------------------------------------------------------------------------
856  * Print info relative to all key definitions to log file.
857  *----------------------------------------------------------------------------*/
858 
859 void
861 
862 /*----------------------------------------------------------------------------
863  * Print info relative to a given field key to log file.
864  *
865  * parameters:
866  * int key_id <-- id of associated key
867  * log_defaults <-- if true, log default field values in addition to
868  * defined field values
869  *----------------------------------------------------------------------------*/
870 
871 void
872 cs_field_log_key_vals(int key_id,
873  bool log_defaults);
874 
875 /*----------------------------------------------------------------------------
876  * Print info relative to all given field keys to log file.
877  *
878  * parameters:
879  * log_defaults <-- if true, log default field values in addition to
880  * defined field values
881  *----------------------------------------------------------------------------*/
882 
883 void
884 cs_field_log_all_key_vals(bool log_defaults);
885 
886 /*----------------------------------------------------------------------------
887  * Define base keys.
888  *
889  * Keys defined by this function are:
890  * "label" (string)
891  * "log" (integer)
892  * "post_vis" (integer)
893  * "post_probes" (integer)
894  * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
895  * "moment_id" (integer, restricted to
896  * CS_FIELD_ACCUMULATOR | CS_FIELD_POSTPROCESS);
897  *
898  * A recommened practice for different submodules would be to use
899  * "cs_<module>_key_init() functions to define keys specific to those modules.
900  *----------------------------------------------------------------------------*/
901 
902 void
904 
905 /*----------------------------------------------------------------------------
906  * Return a label associated with a field.
907  *
908  * If the "label" key has been set for this field, its associated string
909  * is returned. Otherwise, the field's name is returned.
910  *
911  * parameters:
912  * f <-- pointer to field structure
913  *
914  * returns:
915  * pointer to character string associated with label for this field
916  *----------------------------------------------------------------------------*/
917 
918 const char *
920 
921 /*----------------------------------------------------------------------------*/
922 
924 
925 #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:2780
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:3010
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:2734
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:2297
void cs_field_init_bc_coeffs(cs_field_t *f)
Initialize boundary condition coefficients arrays.
Definition: cs_field.c:1786
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:3186
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:2426
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.c:2583
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:1600
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:3127
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
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:1397
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:2629
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:1569
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:2476
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:3768
int cs_field_lock_key(cs_field_t *f, int key_id)
Lock a field relative to a given key.
Definition: cs_field.c:2692
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.c:2525
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.c:2083
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:2324
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:3800
void( cs_field_log_key_struct_t)(const void *t)
Definition: cs_field.h:143
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:2847
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:2208
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.c:2028
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:2607
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:3644
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:2960
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:2660
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:2187
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:2551
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:2389
cs_real_t * bc
Definition: cs_field.h:92
cs_field_t * cs_field_find_or_create(const char *name, int type_flag, int location_id, int dim, bool interleaved)
Return a field matching a given name and attributes, creating it if necessary.
Definition: cs_field.c:1446
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.c:2138
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:1375
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:3827
#define END_C_DECLS
Definition: cs_defs.h:430
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:3077
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:1510
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.c:3526
cs_real_t * af
Definition: cs_field.h:87
Definition: cs_field_pointer.h:93
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:3465
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:3326
void cs_field_current_to_previous(cs_field_t *f)
Copy current field values to previous values if applicable.
Definition: cs_field.c:1970
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:2164
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:2114
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:2893
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:2352
cs_field_error_type_t
Definition: cs_field.h:67
cs_real_t * a
Definition: cs_field.h:85
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:1653