Code_Saturne
CFD tool
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-2012 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 #if defined(HAVE_MPI)
31 #include <mpi.h>
32 #endif
33 
34 /*----------------------------------------------------------------------------
35  * Local headers
36  *----------------------------------------------------------------------------*/
37 
38 #include "cs_defs.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*=============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*
49  * Field property type
50  */
51 
52 #define CS_FIELD_INTENSIVE (1 << 0)
53 #define CS_FIELD_EXTENSIVE (1 << 1)
54 
55 /* Field category */
56 
57 #define CS_FIELD_VARIABLE (1 << 2)
58 #define CS_FIELD_PROPERTY (1 << 3)
59 #define CS_FIELD_POSTPROCESS (1 << 4)
60 #define CS_FIELD_ACCUMULATOR (1 << 5)
61 
62 #define CS_FIELD_USER (1 << 6)
63 
64 /*============================================================================
65  * Type definitions
66  *============================================================================*/
67 
68 /* Field handling error types */
69 /*----------------------------*/
70 
71 typedef enum {
72 
78 
80 
81 /* Field boundary condition descriptor (for variables) */
82 /*-----------------------------------------------------*/
83 
84 typedef struct {
85 
86  int location_id; /* Id of matching location */
87 
88  cs_real_t *a; /* Explicit coefficient */
89  cs_real_t *b; /* Implicit coefficient */
90  cs_real_t *af; /* Explicit coefficient for flux */
91  cs_real_t *bf; /* Implicit coefficient for flux */
92 
94 
95 /* Field descriptor */
96 /*------------------*/
97 
98 typedef struct {
99 
100  const char *name; /* Canonical name */
101 
102  int id; /* Field id */
103  int type; /* Field type flag */
104 
105  int dim; /* Field dimension */
106  bool interleaved; /* is field interleaved ? */
107 
108  int location_id; /* Id of matching location */
109 
110  int n_time_vals; /* Number of time values (1 or 2) */
111 
112  cs_real_t *val; /* For each active location, pointer
113  to matching values array */
114 
115  cs_real_t *val_pre; /* For each active location, pointer
116  to matching previous values array
117  (if n_time_vals == 2) */
118 
119  cs_field_bc_coeffs_t *bc_coeffs; /* Boundary condition coefficients,
120  for variable type fields */
121 
122  bool is_owner; /* Ownership flag for values
123  and boundary coefficients */
124 
125 } cs_field_t;
126 
127 /*============================================================================
128  * Public Fortran function definitions
129  *============================================================================*/
130 
131 /*----------------------------------------------------------------------------
132  * Define a field.
133  *
134  * Fortran interface; use flddef (see field.f90)
135  *
136  * subroutine fldde1 (name, lname, iexten, itycat, ityloc, idim, ilved,
137  * *****************
138  * iprev, idfld)
139  *
140  * character* name : <-- : Field name
141  * integer lname : <-- : Field name length
142  * integer iexten : <-- : 1: intensive; 2: extensive
143  * integer itycat : <-- : Field category (may be added)
144  * : : 4: variable
145  * : : 8: property
146  * : : 16: postprocess
147  * : : 32: accumulator
148  * : : 64: user
149  * integer ityloc : <-- : Location type
150  * : : 0: none
151  * : : 1: cells
152  * : : 2: interior faces
153  * : : 3: interior faces
154  * : : 4: vertices
155  * integer idim : <-- : Field dimension
156  * integer ilved : <-- : 0: not intereaved; 1: interleaved
157  * integer iprev : <-- : 0: no previous values, 1: previous
158  * integer idfld : --> : id of defined field
159  *----------------------------------------------------------------------------*/
160 
161 void CS_PROCF (fldde1, FLDDE1)
162 (
163  const char *name,
164  const cs_int_t *lname,
165  const cs_int_t *iexten,
166  const cs_int_t *itycat,
167  const cs_int_t *ityloc,
168  const cs_int_t *idim,
169  const cs_int_t *ilved,
170  const cs_int_t *iprev,
171  cs_int_t *idfld
172  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
173  by many Fortran compilers) */
174 );
175 
176 /*----------------------------------------------------------------------------
177  * Allocate field values
178  *
179  * Fortran interface
180  *
181  * subroutine fldalo (ifield)
182  * *****************
183  *
184  * integer ifield : <-- : Field id
185  *----------------------------------------------------------------------------*/
186 
187 void CS_PROCF (fldalo, FLDALO)
188 (
189  const cs_int_t *ifield
190 );
191 
192 /*----------------------------------------------------------------------------
193  * Map values to a field.
194  *
195  * Fortran interface
196  *
197  * subroutine fldmap (ifield, val, valp)
198  * *****************
199  *
200  * integer ifield : <-- : Field id
201  * cs_real_t* val : <-- : Pointer to field values array
202  * cs_real_t* valp : <-- : Pointer to values at previous
203  * : : time step if field was defined
204  * : : with iprev = 1
205  *----------------------------------------------------------------------------*/
206 
207 void CS_PROCF (fldmap, FLDMAP)
208 (
209  const cs_int_t *ifield,
210  cs_real_t *val,
211  cs_real_t *valp
212 );
213 
214 /*----------------------------------------------------------------------------
215  * Map field boundary coefficient arrays.
216  *
217  * Fortran interface
218  *
219  * subroutine fldbcm (ifield, icpled, a, b, af, bf)
220  * *****************
221  *
222  * integer ifield : <-- : Field id
223  * cs_real_t* a : <-- : explicit BC coefficients array
224  * cs_real_t* b : <-- : implicit BC coefficients array
225  * cs_real_t* af : <-- : explicit flux BC coefficients array,
226  * : : or a (or NULL)
227  * cs_real_t* bf : <-- : implicit flux BC coefficients array,
228  * : : or a (or NULL)
229  *----------------------------------------------------------------------------*/
230 
231 void CS_PROCF (fldbcm, FLDBCM)
232 (
233  const cs_int_t *ifield,
234  cs_real_t *a,
235  cs_real_t *b,
236  cs_real_t *af,
237  cs_real_t *bf
238 );
239 
240 /*----------------------------------------------------------------------------
241  * Allocate arrays for all defined fields based on their location.
242  *
243  * Location sized must thus be known.
244  *
245  * Fields that do not own their data should all have been mapped at this
246  * stage, and are checked.
247  *
248  * Fortran interface
249  *
250  * subroutine fldama
251  * *****************
252  *----------------------------------------------------------------------------*/
253 
254 void CS_PROCF (fldama, FLDAMA)
255 (
256  void
257 );
258 
259 /*----------------------------------------------------------------------------
260  * Retrieve field value pointer for scalar field
261  *
262  * Fortran interface; use fldpts
263  *
264  * function fldps1 (ifield, iprev)
265  * ***************
266  *
267  * integer ifield : <-- : Field id
268  * integer iprev : <-- : if 1, pointer to previous values
269  *----------------------------------------------------------------------------*/
270 
271 void CS_PROCF (fldps1, FLDPS1)
272 (
273  const cs_int_t *ifield,
274  const cs_int_t *iprev
275 );
276 
277 /*----------------------------------------------------------------------------
278  * Retrieve field value pointer for vector field
279  *
280  * Fortran interface; use fldptv
281  *
282  * function fldpv1 (ifield, iprev)
283  * ***************
284  *
285  * integer ifield : <-- : Field id
286  * integer iprev : <-- : if 1, pointer to previous values
287  *----------------------------------------------------------------------------*/
288 
289 void CS_PROCF (fldpv1, FLDPV1)
290 (
291  const cs_int_t *ifield,
292  const cs_int_t *iprev
293 );
294 
295 /*----------------------------------------------------------------------------
296  * Return an id associated with a given field name if present.
297  *
298  * If the field has not been defined previously, -1 is returned.
299  *
300  * Fortran interface; use fldfid (see field.f90)
301  *
302  * subroutine fldfi1 (name, lname, ifield)
303  * *****************
304  *
305  * character* name : <-- : Field name
306  * integer lname : <-- : Field name length
307  * integer ifield : --> : id of given key
308  *----------------------------------------------------------------------------*/
309 
310 void CS_PROCF (fldfi1, FLDFI1)
311 (
312  const char *name,
313  const cs_int_t *lname,
314  cs_int_t *ifield
315  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
316  by many Fortran compilers) */
317 );
318 
319 /*----------------------------------------------------------------------------
320  * Return an id associated with a given key name if present.
321  *
322  * If the key has not been defined previously, -1 is returned.
323  *
324  * Fortran interface; use fldkid (see field.f90)
325  *
326  * subroutine fldki1 (name, lname, ikeyid)
327  * *****************
328  *
329  * character* name : <-- : Key name
330  * integer lname : <-- : Key name length
331  * integer ikey : --> : id of given key
332  *----------------------------------------------------------------------------*/
333 
334 void CS_PROCF (fldki1, FLDKI1)
335 (
336  const char *name,
337  const cs_int_t *lname,
338  cs_int_t *ikey
339  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
340  by many Fortran compilers) */
341 );
342 
343 /*----------------------------------------------------------------------------
344  * Assign an integer value for a given key to a field.
345  *
346  * If the key id is not valid, or the value type or field category is not
347  * compatible, a fatal error is provoked.
348  *
349  * subroutine fldski (ifield, ikey, value)
350  * *****************
351  *
352  * integer ifield : <-- : Field id
353  * integer ikey : <-- : Key id
354  * integer value : <-- : Associated value
355  *----------------------------------------------------------------------------*/
356 
357 void CS_PROCF (fldski, FLDSKI)
358 (
359  const cs_int_t *ifield,
360  const cs_int_t *ikey,
361  cs_int_t *value
362 );
363 
364 /*----------------------------------------------------------------------------
365  * Return a integer value for a given key associated with a field.
366  *
367  * If the key id is not valid, or the value type or field category is not
368  * compatible, a fatal error is provoked.
369  *
370  * subroutine fldgki (ifield, ikey, value)
371  * *****************
372  *
373  * integer ifield : <-- : Field id
374  * integer ikey : <-- : Key id
375  * integer value : --> : Associated value
376  *----------------------------------------------------------------------------*/
377 
378 void CS_PROCF (fldgki, FLDGKI)
379 (
380  const cs_int_t *ifield,
381  const cs_int_t *ikey,
382  cs_int_t *value
383 );
384 
385 /*----------------------------------------------------------------------------
386  * Assign a floating point value for a given key to a field.
387  *
388  * If the key id is not valid, or the value type or field category is not
389  * compatible, a fatal error is provoked.
390  *
391  * subroutine fldskd (ifield, ikey, value)
392  * *****************
393  *
394  * integer ifield : <-- : Field id
395  * integer ikey : <-- : Key id
396  * double precision value : <-- : Associated value
397  *----------------------------------------------------------------------------*/
398 
399 void CS_PROCF (fldskd, FLDSKD)
400 (
401  const cs_int_t *ifield,
402  const cs_int_t *ikey,
403  cs_real_t *value
404 );
405 
406 /*----------------------------------------------------------------------------
407  * Return a floating point value for a given key associated with a field.
408  *
409  * If the key id is not valid, or the value type or field category is not
410  * compatible, a fatal error is provoked.
411  *
412  * subroutine fldgkd (ifield, ikey, value)
413  * *****************
414  *
415  * integer ifield : <-- : Field id
416  * integer ikey : <-- : Key id
417  * double precision value : --> : Associated value
418  *----------------------------------------------------------------------------*/
419 
420 void CS_PROCF (fldgkd, FLDGKD)
421 (
422  const cs_int_t *ifield,
423  const cs_int_t *ikey,
424  cs_real_t *value
425 );
426 
427 /*----------------------------------------------------------------------------
428  * Assign a character string for a given key to a field.
429  *
430  * If the key id is not valid, or the value type or field category is not
431  * compatible, a fatal error is provoked.
432  *
433  * Fortran interface; use fldsks (see field.f90)
434  *
435  * subroutine fldsk1 (ifield, ikey, str, lstr)
436  * *****************
437  *
438  * integer ifield : <-- : Field id
439  * integer ikey : <-- : Key id
440  * character* str : <-- : Associated string
441  * integer lstr : <-- : Associated string length
442  *----------------------------------------------------------------------------*/
443 
444 void CS_PROCF (fldsk1, FLDSK1)
445 (
446  const cs_int_t *ifield,
447  const cs_int_t *ikey,
448  const char *str,
449  const cs_int_t *lstr
450  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
451  by many Fortran compilers) */
452 );
453 
454 /*----------------------------------------------------------------------------
455  * Return a character string for a given key associated with a field.
456  *
457  * If the key id is not valid, or the value type or field category is not
458  * compatible, a fatal error is provoked.
459  *
460  * Fortran interface; use fldgk1 (see field.f90)
461  *
462  * subroutine fldgk1 (ifield, ikey, str, lstr)
463  * *****************
464  *
465  * integer ifield : <-- : Field id
466  * integer ikey : <-- : Key id
467  * character* str : --> : Associated string
468  * integer lstr : <-- : Associated string length
469  *----------------------------------------------------------------------------*/
470 
471 void CS_PROCF (fldgk1, FLDGK1)
472 (
473  const cs_int_t *ifield,
474  const cs_int_t *ikey,
475  char *str,
476  const cs_int_t *lstr
477  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
478  by many Fortran compilers) */
479 );
480 
481 /*=============================================================================
482  * Public function prototypes
483  *============================================================================*/
484 
485 /*----------------------------------------------------------------------------
486  * Return the number of defined fields.
487  *
488  * returns:
489  * number of defined fields.
490  *----------------------------------------------------------------------------*/
491 
492 int
493 cs_field_n_fields(void);
494 
495 /*----------------------------------------------------------------------------
496  * Create a field descriptor.
497  *
498  * For fields with a dimension greater than 1, components are interleaved.
499  *
500  * parameters:
501  * name <-- field name
502  * type_flag <-- mask of field property and category values
503  * location_id <-- id of associated location
504  * dim <-- field dimension (number of components)
505  * interleaved <-- indicate if values ar interleaved
506  * (ignored if number of components < 2)
507  * has_previous <-- maintain values at the previous time step ?
508  *
509  * returns:
510  * pointer to new field.
511  *----------------------------------------------------------------------------*/
512 
513 cs_field_t *
514 cs_field_create(const char *name,
515  int type_flag,
516  int location_id,
517  int dim,
518  bool interleaved,
519  bool has_previous);
520 
521 /*----------------------------------------------------------------------------
522  * Allocate arrays for field values.
523  *
524  * parameters:
525  * f <-- pointer to field structure
526  *----------------------------------------------------------------------------*/
527 
528 void
530 
531 /*----------------------------------------------------------------------------
532  * Map existing values to field descriptor.
533  *
534  * parameters:
535  * f <-> pointer to field structure
536  * val <-- pointer to array of values
537  * val_pre <-- pointer to array of previous values, or NULL
538  *----------------------------------------------------------------------------*/
539 
540 void
542  cs_real_t *val,
543  cs_real_t *val_pre);
544 
545 /*----------------------------------------------------------------------------
546  * Allocate boundary condition coefficient arrays.
547  *
548  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
549  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
550  *
551  * Boundary condition coefficients are not currently supported for other
552  * locations (though support could be added by mapping a boundary->location
553  * indirection array in the cs_mesh_location_t structure).
554  *
555  * For multidimensional fields, arrays are assumed to have the same
556  * interleaving behavior as the field, unless components are coupled.
557  *
558  * For multidimensional fields with coupled components, interleaving
559  * is the norm, and implicit coefficients arrays are arrays of block matrices,
560  * not vectors, so the number of entris for each boundary face is
561  * dim*dim instead of dim.
562  *
563  * parameters:
564  * f <-- pointer to field structure
565  * have_flux_bc <-- if true, flux BC coefficients (af and bf) are added
566  *----------------------------------------------------------------------------*/
567 
568 void
570  bool have_flux_bc);
571 
572 /*----------------------------------------------------------------------------
573  * Map existing field boundary condition coefficient arrays.
574  *
575  * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
576  * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
577  *
578  * Boundary condition coefficients are not currently supported for other
579  * locations (though support could be added by mapping a boundary->location
580  * indirection array in the cs_mesh_location_t structure).
581  *
582  * For multidimensional fields, arrays are assumed to have the same
583  * interleaving behavior as the field, unless components are coupled.
584  *
585  * For multidimensional fields with coupled components, interleaving
586  * is the norm, and implicit coefficients arrays are arrays of block matrices,
587  * not vectors, so the number of entris for each boundary face is
588  * dim*dim instead of dim.
589  *
590  * parameters:
591  * f <-> pointer to field structure
592  * a <-- explicit BC coefficients array
593  * b <-- implicit BC coefficients array
594  * af <-- explicit flux BC coefficients array, or NULL
595  * bf <-- implicit flux BC coefficients array, or NULL
596  *----------------------------------------------------------------------------*/
597 
598 void
600  cs_real_t *a,
601  cs_real_t *b,
602  cs_real_t *af,
603  cs_real_t *bf);
604 
605 /*----------------------------------------------------------------------------
606  * Destroy all defined fields.
607  *----------------------------------------------------------------------------*/
608 
609 void
611 
612 /*----------------------------------------------------------------------------
613  * Allocate arrays for all defined fields based on their location.
614  *
615  * Location sized must thus be known.
616  *
617  * Fields that do not own their data should all have been mapped at this
618  * stage, and are checked.
619  *----------------------------------------------------------------------------*/
620 
621 void
623 
624 /*----------------------------------------------------------------------------
625  * Return a pointer to a field based on its id.
626  *
627  * This function requires that a field of the given id is defined.
628  *
629  * parameters:
630  * id <-- field id
631  *
632  * returns:
633  * pointer to the field structure
634  *----------------------------------------------------------------------------*/
635 
636 cs_field_t *
637 cs_field_by_id(int id);
638 
639 /*----------------------------------------------------------------------------
640  * Return a pointer to a field based on its name.
641  *
642  * This function requires that a field of the given name is defined.
643  *
644  * parameters:
645  * name <-- field name
646  *
647  * returns:
648  * pointer to the field structure
649  *----------------------------------------------------------------------------*/
650 
651 cs_field_t *
652 cs_field_by_name(const char *name);
653 
654 /*----------------------------------------------------------------------------
655  * Return a pointer to a field based on its name if present.
656  *
657  * If no field of the given name is defined, NULL is returned.
658  *
659  * parameters:
660  * name <-- field name
661  *
662  * returns:
663  * pointer to the field structure, or NULL
664  *----------------------------------------------------------------------------*/
665 
666 cs_field_t *
667 cs_field_by_name_try(const char *name);
668 
669 /*----------------------------------------------------------------------------
670  * Return an id associated with a given key name.
671  *
672  * The key must have been defined previously.
673  *
674  * parameters:
675  * name <-- key name
676  *
677  * returns:
678  * id associated with key
679  *----------------------------------------------------------------------------*/
680 
681 int
682 cs_field_key_id(const char *name);
683 
684 /*----------------------------------------------------------------------------
685  * Return an id associated with a given key name if present.
686  *
687  * If the key has not been defined previously, -1 is returned.
688  *
689  * parameters:
690  * name <-- key name
691  *
692  * returns:
693  * id associated with key, or -1
694  *----------------------------------------------------------------------------*/
695 
696 int
697 cs_field_key_id_try(const char *name);
698 
699 /*----------------------------------------------------------------------------
700  * Define a key for an integer value by its name and return an associated id.
701  *
702  * If the key has already been defined, its previous default value is replaced
703  * by the current value, and its id is returned.
704  *
705  * parameters:
706  * name <-- key name
707  * default_value <-- default value associated with key
708  * type flag <-- mask associated with field types with which the
709  * key may be associated, or 0
710  *
711  * returns:
712  * id associated with key
713  *----------------------------------------------------------------------------*/
714 
715 int
716 cs_field_define_key_int(const char *name,
717  int default_value,
718  int type_flag);
719 
720 /*----------------------------------------------------------------------------
721  * Define a key for an floating point value by its name and return an
722  * associated id.
723  *
724  * If the key has already been defined, its previous default value is replaced
725  * by the current value, and its id is returned.
726  *
727  * parameters:
728  * name <-- key name
729  * default_value <-- default value associated with key
730  * type flag <-- mask associated with field types with which the
731  * key may be associated, or 0
732  *
733  * returns:
734  * id associated with key
735  *----------------------------------------------------------------------------*/
736 
737 int
738 cs_field_define_key_double(const char *name,
739  double default_value,
740  int type_flag);
741 
742 /*----------------------------------------------------------------------------
743  * Define a key for an string point value by its name and return an
744  * associated id.
745  *
746  * If the key has already been defined, its previous default value is replaced
747  * by the current value, and its id is returned.
748  *
749  * parameters:
750  * name <-- key name
751  * default_value <-- default value associated with key
752  * type flag <-- mask associated with field types with which the
753  * key may be associated, or 0
754  *
755  * returns:
756  * id associated with key
757  *----------------------------------------------------------------------------*/
758 
759 int
760 cs_field_define_key_str(const char *name,
761  const char *default_value,
762  int type_flag);
763 
764 /*----------------------------------------------------------------------------
765  * Define a sub key.
766  *
767  * The sub key is the same type as the parent key.
768  *
769  * For a given field, when querying a sub key's value and that value has not
770  * been set, the query will return the value of the parent key.
771  *
772  * parameters:
773  * name <-- key name
774  * parent_id <-- parent key id
775  *
776  * returns:
777  * id associated with key
778  *----------------------------------------------------------------------------*/
779 
780 int
781 cs_field_define_sub_key(const char *name,
782  int parent_id);
783 
784 /*----------------------------------------------------------------------------
785  * Destroy all defined field keys and associated values.
786  *----------------------------------------------------------------------------*/
787 
788 void
790 
791 /*----------------------------------------------------------------------------
792  * Get the type flag associated with a given key id.
793  *
794  * If the key has not been defined previously, -1 is returned.
795  *
796  * parameters:
797  * key_id <-- id of associated key
798  *
799  * returns:
800  * type flag associated with key, or -1
801  *----------------------------------------------------------------------------*/
802 
803 int
804 cs_field_key_flag(int key_id);
805 
806 /*----------------------------------------------------------------------------
807  * Assign a integer value for a given key to a field.
808  *
809  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
810  * If the field category is not compatible with the key (as defined
811  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
812  *
813  * parameters:
814  * f <-- pointer to field structure
815  * key_id <-- id of associated key
816  * value <-- value associated with key
817  *
818  * returns:
819  * 0 in case of success, > 1 in case of error
820  *----------------------------------------------------------------------------*/
821 
822 int
824  int key_id,
825  int value);
826 
827 /*----------------------------------------------------------------------------
828  * Return a integer value for a given key associated with a field.
829  *
830  * If the key id is not valid, or the value type or field category is not
831  * compatible, a fatal error is provoked.
832  *
833  * parameters:
834  * f <-- pointer to field structure
835  * key_id <-- id of associated key
836  *
837  * returns:
838  * integer value associated with the key id for this field
839  *----------------------------------------------------------------------------*/
840 
841 int
843  int key_id);
844 
845 /*----------------------------------------------------------------------------
846  * Assign a floating point value for a given key to a field.
847  *
848  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
849  * If the field category is not compatible with the key (as defined
850  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
851  *
852  * parameters:
853  * f <-- pointer to field structure
854  * key_id <-- id of associated key
855  * value <-- value associated with key
856  *
857  * returns:
858  * 0 in case of success, > 1 in case of error
859  *----------------------------------------------------------------------------*/
860 
861 int
863  int key_id,
864  double value);
865 
866 /*----------------------------------------------------------------------------
867  * Return a floating point value for a given key associated with a field.
868  *
869  * If the key id is not valid, or the value type or field category is not
870  * compatible, a fatal error is provoked.
871  *
872  * parameters:
873  * f <-- pointer to field structure
874  * key_id <-- id of associated key
875  *
876  * returns:
877  * floating point value associated with the key id for this field
878  *----------------------------------------------------------------------------*/
879 
880 double
882  int key_id);
883 
884 /*----------------------------------------------------------------------------
885  * Assign a character string value for a given key to a field.
886  *
887  * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
888  * If the field category is not compatible with the key (as defined
889  * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
890  *
891  * parameters:
892  * f <-- pointer to field structure
893  * key_id <-- id of associated key
894  * str <-- string associated with key
895  *
896  * returns:
897  * 0 in case of success, > 1 in case of error
898  *----------------------------------------------------------------------------*/
899 
900 int
902  int key_id,
903  const char *str);
904 
905 /*----------------------------------------------------------------------------
906  * Return a string for a given key associated with a field.
907  *
908  * If the key id is not valid, or the value type or field category is not
909  * compatible, a fatal error is provoked.
910  *
911  * parameters:
912  * f <-- pointer to field structure
913  * key_id <-- id of associated key
914  *
915  * returns:
916  * pointer to character string associated with the key id for this field
917  *----------------------------------------------------------------------------*/
918 
919 const char *
921  int key_id);
922 
923 /*----------------------------------------------------------------------------
924  * Print info relative to all field definitions to log file.
925  *----------------------------------------------------------------------------*/
926 
927 void
928 cs_field_log_defs(void);
929 
930 /*----------------------------------------------------------------------------
931  * Print info relative to a given field to log file.
932  *
933  * parameters:
934  * f <-- pointer to field structure
935  * log_keywords <-- log level for keywords (0: do not log,
936  * 1: log non-default values, 2: log all)
937  *----------------------------------------------------------------------------*/
938 
939 void
941  int log_keywords);
942 
943 /*----------------------------------------------------------------------------
944  * Print info relative to all defined fields to log file.
945  *
946  * parameters:
947  * log_keywords <-- log level for keywords (0: do not log,
948  * 1: log non-default values, 2: log all)
949  *----------------------------------------------------------------------------*/
950 
951 void
952 cs_field_log_fields(int log_keywords);
953 
954 /*----------------------------------------------------------------------------
955  * Print info relative to all key definitions to log file.
956  *----------------------------------------------------------------------------*/
957 
958 void
960 
961 /*----------------------------------------------------------------------------
962  * Print info relative to a given field key to log file.
963  *
964  * parameters:
965  * int key_id <-- id of associated key
966  * log_defaults <-- if true, log default field values in addition to
967  * defined field values
968  *----------------------------------------------------------------------------*/
969 
970 void
971 cs_field_log_key_vals(int key_id,
972  bool log_defaults);
973 
974 /*----------------------------------------------------------------------------
975  * Print info relative to all given field keys to log file.
976  *
977  * parameters:
978  * log_defaults <-- if true, log default field values in addition to
979  * defined field values
980  *----------------------------------------------------------------------------*/
981 
982 void
983 cs_field_log_all_key_vals(bool log_defaults);
984 
985 /*----------------------------------------------------------------------------
986  * Define base keys.
987  *
988  * Keys defined by this function are:
989  * "label" (string)
990  * "post_vis" (integer)
991  * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
992  * "moment_dt" (integer, restricted to CS_FIELD_PROPERTY);
993  *
994  * A recommened practice for different submodules would be to use
995  * "cs_<module>_key_init() functions to define keys specific to those modules.
996  *----------------------------------------------------------------------------*/
997 
998 void
1000 
1001 /*----------------------------------------------------------------------------*/
1002 
1004 
1005 #endif /* __CS_FIELD_H__ */
bool interleaved
Definition: cs_field.h:106
int dim
Definition: cs_field.h:105
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:1738
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:1958
int type
Definition: cs_field.h:103
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:1697
int id
Definition: cs_field.h:102
void fldgk1(const cs_int_t *ifield, const cs_int_t *ikey, char *str, const cs_int_t *lstr CS_ARGF_SUPP_CHAINE)
Definition: cs_field.c:998
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:1447
Definition: cs_field.h:98
cs_real_t * b
Definition: cs_field.h:89
void cs_field_log_defs(void)
Print info relative to all field definitions to log file.
Definition: cs_field.c:2015
int cs_field_define_key_str(const char *name, const char *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:1572
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.c:1668
void cs_field_map_values(cs_field_t *f, cs_real_t *val, cs_real_t *val_pre)
Map existing values to field descriptor.
Definition: cs_field.c:1113
void fldama(void)
Definition: cs_field.c:658
int n_time_vals
Definition: cs_field.h:110
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
cs_field_t * cs_field_create(const char *name, int type_flag, int location_id, int dim, bool interleaved, bool has_previous)
Create a field descriptor.
Definition: cs_field.c:1058
void cs_field_allocate_values(cs_field_t *f)
Allocate arrays for field values.
Definition: cs_field.c:1085
Definition: cs_field.h:73
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:2480
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:119
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.c:1618
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.c:1343
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:1474
bool is_owner
Definition: cs_field.h:122
void cs_field_define_keys_base(void)
Define base keys.
Definition: cs_field.c:2509
#define CS_ARGF_SUPP_CHAINE
Definition: cs_defs.h:394
void fldfi1(const char *name, const cs_int_t *lname, cs_int_t *ifield CS_ARGF_SUPP_CHAINE)
Definition: cs_field.c:760
int cs_int_t
Definition: cs_defs.h:263
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:1805
Definition: cs_field.h:84
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.c:1298
Definition: cs_field.h:77
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:2385
Definition: cs_field.h:74
int location_id
Definition: cs_field.h:86
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:1913
void fldgki(const cs_int_t *ifield, const cs_int_t *ikey, cs_int_t *value)
Definition: cs_field.c:861
double precision, save a
Definition: cs_fuel_incl.f90:143
Definition: cs_field.h:75
const char * name
Definition: cs_field.h:100
int location_id
Definition: cs_field.h:108
cs_real_t * a
Definition: cs_field.h:88
void fldski(const cs_int_t *ifield, const cs_int_t *ikey, cs_int_t *value)
Definition: cs_field.c:825
void cs_field_destroy_all_keys(void)
Destroy all defined field keys and associated values.
Definition: cs_field.c:1644
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:1537
void fldbcm(const cs_int_t *ifield, cs_real_t *a, cs_real_t *b, cs_real_t *af, cs_real_t *bf)
Definition: cs_field.c:627
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.c:1398
void fldskd(const cs_int_t *ifield, const cs_int_t *ikey, cs_real_t *value)
Definition: cs_field.c:886
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.c:1034
void fldki1(const char *name, const cs_int_t *lname, cs_int_t *ikey CS_ARGF_SUPP_CHAINE)
Definition: cs_field.c:793
void fldps1(const cs_int_t *ifield, const cs_int_t *iprev)
Definition: cs_field.c:678
void fldalo(const cs_int_t *ifield)
Definition: cs_field.c:573
void fldsk1(const cs_int_t *ifield, const cs_int_t *ikey, const char *str, const cs_int_t *lstr CS_ARGF_SUPP_CHAINE)
Definition: cs_field.c:950
cs_real_t * af
Definition: cs_field.h:90
void fldpv1(const cs_int_t *ifield, const cs_int_t *iprev)
Definition: cs_field.c:714
void fldde1(const char *name, const cs_int_t *lname, const cs_int_t *iexten, const cs_int_t *itycat, const cs_int_t *ityloc, const cs_int_t *idim, const cs_int_t *ilved, const cs_int_t *iprev, cs_int_t *idfld CS_ARGF_SUPP_CHAINE)
#define END_C_DECLS
Definition: cs_defs.h:366
double cs_real_t
Definition: cs_defs.h:264
void cs_field_map_bc_coeffs(cs_field_t *f, cs_real_t *a, cs_real_t *b, cs_real_t *af, cs_real_t *bf)
Map existing field boundary condition coefficient arrays.
Definition: cs_field.c:1254
void cs_field_allocate_bc_coeffs(cs_field_t *f, bool have_flux_bc)
Allocate boundary condition coefficients arrays.
Definition: cs_field.c:1159
#define CS_PROCF(x, y)
Definition: cs_defs.h:379
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.c:2303
cs_real_t * val
Definition: cs_field.h:112
void cs_field_log_fields(int log_keywords)
Print info relative to all defined fields to log file.
Definition: cs_field.c:2242
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:2128
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:1424
Definition: cs_field.h:76
cs_real_t * bf
Definition: cs_field.h:91
cs_real_t * val_pre
Definition: cs_field.h:115
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:1374
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:1846
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:1502
cs_field_error_type_t
Definition: cs_field.h:71
void fldgkd(const cs_int_t *ifield, const cs_int_t *ikey, cs_real_t *value)
Definition: cs_field.c:922
void fldmap(const cs_int_t *ifield, cs_real_t *val, cs_real_t *valp)
Definition: cs_field.c:598
double precision, save b
Definition: cs_fuel_incl.f90:143