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