My Project
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-2019 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_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 
60 /* Field category */
61 
63 #define CS_FIELD_VARIABLE (1 << 2)
64 
66 #define CS_FIELD_PROPERTY (1 << 3)
67 
69 #define CS_FIELD_POSTPROCESS (1 << 4)
70 
72 #define CS_FIELD_ACCUMULATOR (1 << 5)
73 
75 #define CS_FIELD_USER (1 << 6)
76 
78 #define CS_FIELD_CDO (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 
116  cs_real_t *hint; /* coefficient for internal coupling */
117  cs_real_t *hext; /* coefficient for internal coupling */
118 
120 
121 /* Field descriptor */
122 /*------------------*/
123 
124 typedef struct {
125 
126  const char *name; /* Canonical name */
127 
128  int id; /* Field id */
129  int type; /* Field type flag */
130 
131  int dim; /* Field dimension */
132 
133  int location_id; /* Id of matching location */
134 
135  int n_time_vals; /* Number of time values */
136 
137  cs_real_t **vals; /* For each active location, pointer
138  to matching values arrays
139  vals[0][:] = val
140  vals[1][:] = val_pre
141  vals[p][:] = p ith previous field
142  p < n_time_vals */
143 
144 
145  cs_real_t *val; /* For each active location, pointer
146  to matching values array */
147 
148  cs_real_t *val_pre; /* For each active location, pointer
149  to matching previous values array
150  (if n_time_vals == 2) */
151 
152  cs_field_bc_coeffs_t *bc_coeffs; /* Boundary condition coefficients,
153  for variable type fields */
154 
155  bool is_owner; /* Ownership flag for values */
156 
157 } cs_field_t;
158 
159 /*----------------------------------------------------------------------------
160  * Function pointer for structure associated to field key
161  *
162  * parameters:
163  * t <-- pointer to structure
164  *----------------------------------------------------------------------------*/
165 
166 typedef void
167 (cs_field_log_key_struct_t) (const void *t);
168 
169 /*============================================================================
170  * Global variables
171  *============================================================================*/
172 
173 /* Names for components */
174 
175 extern const char *cs_glob_field_comp_name_3[];
176 extern const char *cs_glob_field_comp_name_6[];
177 extern const char *cs_glob_field_comp_name_9[];
178 
179 /*=============================================================================
180  * Public function prototypes
181  *============================================================================*/
182 
183 /*----------------------------------------------------------------------------
184  * Return the number of defined fields.
185  *
186  * returns:
187  * number of defined fields.
188  *----------------------------------------------------------------------------*/
189 
190 int
191 cs_field_n_fields(void);
192 
193 /*----------------------------------------------------------------------------
194  * Create a field descriptor.
195  *
196  * parameters:
197  * name <-- field name
198  * type_flag <-- mask of field property and category values
199  * location_id <-- id of associated location
200  * dim <-- field dimension (number of components)
201  * has_previous <-- maintain values at the previous time step ?
202  *
203  * returns:
204  * pointer to new field.
205  *----------------------------------------------------------------------------*/
206 
207 cs_field_t *
208 cs_field_create(const char *name,
209  int type_flag,
210  int location_id,
211  int dim,
212  bool has_previous);
213 
214 /*----------------------------------------------------------------------------*/
233 /*----------------------------------------------------------------------------*/
234 
235 cs_field_t *
236 cs_field_find_or_create(const char *name,
237  int type_flag,
238  int location_id,
239  int dim,
240  bool has_previous);
241 
242 /*----------------------------------------------------------------------------
243  * Change the number of time values managed by a field.
244  *
245  * The minimum will never be below 1, as the current time is always handled.
246  *
247  * parameters:
248  * f <-> pointer to field structure
249  * n_time_vals <-- number of time values to maintain
250  *----------------------------------------------------------------------------*/
251 
252 void
254  int n_time_vals);
255 
256 /*----------------------------------------------------------------------------
257  * Allocate arrays for field values.
258  *
259  * parameters:
260  * f <-- pointer to field structure
261  *----------------------------------------------------------------------------*/
262 
263 void
265 
266 /*----------------------------------------------------------------------------
267  * Map existing value arrays to field descriptor.
268  *
269  * parameters:
270  * f <-> pointer to field structure
271  * val <-- pointer to array of values
272  * val_pre <-- pointer to array of previous values, or NULL
273  *----------------------------------------------------------------------------*/
274 
275 void
277  cs_real_t *val,
278  cs_real_t *val_pre);
279 
280 /*----------------------------------------------------------------------------
281  * Allocate boundary condition coefficient arrays.
282  *
283  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
284  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
285  *
286  * Boundary condition coefficients are not currently supported for other
287  * locations (though support could be added by mapping a boundary->location
288  * indirection array in the cs_mesh_location_t structure).
289  *
290  * For multidimensional fields with coupled components, implicit b and bf
291  * coefficient arrays are arrays of block matrices, not vectors, so the
292  * number of entries for each boundary face is dim*dim instead of dim.
293  *
294  * parameters:
295  * f <-- pointer to field structure
296  * have_flux_bc <-- if true, flux BC coefficients (af and bf) are added
297  * have_mom_bc <-- if true, div BC coefficients (ad and bd) are added
298  * have_conv_bc <-- if true, convection BC coefficients (ac and bc) are added
299  * have_exch_bc <-- if true, exchange boundary coefficients (hint and hext)
300  * are added
301  *----------------------------------------------------------------------------*/
302 
303 void
305  bool have_flux_bc,
306  bool have_mom_bc,
307  bool have_conv_bc,
308  bool have_exch_bc);
309 
310 /*----------------------------------------------------------------------------*/
311 /* Initialize boundary condition coefficients arrays.
312  *
313  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
314  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
315  *
316  * Boundary condition coefficients are not currently supported for other
317  * locations (though support could be added by mapping a boundary->location
318  * indirection array in the cs_mesh_location_t structure).
319  *
320  * For multidimensional fields with coupled components, implicit b and bf
321  * coefficient arrays are arrays of block matrices, not vectors, so the
322  * number of entries for each boundary face is dim*dim instead of dim.
323  *
324  * parameters:
325  * f <-> pointer to field structure
326  *----------------------------------------------------------------------------*/
327 
328 void
330 
331 /*----------------------------------------------------------------------------
332  * Set current field values to the given constant.
333  *
334  * parameters:
335  * f <-> pointer to field structure
336  * c <-- assigned value
337  *----------------------------------------------------------------------------*/
338 
339 void
341  cs_real_t c);
342 
343 /*----------------------------------------------------------------------------
344  * Copy current field values to previous values if applicable.
345  *
346  * For fields with only one time value, or values not allocated yet,
347  * this is a no-op.
348  *
349  * parameters:
350  * f <-> pointer to field structure
351  *----------------------------------------------------------------------------*/
352 
353 void
355 
356 /*----------------------------------------------------------------------------
357  * Destroy all defined fields.
358  *----------------------------------------------------------------------------*/
359 
360 void
362 
363 /*----------------------------------------------------------------------------
364  * Allocate arrays for all defined fields based on their location.
365  *
366  * Location sized must thus be known.
367  *
368  * Fields that do not own their data should all have been mapped at this
369  * stage, and are checked.
370  *----------------------------------------------------------------------------*/
371 
372 void
374 
375 /*----------------------------------------------------------------------------
376  * Return a pointer to a field based on its id.
377  *
378  * This function requires that a field of the given id is defined.
379  *
380  * parameters:
381  * id <-- field id
382  *
383  * returns:
384  * pointer to the field structure
385  *----------------------------------------------------------------------------*/
386 
387 cs_field_t *
388 cs_field_by_id(int id);
389 
390 /*----------------------------------------------------------------------------
391  * Return a pointer to a field based on its name.
392  *
393  * This function requires that a field of the given name is defined.
394  *
395  * parameters:
396  * name <-- field name
397  *
398  * returns:
399  * pointer to the field structure
400  *----------------------------------------------------------------------------*/
401 
402 cs_field_t *
403 cs_field_by_name(const char *name);
404 
405 /*----------------------------------------------------------------------------
406  * Return a pointer to a field based on its name if present.
407  *
408  * If no field of the given name is defined, NULL is returned.
409  *
410  * parameters:
411  * name <-- field name
412  *
413  * returns:
414  * pointer to the field structure, or NULL
415  *----------------------------------------------------------------------------*/
416 
417 cs_field_t *
418 cs_field_by_name_try(const char *name);
419 
420 /*----------------------------------------------------------------------------
421  * Return the id of a defined field based on its name.
422  *
423  * If no field with the given name exists, -1 is returned.
424  *
425  * parameters:
426  * name <-- field name
427  *
428  * returns:
429  * id the field, or -1 if not found
430  *----------------------------------------------------------------------------*/
431 
432 int
433 cs_field_id_by_name(const char *name);
434 
435 /*----------------------------------------------------------------------------
436  * Return the id of a defined field and an associated component
437  * based on a component name.
438  *
439  * If no field with the given name exists, -1 is returned.
440  *
441  * parameters:
442  * name <-- field or field+component name
443  * f_id --> field id, or -1 if no match was found
444  * c_id --> component id, or -1 for all components
445  *----------------------------------------------------------------------------*/
446 
447 void
448 cs_field_component_id_by_name(const char *name,
449  int *f_id,
450  int *c_id);
451 
452 /*----------------------------------------------------------------------------
453  * Return an id associated with a given key name.
454  *
455  * The key must have been defined previously.
456  *
457  * parameters:
458  * name <-- key name
459  *
460  * returns:
461  * id associated with key
462  *----------------------------------------------------------------------------*/
463 
464 int
465 cs_field_key_id(const char *name);
466 
467 /*----------------------------------------------------------------------------
468  * Return an id associated with a given key name if present.
469  *
470  * If the key has not been defined previously, -1 is returned.
471  *
472  * parameters:
473  * name <-- key name
474  *
475  * returns:
476  * id associated with key, or -1
477  *----------------------------------------------------------------------------*/
478 
479 int
480 cs_field_key_id_try(const char *name);
481 
482 /*----------------------------------------------------------------------------
483  * Define a key for an integer value by its name and return an associated id.
484  *
485  * If the key has already been defined, its previous default value is replaced
486  * by the current value, and its id is returned.
487  *
488  * parameters:
489  * name <-- key name
490  * default_value <-- default value associated with key
491  * type flag <-- mask associated with field types with which the
492  * key may be associated, or 0
493  *
494  * returns:
495  * id associated with key
496  *----------------------------------------------------------------------------*/
497 
498 int
499 cs_field_define_key_int(const char *name,
500  int default_value,
501  int type_flag);
502 
503 /*----------------------------------------------------------------------------
504  * Define a key for an floating point value by its name and return an
505  * associated id.
506  *
507  * If the key has already been defined, its previous default value is replaced
508  * by the current value, and its id is returned.
509  *
510  * parameters:
511  * name <-- key name
512  * default_value <-- default value associated with key
513  * type flag <-- mask associated with field types with which the
514  * key may be associated, or 0
515  *
516  * returns:
517  * id associated with key
518  *----------------------------------------------------------------------------*/
519 
520 int
521 cs_field_define_key_double(const char *name,
522  double default_value,
523  int type_flag);
524 
525 /*----------------------------------------------------------------------------
526  * Define a key for an string point value by its name and return an
527  * associated id.
528  *
529  * If the key has already been defined, its previous default value is replaced
530  * by the current value, and its id is returned.
531  *
532  * parameters:
533  * name <-- key name
534  * default_value <-- default value associated with key
535  * type flag <-- mask associated with field types with which the
536  * key may be associated, or 0
537  *
538  * returns:
539  * id associated with key
540  *----------------------------------------------------------------------------*/
541 
542 int
543 cs_field_define_key_str(const char *name,
544  const char *default_value,
545  int type_flag);
546 
547 /*----------------------------------------------------------------------------
548  * Define a key for a structure value by its name and return an
549  * associated id.
550  *
551  * If the key has already been defined, its previous default value is replaced
552  * by the current value, and its id is returned.
553  *
554  * parameters:
555  * name <-- key name
556  * default_value <-- pointer to default value associated with key
557  * log_funct <-- pointer to logging function
558  * log_func_default <-- pointer to default logging function
559  * size <-- sizeof structure
560  * type_flag <-- mask associated with field types with which
561  * the key may be associated, or 0
562  *
563  * returns:
564  * id associated with key
565  *----------------------------------------------------------------------------*/
566 
567 int
568 cs_field_define_key_struct(const char *name,
569  const void *default_value,
570  cs_field_log_key_struct_t *log_func,
571  cs_field_log_key_struct_t *log_func_default,
572  size_t size,
573  int type_flag);
574 
575 /*----------------------------------------------------------------------------
576  * Define a sub key.
577  *
578  * The sub key is the same type as the parent key.
579  *
580  * For a given field, when querying a sub key's value and that value has not
581  * been set, the query will return the value of the parent key.
582  *
583  * parameters:
584  * name <-- key name
585  * parent_id <-- parent key id
586  *
587  * returns:
588  * id associated with key
589  *----------------------------------------------------------------------------*/
590 
591 int
592 cs_field_define_sub_key(const char *name,
593  int parent_id);
594 
595 /*----------------------------------------------------------------------------
596  * Destroy all defined field keys and associated values.
597  *----------------------------------------------------------------------------*/
598 
599 void
601 
602 /*----------------------------------------------------------------------------
603  * Get the type flag associated with a given key id.
604  *
605  * If the key has not been defined previously, -1 is returned.
606  *
607  * parameters:
608  * key_id <-- id of associated key
609  *
610  * returns:
611  * type flag associated with key, or -1
612  *----------------------------------------------------------------------------*/
613 
614 int
615 cs_field_key_flag(int key_id);
616 
617 /*----------------------------------------------------------------------------
618  * Disable logging setup values associated with a given key.
619  *
620  * This is useful when a key is used not for setup purposes, but to track
621  * values associated with a field, such as convergence or performance data.
622  *
623  * parameters:
624  * key_id <-- id of associated key
625  *----------------------------------------------------------------------------*/
626 
627 void
629 
630 /*----------------------------------------------------------------------------
631  * Query if a given key has been set for a field.
632  *
633  * If the key id is not valid, or the field category is not
634  * compatible, a fatal error is provoked.
635  *
636  * parameters:
637  * f <-- pointer to field structure
638  * key_id <-- id of associated key
639  *
640  * returns:
641  * true if the key has been set for this field, false otherwise
642  *----------------------------------------------------------------------------*/
643 
644 bool
646  int key_id);
647 
648 /*----------------------------------------------------------------------------
649  * Query if a given key has been locked for a field.
650  *
651  * If the key id is not valid, or the field category is not
652  * compatible, a fatal error is provoked.
653  *
654  * parameters:
655  * f <-- pointer to field structure
656  * key_id <-- id of associated key
657  *
658  * returns:
659  * true if the key has been locked for this field, false otherwise
660  *----------------------------------------------------------------------------*/
661 
662 bool
664  int key_id);
665 
666 /*----------------------------------------------------------------------------
667  * Lock a field relative to a given key.
668  *
669  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
670  * If the field category is not compatible with the key (as defined
671  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
672  *
673  * parameters:
674  * f <-- pointer to field structure
675  * key_id <-- id of associated key
676  * value <-- value associated with key
677  *
678  * returns:
679  * 0 in case of success, > 1 in case of error
680  *----------------------------------------------------------------------------*/
681 
682 int
684  int key_id);
685 
686 /*----------------------------------------------------------------------------
687  * Assign a integer value for a given key to a field.
688  *
689  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
690  * If the field category is not compatible with the key (as defined
691  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
692  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
693  * If the key value has been locked, CS_FIELD_LOCKED is returned.
694  *
695  * parameters:
696  * f <-- pointer to field structure
697  * key_id <-- id of associated key
698  * value <-- value associated with key
699  *
700  * returns:
701  * 0 in case of success, > 1 in case of error
702  *----------------------------------------------------------------------------*/
703 
704 int
706  int key_id,
707  int value);
708 
709 /*----------------------------------------------------------------------------
710  * Return a integer value for a given key associated with a field.
711  *
712  * If the key id is not valid, or the value type or field category is not
713  * compatible, a fatal error is provoked.
714  *
715  * parameters:
716  * f <-- pointer to field structure
717  * key_id <-- id of associated key
718  *
719  * returns:
720  * integer value associated with the key id for this field
721  *----------------------------------------------------------------------------*/
722 
723 int
725  int key_id);
726 
727 /*----------------------------------------------------------------------------
728  * Set integer bits matching a mask to 1 for a given key for a field.
729  *
730  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
731  * If the field category is not compatible with the key (as defined
732  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
733  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
734  * If the key value has been locked, CS_FIELD_LOCKED is returned.
735  *
736  * parameters:
737  * f <-- pointer to field structure
738  * key_id <-- id of associated key
739  * mask <-- mask associated with key
740  *
741  * returns:
742  * 0 in case of success, > 1 in case of error
743  *----------------------------------------------------------------------------*/
744 
745 int
747  int key_id,
748  int mask);
749 
750 /*----------------------------------------------------------------------------
751  * Set integer bits matching a mask to 0 for a given key for a field.
752  *
753  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
754  * If the field category is not compatible with the key (as defined
755  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
756  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
757  * If the key value has been locked, CS_FIELD_LOCKED is returned.
758  *
759  * parameters:
760  * f <-- pointer to field structure
761  * key_id <-- id of associated key
762  * mask <-- mask associated with key
763  *
764  * returns:
765  * 0 in case of success, > 1 in case of error
766  *----------------------------------------------------------------------------*/
767 
768 int
770  int key_id,
771  int mask);
772 
773 /*----------------------------------------------------------------------------
774  * Assign a floating point value for a given key to a field.
775  *
776  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
777  * If the field category is not compatible with the key (as defined
778  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
779  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
780  * If the key value has been locked, CS_FIELD_LOCKED is returned.
781  *
782  * parameters:
783  * f <-- pointer to field structure
784  * key_id <-- id of associated key
785  * value <-- value associated with key
786  *
787  * returns:
788  * 0 in case of success, > 1 in case of error
789  *----------------------------------------------------------------------------*/
790 
791 int
793  int key_id,
794  double value);
795 
796 /*----------------------------------------------------------------------------
797  * Return a floating point value for a given key associated with a field.
798  *
799  * If the key id is not valid, or the value type or field category is not
800  * compatible, a fatal error is provoked.
801  *
802  * parameters:
803  * f <-- pointer to field structure
804  * key_id <-- id of associated key
805  *
806  * returns:
807  * floating point value associated with the key id for this field
808  *----------------------------------------------------------------------------*/
809 
810 double
812  int key_id);
813 
814 /*----------------------------------------------------------------------------
815  * Assign a character string value for a given key to a field.
816  *
817  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
818  * If the field category is not compatible with the key (as defined
819  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
820  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
821  * If the key value has been locked, CS_FIELD_LOCKED is returned.
822  *
823  * parameters:
824  * f <-- pointer to field structure
825  * key_id <-- id of associated key
826  * str <-- string associated with key
827  *
828  * returns:
829  * 0 in case of success, > 1 in case of error
830  *----------------------------------------------------------------------------*/
831 
832 int
834  int key_id,
835  const char *str);
836 
837 /*----------------------------------------------------------------------------
838  * Return a string for a given key associated with a field.
839  *
840  * If the key id is not valid, or the value type or field category is not
841  * compatible, a fatal error is provoked.
842  *
843  * parameters:
844  * f <-- pointer to field structure
845  * key_id <-- id of associated key
846  *
847  * returns:
848  * pointer to character string associated with the key id for this field
849  *----------------------------------------------------------------------------*/
850 
851 const char *
853  int key_id);
854 
855 
856 /*----------------------------------------------------------------------------
857  * Assign a simple structure for a given key to a field.
858  *
859  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
860  * If the field category is not compatible with the key (as defined
861  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
862  * If the key value has been locked, CS_FIELD_LOCKED is returned.
863  *
864  * parameters:
865  * f <-- pointer to field structure
866  * key_id <-- id of associated key
867  * s <-- structure associated with key
868  *
869  * returns:
870  * 0 in case of success, > 1 in case of error
871  *----------------------------------------------------------------------------*/
872 
873 int
875  int key_id,
876  void *s);
877 
878 /*----------------------------------------------------------------------------
879  * Return a structure for a given key associated with a field.
880  *
881  * If the key id is not valid, or the value type or field category is not
882  * compatible, a fatal error is provoked.
883  *
884  * parameters:
885  * f <-- pointer to field structure
886  * key_id <-- id of associated key
887  * s <-- structure associated with key
888  *
889  * returns:
890  * pointer to structure associated with the key id for this field
891  * (same as s)
892  *----------------------------------------------------------------------------*/
893 
894 const void *
896  int key_id,
897  void *s);
898 
899 /*----------------------------------------------------------------------------*/
915 /*----------------------------------------------------------------------------*/
916 
917 void *
919  int key_id);
920 
921 /*----------------------------------------------------------------------------*/
934 /*----------------------------------------------------------------------------*/
935 
936 const void *
938  int key_id);
939 
940 /*----------------------------------------------------------------------------
941  * Print info relative to all field definitions to log file.
942  *----------------------------------------------------------------------------*/
943 
944 void
945 cs_field_log_defs(void);
946 
947 /*----------------------------------------------------------------------------
948  * Print info relative to a given field to log file.
949  *
950  * parameters:
951  * f <-- pointer to field structure
952  * log_keywords <-- log level for keywords (0: do not log,
953  * 1: log non-default values, 2: log all)
954  *----------------------------------------------------------------------------*/
955 
956 void
958  int log_keywords);
959 
960 /*----------------------------------------------------------------------------
961  * Print info relative to all defined fields to log file.
962  *
963  * parameters:
964  * log_keywords <-- log level for keywords (0: do not log,
965  * 1: log non-default values, 2: log all)
966  *----------------------------------------------------------------------------*/
967 
968 void
969 cs_field_log_fields(int log_keywords);
970 
971 /*----------------------------------------------------------------------------
972  * Print info relative to all key definitions to log file.
973  *----------------------------------------------------------------------------*/
974 
975 void
977 
978 /*----------------------------------------------------------------------------
979  * Print info relative to a given field key to log file.
980  *
981  * parameters:
982  * int key_id <-- id of associated key
983  * log_defaults <-- if true, log default field values in addition to
984  * defined field values
985  *----------------------------------------------------------------------------*/
986 
987 void
988 cs_field_log_key_vals(int key_id,
989  bool log_defaults);
990 
991 /*----------------------------------------------------------------------------
992  * Print info relative to all given field keys to log file.
993  *
994  * parameters:
995  * log_defaults <-- if true, log default field values in addition to
996  * defined field values
997  *----------------------------------------------------------------------------*/
998 
999 void
1000 cs_field_log_all_key_vals(bool log_defaults);
1001 
1002 /*----------------------------------------------------------------------------
1003  * Define base keys.
1004  *
1005  * Keys defined by this function are:
1006  * "label" (string)
1007  * "log" (integer)
1008  * "post_vis" (integer)
1009  * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
1010  * "moment_id" (integer, restricted to
1011  * CS_FIELD_ACCUMULATOR | CS_FIELD_POSTPROCESS);
1012  *
1013  * A recommened practice for different submodules would be to use
1014  * "cs_<module>_key_init() functions to define keys specific to those modules.
1015  *----------------------------------------------------------------------------*/
1016 
1017 void
1019 
1020 /*----------------------------------------------------------------------------
1021  * Return a label associated with a field.
1022  *
1023  * If the "label" key has been set for this field, its associated string
1024  * is returned. Otherwise, the field's name is returned.
1025  *
1026  * parameters:
1027  * f <-- pointer to field structure
1028  *
1029  * returns:
1030  * pointer to character string associated with label for this field
1031  *----------------------------------------------------------------------------*/
1032 
1033 const char *
1034 cs_field_get_label(const cs_field_t *f);
1035 
1036 /*----------------------------------------------------------------------------*/
1037 
1039 
1040 #endif /* __CS_FIELD_H__ */
cs_field_by_name
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.c:2331
cs_field_define_keys_base
void cs_field_define_keys_base(void)
Define base keys.
Definition: cs_field.c:4231
cs_field_t::dim
int dim
Definition: cs_field.h:131
cs_field_n_fields
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.c:1527
f_id
void const int * f_id
Definition: cs_gui.h:292
cs_field_allocate_bc_coeffs
void cs_field_allocate_bc_coeffs(cs_field_t *f, bool have_flux_bc, bool have_mom_bc, bool have_conv_bc, bool have_exch_bc)
Allocate boundary condition coefficients arrays.
Definition: cs_field.c:1792
cs_field_create
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:1547
CS_FIELD_LOCKED
Definition: cs_field.h:96
cs_defs.h
cs_field_bc_coeffs_t::hext
cs_real_t * hext
Definition: cs_field.h:117
cs_field_bc_coeffs_t::a
cs_real_t * a
Definition: cs_field.h:107
cs_field_set_key_int_bits
int cs_field_set_key_int_bits(cs_field_t *f, int key_id, int mask)
Set integer bits matching a mask to 1 for a given key for a field.
Definition: cs_field.c:3045
cs_field_bc_coeffs_t::ac
cs_real_t * ac
Definition: cs_field.h:113
cs_field_get_key_struct_const_ptr
const void * cs_field_get_key_struct_const_ptr(const cs_field_t *f, int key_id)
Return a read-only pointer to a simple structure for a given key to a field.
Definition: cs_field.c:3533
cs_field_t::vals
cs_real_t ** vals
Definition: cs_field.h:137
cs_field_set_n_time_vals
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:1651
cs_field_bc_coeffs_t::af
cs_real_t * af
Definition: cs_field.h:109
cs_field_log_key_defs
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.c:3923
cs_field_t::id
int id
Definition: cs_field.h:128
cs_field_t::bc_coeffs
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:152
cs_field_get_label
const char * cs_field_get_label(const cs_field_t *f)
Return a label associated with a field.
Definition: cs_field.c:4257
cs_field_bc_coeffs_t::b
cs_real_t * b
Definition: cs_field.h:108
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_field_id_by_name
int cs_field_id_by_name(const char *name)
Return the id of a defined field based on its name.
Definition: cs_field.c:2380
cs_field_clear_key_int_bits
int cs_field_clear_key_int_bits(cs_field_t *f, int key_id, int mask)
Set integer bits matching a mask to 0 for a given key for a field.
Definition: cs_field.c:3076
cs_field_t::name
const char * name
Definition: cs_field.h:126
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_field_t::is_owner
bool is_owner
Definition: cs_field.h:155
cs_field_t::type
int type
Definition: cs_field.h:129
cs_field_t::n_time_vals
int n_time_vals
Definition: cs_field.h:135
cs_field_find_or_create
cs_field_t * cs_field_find_or_create(const char *name, int type_flag, int location_id, int dim, bool has_previous)
Return a field matching a given name and attributes, creating it if necessary.
Definition: cs_field.c:1591
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_field_set_key_int
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:2930
cs_field_log_fields
void cs_field_log_fields(int log_keywords)
Print info relative to all defined fields to log file.
Definition: cs_field.c:3862
cs_field_current_to_previous
void cs_field_current_to_previous(cs_field_t *f)
Copy current field values to previous values if applicable.
Definition: cs_field.c:2161
cs_field_set_key_str
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:3219
cs_field_log_all_key_vals
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:4200
cs_field_define_key_struct
int cs_field_define_key_struct(const char *name, const void *default_value, cs_field_log_key_struct_t *log_func, cs_field_log_key_struct_t *log_func_default, 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:2670
cs_field_log_key_struct_t
void() cs_field_log_key_struct_t(const void *t)
Definition: cs_field.h:167
cs_field_log_defs
void cs_field_log_defs(void)
Print info relative to all field definitions to log file.
Definition: cs_field.c:3590
cs_field_set_key_struct
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:3336
cs_field_t::val
cs_real_t * val
Definition: cs_field.h:145
cs_field_destroy_all_keys
void cs_field_destroy_all_keys(void)
Destroy all defined field keys and associated values.
Definition: cs_field.c:2747
cs_glob_field_comp_name_3
const char * cs_glob_field_comp_name_3[]
cs_field_define_key_double
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:2582
cs_field_bc_coeffs_t::ad
cs_real_t * ad
Definition: cs_field.h:111
cs_field_map_values
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:1741
cs_field_get_key_struct
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:3386
cs_field_is_key_set
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:2825
CS_FIELD_INVALID_CATEGORY
Definition: cs_field.h:94
cs_field_allocate_values
void cs_field_allocate_values(cs_field_t *f)
Allocate arrays for field values.
Definition: cs_field.c:1710
cs_field_by_name_try
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:2357
cs_field_bc_coeffs_t::bf
cs_real_t * bf
Definition: cs_field.h:110
cs_field_by_id
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2307
cs_field_get_key_double
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:3152
cs_field_define_key_int
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:2545
cs_field_init_bc_coeffs
void cs_field_init_bc_coeffs(cs_field_t *f)
Initialize boundary condition coefficients arrays.
Definition: cs_field.c:1940
cs_field_key_id_try
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:2517
cs_glob_field_comp_name_6
const char * cs_glob_field_comp_name_6[]
cs_field_is_key_locked
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:2856
cs_field_define_key_str
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:2619
cs_field_get_key_int
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:2976
cs_field_set_key_double
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:3106
cs_field_get_key_str
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:3269
cs_field_component_id_by_name
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:2401
cs_field_log_info
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:3728
cs_field_destroy_all
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.c:2219
cs_field_bc_coeffs_t::location_id
int location_id
Definition: cs_field.h:105
cs_field_bc_coeffs_t::hint
cs_real_t * hint
Definition: cs_field.h:116
t
Definition: cs_field_pointer.h:98
cs_field_bc_coeffs_t::bd
cs_real_t * bd
Definition: cs_field.h:112
cs_field_lock_key
int cs_field_lock_key(cs_field_t *f, int key_id)
Lock a field relative to a given key.
Definition: cs_field.c:2888
cs_field_error_type_t
cs_field_error_type_t
Definition: cs_field.h:89
cs_field_define_sub_key
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.c:2721
CS_FIELD_INVALID_KEY_NAME
Definition: cs_field.h:92
cs_field_key_flag
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.c:2779
cs_field_t::val_pre
cs_real_t * val_pre
Definition: cs_field.h:148
CS_FIELD_INVALID_TYPE
Definition: cs_field.h:95
CS_FIELD_INVALID_KEY_ID
Definition: cs_field.h:93
CS_FIELD_OK
Definition: cs_field.h:91
cs_field_bc_coeffs_t
Field boundary condition descriptor (for variables)
Definition: cs_field.h:103
cs_field_key_id
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2490
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_field_get_key_struct_ptr
void * cs_field_get_key_struct_ptr(cs_field_t *f, int key_id)
Return a pointer to a simple structure for a given key to a field.
Definition: cs_field.c:3457
cs_field_bc_coeffs_t::bc
cs_real_t * bc
Definition: cs_field.h:114
cs_field_t::location_id
int location_id
Definition: cs_field.h:133
cs_field_key_disable_setup_log
void cs_field_key_disable_setup_log(int key_id)
Disable logging setup values associated with a given key.
Definition: cs_field.c:2803
cs_field_set_values
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:2136
cs_field_log_key_vals
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:4076
cs_field_allocate_or_map_all
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.c:2276
cs_glob_field_comp_name_9
const char * cs_glob_field_comp_name_9[]