9.2
general 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-2026 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 * Standard library headers
32 *----------------------------------------------------------------------------*/
33
34#include <string>
35
36/*----------------------------------------------------------------------------
37 * Local headers
38 *----------------------------------------------------------------------------*/
39
40#include "base/cs_defs.h"
41#include "base/cs_array.h"
42
43/*=============================================================================
44 * Macro definitions
45 *============================================================================*/
46
53/*
54 * Field property type
55 */
56
58#define CS_FIELD_INTENSIVE (1 << 0)
59
61#define CS_FIELD_EXTENSIVE (1 << 1)
62
63/* Field category */
64
66#define CS_FIELD_VARIABLE (1 << 2)
67
69#define CS_FIELD_PROPERTY (1 << 3)
70
72#define CS_FIELD_POSTPROCESS (1 << 4)
73
75#define CS_FIELD_ACCUMULATOR (1 << 5)
76
78#define CS_FIELD_USER (1 << 6)
79
81#define CS_FIELD_CDO (1 << 7)
82
85/*============================================================================
86 * Type definitions
87 *============================================================================*/
88
89/* Field handling error types */
90/*----------------------------*/
91
92typedef enum {
93
101
103
105/*------------------------------------------------------*/
106
108
109public:
110
111 int *icodcl; /* low-level BC type code */
112 cs_real_t *rcodcl1; /* 1st component of low-level BC */
113 cs_real_t *rcodcl2; /* 2nd component of low-level BC
114 (a.k.a. hext Exterior exchange coefficient */
115 cs_real_t *rcodcl3; /* 3rd component of low-level BC */
116
117 cs_real_t *h_int_tot; /* Total internal exchange coefficient
118 (used for internal coupling and
119 coupling) */
120
121 cs_real_t *h_rad; /* Exchange coef for radiative transfer
122 (used for internal coupling and
123 coupling) */
124
125 cs_real_t *flux_rad; /* Exchange coef for radiative transfer
126 (used for internal coupling and
127 coupling) */
128
129 cs_real_t *val_f; /* face value for gradient */
130 cs_real_t *val_f_pre; /* previous face value for gradient */
131
132 cs_real_t *flux_diff; /* face value for diffusion */
133
134 /* Members that should become private */
135 cs_real_t *a; /* Explicit coefficient */
136 cs_real_t *b; /* Implicit coefficient */
137 cs_real_t *af; /* Explicit coefficient for flux */
138 cs_real_t *bf; /* Implicit coefficient for flux */
139 cs_real_t *ad; /* Explicit coefficient for divergence */
140 cs_real_t *bd; /* Implicit coefficient for divergence */
141 cs_real_t *ac; /* Explicit coefficient for convection */
142 cs_real_t *bc; /* Implicit coefficient for convection */
143
144 /*--------------------------------------------------------------------------
145 * Constructors
146 *--------------------------------------------------------------------------*/
147
149 {
151 }
152
154 (
155 int field_dim
156 )
157 {
158 icodcl = nullptr;
159 rcodcl1 = nullptr;
160 rcodcl2 = nullptr;
161 rcodcl3 = nullptr;
162
163 h_rad = nullptr;
164 flux_rad = nullptr;
165
166 h_int_tot = nullptr;
167
168 val_f = nullptr;
169 val_f_pre = nullptr;
170
171 flux_diff = nullptr;
172
173 a = nullptr;
174 b = nullptr;
175 af = nullptr;
176 bf = nullptr;
177 ad = nullptr;
178 bd = nullptr;
179 ac = nullptr;
180 bc = nullptr;
181
182 dim = field_dim;
183 }
184
185 /*--------------------------------------------------------------------------
186 * Destructor
187 *--------------------------------------------------------------------------*/
188
190 {
191 /* For now, do not delete data, as it may be shared */
192 }
193
194 /* Accessors for external value (e.g. rcodcl1)
195 ------------------------------------------- */
196
199 (
200 ) const;
201
204 (
205 ) const;
206
209 (
210 ) const;
211
214 (
215 ) const;
216
219 (
220 ) const;
221
222 /* Accessors for external exchange coefficient (e.g. rcodcl2)
223 ---------------------------------------------------------- */
224
227 (
228 ) const;
229
232 (
233 ) const;
234
237 (
238 ) const;
239
242 (
243 ) const;
244
245 /* Accessors for prescribed flux density (e.g. rcodcl3)
246 ---------------------------------------------------- */
247
250 (
251 ) const;
252
255 (
256 ) const;
257
260 (
261 ) const;
262
265 (
266 ) const;
267
268private:
269 int dim;
270};
271
272/* Field descriptor */
273/*------------------*/
274
276
277public:
278
279 const char *name; /* Canonical name */
280
281 int id; /* Field id */
282 int type; /* Field type flag */
283
284 int dim; /* Field dimension */
285
286 int location_id; /* Id of matching location */
287
288 int n_time_vals; /* Number of time values */
289
290 cs_real_t **vals; /* For each active location, pointer
291 to matching values arrays
292 vals[0][:] = val
293 vals[1][:] = val_pre
294 vals[p][:] = p ith previous field
295 p < n_time_vals */
296
297
298 cs_real_t *val; /* For each active location, pointer
299 to matching values array */
300
301 cs_real_t *val_pre; /* For each active location, pointer
302 to matching previous values array
303 (if n_time_vals == 2) */
304
305 cs_real_t *grad; /* For each active location, pointer
306 to matching gradient array for
307 variable type fields */
308
309 cs_field_bc_coeffs_t *bc_coeffs; /* Boundary condition coefficients,
310 for variable type fields */
311
312 bool is_owner; /* Ownership flag for values */
313
314 int ns_size; /* Multidim series size */
315 int ns_idx; /* Multidim series index of field */
316 int ns_owner; /* Multidim series owner id */
317
318 /* Setter and getter methods for key-based values
319 ---------------------------------------------- */
320
321 int
322 set_key_int(int key_id,
323 int value);
324
325 int
326 set_key_int(const char *key,
327 int value);
328
329 int
330 get_key_int(int key_id) const;
331
332 int
333 get_key_int(const char *key) const;
334
335 int
336 set_key_int_bits(int key_id,
337 int mask);
338
339 int
340 set_key_int_bits(const char *key,
341 int mask);
342
343 int
344 clear_key_int_bits(int key_id,
345 int mask);
346
347 int
348 clear_key_int_bits(const char *key,
349 int mask);
350
351 int
352 set_key_double(int key_id,
353 double value);
354
355 int
356 set_key_double(const char *key,
357 double value);
358
359 double
360 get_key_double(int key_id) const;
361
362 double
363 get_key_double(const char *key) const;
364
365 int
366 set_key_str(int key_id,
367 const char *str);
368
369 int
370 set_key_str(const char *key,
371 const char *str);
372
373 const char *
374 get_key_str(int key_id) const;
375
376 const char *
377 get_key_str(const char *key) const;
378
379 const void *
381 (
382 const int key_id,
383 void *s
384 ) const;
385
386 const void *
388 (
389 const char *key,
390 void *s
391 ) const;
392
394 view
395 (
396 const int time_id = 0
397 ) const;
398
399 [[deprecated("Use `get_val_s` instead")]]
402 (
403 const int time_id = 0
404 ) const;
405
406 [[deprecated("Use `get_val_v` instead")]]
409 (
410 const int time_id = 0
411 ) const;
412
413 [[deprecated("Use `get_val_t` instead")]]
416 (
417 const int time_id = 0
418 ) const;
419
422 (
423 const int time_id = 0
424 ) const;
425
428 (
429 const int time_id = 0
430 ) const;
431
434 (
435 const int time_id = 0
436 ) const;
437
440 () const;
441
444 () const;
445
448 () const;
449
452 (
453 const int time_id = 0
454 ) const;
455
457 ns_view
458 (
459 const int time_id = 0
460 ) const;
461
462 [[deprecated("Use `get_ns_val_s` instead")]]
465 (
466 const int time_id = 0
467 ) const;
468
469 [[deprecated("Use `get_ns_val_v` instead")]]
472 (
473 const int time_id = 0
474 ) const;
475
476 [[deprecated("Use `get_ns_val_t` instead")]]
479 (
480 const int time_id = 0
481 ) const;
482
485 (
486 const int time_id = 0
487 ) const;
488
491 (
492 const int time_id = 0
493 ) const;
494
497 (
498 const int time_id = 0
499 ) const;
500
501 /* State update methods
502 -------------------- */
503
504 void
506
507 void
509 (
510 const int time_id = -1
511 );
512
513 void
514 clear
515 (
516 const int time_id = -1
517 );
518
519 void
520 update_sub_fields_mapping(void) const;
521
522 void
524 (
525 cs_real_t *val_new,
526 cs_real_t *val_pre_new
527 );
528
531
533 void
535 (
536 int owner_id
537 )
538 {
539 ns_owner = owner_id;
540 }
541
543 void
545 (
546 const int series_size,
547 const int series_idx,
548 const int series_owner
549 )
550 {
552 ns_idx = series_idx;
554 }
555
556 /* Query methods
557 ------------- */
558
560 inline
561 bool
563 {
564 return (ns_owner == id);
565 }
566
568 inline
569 bool
571 {
572 return (ns_owner > -1);
573 }
574
576 inline
577 bool
578 owner() const
579 {
580 return (is_owner && (is_series_owner() || !is_part_of_series()) );
581 }
582
584 inline
585 int
587 {
588 return ns_size;
589 }
590
592 inline
593 int
595 {
596 return ns_owner;
597 }
598
600 inline
601 int
602 series_id() const
603 {
604 return ns_idx;
605 }
606
608 inline
609 bool
611 {
612 return (ns_size > 1 && is_series_owner());
613 }
614
616 inline
617 bool
619 {
620 return (ns_size > 1 && !is_series_owner());
621 }
622
624 inline
625 bool
627 (
628 const int owner_id
629 ) const
630 {
631 return (is_sub_field() && ns_owner == owner_id);
632 }
633
635 void
637
639 void
640 map_to_ns_data(void);
641
642};
643
644/*----------------------------------------------------------------------------
645 * Function pointer for structure associated to field key
646 *
647 * parameters:
648 * t <-- pointer to structure
649 *----------------------------------------------------------------------------*/
650
651typedef void
652(cs_field_log_key_struct_t) (const void *t);
653
654/*----------------------------------------------------------------------------
655 * Function pointer for structure associated to field key
656 *
657 * parameters:
658 * t <-- pointer to structure
659 *----------------------------------------------------------------------------*/
660
661typedef void
663
664/*============================================================================
665 * Global variables
666 *============================================================================*/
667
668/* Names for components */
669
670extern const char *cs_glob_field_comp_name_3[];
671extern const char *cs_glob_field_comp_name_6[];
672extern const char *cs_glob_field_comp_name_9[];
673
674/*=============================================================================
675 * Public function prototypes
676 *============================================================================*/
677
678/*----------------------------------------------------------------------------
679 * Create bc_coeffs structure.
680 *
681 * \param[in] bc_coeffs bc coefficients
682 *----------------------------------------------------------------------------*/
683
684void
686
687/*----------------------------------------------------------------------------
688 * Shallow copy of boundary condition coefficients.
689 *
690 * \param[in] ref source bc coefficients
691 * \param[inout] copy shallow copy of bc coefficients
692 *----------------------------------------------------------------------------*/
693
694void
697
698/*----------------------------------------------------------------------------
699 * \brief Free copy of boundary condition coefficients.
700 *
701 * \param[in] ref reference bc coefficients
702 * \param[inout] copy shallow copy of bc coefficients
703 *----------------------------------------------------------------------------*/
704
705void
708
709/*----------------------------------------------------------------------------*/
710/*
711 * \brief Free contents of local boundary condition coefficients.
712 *
713 * \param[inout] bc_coeffs bc coefficients
714 */
715/*----------------------------------------------------------------------------*/
716
717void
719
720/*----------------------------------------------------------------------------
721 * Return the number of defined fields.
722 *
723 * returns:
724 * number of defined fields.
725 *----------------------------------------------------------------------------*/
726
727int
729
730/*----------------------------------------------------------------------------
731 * Create a field descriptor.
732 *
733 * parameters:
734 * name <-- field name
735 * type_flag <-- mask of field property and category values
736 * location_id <-- id of associated location
737 * dim <-- field dimension (number of components)
738 * has_previous <-- maintain values at the previous time step ?
739 *
740 * returns:
741 * pointer to new field.
742 *----------------------------------------------------------------------------*/
743
745cs_field_create(const char *name,
746 int type_flag,
747 int location_id,
748 int dim,
749 bool has_previous);
750
751/*----------------------------------------------------------------------------*/
763/*----------------------------------------------------------------------------*/
764
766cs_field_create_by_composite_name(const char *name_prefix,
767 const char *name_suffix,
768 int type_flag,
769 int location_id,
770 int dim,
771 bool has_previous);
772
773/*----------------------------------------------------------------------------*/
792/*----------------------------------------------------------------------------*/
793
795cs_field_find_or_create(const char *name,
796 int type_flag,
797 int location_id,
798 int dim,
799 bool has_previous);
800
801/*----------------------------------------------------------------------------
802 * Change the number of time values managed by a field.
803 *
804 * The minimum will never be below 1, as the current time is always handled.
805 *
806 * parameters:
807 * f <-> pointer to field structure
808 * n_time_vals <-- number of time values to maintain
809 *----------------------------------------------------------------------------*/
810
811void
813 int n_time_vals);
814
815/*----------------------------------------------------------------------------
816 * Allocate arrays for field values.
817 *
818 * parameters:
819 * f <-- pointer to field structure
820 *----------------------------------------------------------------------------*/
821
822void
824
825/*----------------------------------------------------------------------------
826 * Remap arrays for sub-field values.
827 *
828 * parameters:
829 * owner_id <-- id of owner field structure
830 *----------------------------------------------------------------------------*/
831
832void
833cs_field_remap_sub_fields_data(const int owner_id);
834
835/*----------------------------------------------------------------------------
836 * Map existing value arrays to field descriptor.
837 *
838 * parameters:
839 * f <-> pointer to field structure
840 * val <-- pointer to array of values
841 * val_pre <-- pointer to array of previous values, or nullptr
842 *----------------------------------------------------------------------------*/
843
844void
846 cs_real_t *val,
847 cs_real_t *val_pre);
848
849/*----------------------------------------------------------------------------
850 * Allocate boundary condition coefficient arrays.
851 *
852 * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
853 * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
854 *
855 * Boundary condition coefficients are not currently supported for other
856 * locations (though support could be added by mapping a boundary->location
857 * indirection array in the cs_mesh_location_t structure).
858 *
859 * For multidimensional fields with coupled components, implicit b and bf
860 * coefficient arrays are arrays of block matrices, not vectors, so the
861 * number of entries for each boundary face is dim*dim instead of dim.
862 *
863 * parameters:
864 * f <-- pointer to field structure
865 * have_flux_bc <-- if true, flux BC coefficients (af and bf) are added
866 * have_mom_bc <-- if true, div BC coefficients (ad and bd) are added
867 * have_conv_bc <-- if true, convection BC coefficients (ac and bc) are added
868 * have_exch_bc <-- if true, exchange boundary coefficients (hint and hext)
869 * are added
870 * have_rad_bc <-- if true, radiative boundary coefficients (h_rad and
871 * flux_rad) are added
872 *----------------------------------------------------------------------------*/
873
874void
876 bool have_flux_bc,
877 bool have_mom_bc,
878 bool have_conv_bc,
879 bool have_exch_bc,
880 bool have_rad_bc);
881
882/*----------------------------------------------------------------------------*/
883/* Initialize boundary condition coefficients arrays.
884 *
885 * For fields on location CS_MESH_LOCATION_CELLS, boundary conditions
886 * are located on CS_MESH_LOCATION_BOUNDARY_FACES.
887 *
888 * Boundary condition coefficients are not currently supported for other
889 * locations (though support could be added by mapping a boundary->location
890 * indirection array in the cs_mesh_location_t structure).
891 *
892 * For multidimensional fields with coupled components, implicit b and bf
893 * coefficient arrays are arrays of block matrices, not vectors, so the
894 * number of entries for each boundary face is dim*dim instead of dim.
895 *
896 * parameters:
897 * f <-> pointer to field structure
898 *----------------------------------------------------------------------------*/
899
900void
902
903/*----------------------------------------------------------------------------
904 * Allocate arrays for field gradient.
905 *
906 * parameters:
907 * f <-- pointer to field structure
908 *----------------------------------------------------------------------------*/
909
910void
912
913/*----------------------------------------------------------------------------
914 * Set current field values to the given constant.
915 *
916 * parameters:
917 * f <-> pointer to field structure
918 * c <-- assigned value
919 *----------------------------------------------------------------------------*/
920
921void
923 cs_real_t c);
924
925/*----------------------------------------------------------------------------
926 * Copy current field values to previous values if applicable.
927 *
928 * For fields with only one time value, or values not allocated yet,
929 * this is a no-op.
930 *
931 * parameters:
932 * f <-> pointer to field structure
933 *----------------------------------------------------------------------------*/
934
935void
937
938/*----------------------------------------------------------------------------
939 * Destroy all defined fields.
940 *----------------------------------------------------------------------------*/
941
942void
944
945/*----------------------------------------------------------------------------
946 * Allocate arrays for all defined fields based on their location.
947 *
948 * Location sized must thus be known.
949 *
950 * Fields that do not own their data should all have been mapped at this
951 * stage, and are checked.
952 *----------------------------------------------------------------------------*/
953
954void
956
957/*----------------------------------------------------------------------------
958 * Return a pointer to a field based on its id.
959 *
960 * This function requires that a field of the given id is defined.
961 *
962 * parameters:
963 * id <-- field id
964 *
965 * returns:
966 * pointer to the field structure
967 *----------------------------------------------------------------------------*/
968
969extern "C" cs_field_t *
970cs_field_by_id(int id);
971
972/*----------------------------------------------------------------------------
973 * Return a pointer to a field based on its name.
974 *
975 * This function requires that a field of the given name is defined.
976 *
977 * parameters:
978 * name <-- field name
979 *
980 * returns:
981 * pointer to the field structure
982 *----------------------------------------------------------------------------*/
983
985cs_field_by_name(const char *name);
986
987/*----------------------------------------------------------------------------
988 * Return a pointer to a field based on its name if present.
989 *
990 * If no field of the given name is defined, nullptr is returned.
991 *
992 * parameters:
993 * name <-- field name
994 *
995 * returns:
996 * pointer to the field structure, or nullptr
997 *----------------------------------------------------------------------------*/
998
1000cs_field_by_name_try(const char *name);
1001
1002/*----------------------------------------------------------------------------*/
1013/*----------------------------------------------------------------------------*/
1014
1015cs_field_t *
1016cs_field_by_composite_name(const char *name_prefix,
1017 const char *name_suffix);
1018
1019/*----------------------------------------------------------------------------*/
1034/*----------------------------------------------------------------------------*/
1035
1036cs_field_t *
1037cs_field_by_composite_name_try(const char *name_prefix,
1038 const char *name_suffix);
1039
1040/*----------------------------------------------------------------------------*/
1059/*----------------------------------------------------------------------------*/
1060
1061cs_field_t *
1062cs_field_by_double_composite_name_try(const char *name_part_1,
1063 const char *name_part_2,
1064 const char *name_part_3);
1065
1066/*----------------------------------------------------------------------------
1067 * Return the id of a defined field based on its name.
1068 *
1069 * If no field with the given name exists, -1 is returned.
1070 *
1071 * parameters:
1072 * name <-- field name
1073 *
1074 * returns:
1075 * id the field, or -1 if not found
1076 *----------------------------------------------------------------------------*/
1077
1078int
1079cs_field_id_by_name(const char *name);
1080
1081/*----------------------------------------------------------------------------
1082 * Return the id of a defined field and an associated component
1083 * based on a component name.
1084 *
1085 * If no field with the given name exists, -1 is returned.
1086 *
1087 * parameters:
1088 * name <-- field or field+component name
1089 * f_id --> field id, or -1 if no match was found
1090 * c_id --> component id, or -1 for all components
1091 *----------------------------------------------------------------------------*/
1092
1093void
1094cs_field_component_id_by_name(const char *name,
1095 int *f_id,
1096 int *c_id);
1097
1098/*----------------------------------------------------------------------------
1099 * Return an id associated with a given key name.
1100 *
1101 * The key must have been defined previously.
1102 *
1103 * parameters:
1104 * name <-- key name
1105 *
1106 * returns:
1107 * id associated with key
1108 *----------------------------------------------------------------------------*/
1109
1110int
1111cs_field_key_id(const char *name);
1112
1113/*----------------------------------------------------------------------------
1114 * Return an id associated with a given key name if present.
1115 *
1116 * If the key has not been defined previously, -1 is returned.
1117 *
1118 * parameters:
1119 * name <-- key name
1120 *
1121 * returns:
1122 * id associated with key, or -1
1123 *----------------------------------------------------------------------------*/
1124
1125extern "C" int
1126cs_field_key_id_try(const char *name);
1127
1128/*----------------------------------------------------------------------------
1129 * Define a key for an integer value by its name and return an associated id.
1130 *
1131 * If the key has already been defined, its previous default value is replaced
1132 * by the current value, and its id is returned.
1133 *
1134 * parameters:
1135 * name <-- key name
1136 * default_value <-- default value associated with key
1137 * type flag <-- mask associated with field types with which the
1138 * key may be associated, or 0
1139 *
1140 * returns:
1141 * id associated with key
1142 *----------------------------------------------------------------------------*/
1143
1144int
1145cs_field_define_key_int(const char *name,
1146 int default_value,
1147 int type_flag);
1148
1149/*----------------------------------------------------------------------------
1150 * Define a key for an floating point value by its name and return an
1151 * associated id.
1152 *
1153 * If the key has already been defined, its previous default value is replaced
1154 * by the current value, and its id is returned.
1155 *
1156 * parameters:
1157 * name <-- key name
1158 * default_value <-- default value associated with key
1159 * type flag <-- mask associated with field types with which the
1160 * key may be associated, or 0
1161 *
1162 * returns:
1163 * id associated with key
1164 *----------------------------------------------------------------------------*/
1165
1166int
1167cs_field_define_key_double(const char *name,
1168 double default_value,
1169 int type_flag);
1170
1171/*----------------------------------------------------------------------------
1172 * Define a key for an string point value by its name and return an
1173 * associated id.
1174 *
1175 * If the key has already been defined, its previous default value is replaced
1176 * by the current value, and its id is returned.
1177 *
1178 * parameters:
1179 * name <-- key name
1180 * default_value <-- default value associated with key
1181 * type flag <-- mask associated with field types with which the
1182 * key may be associated, or 0
1183 *
1184 * returns:
1185 * id associated with key
1186 *----------------------------------------------------------------------------*/
1187
1188int
1189cs_field_define_key_str(const char *name,
1190 const char *default_value,
1191 int type_flag);
1192
1193/*----------------------------------------------------------------------------
1194 * Define a key for a structure value by its name and return an
1195 * associated id.
1196 *
1197 * If the key has already been defined, its previous default value is replaced
1198 * by the current value, and its id is returned.
1199 *
1200 * parameters:
1201 * name <-- key name
1202 * default_value <-- pointer to default value associated with key
1203 * log_funct <-- pointer to logging function
1204 * log_func_default <-- pointer to default logging function
1205 * clear_func <-- pointer to substructures free function
1206 * size <-- sizeof structure
1207 * type_flag <-- mask associated with field types with which
1208 * the key may be associated, or 0
1209 *
1210 * returns:
1211 * id associated with key
1212 *----------------------------------------------------------------------------*/
1213
1214int
1215cs_field_define_key_struct(const char *name,
1216 const void *default_value,
1217 cs_field_log_key_struct_t *log_func,
1218 cs_field_log_key_struct_t *log_func_default,
1219 cs_field_clear_key_struct_t *clear_func,
1220 size_t size,
1221 int type_flag);
1222
1223/*----------------------------------------------------------------------------
1224 * Define a sub key.
1225 *
1226 * The sub key is the same type as the parent key.
1227 *
1228 * For a given field, when querying a sub key's value and that value has not
1229 * been set, the query will return the value of the parent key.
1230 *
1231 * parameters:
1232 * name <-- key name
1233 * parent_id <-- parent key id
1234 *
1235 * returns:
1236 * id associated with key
1237 *----------------------------------------------------------------------------*/
1238
1239int
1240cs_field_define_sub_key(const char *name,
1241 int parent_id);
1242
1243/*----------------------------------------------------------------------------
1244 * Destroy all defined field keys and associated values.
1245 *----------------------------------------------------------------------------*/
1246
1247void
1249
1250/*----------------------------------------------------------------------------
1251 * Get the type flag associated with a given key id.
1252 *
1253 * If the key has not been defined previously, -1 is returned.
1254 *
1255 * parameters:
1256 * key_id <-- id of associated key
1257 *
1258 * returns:
1259 * type flag associated with key, or -1
1260 *----------------------------------------------------------------------------*/
1261
1262int
1263cs_field_key_flag(int key_id);
1264
1265/*----------------------------------------------------------------------------
1266 * Disable logging setup values associated with a given key.
1267 *
1268 * This is useful when a key is used not for setup purposes, but to track
1269 * values associated with a field, such as convergence or performance data.
1270 *
1271 * parameters:
1272 * key_id <-- id of associated key
1273 *----------------------------------------------------------------------------*/
1274
1275void
1277
1278/*----------------------------------------------------------------------------
1279 * Query if a given key has been set for a field.
1280 *
1281 * If the key id is not valid, or the field category is not
1282 * compatible, a fatal error is provoked.
1283 *
1284 * parameters:
1285 * f <-- pointer to field structure
1286 * key_id <-- id of associated key
1287 *
1288 * returns:
1289 * true if the key has been set for this field, false otherwise
1290 *----------------------------------------------------------------------------*/
1291
1292bool
1294 int key_id);
1295
1296/*----------------------------------------------------------------------------
1297 * Query if a given key has been locked for a field.
1298 *
1299 * If the key id is not valid, or the field category is not
1300 * compatible, a fatal error is provoked.
1301 *
1302 * parameters:
1303 * f <-- pointer to field structure
1304 * key_id <-- id of associated key
1305 *
1306 * returns:
1307 * true if the key has been locked for this field, false otherwise
1308 *----------------------------------------------------------------------------*/
1309
1310bool
1312 int key_id);
1313
1314/*----------------------------------------------------------------------------
1315 * Lock a field relative to a given key.
1316 *
1317 * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
1318 * If the field category is not compatible with the key (as defined
1319 * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
1320 *
1321 * parameters:
1322 * f <-- pointer to field structure
1323 * key_id <-- id of associated key
1324 * value <-- value associated with key
1325 *
1326 * returns:
1327 * 0 in case of success, > 1 in case of error
1328 *----------------------------------------------------------------------------*/
1329
1330int
1332 int key_id);
1333
1334/*----------------------------------------------------------------------------
1335 * Assign a integer value for a given key to a field.
1336 *
1337 * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
1338 * If the field category is not compatible with the key (as defined
1339 * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
1340 * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
1341 * If the key value has been locked, CS_FIELD_LOCKED is returned.
1342 *
1343 * parameters:
1344 * f <-- pointer to field structure
1345 * key_id <-- id of associated key
1346 * value <-- value associated with key
1347 *
1348 * returns:
1349 * 0 in case of success, > 1 in case of error
1350 *----------------------------------------------------------------------------*/
1351
1352extern "C" [[deprecated("Use f->set_key_int instead")]] int
1354 int key_id,
1355 int value);
1356
1357/*----------------------------------------------------------------------------
1358 * Return a integer value for a given key associated with a field.
1359 *
1360 * If the key id is not valid, or the value type or field category is not
1361 * compatible, a fatal error is provoked.
1362 *
1363 * parameters:
1364 * f <-- pointer to field structure
1365 * key_id <-- id of associated key
1366 *
1367 * returns:
1368 * integer value associated with the key id for this field
1369 *----------------------------------------------------------------------------*/
1370
1371extern "C" [[deprecated("Use f->get_key_int instead")]] int
1373 int key_id);
1374
1375/*----------------------------------------------------------------------------
1376 * Set integer bits matching a mask to 1 for a given key for a field.
1377 *
1378 * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
1379 * If the field category is not compatible with the key (as defined
1380 * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
1381 * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
1382 * If the key value has been locked, CS_FIELD_LOCKED is returned.
1383 *
1384 * parameters:
1385 * f <-- pointer to field structure
1386 * key_id <-- id of associated key
1387 * mask <-- mask associated with key
1388 *
1389 * returns:
1390 * 0 in case of success, > 1 in case of error
1391 *----------------------------------------------------------------------------*/
1392
1393extern "C" [[deprecated("Use f->set_key_int_bits instead")]] int
1395 int key_id,
1396 int mask);
1397
1398/*----------------------------------------------------------------------------
1399 * Assign a floating point value for a given key to a field.
1400 *
1401 * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
1402 * If the field category is not compatible with the key (as defined
1403 * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
1404 * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
1405 * If the key value has been locked, CS_FIELD_LOCKED is returned.
1406 *
1407 * parameters:
1408 * f <-- pointer to field structure
1409 * key_id <-- id of associated key
1410 * value <-- value associated with key
1411 *
1412 * returns:
1413 * 0 in case of success, > 1 in case of error
1414 *----------------------------------------------------------------------------*/
1415
1416extern "C" [[deprecated("Use f->set_key_double instead")]] int
1418 int key_id,
1419 double value);
1420
1421/*----------------------------------------------------------------------------
1422 * Return a floating point value for a given key associated with a field.
1423 *
1424 * If the key id is not valid, or the value type or field category is not
1425 * compatible, a fatal error is provoked.
1426 *
1427 * parameters:
1428 * f <-- pointer to field structure
1429 * key_id <-- id of associated key
1430 *
1431 * returns:
1432 * floating point value associated with the key id for this field
1433 *----------------------------------------------------------------------------*/
1434
1435extern "C" [[deprecated("Use f->get_key_double instead")]] double
1437 int key_id);
1438
1439/*----------------------------------------------------------------------------
1440 * Assign a character string value for a given key to a field.
1441 *
1442 * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
1443 * If the field category is not compatible with the key (as defined
1444 * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
1445 * If the data type does not match, CS_FIELD_INVALID_TYPE is returned.
1446 * If the key value has been locked, CS_FIELD_LOCKED is returned.
1447 *
1448 * parameters:
1449 * f <-- pointer to field structure
1450 * key_id <-- id of associated key
1451 * str <-- string associated with key
1452 *
1453 * returns:
1454 * 0 in case of success, > 1 in case of error
1455 *----------------------------------------------------------------------------*/
1456
1457extern "C" [[deprecated("Use f->set_key_str instead")]] int
1459 int key_id,
1460 const char *str);
1461
1462/*----------------------------------------------------------------------------
1463 * Return a string for a given key associated with a field.
1464 *
1465 * If the key id is not valid, or the value type or field category is not
1466 * compatible, a fatal error is provoked.
1467 *
1468 * parameters:
1469 * f <-- pointer to field structure
1470 * key_id <-- id of associated key
1471 *
1472 * returns:
1473 * pointer to character string associated with the key id for this field
1474 *----------------------------------------------------------------------------*/
1475
1476extern "C" [[deprecated("Use f->get_key_str instead")]] const char *
1478 int key_id);
1479
1480/*----------------------------------------------------------------------------
1481 * Assign a simple structure for a given key to a field.
1482 *
1483 * If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned.
1484 * If the field category is not compatible with the key (as defined
1485 * by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
1486 * If the key value has been locked, CS_FIELD_LOCKED is returned.
1487 *
1488 * parameters:
1489 * f <-- pointer to field structure
1490 * key_id <-- id of associated key
1491 * s <-- structure associated with key
1492 *
1493 * returns:
1494 * 0 in case of success, > 1 in case of error
1495 *----------------------------------------------------------------------------*/
1496
1497int
1499 int key_id,
1500 void *s);
1501
1502/*----------------------------------------------------------------------------
1503 * Return a structure for a given key associated with a field.
1504 *
1505 * If the key id is not valid, or the value type or field category is not
1506 * compatible, a fatal error is provoked.
1507 *
1508 * parameters:
1509 * f <-- pointer to field structure
1510 * key_id <-- id of associated key
1511 * s <-- structure associated with key
1512 *
1513 * returns:
1514 * pointer to structure associated with the key id for this field
1515 * (same as s)
1516 *----------------------------------------------------------------------------*/
1517
1518const void *
1520 int key_id,
1521 void *s);
1522
1523/*----------------------------------------------------------------------------*/
1524/*
1525 * \brief Return a pointer to a simple structure for a given key to a field.
1526 *
1527 * If the key id is not valid, the value type or field category is not
1528 * compatible, or the structure has been locked, a fatal error is provoked.
1529 *
1530 * Note that using this function marks the field's value for this structure
1531 * as set, and if no values have been set yet, the structure is set to
1532 * default values.
1533 *
1534 * \param[in] f pointer to field structure
1535 * \param[in] key_id id of associated key
1536 *
1537 * \return pointer to key structure in case of success,
1538 * nullptr in case of error
1539 */
1540/*----------------------------------------------------------------------------*/
1541
1542void *
1544 int key_id);
1545
1546/*----------------------------------------------------------------------------*/
1547/*
1548 * \brief Return a read-only pointer to a simple structure for a given key
1549 * to a field.
1550 *
1551 * If the key id is not valid, the value type or field category is not
1552 * compatible, a fatal error is provoked.
1553 *
1554 * \param[in] f pointer to field structure
1555 * \param[in] key_id id of associated key
1556 *
1557 * \return pointer to key structure in case of success,
1558 * nullptr in case of error
1559 */
1560/*----------------------------------------------------------------------------*/
1561
1562const void *
1564 int key_id);
1565
1566/*----------------------------------------------------------------------------
1567 * Print info relative to all field definitions to log file.
1568 *----------------------------------------------------------------------------*/
1569
1570void
1571cs_field_log_defs(void);
1572
1573/*----------------------------------------------------------------------------
1574 * Print info relative to a given field to log file.
1575 *
1576 * parameters:
1577 * f <-- pointer to field structure
1578 * log_keywords <-- log level for keywords (0: do not log,
1579 * 1: log non-default values, 2: log all)
1580 *----------------------------------------------------------------------------*/
1581
1582void
1584 int log_keywords);
1585
1586/*----------------------------------------------------------------------------
1587 * Print info relative to all defined fields to log file.
1588 *
1589 * parameters:
1590 * log_keywords <-- log level for keywords (0: do not log,
1591 * 1: log non-default values, 2: log all)
1592 *----------------------------------------------------------------------------*/
1593
1594void
1595cs_field_log_fields(int log_keywords);
1596
1597/*----------------------------------------------------------------------------
1598 * Print info relative to all key definitions to log file.
1599 *----------------------------------------------------------------------------*/
1600
1601void
1603
1604/*----------------------------------------------------------------------------
1605 * Print info relative to a given field key to log file.
1606 *
1607 * parameters:
1608 * int key_id <-- id of associated key
1609 * log_defaults <-- if true, log default field values in addition to
1610 * defined field values
1611 *----------------------------------------------------------------------------*/
1612
1613void
1614cs_field_log_key_vals(int key_id,
1615 bool log_defaults);
1616
1617/*----------------------------------------------------------------------------
1618 * Print info relative to all given field keys to log file.
1619 *
1620 * parameters:
1621 * log_defaults <-- if true, log default field values in addition to
1622 * defined field values
1623 *----------------------------------------------------------------------------*/
1624
1625void
1626cs_field_log_all_key_vals(bool log_defaults);
1627
1628/*----------------------------------------------------------------------------
1629 * Define base keys.
1630 *
1631 * Keys defined by this function are:
1632 * "label" (string)
1633 * "log" (integer)
1634 * "post_vis" (integer)
1635 * "coupled" (integer, restricted to CS_FIELD_VARIABLE)
1636 * "moment_id" (integer, restricted to
1637 * CS_FIELD_ACCUMULATOR | CS_FIELD_POSTPROCESS);
1638 *
1639 * A recommened practice for different submodules would be to use
1640 * "cs_<module>_key_init() functions to define keys specific to those modules.
1641 *----------------------------------------------------------------------------*/
1642
1643void
1645
1646/*----------------------------------------------------------------------------
1647 * Return a label associated with a field.
1648 *
1649 * If the "label" key has been set for this field, its associated string
1650 * is returned. Otherwise, the field's name is returned.
1651 *
1652 * parameters:
1653 * f <-- pointer to field structure
1654 *
1655 * returns:
1656 * pointer to character string associated with label for this field
1657 *----------------------------------------------------------------------------*/
1658
1659const char *
1661
1662/*----------------------------------------------------------------------------
1663 * Get the boundary coefficient multipliers for some field.
1664 *
1665 * This function is intended for use by the field redistribution routines.
1666 *
1667 * parameters:
1668 * f <-- pointer to the field
1669 * i_mult <-> multiplier for the integer bc coefficients.
1670 * a_mult <-> multiplier for the "a" bc coefficients.
1671 * b_mult <-> multiplier for the "b" bc coefficients.
1672 *----------------------------------------------------------------------------*/
1673
1674void
1676 cs_lnum_t *i_mult,
1677 cs_lnum_t *a_mult,
1678 cs_lnum_t *b_mult);
1679
1680/*=============================================================================
1681 * C++ functions
1682 *============================================================================*/
1683
1684/*----------------------------------------------------------------------------*/
1685/* Getter function based on field name, raises error if fails */
1686/*----------------------------------------------------------------------------*/
1687
1688cs_field_t *
1689cs_field(const char *name);
1690
1691/*----------------------------------------------------------------------------*/
1692/* Getter function based on field name, raises error if fails */
1693/*----------------------------------------------------------------------------*/
1694
1695cs_field_t *
1696cs_field(const std::string& name);
1697
1698/*----------------------------------------------------------------------------*/
1699/* Getter function based on field id, raises error if fails */
1700/*----------------------------------------------------------------------------*/
1701
1702cs_field_t *
1703cs_field(const int id);
1704
1705/*----------------------------------------------------------------------------*/
1706/* Getter function based on field name, returns nullptr if fails */
1707/*----------------------------------------------------------------------------*/
1708
1709cs_field_t *
1710cs_field_try(const char *name);
1711
1712/*----------------------------------------------------------------------------*/
1713/* Getter function based on field name, returns nullptr if fails */
1714/*----------------------------------------------------------------------------*/
1715
1716cs_field_t *
1717cs_field_try(const std::string& name);
1718
1719/*----------------------------------------------------------------------------*/
1720/* Getter function based on field id, returns nullptr if fails */
1721/*----------------------------------------------------------------------------*/
1722
1723cs_field_t *
1724cs_field_try(const int id);
1725
1726/*----------------------------------------------------------------------------*/
1727
1728#endif /* CS_FIELD_H */
Define a templated array class (owner of data)
Definition: cs_array.h:1118
Define a templated mdspan class (non owner of data)
Definition: cs_mdspan.h:68
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
cs::mdspan< cs_real_t, 2, cs::layout::left > get_val_ext_v() const
Return a 2D span view of boundary condition external vector values.
Definition: cs_field.cpp:5888
cs_real_t * rcodcl2
Definition: cs_field.h:113
cs_real_t * af
Definition: cs_field.h:137
cs_span< cs_real_t > get_val_ext_s() const
Return a 1D span view of boundary condition external scalar values.
Definition: cs_field.cpp:5848
~cs_field_bc_coeffs_t()
Definition: cs_field.h:189
cs_real_t * bc
Definition: cs_field.h:142
cs_real_t * rcodcl3
Definition: cs_field.h:115
cs_real_t * b
Definition: cs_field.h:136
cs_field_bc_coeffs_t(void)
Definition: cs_field.h:148
cs_span< cs_real_t > get_q_ext_s() const
Return a 1D span view of boundary condition prescribed flux.
Definition: cs_field.cpp:6062
cs_real_t * flux_diff
Definition: cs_field.h:132
cs_real_t * a
Definition: cs_field.h:135
cs_span< cs_real_t > get_h_ext() const
Return a 1D span view of boundary condition external exchange coefficient.
Definition: cs_field.cpp:5931
cs_real_t * ad
Definition: cs_field.h:139
cs_span< cs_real_t > get_val_ext() const
Return a 1D span view of boundary condition external values.
Definition: cs_field.cpp:5826
cs::mdspan< cs_real_t, 2, cs::layout::left > get_q_ext_v() const
Return a 2D span view of boundary condition vector prescribed flux.
Definition: cs_field.cpp:6081
cs::mdspan< cs_real_t, 2, cs::layout::left > get_val_ext_t() const
Return a 2D span view of boundary condition external tensor values.
Definition: cs_field.cpp:5909
cs::mdspan< cs_real_t, 2, cs::layout::left > get_h_ext_v() const
Return a 2D span view of boundary condition vector external exchange coefficients.
Definition: cs_field.cpp:5997
cs_real_t * h_int_tot
Definition: cs_field.h:117
cs_field_bc_coeffs_t(int field_dim)
Definition: cs_field.h:154
cs_real_t * ac
Definition: cs_field.h:141
cs_real_t * rcodcl1
Definition: cs_field.h:112
cs_span< cs_real_t > get_h_ext_s() const
Return a 1D span view of boundary condition external exchange coefficient.
Definition: cs_field.cpp:5976
cs_real_t * bf
Definition: cs_field.h:138
cs_real_t * bd
Definition: cs_field.h:140
cs::mdspan< cs_real_t, 2, cs::layout::left > get_q_ext_2d() const
Return a 2D span view of boundary condition prescribed flux (1st dimension: face id,...
Definition: cs_field.cpp:6038
cs_real_t * val_f_pre
Definition: cs_field.h:130
cs::mdspan< cs_real_t, 2, cs::layout::left > get_val_ext_2d() const
Return a 2D span view of boundary condition external values (1st dimension: face id,...
Definition: cs_field.cpp:5868
cs_span< cs_real_t > get_q_ext() const
Return a 1D span view of boundary condition prescribed flux.
Definition: cs_field.cpp:6018
cs_real_t * flux_rad
Definition: cs_field.h:125
cs_real_t * val_f
Definition: cs_field.h:129
cs::mdspan< cs_real_t, 2, cs::layout::left > get_h_ext_2d() const
Return a 2D span view of boundary condition external exchange coefficient (1st dimension: face id,...
Definition: cs_field.cpp:5951
int * icodcl
Definition: cs_field.h:111
cs_real_t * h_rad
Definition: cs_field.h:121
Field descriptor.
Definition: cs_field.h:275
void update_sub_fields_mapping(void) const
Update data mapping for all sub-fields.
Definition: cs_field.cpp:5685
cs_array_2d< cs_real_t > ** _vals
Definition: cs_field.h:529
CS_F_HOST_DEVICE void set_ns_parameters(const int series_size, const int series_idx, const int series_owner)
Definition: cs_field.h:545
const char * get_key_str(int key_id) const
Return a character string for a given key associated with a field.
Definition: cs_field.cpp:4893
int location_id
Definition: cs_field.h:286
void map_values(cs_real_t *val_new, cs_real_t *val_pre_new)
Map existing value arrays to field descriptor.
Definition: cs_field.cpp:5705
CS_F_HOST_DEVICE int series_size() const
Definition: cs_field.h:586
void update_public_pointers(void)
Update public pointers based on private members.
Definition: cs_field.cpp:5566
CS_F_HOST_DEVICE int series_owner() const
Definition: cs_field.h:594
cs_span_2d< cs_real_t > get_ns_vals_s(const int time_id=0) const
Return a 1D span view of field values. If the field is not a scalar a fatal error is provoked.
Definition: cs_field.cpp:5353
CS_F_HOST void map_to_ns_data(void)
Map internal and public pointers to data series owner.
Definition: cs_field.cpp:5795
cs_real_t * grad
Definition: cs_field.h:305
cs_span_2d< cs_real_t > view(const int time_id=0) const
Return a 2D span view of field values (n_vals, dim), even if the field is a scalar,...
Definition: cs_field.cpp:5061
cs_real_t ** vals
Definition: cs_field.h:290
CS_F_HOST_DEVICE bool is_sub_field_of(const int owner_id) const
Definition: cs_field.h:627
int get_key_int(int key_id) const
Return a integer value for a given key associated with a field.
Definition: cs_field.cpp:4507
cs_span_2d< cs_real_t > get_ns_val_s(const int time_id=0) const
Return a 1D span view of field values. If the field is not a scalar a fatal error is provoked.
Definition: cs_field.cpp:5455
int set_key_int(int key_id, int value)
Assign a integer value for a given key to a field.
Definition: cs_field.cpp:4445
int ns_idx
Definition: cs_field.h:315
CS_F_HOST_DEVICE bool is_sub_field() const
Definition: cs_field.h:618
cs_span_3d< cs_real_t > get_ns_vals_v(const int time_id=0) const
Return a 2D span view of field values. If the field is not a vector a fatal error is provoked.
Definition: cs_field.cpp:5389
cs_span< cs_real_t > get_val_s(const int time_id=0) const
Return a 1D span view of field values. If the field is not a scalar a fatal error is provoked.
Definition: cs_field.cpp:5080
cs_span_2d< cs_real_t > get_val_t(const int time_id=0) const
Return a 2D span view of field values. If the field is not a tensor a fatal error is provoked.
Definition: cs_field.cpp:5129
cs_span_2d< cs_real_t > get_grad_s() const
Return a 2D span view of gradient values. If the field is not a scalar or if the gradient member is n...
Definition: cs_field.cpp:5237
cs_span_3d< cs_real_t > get_grad_t() const
Return a 3D span view of gradient values. If the field is not a tensor or if the gradient member is n...
Definition: cs_field.cpp:5296
int type
Definition: cs_field.h:282
cs_span_3d< cs_real_t > get_ns_val_v(const int time_id=0) const
Return a 2D span view of field values. If the field is not a vector a fatal error is provoked.
Definition: cs_field.cpp:5489
cs_span_3d< cs_real_t > get_ns_val_t(const int time_id=0) const
Return a 2D span view of field values. If the field is not a tensor a fatal error is provoked.
Definition: cs_field.cpp:5521
int n_time_vals
Definition: cs_field.h:288
void clear(const int time_id=-1)
Clear data allocation.
Definition: cs_field.cpp:5650
int set_key_str(int key_id, const char *str)
Assign a character string for a given key to a field.
Definition: cs_field.cpp:4828
int clear_key_int_bits(int key_id, int mask)
Set integer bits matching a mask to 0 for a given key for a field.
Definition: cs_field.cpp:4636
CS_F_HOST_DEVICE bool has_sub_fields() const
Definition: cs_field.h:610
double get_key_double(int key_id) const
Return a floating point value for a given key associated with a field.
Definition: cs_field.cpp:4745
cs_real_t * val_pre
Definition: cs_field.h:301
cs_alloc_mode_t get_vals_alloc_mode(const int time_id=0) const
Get the allocation mode of the values array.
Definition: cs_field.cpp:5552
cs_span_2d< cs_real_t > get_val_v(const int time_id=0) const
Return a 2D span view of field values. If the field is not a vector a fatal error is provoked.
Definition: cs_field.cpp:5103
int ns_owner
Definition: cs_field.h:316
void update_size(const int time_id=-1)
Resize field values automatically (vals, val, val_pre) based on the corresponding mesh_location.
Definition: cs_field.cpp:5589
CS_F_HOST_DEVICE bool is_series_owner() const
Definition: cs_field.h:562
cs_span< cs_real_t > get_vals_s(const int time_id=0) const
Return a 1D span view of field values. If the field is not a scalar a fatal error is provoked.
Definition: cs_field.cpp:5157
const char * name
Definition: cs_field.h:279
cs_span_3d< cs_real_t > get_grad_v() const
Return a 3D span view of gradient values. If the field is not a vector or if the gradient member is n...
Definition: cs_field.cpp:5266
int set_key_int_bits(int key_id, int mask)
Set integer bits matching a mask to 1 for a given key for a field.
Definition: cs_field.cpp:4590
bool is_owner
Definition: cs_field.h:312
const void * get_key_struct(const int key_id, void *s) const
Return a structure for a given key associated with a field.
Definition: cs_field.cpp:4971
int set_key_double(int key_id, double value)
Assign a floating point value for a given key to a field.
Definition: cs_field.cpp:4683
cs_real_t * val
Definition: cs_field.h:298
int id
Definition: cs_field.h:281
cs_span_2d< cs_real_t > get_vals_t(const int time_id=0) const
Return a 2D span view of field values. If the field is not a tensor a fatal error is provoked.
Definition: cs_field.cpp:5210
cs_span_2d< cs_real_t > get_vals_v(const int time_id=0) const
Return a 2D span view of field values. If the field is not a vector a fatal error is provoked.
Definition: cs_field.cpp:5182
CS_F_HOST void initialize_sub_fields(void)
Initialize values related to sub-fields (indices mainly)
Definition: cs_field.cpp:5737
cs_span_3d< cs_real_t > ns_view(const int time_id=0) const
Return a 3D span view of field values. The view is of dimensions (ns_fields, n_vals,...
Definition: cs_field.cpp:5325
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:309
cs_array_3d< cs_real_t > ** _ns_vals
Definition: cs_field.h:530
CS_F_HOST_DEVICE void set_ns_owner(int owner_id)
Definition: cs_field.h:535
CS_F_HOST_DEVICE bool is_part_of_series() const
Definition: cs_field.h:570
int dim
Definition: cs_field.h:284
CS_F_HOST_DEVICE bool owner() const
Definition: cs_field.h:578
cs_span_3d< cs_real_t > get_ns_vals_t(const int time_id=0) const
Return a 2D span view of field values. If the field is not a tensor a fatal error is provoked.
Definition: cs_field.cpp:5423
CS_F_HOST_DEVICE int series_id() const
Definition: cs_field.h:602
int ns_size
Definition: cs_field.h:314
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:555
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
#define CS_F_HOST
Definition: cs_defs.h:553
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.cpp:3174
void cs_field_bc_coeffs_init(cs_field_bc_coeffs_t *bc_coeffs)
Definition: cs_field.cpp:1353
void cs_field_init_bc_coeffs(cs_field_t *f)
Initialize boundary condition coefficients arrays.
Definition: cs_field.cpp:2055
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.cpp:2783
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.cpp:3199
void cs_field_get_bc_coeff_mult(const cs_field_t *f, cs_lnum_t *i_mult, cs_lnum_t *a_mult, cs_lnum_t *b_mult)
int cs_field_key_flag(int key_id)
Get the type flag associated with a given key id.
Definition: cs_field.cpp:3020
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.cpp:3543
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.cpp:1687
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.cpp:2436
cs_field_t * cs_field_by_double_composite_name_try(const char *name_part_1, const char *name_part_2, const char *name_part_3)
Return pointer to a field based on a double composite name if present.
Definition: cs_field.cpp:2568
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.cpp:2857
void cs_field_set_values(cs_field_t *f, cs_real_t c)
Set current field values to the given constant.
Definition: cs_field.cpp:2227
cs_field_t * cs_field_by_composite_name(const char *name_prefix, const char *name_suffix)
Return a pointer to a field based on a composite name.
Definition: cs_field.cpp:2486
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.cpp:3464
void cs_field_destroy_all_keys(void)
Destroy all defined field keys and associated values.
Definition: cs_field.cpp:2988
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.cpp:1525
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.cpp:1505
void cs_field_log_defs(void)
Print info relative to all field definitions to log file.
Definition: cs_field.cpp:3602
const char * cs_field_get_label(const cs_field_t *f)
Return a label associated with a field.
Definition: cs_field.cpp:4270
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.cpp:3097
void cs_field_allocate_values(cs_field_t *f)
Allocate arrays for field values.
Definition: cs_field.cpp:1783
void cs_field_bc_coeffs_shallow_copy(const cs_field_bc_coeffs_t *ref, cs_field_bc_coeffs_t *copy)
Shallow copy of boundary condition coefficients.
Definition: cs_field.cpp:1389
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.cpp:3329
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.cpp:3381
cs_field_error_type_t
Definition: cs_field.h:92
@ CS_FIELD_INVALID_KEY_NAME
Definition: cs_field.h:95
@ CS_FIELD_INVALID_FIELD
Definition: cs_field.h:99
@ CS_FIELD_INVALID_TYPE
Definition: cs_field.h:98
@ CS_FIELD_INVALID_CATEGORY
Definition: cs_field.h:97
@ CS_FIELD_LOCKED
Definition: cs_field.h:100
@ CS_FIELD_OK
Definition: cs_field.h:94
@ CS_FIELD_INVALID_KEY_ID
Definition: cs_field.h:96
void() cs_field_clear_key_struct_t(void *t)
Definition: cs_field.h:662
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.cpp:3355
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.cpp:3066
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.cpp:2462
cs_field_t * cs_field(const char *name)
Return a pointer to a field based on its name. This function requires that a field of the given name ...
Definition: cs_field.cpp:4319
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.cpp:3227
void cs_field_bc_coeffs_clear(cs_field_bc_coeffs_t *bc_coeffs)
Free contents of local boundary condition coefficients.
Definition: cs_field.cpp:1468
void cs_field_key_disable_setup_log(int key_id)
Disable logging setup values associated with a given key.
Definition: cs_field.cpp:3044
int cs_field_define_sub_key(const char *name, int parent_id)
Define a sub key.
Definition: cs_field.cpp:2962
void cs_field_allocate_or_map_all(void)
Allocate arrays for all defined fields based on their location.
Definition: cs_field.cpp:2370
void cs_field_bc_coeffs_free_copy(const cs_field_bc_coeffs_t *ref, cs_field_bc_coeffs_t *copy)
Free copy of boundary condition coefficients.
Definition: cs_field.cpp:1409
void cs_field_destroy_all(void)
Destroy all defined fields.
Definition: cs_field.cpp:2294
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.cpp:1842
cs_field_t * cs_field_create_by_composite_name(const char *name_prefix, const char *name_suffix, int type_flag, int location_id, int dim, bool has_previous)
Create a field descriptor.
Definition: cs_field.cpp:1566
void cs_field_remap_sub_fields_data(const int owner_id)
Update data pointers of sub-fields of a given field.
Definition: cs_field.cpp:1819
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.cpp:3433
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.cpp:3740
void cs_field_allocate_bc_coeffs(cs_field_t *f, bool have_flux_bc, bool have_mom_bc, bool have_conv_bc, bool have_exch_bc, bool have_rad_bc)
Allocate boundary condition coefficients arrays.
Definition: cs_field.cpp:1884
void cs_field_log_key_defs(void)
Print info relative to all key definitions to log file.
Definition: cs_field.cpp:3935
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.cpp:2412
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.cpp:3302
const char * cs_glob_field_comp_name_9[]
const char * cs_glob_field_comp_name_6[]
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, cs_field_clear_key_struct_t *clear_func, size_t size, int type_flag)
Define a key for a structure value by its name and return an associated id.
Definition: cs_field.cpp:2909
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.cpp:2728
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.cpp:2820
void cs_field_define_keys_base(void)
Define base keys.
Definition: cs_field.cpp:4244
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.cpp:2755
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.cpp:1623
void cs_field_log_fields(int log_keywords)
Print info relative to all defined fields to log file.
Definition: cs_field.cpp:3874
void cs_field_current_to_previous(cs_field_t *f)
Copy current field values to previous values if applicable.
Definition: cs_field.cpp:2253
void cs_field_log_all_key_vals(bool log_defaults)
Print info relative to all given field keys to log file.
Definition: cs_field.cpp:4213
int cs_field_lock_key(cs_field_t *f, int key_id)
Lock a field relative to a given key.
Definition: cs_field.cpp:3129
cs_field_t * cs_field_by_composite_name_try(const char *name_prefix, const char *name_suffix)
Return a pointer to a field based on a composite name if present.
Definition: cs_field.cpp:2517
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.cpp:2639
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.cpp:3277
int cs_field_id_by_name(const char *name)
Return the id of a defined field based on its name.
Definition: cs_field.cpp:2618
void() cs_field_log_key_struct_t(const void *t)
Definition: cs_field.h:652
const char * cs_glob_field_comp_name_3[]
cs_field_t * cs_field_try(const char *name)
Return a pointer to a field based on its name. If no field of the given name is defined,...
Definition: cs_field.cpp:4392
void cs_field_allocate_gradient(cs_field_t *f)
Allocate arrays for field gradient.
Definition: cs_field.cpp:2203
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.cpp:4089
@ t
Definition: cs_field_pointer.h:91
cs_alloc_mode_t
Definition: cs_mem.h:46