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 /*----------------------------------------------------------------------------
215  * Return a field matching a given name and attributes,
216  * creating it if necessary.
217  *
218  * If a field with the same name but different attributes is present,
219  * this is considered an error.
220  *
221  * The default number of time values associated with a field created through
222  * this function is 1. To modify it, use cs_field_set_n_time_vals().
223  *
224  * parameters:
225  * name <-- field name
226  * type_flag <-- mask of field property and category values
227  * location_id <-- id of associated location
228  * dim <-- field dimension (number of components)
229  *
230  * returns:
231  * pointer to field
232  *----------------------------------------------------------------------------*/
233 
234 cs_field_t *
235 cs_field_find_or_create(const char *name,
236  int type_flag,
237  int location_id,
238  int dim);
239 
240 /*----------------------------------------------------------------------------
241  * Change the number of time values managed by a field.
242  *
243  * The minimum will never be below 1, as the current time is always handled.
244  *
245  * parameters:
246  * f <-> pointer to field structure
247  * n_time_vals <-- number of time values to maintain
248  *----------------------------------------------------------------------------*/
249 
250 void
252  int n_time_vals);
253 
254 /*----------------------------------------------------------------------------
255  * Allocate arrays for field values.
256  *
257  * parameters:
258  * f <-- pointer to field structure
259  *----------------------------------------------------------------------------*/
260 
261 void
263 
264 /*----------------------------------------------------------------------------
265  * Map existing value arrays to field descriptor.
266  *
267  * parameters:
268  * f <-> pointer to field structure
269  * val <-- pointer to array of values
270  * val_pre <-- pointer to array of previous values, or NULL
271  *----------------------------------------------------------------------------*/
272 
273 void
275  cs_real_t *val,
276  cs_real_t *val_pre);
277 
278 /*----------------------------------------------------------------------------
279  * Allocate boundary condition coefficient arrays.
280  *
281  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
282  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
283  *
284  * Boundary condition coefficients are not currently supported for other
285  * locations (though support could be added by mapping a boundary->location
286  * indirection array in the cs_mesh_location_t structure).
287  *
288  * For multidimensional fields with coupled components, implicit b and bf
289  * coefficient arrays are arrays of block matrices, not vectors, so the
290  * number of entries for each boundary face is dim*dim instead of dim.
291  *
292  * parameters:
293  * f <-- pointer to field structure
294  * have_flux_bc <-- if true, flux BC coefficients (af and bf) are added
295  * have_mom_bc <-- if true, div BC coefficients (ad and bd) are added
296  * have_conv_bc <-- if true, convection BC coefficients (ac and bc) are added
297  *----------------------------------------------------------------------------*/
298 
299 void
301  bool have_flux_bc,
302  bool have_mom_bc,
303  bool have_conv_bc);
304 
305 /*----------------------------------------------------------------------------*/
306 /* Initialize boundary condition coefficients arrays.
307  *
308  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
309  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
310  *
311  * Boundary condition coefficients are not currently supported for other
312  * locations (though support could be added by mapping a boundary->location
313  * indirection array in the cs_mesh_location_t structure).
314  *
315  * For multidimensional fields with coupled components, implicit b and bf
316  * coefficient arrays are arrays of block matrices, not vectors, so the
317  * number of entries for each boundary face is dim*dim instead of dim.
318  *
319  * parameters:
320  * f <-> pointer to field structure
321  *----------------------------------------------------------------------------*/
322 
323 void
325 
326 /*----------------------------------------------------------------------------
327  * Set current field values to the given constant.
328  *
329  * parameters:
330  * f <-> pointer to field structure
331  * c <-- assigned value
332  *----------------------------------------------------------------------------*/
333 
334 void
336  cs_real_t c);
337 
338 /*----------------------------------------------------------------------------
339  * Copy current field values to previous values if applicable.
340  *
341  * For fields with only one time value, or values not allocated yet,
342  * this is a no-op.
343  *
344  * parameters:
345  * f <-> pointer to field structure
346  *----------------------------------------------------------------------------*/
347 
348 void
350 
351 /*----------------------------------------------------------------------------
352  * Destroy all defined fields.
353  *----------------------------------------------------------------------------*/
354 
355 void
357 
358 /*----------------------------------------------------------------------------
359  * Allocate arrays for all defined fields based on their location.
360  *
361  * Location sized must thus be known.
362  *
363  * Fields that do not own their data should all have been mapped at this
364  * stage, and are checked.
365  *----------------------------------------------------------------------------*/
366 
367 void
369 
370 /*----------------------------------------------------------------------------
371  * Return a pointer to a field based on its id.
372  *
373  * This function requires that a field of the given id is defined.
374  *
375  * parameters:
376  * id <-- field id
377  *
378  * returns:
379  * pointer to the field structure
380  *----------------------------------------------------------------------------*/
381 
382 cs_field_t *
383 cs_field_by_id(int id);
384 
385 /*----------------------------------------------------------------------------
386  * Return a pointer to a field based on its name.
387  *
388  * This function requires that a field of the given name is defined.
389  *
390  * parameters:
391  * name <-- field name
392  *
393  * returns:
394  * pointer to the field structure
395  *----------------------------------------------------------------------------*/
396 
397 cs_field_t *
398 cs_field_by_name(const char *name);
399 
400 /*----------------------------------------------------------------------------
401  * Return a pointer to a field based on its name if present.
402  *
403  * If no field of the given name is defined, NULL is returned.
404  *
405  * parameters:
406  * name <-- field name
407  *
408  * returns:
409  * pointer to the field structure, or NULL
410  *----------------------------------------------------------------------------*/
411 
412 cs_field_t *
413 cs_field_by_name_try(const char *name);
414 
415 /*----------------------------------------------------------------------------
416  * Return the id of a defined field based on its name.
417  *
418  * If no field with the given name exists, -1 is returned.
419  *
420  * parameters:
421  * name <-- field name
422  *
423  * returns:
424  * id the field, or -1 if not found
425  *----------------------------------------------------------------------------*/
426 
427 int
428 cs_field_id_by_name(const char *name);
429 
430 /*----------------------------------------------------------------------------
431  * Return the id of a defined field and an associated component
432  * based on a component name.
433  *
434  * If no field with the given name exists, -1 is returned.
435  *
436  * parameters:
437  * name <-- field or field+component name
438  * f_id --> field id, or -1 if no match was found
439  * c_id --> component id, or -1 for all components
440  *----------------------------------------------------------------------------*/
441 
442 void
443 cs_field_component_id_by_name(const char *name,
444  int *f_id,
445  int *c_id);
446 
447 /*----------------------------------------------------------------------------
448  * Return an id associated with a given key name.
449  *
450  * The key must have been defined previously.
451  *
452  * parameters:
453  * name <-- key name
454  *
455  * returns:
456  * id associated with key
457  *----------------------------------------------------------------------------*/
458 
459 int
460 cs_field_key_id(const char *name);
461 
462 /*----------------------------------------------------------------------------
463  * Return an id associated with a given key name if present.
464  *
465  * If the key has not been defined previously, -1 is returned.
466  *
467  * parameters:
468  * name <-- key name
469  *
470  * returns:
471  * id associated with key, or -1
472  *----------------------------------------------------------------------------*/
473 
474 int
475 cs_field_key_id_try(const char *name);
476 
477 /*----------------------------------------------------------------------------
478  * Define a key for an integer value by its name and return an associated id.
479  *
480  * If the key has already been defined, its previous default value is replaced
481  * by the current value, and its id is returned.
482  *
483  * parameters:
484  * name <-- key name
485  * default_value <-- default value associated with key
486  * type flag <-- mask associated with field types with which the
487  * key may be associated, or 0
488  *
489  * returns:
490  * id associated with key
491  *----------------------------------------------------------------------------*/
492 
493 int
494 cs_field_define_key_int(const char *name,
495  int default_value,
496  int type_flag);
497 
498 /*----------------------------------------------------------------------------
499  * Define a key for an floating point value by its name and return an
500  * associated id.
501  *
502  * If the key has already been defined, its previous default value is replaced
503  * by the current value, and its id is returned.
504  *
505  * parameters:
506  * name <-- key name
507  * default_value <-- default value associated with key
508  * type flag <-- mask associated with field types with which the
509  * key may be associated, or 0
510  *
511  * returns:
512  * id associated with key
513  *----------------------------------------------------------------------------*/
514 
515 int
516 cs_field_define_key_double(const char *name,
517  double default_value,
518  int type_flag);
519 
520 /*----------------------------------------------------------------------------
521  * Define a key for an string point value by its name and return an
522  * associated id.
523  *
524  * If the key has already been defined, its previous default value is replaced
525  * by the current value, and its id is returned.
526  *
527  * parameters:
528  * name <-- key name
529  * default_value <-- default value associated with key
530  * type flag <-- mask associated with field types with which the
531  * key may be associated, or 0
532  *
533  * returns:
534  * id associated with key
535  *----------------------------------------------------------------------------*/
536 
537 int
538 cs_field_define_key_str(const char *name,
539  const char *default_value,
540  int type_flag);
541 
542 /*----------------------------------------------------------------------------
543  * Define a key for a structure value by its name and return an
544  * associated id.
545  *
546  * If the key has already been defined, its previous default value is replaced
547  * by the current value, and its id is returned.
548  *
549  * parameters:
550  * name <-- key name
551  * default_value <-- pointer to default value associated with key
552  * log_funct <-- pointer to logging function
553  * log_func_default <-- pointer to default logging function
554  * size <-- sizeof structure
555  * type_flag <-- mask associated with field types with which
556  * the key may be associated, or 0
557  *
558  * returns:
559  * id associated with key
560  *----------------------------------------------------------------------------*/
561 
562 int
563 cs_field_define_key_struct(const char *name,
564  const void *default_value,
565  cs_field_log_key_struct_t *log_func,
566  cs_field_log_key_struct_t *log_func_default,
567  size_t size,
568  int type_flag);
569 
570 /*----------------------------------------------------------------------------
571  * Define a sub key.
572  *
573  * The sub key is the same type as the parent key.
574  *
575  * For a given field, when querying a sub key's value and that value has not
576  * been set, the query will return the value of the parent key.
577  *
578  * parameters:
579  * name <-- key name
580  * parent_id <-- parent key id
581  *
582  * returns:
583  * id associated with key
584  *----------------------------------------------------------------------------*/
585 
586 int
587 cs_field_define_sub_key(const char *name,
588  int parent_id);
589 
590 /*----------------------------------------------------------------------------
591  * Destroy all defined field keys and associated values.
592  *----------------------------------------------------------------------------*/
593 
594 void
596 
597 /*----------------------------------------------------------------------------
598  * Get the type flag associated with a given key id.
599  *
600  * If the key has not been defined previously, -1 is returned.
601  *
602  * parameters:
603  * key_id <-- id of associated key
604  *
605  * returns:
606  * type flag associated with key, or -1
607  *----------------------------------------------------------------------------*/
608 
609 int
610 cs_field_key_flag(int key_id);
611 
612 /*----------------------------------------------------------------------------
613  * Disable logging setup values associated with a given key.
614  *
615  * This is useful when a key is used not for setup purposes, but to track
616  * values associated with a field, such as convergence or performance data.
617  *
618  * parameters:
619  * key_id <-- id of associated key
620  *----------------------------------------------------------------------------*/
621 
622 void
624 
625 /*----------------------------------------------------------------------------
626  * Query if a given key has been set for a field.
627  *
628  * If the key id is not valid, or the field category is not
629  * compatible, a fatal error is provoked.
630  *
631  * parameters:
632  * f <-- pointer to field structure
633  * key_id <-- id of associated key
634  *
635  * returns:
636  * true if the key has been set for this field, false otherwise
637  *----------------------------------------------------------------------------*/
638 
639 bool
641  int key_id);
642 
643 /*----------------------------------------------------------------------------
644  * Query if a given key has been locked for a field.
645  *
646  * If the key id is not valid, or the field category is not
647  * compatible, a fatal error is provoked.
648  *
649  * parameters:
650  * f <-- pointer to field structure
651  * key_id <-- id of associated key
652  *
653  * returns:
654  * true if the key has been locked for this field, false otherwise
655  *----------------------------------------------------------------------------*/
656 
657 bool
659  int key_id);
660 
661 /*----------------------------------------------------------------------------
662  * Lock a field relative to a given key.
663  *
664  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
665  * If the field category is not compatible with the key (as defined
666  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
667  *
668  * parameters:
669  * f <-- pointer to field structure
670  * key_id <-- id of associated key
671  * value <-- value associated with key
672  *
673  * returns:
674  * 0 in case of success, > 1 in case of error
675  *----------------------------------------------------------------------------*/
676 
677 int
679  int key_id);
680 
681 /*----------------------------------------------------------------------------
682  * Assign a integer value for a given key to a field.
683  *
684  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
685  * If the field category is not compatible with the key (as defined
686  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
687  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
688  * If the key value has been locked, CS_FIELD_LOCKED is returned.
689  *
690  * parameters:
691  * f <-- pointer to field structure
692  * key_id <-- id of associated key
693  * value <-- value associated with key
694  *
695  * returns:
696  * 0 in case of success, > 1 in case of error
697  *----------------------------------------------------------------------------*/
698 
699 int
701  int key_id,
702  int value);
703 
704 /*----------------------------------------------------------------------------
705  * Return a integer value for a given key associated with a field.
706  *
707  * If the key id is not valid, or the value type or field category is not
708  * compatible, a fatal error is provoked.
709  *
710  * parameters:
711  * f <-- pointer to field structure
712  * key_id <-- id of associated key
713  *
714  * returns:
715  * integer value associated with the key id for this field
716  *----------------------------------------------------------------------------*/
717 
718 int
720  int key_id);
721 
722 /*----------------------------------------------------------------------------
723  * Set integer bits matching a mask to 1 for a given key for a field.
724  *
725  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
726  * If the field category is not compatible with the key (as defined
727  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
728  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
729  * If the key value has been locked, CS_FIELD_LOCKED is returned.
730  *
731  * parameters:
732  * f <-- pointer to field structure
733  * key_id <-- id of associated key
734  * mask <-- mask associated with key
735  *
736  * returns:
737  * 0 in case of success, > 1 in case of error
738  *----------------------------------------------------------------------------*/
739 
740 int
742  int key_id,
743  int mask);
744 
745 /*----------------------------------------------------------------------------
746  * Set integer bits matching a mask to 0 for a given key for a field.
747  *
748  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
749  * If the field category is not compatible with the key (as defined
750  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
751  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
752  * If the key value has been locked, CS_FIELD_LOCKED is returned.
753  *
754  * parameters:
755  * f <-- pointer to field structure
756  * key_id <-- id of associated key
757  * mask <-- mask associated with key
758  *
759  * returns:
760  * 0 in case of success, > 1 in case of error
761  *----------------------------------------------------------------------------*/
762 
763 int
765  int key_id,
766  int mask);
767 
768 /*----------------------------------------------------------------------------
769  * Assign a floating point value for a given key to a field.
770  *
771  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
772  * If the field category is not compatible with the key (as defined
773  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
774  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
775  * If the key value has been locked, CS_FIELD_LOCKED is returned.
776  *
777  * parameters:
778  * f <-- pointer to field structure
779  * key_id <-- id of associated key
780  * value <-- value associated with key
781  *
782  * returns:
783  * 0 in case of success, > 1 in case of error
784  *----------------------------------------------------------------------------*/
785 
786 int
788  int key_id,
789  double value);
790 
791 /*----------------------------------------------------------------------------
792  * Return a floating point value for a given key associated with a field.
793  *
794  * If the key id is not valid, or the value type or field category is not
795  * compatible, a fatal error is provoked.
796  *
797  * parameters:
798  * f <-- pointer to field structure
799  * key_id <-- id of associated key
800  *
801  * returns:
802  * floating point value associated with the key id for this field
803  *----------------------------------------------------------------------------*/
804 
805 double
807  int key_id);
808 
809 /*----------------------------------------------------------------------------
810  * Assign a character string value for a given key to a field.
811  *
812  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
813  * If the field category is not compatible with the key (as defined
814  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
815  * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
816  * If the key value has been locked, CS_FIELD_LOCKED is returned.
817  *
818  * parameters:
819  * f <-- pointer to field structure
820  * key_id <-- id of associated key
821  * str <-- string associated with key
822  *
823  * returns:
824  * 0 in case of success, > 1 in case of error
825  *----------------------------------------------------------------------------*/
826 
827 int
829  int key_id,
830  const char *str);
831 
832 /*----------------------------------------------------------------------------
833  * Return a string for a given key associated with a field.
834  *
835  * If the key id is not valid, or the value type or field category is not
836  * compatible, a fatal error is provoked.
837  *
838  * parameters:
839  * f <-- pointer to field structure
840  * key_id <-- id of associated key
841  *
842  * returns:
843  * pointer to character string associated with the key id for this field
844  *----------------------------------------------------------------------------*/
845 
846 const char *
848  int key_id);
849 
850 
851 /*----------------------------------------------------------------------------
852  * Assign a simple structure for a given key to a field.
853  *
854  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
855  * If the field category is not compatible with the key (as defined
856  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
857  * If the key value has been locked, CS_FIELD_LOCKED is returned.
858  *
859  * parameters:
860  * f <-- pointer to field structure
861  * key_id <-- id of associated key
862  * s <-- structure associated with key
863  *
864  * returns:
865  * 0 in case of success, > 1 in case of error
866  *----------------------------------------------------------------------------*/
867 
868 int
870  int key_id,
871  void *s);
872 
873 /*----------------------------------------------------------------------------
874  * Return a structure for a given key associated with a field.
875  *
876  * If the key id is not valid, or the value type or field category is not
877  * compatible, a fatal error is provoked.
878  *
879  * parameters:
880  * f <-- pointer to field structure
881  * key_id <-- id of associated key
882  * s <-- structure associated with key
883  *
884  * returns:
885  * pointer to structure associated with the key id for this field
886  * (same as s)
887  *----------------------------------------------------------------------------*/
888 
889 const void *
891  int key_id,
892  void *s);
893 
894 /*----------------------------------------------------------------------------*/
910 /*----------------------------------------------------------------------------*/
911 
912 void *
914  int key_id);
915 
916 /*----------------------------------------------------------------------------*/
929 /*----------------------------------------------------------------------------*/
930 
931 const void *
933  int key_id);
934 
935 /*----------------------------------------------------------------------------
936  * Print info relative to all field definitions to log file.
937  *----------------------------------------------------------------------------*/
938 
939 void
940 cs_field_log_defs(void);
941 
942 /*----------------------------------------------------------------------------
943  * Print info relative to a given field to log file.
944  *
945  * parameters:
946  * f <-- pointer to field structure
947  * log_keywords <-- log level for keywords (0: do not log,
948  * 1: log non-default values, 2: log all)
949  *----------------------------------------------------------------------------*/
950 
951 void
953  int log_keywords);
954 
955 /*----------------------------------------------------------------------------
956  * Print info relative to all defined fields to log file.
957  *
958  * parameters:
959  * log_keywords <-- log level for keywords (0: do not log,
960  * 1: log non-default values, 2: log all)
961  *----------------------------------------------------------------------------*/
962 
963 void
964 cs_field_log_fields(int log_keywords);
965 
966 /*----------------------------------------------------------------------------
967  * Print info relative to all key definitions to log file.
968  *----------------------------------------------------------------------------*/
969 
970 void
972 
973 /*----------------------------------------------------------------------------
974  * Print info relative to a given field key to log file.
975  *
976  * parameters:
977  * int key_id <-- id of associated key
978  * log_defaults <-- if true, log default field values in addition to
979  * defined field values
980  *----------------------------------------------------------------------------*/
981 
982 void
983 cs_field_log_key_vals(int key_id,
984  bool log_defaults);
985 
986 /*----------------------------------------------------------------------------
987  * Print info relative to all given field keys to log file.
988  *
989  * parameters:
990  * log_defaults <-- if true, log default field values in addition to
991  * defined field values
992  *----------------------------------------------------------------------------*/
993 
994 void
995 cs_field_log_all_key_vals(bool log_defaults);
996 
997 /*----------------------------------------------------------------------------
998  * Define base keys.
999  *
1000  * Keys defined by this function are:
1001  * "label" (string)
1002  * "log" (integer)
1003  * "post_vis" (integer)
1004  * "post_probes" (integer)
1005  * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
1006  * "moment_id" (integer, restricted to
1007  * CS_FIELD_ACCUMULATOR | CS_FIELD_POSTPROCESS);
1008  *
1009  * A recommened practice for different submodules would be to use
1010  * "cs_<module>_key_init() functions to define keys specific to those modules.
1011  *----------------------------------------------------------------------------*/
1012 
1013 void
1015 
1016 /*----------------------------------------------------------------------------
1017  * Return a label associated with a field.
1018  *
1019  * If the "label" key has been set for this field, its associated string
1020  * is returned. Otherwise, the field's name is returned.
1021  *
1022  * parameters:
1023  * f <-- pointer to field structure
1024  *
1025  * returns:
1026  * pointer to character string associated with label for this field
1027  *----------------------------------------------------------------------------*/
1028 
1029 const char *
1030 cs_field_get_label(const cs_field_t *f);
1031 
1032 /*----------------------------------------------------------------------------*/
1033 
1035 
1036 #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:2907
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:3200
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:2861
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:2421
void cs_field_init_bc_coeffs(cs_field_t *f)
Initialize boundary condition coefficients arrays.
Definition: cs_field.c:1885
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:3521
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:2550
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.c:2710
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:1705
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:3317
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
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:2756
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:1674
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:4134
int cs_field_lock_key(cs_field_t *f, int key_id)
Lock a field relative to a given key.
Definition: cs_field.c:2819
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.c:2652
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.c:2207
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:2448
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:3037
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:2332
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.c:2150
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:2734
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:4010
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:3150
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:2787
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:1517
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:2976
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:3007
int cs_field_id_by_name(const char *name)
Return the id of a defined field based on its name.
Definition: cs_field.c:2311
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:2678
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:3388
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:2067
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:2513
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:2262
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:1497
const char * cs_field_get_label(const cs_field_t *f)
Return a label associated with a field.
Definition: cs_field.c:4193
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:2601
#define END_C_DECLS
Definition: cs_defs.h:452
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:3267
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:1615
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.c:3854
cs_real_t * af
Definition: cs_field.h:109
Definition: cs_field_pointer.h:94
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:3793
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:3659
void cs_field_current_to_previous(cs_field_t *f)
Copy current field values to previous values if applicable.
Definition: cs_field.c:2092
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:2288
Definition: cs_field.h:94
bool is_owner
Definition: cs_field.h:155
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:1560
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2238
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:3083
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:2476
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:3464
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:1754