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-2018 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_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 
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  *----------------------------------------------------------------------------*/
300 
301 void
303  bool have_flux_bc,
304  bool have_mom_bc,
305  bool have_conv_bc);
306 
307 /*----------------------------------------------------------------------------*/
308 /* Initialize boundary condition coefficients arrays.
309  *
310  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
311  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
312  *
313  * Boundary condition coefficients are not currently supported for other
314  * locations (though support could be added by mapping a boundary->location
315  * indirection array in the cs_mesh_location_t structure).
316  *
317  * For multidimensional fields with coupled components, implicit b and bf
318  * coefficient arrays are arrays of block matrices, not vectors, so the
319  * number of entries for each boundary face is dim*dim instead of dim.
320  *
321  * parameters:
322  * f <-> pointer to field structure
323  *----------------------------------------------------------------------------*/
324 
325 void
327 
328 /*----------------------------------------------------------------------------
329  * Set current field values to the given constant.
330  *
331  * parameters:
332  * f <-> pointer to field structure
333  * c <-- assigned value
334  *----------------------------------------------------------------------------*/
335 
336 void
338  cs_real_t c);
339 
340 /*----------------------------------------------------------------------------
341  * Copy current field values to previous values if applicable.
342  *
343  * For fields with only one time value, or values not allocated yet,
344  * this is a no-op.
345  *
346  * parameters:
347  * f <-> pointer to field structure
348  *----------------------------------------------------------------------------*/
349 
350 void
352 
353 /*----------------------------------------------------------------------------
354  * Destroy all defined fields.
355  *----------------------------------------------------------------------------*/
356 
357 void
359 
360 /*----------------------------------------------------------------------------
361  * Allocate arrays for all defined fields based on their location.
362  *
363  * Location sized must thus be known.
364  *
365  * Fields that do not own their data should all have been mapped at this
366  * stage, and are checked.
367  *----------------------------------------------------------------------------*/
368 
369 void
371 
372 /*----------------------------------------------------------------------------
373  * Return a pointer to a field based on its id.
374  *
375  * This function requires that a field of the given id is defined.
376  *
377  * parameters:
378  * id <-- field id
379  *
380  * returns:
381  * pointer to the field structure
382  *----------------------------------------------------------------------------*/
383 
384 cs_field_t *
385 cs_field_by_id(int id);
386 
387 /*----------------------------------------------------------------------------
388  * Return a pointer to a field based on its name.
389  *
390  * This function requires that a field of the given name is defined.
391  *
392  * parameters:
393  * name <-- field name
394  *
395  * returns:
396  * pointer to the field structure
397  *----------------------------------------------------------------------------*/
398 
399 cs_field_t *
400 cs_field_by_name(const char *name);
401 
402 /*----------------------------------------------------------------------------
403  * Return a pointer to a field based on its name if present.
404  *
405  * If no field of the given name is defined, NULL is returned.
406  *
407  * parameters:
408  * name <-- field name
409  *
410  * returns:
411  * pointer to the field structure, or NULL
412  *----------------------------------------------------------------------------*/
413 
414 cs_field_t *
415 cs_field_by_name_try(const char *name);
416 
417 /*----------------------------------------------------------------------------
418  * Return the id of a defined field based on its name.
419  *
420  * If no field with the given name exists, -1 is returned.
421  *
422  * parameters:
423  * name <-- field name
424  *
425  * returns:
426  * id the field, or -1 if not found
427  *----------------------------------------------------------------------------*/
428 
429 int
430 cs_field_id_by_name(const char *name);
431 
432 /*----------------------------------------------------------------------------
433  * Return the id of a defined field and an associated component
434  * based on a component name.
435  *
436  * If no field with the given name exists, -1 is returned.
437  *
438  * parameters:
439  * name <-- field or field+component name
440  * f_id --> field id, or -1 if no match was found
441  * c_id --> component id, or -1 for all components
442  *----------------------------------------------------------------------------*/
443 
444 void
445 cs_field_component_id_by_name(const char *name,
446  int *f_id,
447  int *c_id);
448 
449 /*----------------------------------------------------------------------------
450  * Return an id associated with a given key name.
451  *
452  * The key must have been defined previously.
453  *
454  * parameters:
455  * name <-- key name
456  *
457  * returns:
458  * id associated with key
459  *----------------------------------------------------------------------------*/
460 
461 int
462 cs_field_key_id(const char *name);
463 
464 /*----------------------------------------------------------------------------
465  * Return an id associated with a given key name if present.
466  *
467  * If the key has not been defined previously, -1 is returned.
468  *
469  * parameters:
470  * name <-- key name
471  *
472  * returns:
473  * id associated with key, or -1
474  *----------------------------------------------------------------------------*/
475 
476 int
477 cs_field_key_id_try(const char *name);
478 
479 /*----------------------------------------------------------------------------
480  * Define a key for an integer value by its name and return an associated id.
481  *
482  * If the key has already been defined, its previous default value is replaced
483  * by the current value, and its id is returned.
484  *
485  * parameters:
486  * name <-- key name
487  * default_value <-- default value associated with key
488  * type flag <-- mask associated with field types with which the
489  * key may be associated, or 0
490  *
491  * returns:
492  * id associated with key
493  *----------------------------------------------------------------------------*/
494 
495 int
496 cs_field_define_key_int(const char *name,
497  int default_value,
498  int type_flag);
499 
500 /*----------------------------------------------------------------------------
501  * Define a key for an floating point value by its name and return an
502  * associated id.
503  *
504  * If the key has already been defined, its previous default value is replaced
505  * by the current value, and its id is returned.
506  *
507  * parameters:
508  * name <-- key name
509  * default_value <-- default value associated with key
510  * type flag <-- mask associated with field types with which the
511  * key may be associated, or 0
512  *
513  * returns:
514  * id associated with key
515  *----------------------------------------------------------------------------*/
516 
517 int
518 cs_field_define_key_double(const char *name,
519  double default_value,
520  int type_flag);
521 
522 /*----------------------------------------------------------------------------
523  * Define a key for an string point value by its name and return an
524  * associated id.
525  *
526  * If the key has already been defined, its previous default value is replaced
527  * by the current value, and its id is returned.
528  *
529  * parameters:
530  * name <-- key name
531  * default_value <-- default value associated with key
532  * type flag <-- mask associated with field types with which the
533  * key may be associated, or 0
534  *
535  * returns:
536  * id associated with key
537  *----------------------------------------------------------------------------*/
538 
539 int
540 cs_field_define_key_str(const char *name,
541  const char *default_value,
542  int type_flag);
543 
544 /*----------------------------------------------------------------------------
545  * Define a key for a structure value by its name and return an
546  * associated id.
547  *
548  * If the key has already been defined, its previous default value is replaced
549  * by the current value, and its id is returned.
550  *
551  * parameters:
552  * name <-- key name
553  * default_value <-- pointer to default value associated with key
554  * log_funct <-- pointer to logging function
555  * log_func_default <-- pointer to default logging function
556  * size <-- sizeof structure
557  * type_flag <-- mask associated with field types with which
558  * the key may be associated, or 0
559  *
560  * returns:
561  * id associated with key
562  *----------------------------------------------------------------------------*/
563 
564 int
565 cs_field_define_key_struct(const char *name,
566  const void *default_value,
567  cs_field_log_key_struct_t *log_func,
568  cs_field_log_key_struct_t *log_func_default,
569  size_t size,
570  int type_flag);
571 
572 /*----------------------------------------------------------------------------
573  * Define a sub key.
574  *
575  * The sub key is the same type as the parent key.
576  *
577  * For a given field, when querying a sub key's value and that value has not
578  * been set, the query will return the value of the parent key.
579  *
580  * parameters:
581  * name <-- key name
582  * parent_id <-- parent key id
583  *
584  * returns:
585  * id associated with key
586  *----------------------------------------------------------------------------*/
587 
588 int
589 cs_field_define_sub_key(const char *name,
590  int parent_id);
591 
592 /*----------------------------------------------------------------------------
593  * Destroy all defined field keys and associated values.
594  *----------------------------------------------------------------------------*/
595 
596 void
598 
599 /*----------------------------------------------------------------------------
600  * Get the type flag associated with a given key id.
601  *
602  * If the key has not been defined previously, -1 is returned.
603  *
604  * parameters:
605  * key_id <-- id of associated key
606  *
607  * returns:
608  * type flag associated with key, or -1
609  *----------------------------------------------------------------------------*/
610 
611 int
612 cs_field_key_flag(int key_id);
613 
614 /*----------------------------------------------------------------------------
615  * Disable logging setup values associated with a given key.
616  *
617  * This is useful when a key is used not for setup purposes, but to track
618  * values associated with a field, such as convergence or performance data.
619  *
620  * parameters:
621  * key_id <-- id of associated key
622  *----------------------------------------------------------------------------*/
623 
624 void
626 
627 /*----------------------------------------------------------------------------
628  * Query if a given key has been set for a field.
629  *
630  * If the key id is not valid, or the field category is not
631  * compatible, a fatal error is provoked.
632  *
633  * parameters:
634  * f <-- pointer to field structure
635  * key_id <-- id of associated key
636  *
637  * returns:
638  * true if the key has been set for this field, false otherwise
639  *----------------------------------------------------------------------------*/
640 
641 bool
643  int key_id);
644 
645 /*----------------------------------------------------------------------------
646  * Query if a given key has been locked for a field.
647  *
648  * If the key id is not valid, or the field category is not
649  * compatible, a fatal error is provoked.
650  *
651  * parameters:
652  * f <-- pointer to field structure
653  * key_id <-- id of associated key
654  *
655  * returns:
656  * true if the key has been locked for this field, false otherwise
657  *----------------------------------------------------------------------------*/
658 
659 bool
661  int key_id);
662 
663 /*----------------------------------------------------------------------------
664  * Lock a field relative to a given key.
665  *
666  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
667  * If the field category is not compatible with the key (as defined
668  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
669  *
670  * parameters:
671  * f <-- pointer to field structure
672  * key_id <-- id of associated key
673  * value <-- value associated with key
674  *
675  * returns:
676  * 0 in case of success, > 1 in case of error
677  *----------------------------------------------------------------------------*/
678 
679 int
681  int key_id);
682 
683 /*----------------------------------------------------------------------------
684  * Assign a integer value for a given key to a field.
685  *
686  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
687  * If the field category is not compatible with the key (as defined
688  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
689  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
690  * If the key value has been locked, CS_FIELD_LOCKED is returned.
691  *
692  * parameters:
693  * f <-- pointer to field structure
694  * key_id <-- id of associated key
695  * value <-- value associated with key
696  *
697  * returns:
698  * 0 in case of success, > 1 in case of error
699  *----------------------------------------------------------------------------*/
700 
701 int
703  int key_id,
704  int value);
705 
706 /*----------------------------------------------------------------------------
707  * Return a integer value for a given key associated with a field.
708  *
709  * If the key id is not valid, or the value type or field category is not
710  * compatible, a fatal error is provoked.
711  *
712  * parameters:
713  * f <-- pointer to field structure
714  * key_id <-- id of associated key
715  *
716  * returns:
717  * integer value associated with the key id for this field
718  *----------------------------------------------------------------------------*/
719 
720 int
722  int key_id);
723 
724 /*----------------------------------------------------------------------------
725  * Set integer bits matching a mask to 1 for a given key for a field.
726  *
727  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
728  * If the field category is not compatible with the key (as defined
729  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
730  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
731  * If the key value has been locked, CS_FIELD_LOCKED is returned.
732  *
733  * parameters:
734  * f <-- pointer to field structure
735  * key_id <-- id of associated key
736  * mask <-- mask associated with key
737  *
738  * returns:
739  * 0 in case of success, > 1 in case of error
740  *----------------------------------------------------------------------------*/
741 
742 int
744  int key_id,
745  int mask);
746 
747 /*----------------------------------------------------------------------------
748  * Set integer bits matching a mask to 0 for a given key for a field.
749  *
750  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
751  * If the field category is not compatible with the key (as defined
752  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
753  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
754  * If the key value has been locked, CS_FIELD_LOCKED is returned.
755  *
756  * parameters:
757  * f <-- pointer to field structure
758  * key_id <-- id of associated key
759  * mask <-- mask associated with key
760  *
761  * returns:
762  * 0 in case of success, > 1 in case of error
763  *----------------------------------------------------------------------------*/
764 
765 int
767  int key_id,
768  int mask);
769 
770 /*----------------------------------------------------------------------------
771  * Assign a floating point value for a given key to a field.
772  *
773  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
774  * If the field category is not compatible with the key (as defined
775  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
776  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
777  * If the key value has been locked, CS_FIELD_LOCKED is returned.
778  *
779  * parameters:
780  * f <-- pointer to field structure
781  * key_id <-- id of associated key
782  * value <-- value associated with key
783  *
784  * returns:
785  * 0 in case of success, > 1 in case of error
786  *----------------------------------------------------------------------------*/
787 
788 int
790  int key_id,
791  double value);
792 
793 /*----------------------------------------------------------------------------
794  * Return a floating point value for a given key associated with a field.
795  *
796  * If the key id is not valid, or the value type or field category is not
797  * compatible, a fatal error is provoked.
798  *
799  * parameters:
800  * f <-- pointer to field structure
801  * key_id <-- id of associated key
802  *
803  * returns:
804  * floating point value associated with the key id for this field
805  *----------------------------------------------------------------------------*/
806 
807 double
809  int key_id);
810 
811 /*----------------------------------------------------------------------------
812  * Assign a character string value for a given key to a field.
813  *
814  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
815  * If the field category is not compatible with the key (as defined
816  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
817  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
818  * If the key value has been locked, CS_FIELD_LOCKED is returned.
819  *
820  * parameters:
821  * f <-- pointer to field structure
822  * key_id <-- id of associated key
823  * str <-- string associated with key
824  *
825  * returns:
826  * 0 in case of success, > 1 in case of error
827  *----------------------------------------------------------------------------*/
828 
829 int
831  int key_id,
832  const char *str);
833 
834 /*----------------------------------------------------------------------------
835  * Return a string for a given key associated with a field.
836  *
837  * If the key id is not valid, or the value type or field category is not
838  * compatible, a fatal error is provoked.
839  *
840  * parameters:
841  * f <-- pointer to field structure
842  * key_id <-- id of associated key
843  *
844  * returns:
845  * pointer to character string associated with the key id for this field
846  *----------------------------------------------------------------------------*/
847 
848 const char *
850  int key_id);
851 
852 
853 /*----------------------------------------------------------------------------
854  * Assign a simple structure for a given key to a field.
855  *
856  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
857  * If the field category is not compatible with the key (as defined
858  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
859  * If the key value has been locked, CS_FIELD_LOCKED is returned.
860  *
861  * parameters:
862  * f <-- pointer to field structure
863  * key_id <-- id of associated key
864  * s <-- structure associated with key
865  *
866  * returns:
867  * 0 in case of success, > 1 in case of error
868  *----------------------------------------------------------------------------*/
869 
870 int
872  int key_id,
873  void *s);
874 
875 /*----------------------------------------------------------------------------
876  * Return a structure for a given key associated with a field.
877  *
878  * If the key id is not valid, or the value type or field category is not
879  * compatible, a fatal error is provoked.
880  *
881  * parameters:
882  * f <-- pointer to field structure
883  * key_id <-- id of associated key
884  * s <-- structure associated with key
885  *
886  * returns:
887  * pointer to structure associated with the key id for this field
888  * (same as s)
889  *----------------------------------------------------------------------------*/
890 
891 const void *
893  int key_id,
894  void *s);
895 
896 /*----------------------------------------------------------------------------*/
912 /*----------------------------------------------------------------------------*/
913 
914 void *
916  int key_id);
917 
918 /*----------------------------------------------------------------------------*/
931 /*----------------------------------------------------------------------------*/
932 
933 const void *
935  int key_id);
936 
937 /*----------------------------------------------------------------------------
938  * Print info relative to all field definitions to log file.
939  *----------------------------------------------------------------------------*/
940 
941 void
942 cs_field_log_defs(void);
943 
944 /*----------------------------------------------------------------------------
945  * Print info relative to a given field to log file.
946  *
947  * parameters:
948  * f <-- pointer to field structure
949  * log_keywords <-- log level for keywords (0: do not log,
950  * 1: log non-default values, 2: log all)
951  *----------------------------------------------------------------------------*/
952 
953 void
955  int log_keywords);
956 
957 /*----------------------------------------------------------------------------
958  * Print info relative to all defined fields to log file.
959  *
960  * parameters:
961  * log_keywords <-- log level for keywords (0: do not log,
962  * 1: log non-default values, 2: log all)
963  *----------------------------------------------------------------------------*/
964 
965 void
966 cs_field_log_fields(int log_keywords);
967 
968 /*----------------------------------------------------------------------------
969  * Print info relative to all key definitions to log file.
970  *----------------------------------------------------------------------------*/
971 
972 void
974 
975 /*----------------------------------------------------------------------------
976  * Print info relative to a given field key to log file.
977  *
978  * parameters:
979  * int key_id <-- id of associated key
980  * log_defaults <-- if true, log default field values in addition to
981  * defined field values
982  *----------------------------------------------------------------------------*/
983 
984 void
985 cs_field_log_key_vals(int key_id,
986  bool log_defaults);
987 
988 /*----------------------------------------------------------------------------
989  * Print info relative to all given field keys to log file.
990  *
991  * parameters:
992  * log_defaults <-- if true, log default field values in addition to
993  * defined field values
994  *----------------------------------------------------------------------------*/
995 
996 void
997 cs_field_log_all_key_vals(bool log_defaults);
998 
999 /*----------------------------------------------------------------------------
1000  * Define base keys.
1001  *
1002  * Keys defined by this function are:
1003  * "label" (string)
1004  * "log" (integer)
1005  * "post_vis" (integer)
1006  * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
1007  * "moment_id" (integer, restricted to
1008  * CS_FIELD_ACCUMULATOR | CS_FIELD_POSTPROCESS);
1009  *
1010  * A recommened practice for different submodules would be to use
1011  * "cs_<module>_key_init() functions to define keys specific to those modules.
1012  *----------------------------------------------------------------------------*/
1013 
1014 void
1016 
1017 /*----------------------------------------------------------------------------
1018  * Return a label associated with a field.
1019  *
1020  * If the "label" key has been set for this field, its associated string
1021  * is returned. Otherwise, the field's name is returned.
1022  *
1023  * parameters:
1024  * f <-- pointer to field structure
1025  *
1026  * returns:
1027  * pointer to character string associated with label for this field
1028  *----------------------------------------------------------------------------*/
1029 
1030 const char *
1031 cs_field_get_label(const cs_field_t *f);
1032 
1033 /*----------------------------------------------------------------------------*/
1034 
1036 
1037 #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:2911
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:3204
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:2865
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:152
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2425
void cs_field_init_bc_coeffs(cs_field_t *f)
Initialize boundary condition coefficients arrays.
Definition: cs_field.c:1889
cs_real_t * b
Definition: cs_field.h:108
int location_id
Definition: cs_field.h:133
Field descriptor.
Definition: cs_field.h:124
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:3525
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:2554
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.c:2714
int dim
Definition: cs_field.h:131
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:1709
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:3321
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
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:2760
cs_real_t * val_pre
Definition: cs_field.h:148
void cs_field_allocate_values(cs_field_t *f)
Allocate arrays for field values.
Definition: cs_field.c:1678
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:4135
int cs_field_lock_key(cs_field_t *f, int key_id)
Lock a field relative to a given key.
Definition: cs_field.c:2823
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.c:2656
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.c:2211
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:2452
cs_real_t * val
Definition: cs_field.h:145
const char * cs_glob_field_comp_name_9[]
void cs_field_define_keys_base(void)
Define base keys.
Definition: cs_field.c:4166
cs_real_t * hext
Definition: cs_field.h:117
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
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:3041
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:2336
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.c:2154
const char * name
Definition: cs_field.h:126
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:2738
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:4011
cs_real_t * bd
Definition: cs_field.h:112
cs_real_t ** vals
Definition: cs_field.h:137
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:129
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:3154
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:2791
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:1515
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:2980
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:3011
int cs_field_id_by_name(const char *name)
Return the id of a defined field based on its name.
Definition: cs_field.c:2315
int id
Definition: cs_field.h:128
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:2682
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:3392
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:2071
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:2517
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:2266
int n_time_vals
Definition: cs_field.h:135
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.c:1495
const char * cs_field_get_label(const cs_field_t *f)
Return a label associated with a field.
Definition: cs_field.c:4192
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:2605
#define END_C_DECLS
Definition: cs_defs.h:462
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:3271
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:1619
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:1559
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.c:3858
cs_real_t * af
Definition: cs_field.h:109
Definition: cs_field_pointer.h:96
int location_id
Definition: cs_field.h:105
cs_real_t * hint
Definition: cs_field.h:116
void cs_field_log_fields(int log_keywords)
Print info relative to all defined fields to log file.
Definition: cs_field.c:3797
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:3663
void cs_field_current_to_previous(cs_field_t *f)
Copy current field values to previous values if applicable.
Definition: cs_field.c:2096
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:2292
Definition: cs_field.h:94
bool is_owner
Definition: cs_field.h:155
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2242
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:3087
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:2480
cs_field_error_type_t
Definition: cs_field.h:89
cs_real_t * a
Definition: cs_field.h:107
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:3468
void() cs_field_log_key_struct_t(const void *t)
Definition: cs_field.h:167
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:1758