9from types
import coroutine
11from libc.stdlib cimport malloc, free
13cdef
import from "<mpi.h>" nogil:
14 ctypedef struct _mpi_comm_t
15 ctypedef _mpi_comm_t* MPI_Comm
16 int MPI_Comm_c2f(MPI_Comm)
17 MPI_Comm MPI_Comm_f2c(int)
19cdef extern
from "Python.h":
20 int Py_AtExit(void (*)())
22cdef extern
from "yac.h":
23 cdef const int _LOCATION_CELL
"YAC_LOCATION_CELL"
24 cdef const int _LOCATION_CORNER
"YAC_LOCATION_CORNER"
25 cdef const int _LOCATION_EDGE
"YAC_LOCATION_EDGE"
27 cdef const int _EXCHANGE_TYPE_NONE
"YAC_EXCHANGE_TYPE_NONE"
28 cdef const int _EXCHANGE_TYPE_SOURCE
"YAC_EXCHANGE_TYPE_SOURCE"
29 cdef const int _EXCHANGE_TYPE_TARGET
"YAC_EXCHANGE_TYPE_TARGET"
31 cdef const int _ACTION_NONE
"YAC_ACTION_NONE"
32 cdef const int _ACTION_REDUCTION
"YAC_ACTION_REDUCTION"
33 cdef const int _ACTION_COUPLING
"YAC_ACTION_COUPLING"
34 cdef const int _ACTION_GET_FOR_RESTART
"YAC_ACTION_GET_FOR_RESTART"
35 cdef const int _ACTION_PUT_FOR_RESTART
"YAC_ACTION_PUT_FOR_RESTART"
36 cdef const int _ACTION_OUT_OF_BOUND
"YAC_ACTION_OUT_OF_BOUND"
38 cdef const int _REDUCTION_TIME_NONE
"YAC_REDUCTION_TIME_NONE"
39 cdef const int _REDUCTION_TIME_ACCUMULATE
"YAC_REDUCTION_TIME_ACCUMULATE"
40 cdef const int _REDUCTION_TIME_AVERAGE
"YAC_REDUCTION_TIME_AVERAGE"
41 cdef const int _REDUCTION_TIME_MINIMUM
"YAC_REDUCTION_TIME_MINIMUM"
42 cdef const int _REDUCTION_TIME_MAXIMUM
"YAC_REDUCTION_TIME_MAXIMUM"
44 cdef const int _CALENDAR_NOT_SET
"YAC_CALENDAR_NOT_SET"
45 cdef const int _PROLEPTIC_GREGORIAN
"YAC_PROLEPTIC_GREGORIAN"
46 cdef const int _YEAR_OF_365_DAYS
"YAC_YEAR_OF_365_DAYS"
47 cdef const int _YEAR_OF_360_DAYS
"YAC_YEAR_OF_365_DAYS"
49 cdef const int _TIME_UNIT_MILLISECOND
"YAC_TIME_UNIT_MILLISECOND"
50 cdef const int _TIME_UNIT_SECOND
"YAC_TIME_UNIT_SECOND"
51 cdef const int _TIME_UNIT_MINUTE
"YAC_TIME_UNIT_MINUTE"
52 cdef const int _TIME_UNIT_HOUR
"YAC_TIME_UNIT_HOUR"
53 cdef const int _TIME_UNIT_DAY
"YAC_TIME_UNIT_DAY"
54 cdef const int _TIME_UNIT_MONTH
"YAC_TIME_UNIT_MONTH"
55 cdef const int _TIME_UNIT_YEAR
"YAC_TIME_UNIT_YEAR"
56 cdef const int _TIME_UNIT_ISO_FORMAT
"YAC_TIME_UNIT_ISO_FORMAT"
58 cdef const int _AVG_ARITHMETIC
"YAC_AVG_ARITHMETIC"
59 cdef const int _AVG_DIST
"YAC_AVG_DIST"
60 cdef const int _AVG_BARY
"YAC_AVG_BARY"
62 cdef const int _NCC_AVG
"YAC_NCC_AVG"
63 cdef const int _NCC_DIST
"YAC_NCC_DIST"
65 cdef const int _NNN_AVG
"YAC_NNN_AVG"
66 cdef const int _NNN_DIST
"YAC_NNN_DIST"
67 cdef const int _NNN_GAUSS
"YAC_NNN_GAUSS"
68 cdef const int _NNN_RBF
"YAC_NNN_RBF"
70 cdef const int _CONSERV_DESTAREA
"YAC_CONSERV_DESTAREA"
71 cdef const int _CONSERV_FRACAREA
"YAC_CONSERV_FRACAREA"
73 cdef const int _SPMAP_AVG
"YAC_SPMAP_AVG"
74 cdef const int _SPMAP_DIST
"YAC_SPMAP_DIST"
76 cdef const int _SPMAP_NONE
"YAC_SPMAP_NONE"
77 cdef const int _SPMAP_SRCAREA
"YAC_SPMAP_SRCAREA"
78 cdef const int _SPMAP_INVTGTAREA
"YAC_SPMAP_INVTGTAREA"
79 cdef const int _SPMAP_FRACAREA
"YAC_SPMAP_FRACAREA"
81 cdef const int _CONFIG_OUTPUT_FORMAT_YAML
"YAC_CONFIG_OUTPUT_FORMAT_YAML"
82 cdef const int _CONFIG_OUTPUT_FORMAT_JSON
"YAC_CONFIG_OUTPUT_FORMAT_JSON"
84 cdef const int _CONFIG_OUTPUT_SYNC_LOC_DEF_COMP
"YAC_CONFIG_OUTPUT_SYNC_LOC_DEF_COMP"
85 cdef const int _CONFIG_OUTPUT_SYNC_LOC_SYNC_DEF
"YAC_CONFIG_OUTPUT_SYNC_LOC_SYNC_DEF"
86 cdef const int _CONFIG_OUTPUT_SYNC_LOC_ENDDEF
"YAC_CONFIG_OUTPUT_SYNC_LOC_ENDDEF"
89 void yac_cinit_instance ( int * yac_instance_id )
90 void yac_cinit_comm (MPI_Comm comm )
91 void yac_cinit_comm_instance (MPI_Comm comm, int * yac_instance_id )
93 void yac_ccleanup_instance (int yac_instance_id)
94 void yac_cdef_comp_instance ( int yac_instance_id,
95 const char * comp_name,
97 void yac_cdef_comps_instance ( int yac_instance_id,
98 const char ** comp_names,
101 void yac_cpredef_comp_instance ( int yac_instance_id,
102 const char * comp_name,
104 void yac_cget_comp_comm ( int comp_id, MPI_Comm* comp_comm )
105 void yac_cdef_datetime_instance ( int yac_instance_id,
106 const char * start_datetime,
107 const char * end_datetime )
109 const char ** comp_names,
111 MPI_Comm * comps_comm)
112 void yac_cdef_calendar ( int calendar )
113 int yac_cget_calendar ( )
114 void yac_cenddef_instance ( int yac_instance_id )
115 int yac_cget_nbr_comps_instance ( int yac_instance_id )
116 int yac_cget_nbr_grids_instance ( int yac_instance_id )
117 int yac_cget_comp_nbr_grids_instance ( int yac_instance_id, const char* comp_name )
118 int yac_cget_nbr_fields_instance ( int yac_instance_id, const char * comp_name,
119 const char* grid_name)
120 void yac_cget_comp_names_instance ( int yac_instance_id, int nbr_comps,
121 const char ** comp_names )
122 void yac_cget_grid_names_instance ( int yac_instance_id, int nbr_grids,
123 const char ** grid_names )
124 void yac_cget_comp_grid_names_instance ( int yac_instance_id, const char* comp_name,
125 int nbr_grids, const char ** grid_names )
126 void yac_cget_field_names_instance ( int yac_instance_id, const char* comp_name,
127 const char* grid_name,
128 int nbr_fields, const char ** field_names )
129 int yac_cget_field_id_instance ( int yac_instance_id, const char* comp_name,
130 const char* grid_name,
131 const char * field_name )
132 const char* yac_cget_field_timestep_instance ( int yac_instance_id, const char* comp_name,
133 const char* grid_name,
134 const char * field_name )
135 int yac_cget_field_role_instance ( int yac_instance_id, const char* comp_name,
136 const char* grid_name, const char* field_name )
137 void yac_cget_field_source_instance ( int yac_instance_id, const char* tgt_comp_name,
138 const char* tgt_grid_name, const char* tgt_field_name,
139 const char** src_comp_name, const char** src_grid_name,
140 const char** src_field_name)
141 void yac_cenable_field_frac_mask_instance ( int yac_instance_id,
142 const char* comp_name,
143 const char* grid_name,
144 const char * field_name,
145 double frac_mask_fallback_value)
146 int yac_cget_field_collection_size_instance ( int yac_instance_id,
147 const char* comp_name,
148 const char* grid_name,
149 const char * field_name )
150 double yac_cget_field_frac_mask_fallback_value_instance ( int yac_instance_id,
151 const char* comp_name,
152 const char* grid_name,
153 const char * field_name )
154 void yac_cdef_component_metadata_instance ( int yac_instance_id,
155 const char* comp_name,
156 const char* metadata)
157 void yac_cdef_grid_metadata_instance ( int yac_instance_id,
158 const char* grid_name,
159 const char* metadata)
160 void yac_cdef_field_metadata_instance ( int yac_instance_id,
161 const char* comp_name,
162 const char* grid_name,
163 const char* field_name,
164 const char* metadata)
166 const char* comp_name)
168 const char* grid_name)
170 const char* comp_name,
171 const char* grid_name,
172 const char* field_name)
173 char * yac_cget_start_datetime_instance ( int yac_instance_id )
174 char * yac_cget_end_datetime_instance ( int yac_instance_id )
175 char * yac_cget_version ()
176 void yac_cdef_grid_reg2d ( const char * grid_name,
182 void yac_cdef_points_reg2d ( const int grid_id,
185 const double *x_points,
186 const double *y_points,
188 void yac_cdef_grid_curve2d ( const char * grid_name,
194 void yac_cdef_points_curve2d ( const int grid_id,
197 const double *x_points,
198 const double *y_points,
200 void yac_cdef_grid_cloud ( const char * grid_name,
205 void yac_cdef_grid_unstruct ( const char * grid_name,
208 int *num_vertices_per_cell,
213 void yac_cdef_grid_unstruct_ll ( const char * grid_name,
216 int *num_vertices_per_cell,
221 void yac_cdef_grid_unstruct_edge ( const char * grid_name,
225 int *num_edges_per_cell,
231 void yac_cdef_grid_unstruct_edge_ll ( const char * grid_name,
235 int *num_edges_per_cell,
241 void yac_cdef_points_unstruct ( const int grid_id,
242 const int nbr_points,
244 const double *x_points,
245 const double *y_points,
247 void yac_cset_global_index ( const int * global_index,
250 void yac_cdef_field ( const char * field_name,
251 const int component_id,
252 const int * point_ids,
253 const int num_pointsets,
255 const char* timestep,
258 void yac_cdef_field_mask ( const char * field_name,
259 const int component_id,
260 const int * point_ids,
261 const int * mask_ids,
262 const int num_pointsets,
264 const char* timestep,
267 void yac_csync_def_instance ( int yac_instance_id )
270 const char * weight_file)
276 double scale_summand)
278 int ext_couple_config_id, size_t num_src_mask_names,
279 const char * const * src_mask_names)
281 int ext_couple_config_id, const char * tgt_mask_name)
283 int ext_couple_config_id, const char * yaxt_exchanger_name)
286 const char * src_comp_name,
287 const char * src_grid_name,
288 const char * src_field_name,
289 const char * tgt_comp_name,
290 const char * tgt_grid_name,
291 const char * tgt_field_name,
292 const char * coupling_timestep,
293 int time_unit, int time_reduction,
294 int interp_stack_config_id,
295 int src_lag, int tgt_lag,
296 int ext_couple_config_id)
297 void yac_cget_ ( const int field_id,
298 const int collection_size,
302 void yac_cget_async_ ( const int field_id,
303 const int collection_size,
307 void yac_cput_ ( const int field_id,
308 const int collection_size,
312 void yac_cput_frac_ ( const int field_id,
313 const int collection_size,
315 double *send_frac_mask,
318 void yac_cexchange_ ( const int send_field_id,
319 const int recv_field_id,
320 const int collection_size,
326 void yac_cexchange_frac_ ( const int send_field_id,
327 const int recv_field_id,
328 const int collection_size,
330 double *send_frac_mask,
335 void yac_ctest ( int field_id, int * flag )
336 void yac_cwait ( int field_id ) nogil
338 const char* yac_cget_field_name_from_field_id ( int field_id )
339 const char* yac_cget_component_name_from_field_id ( int field_id )
340 const char* yac_cget_grid_name_from_field_id ( int field_id )
341 int yac_cget_role_from_field_id ( int field_id )
342 const char* yac_cget_timestep_from_field_id ( int field_id )
343 size_t yac_cget_grid_size ( int location, int grid_id )
344 size_t yac_cget_points_size ( int points_id )
345 int yac_cget_collection_size_from_field_id ( const int field_id )
349 int interp_stack_config_id, int reduction_type, int partial_coverage)
351 int interp_stack_config_id, int weight_type, int partial_coverage)
354 double max_search_distance,
357 int interp_stack_config_id, int order, int enforced_conserv,
358 int partial_coverage, int normalisation)
360 int interp_stack_config_id, double spread_distance,
361 double max_search_distance, int weight_type, int scale_type,
362 double src_sphere_radius, char * src_filename,
363 char * src_varname, int src_min_global_id,
364 double tgt_sphere_radius, char * tgt_filename,
365 char * tgt_varname, int tgt_min_global_id)
368 int interp_stack_config_id, char * filename)
370 int interp_stack_config_id, double value)
372 int interp_stack_config_id, char * constructor_key, char * do_search_key)
374 int interp_stack_config_id, int creep_distance)
376 int * interp_stack_config_id)
378 int * interp_stack_config_id)
380 void yac_cset_core_mask ( const int * is_core,
383 void yac_cset_mask ( const int * is_valid,
385 void yac_cdef_mask_named ( const int grid_id,
386 const int nbr_points,
388 const int * is_valid,
392 ctypedef void (*yac_abort_func)(MPI_Comm comm, const char *msg,
393 const char *source, int line)
except *
397 const char * yaml_file)
400 const char * filename,
403 int include_definitions);
410_logger = logging.getLogger(
"yac")
411_logger.addHandler(logging.NullHandler())
417 Refers to @ref YAC_LOCATION_CELL, @ref YAC_LOCATION_CORNER and @ref YAC_LOCATION_EDGE
419 CELL = _LOCATION_CELL
420 CORNER = _LOCATION_CORNER
421 EDGE = _LOCATION_EDGE
425 Exchange type of a field
427 Refers to @ref YAC_EXCHANGE_TYPE_NONE, @ref YAC_EXCHANGE_TYPE_SOURCE and @ref YAC_EXCHANGE_TYPE_TARGET
429 NONE = _EXCHANGE_TYPE_NONE
430 SOURCE = _EXCHANGE_TYPE_SOURCE
431 TARGET = _EXCHANGE_TYPE_TARGET
435 Refers to @ref YAC_ACTION_NONE, @ref YAC_ACTION_REDUCTION etc.
438 REDUCTION = _ACTION_REDUCTION
439 COUPLING = _ACTION_COUPLING
440 GET_FOR_RESTART = _ACTION_GET_FOR_RESTART
441 PUT_FOR_RESTART = _ACTION_PUT_FOR_RESTART
442 OUT_OF_BOUND = _ACTION_OUT_OF_BOUND
446 Reduction type for the definition of interpolations
448 Refers to @ref YAC_REDUCTION_TIME_NONE, @ref YAC_REDUCTION_TIME_ACCUMULATE etc.
450 TIME_NONE = _REDUCTION_TIME_NONE
451 TIME_ACCUMULATE = _REDUCTION_TIME_ACCUMULATE
452 TIME_AVERAGE = _REDUCTION_TIME_AVERAGE
453 TIME_MINIMUM = _REDUCTION_TIME_MINIMUM
454 TIME_MAXIMUM = _REDUCTION_TIME_MAXIMUM
458 Calendar type for use in def_calendar
460 Refers to @ref YAC_CALENDAR_NOT_SET, @ref YAC_PROLEPTIC_GREGORIAN etc.
462 CALENDAR_NOT_SET = _CALENDAR_NOT_SET
463 PROLEPTIC_GREGORIAN = _PROLEPTIC_GREGORIAN
464 YEAR_OF_365_DAYS = _YEAR_OF_365_DAYS
465 YEAR_OF_360_DAYS = _YEAR_OF_360_DAYS
469 @see yac_cdef_calendar
475 @see yac_cget_calendar
482 Refers to @ref YAC_TIME_UNIT_MILLISECOND, @ref YAC_TIME_UNIT_SECOND etc.
484 MILLISECOND = _TIME_UNIT_MILLISECOND
485 SECOND = _TIME_UNIT_SECOND
486 MINUTE = _TIME_UNIT_MINUTE
487 HOUR = _TIME_UNIT_HOUR
489 MONTH = _TIME_UNIT_MONTH
490 YEAR = _TIME_UNIT_YEAR
491 ISO_FORMAT = _TIME_UNIT_ISO_FORMAT
495 Reduction type for average interpolation
497 Refers to @ref YAC_AVG_ARITHMETIC, @ref YAC_AVG_DIST and @ref YAC_AVG_BARY
499 AVG_ARITHMETIC = _AVG_ARITHMETIC
505 Reduction type for ncc interpolation
507 Refers to @ref YAC_NCC_AVG and @ref YAC_NCC_DIST
514 Reduction type for nnn interpolation
516 Refers to @ref YAC_NNN_AVG, @ref YAC_NNN_DIST etc.
525 Normalization type for conservative interpolation
527 Refers to @ref YAC_CONSERV_DESTAREA and @ref YAC_CONSERV_FRACAREA
529 DESTAREA = _CONSERV_DESTAREA
530 FRACAREA = _CONSERV_FRACAREA
534 Refers to @ref YAC_SPMAP_AVG and @ref YAC_SPMAP_DIST
541 Refers to @ref YAC_SPMAP_NONE, YAC_SPMAP_SRCAREA
542 YAC_SPMAP_INVTGTAREA, and @ref YAC_SPMAP_FRACAREA
545 SRCAREA = _SPMAP_SRCAREA
546 INVTGTAREA = _SPMAP_INVTGTAREA
547 FRACAREA = _SPMAP_FRACAREA
550 YAML = _CONFIG_OUTPUT_FORMAT_YAML
551 JSON = _CONFIG_OUTPUT_FORMAT_JSON
554 DEF_COMP = _CONFIG_OUTPUT_SYNC_LOC_DEF_COMP
555 SYNC_DEF = _CONFIG_OUTPUT_SYNC_LOC_SYNC_DEF
556 ENDDEF = _CONFIG_OUTPUT_SYNC_LOC_ENDDEF
560 Initializies a YAC instance and provides further functionality
562 The destructor finalizes the YAC instance by calling yac_cfinalize_instance
564 def __init__(self, comm = None, default_instance = False):
566 @see yac_cinit_instance
572 _logger.debug(
"init")
576 _logger.debug(
"init_instance")
579 from mpi4py
import MPI
580 if type(comm)
is MPI.Intracomm:
581 comm = MPI.Comm.py2f(comm)
583 _logger.debug(
"init_comm")
587 _logger.debug(
"init_comm_instance")
589 _logger.debug(f
"instance_id={instance_id}")
600 yac = cls.__new__(cls)
602 yac.owned_instance =
False
610 @see yac_ccleanup_instance
613 _logger.debug(f
"cleanup instance_id={self.instance_id}")
619 @see yac_cdef_comp_instance
622 _logger.debug(f
"def_comp: comp_name={comp_name}")
624 _logger.debug(f
"comp_id={comp_id}")
629 @see yac_cdef_comps_instance
631 cdef int comp_len = len(comp_names)
632 cdef const char **c_comp_names = <const char **>malloc(comp_len * sizeof(const char *))
633 cdef int *c_comp_ids = <int*>malloc(comp_len * sizeof(int))
634 _logger.debug(f
"def_comps: comp_names={comp_names}")
635 byte_comp_names = [c.encode()
for c
in comp_names]
636 for i
in range(comp_len):
637 c_comp_names[i] = byte_comp_names[i]
639 comp_list = [
Component(c_comp_ids[i])
for i
in range(comp_len) ]
642 _logger.debug(
"comp_list={comp_list}")
647 @see yac_cpredef_comp_instance
650 _logger.debug(f
"predef_comp: comp_name={comp_name}")
652 _logger.debug(
"comp_id={comp_id}")
657 @see yac_cdef_datetime_instance
659 The parameters can be given either as a string in iso8601
660 format or as datetime objects
664 if(
type(start_datetime)
is datetime.datetime):
665 start_datetime = start_datetime.isoformat()
668 if start_datetime
is not None:
669 _logger.debug(f
"def_datetime start: {start_datetime}")
671 start_datetime.encode(),
675 if(
type(end_datetime)
is datetime.datetime):
676 end_datetime = end_datetime.isoformat()
679 if end_datetime
is not None:
680 _logger.debug(f
"def_datetime end: {end_datetime}")
683 end_datetime.encode())
688 @see yac_cget_start_datetime_instance (`datetime.datetime`, read-only).
691 return bytes.decode(start)
696 @see yac_cget_end_datetime_instance (`datetime.datetime`, read-only).
699 return bytes.decode(end)
703 @see yac_csync_def_instance
705 _logger.debug(
"sync_def")
709 src_comp : str, src_grid : str, src_field,
710 tgt_comp : str, tgt_grid : str, tgt_field,
711 coupling_timestep : str, timeunit : TimeUnit,
712 time_reduction : Reduction,
713 interp_stack, src_lag = 0, tgt_lag = 0,
714 weight_file =
None, mapping_on_source = 1,
715 scale_factor = 1.0, scale_summand = 0.0,
716 src_masks_names =
None, tgt_mask_name =
None,
717 yaxt_exchanger_name =
None):
719 @see yac_cdef_couple_instance
721 cdef char * weight_file_ptr
722 if weight_file
is None:
723 weight_file_ptr = NULL
725 weight_file_bytes = weight_file.encode()
726 weight_file_ptr = weight_file_bytes
727 cdef const char ** src_mask_names_ptr = NULL
728 cdef const char * tgt_mask_name_ptr = NULL
729 cdef const char * yaxt_exchanger_name_ptr = NULL
730 cdef int couple_config_id
740 if src_masks_names
is not None:
741 if type(src_masks_names)
is str:
742 src_masks = [src_masks_names]
743 src_masks_enc = [s.encode()
for s
in src_masks_names]
744 src_mask_names_ptr = <const char **>malloc(len(src_masks_enc) * sizeof(char*))
745 for i
in range(len(src_masks_enc)):
746 src_mask_names_ptr[i] = src_masks_enc[i]
750 free(src_mask_names_ptr)
751 if tgt_mask_name
is not None:
753 if yaxt_exchanger_name
is not None:
755 _logger.debug(f
"def_couple {(src_comp.encode(), src_grid.encode(), src_field.encode())}, {(tgt_comp.encode(), tgt_grid.encode(), tgt_field.encode())}")
757 src_comp.encode(), src_grid.encode(), src_field.encode(),
758 tgt_comp.encode(), tgt_grid.encode(), tgt_field.encode(),
759 coupling_timestep.encode(),
TimeUnit(timeunit).value,
761 interp_stack.interp_stack_id, src_lag, tgt_lag,
767 @see yac_cenddef_instance
769 _logger.debug(
"enddef")
775 @see yac_cget_comp_names
778 cdef const char **ret = <const char **>malloc(nbr_components * sizeof(const char *))
780 comp_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_components) ]
787 @see yac_cget_grid_names
790 cdef const char **ret = <const char **>malloc(nbr_grids * sizeof(const char *))
792 grid_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_grids) ]
798 @see yac_cget_comp_grid_names
801 cdef const char **ret = <const char **>malloc(nbr_grids * sizeof(const char *))
803 grid_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_grids) ]
809 @see yac_cget_field_names
814 cdef const char **ret = <const char **>malloc(nbr_fields * sizeof(const char *))
816 grid_name.encode(), nbr_fields, ret)
817 field_list = [bytes(ret[i]).decode(
'UTF-8')
for i
in range(nbr_fields) ]
821 def get_field_id(self, comp_name : str, grid_name : str, field_name : str):
823 @see yac_cget_field_id
825 return yac_cget_field_id_instance (self.
instance_id,
832 @see yac_cget_field_timestep
837 field_name.encode()).decode(
'UTF-8')
841 @see yac_cget_field_role
846 field_name.encode()))
850 cdef const char* src_comp
851 cdef const char* src_grid
852 cdef const char* src_field
860 return (src_comp.decode(
"UTF-8"),
861 src_grid.decode(
"UTF-8"),
862 src_field.decode(
"UTF-8"))
866 @see yac_cget_field_collection_size
875 @see yac_cget_field_frac_mask_fallback_value
883 frac_mask_fallback_value : _np.float64):
885 @see yac_cenable_field_frac_mask
887 _logger.debug(f
"enable_field_frac_mask {(comp_name, grid_name, field_name)})")
892 frac_mask_fallback_value)
896 @see yac_cdef_component_metadata
898 _logger.debug(f
"def_component_metadata comp_name={comp_name}")
900 comp_name.encode(), metadata)
904 @see yac_cdef_grid_metadata
906 _logger.debug(f
"def_grid_metadata grid_name={grid_name}")
908 grid_name.encode(), metadata)
911 field_name : str,metadata : bytes):
913 @see yac_cdef_field_metadata
915 _logger.debug(
"def_field_metadata (comp_name, grid_name, field_name)="
916 f
"{(comp_name, grid_name, field_name)}")
918 grid_name.encode(), field_name.encode(),
923 @see yac_cget_component_metadata
927 return bytes(metadata).decode(
'UTF-8')
if metadata != NULL
else None
931 @see yac_cget_grid_metadata
935 return bytes(metadata).decode(
'UTF-8')
if metadata != NULL
else None
939 @see yac_cget_field_metadata
945 return bytes(metadata).decode(
'UTF-8')
if metadata != NULL
else None
949 @see yac_cget_comps_comm
951 from mpi4py
import MPI
953 cptr = [c.encode()
for c
in comp_names]
954 cdef const char ** comp_names_c_ptr = <const char **>malloc(len(comp_names) * sizeof(const char *))
955 for i
in range(len(comp_names)):
956 comp_names_c_ptr[i] = cptr[i]
958 free(comp_names_c_ptr)
960 return MPI.Comm.f2py(MPI_Comm_c2f(comm))
964 @see yac_cread_config_yaml_instance
966 _logger.debug(f
"read_config_yaml yaml_file={yaml_file}")
970 fileformat : ConfigOutputFormat,
971 sync_location : ConfigOutputSyncLoc,
972 include_definitions : bool =
False):
974 @see yac_cset_config_output_file_instance
980 1
if include_definitions
else 0)
984 Stores the component_id and provides further functionality
992 @see yac_cget_comp_comm (`MPI.Comm`, read-only)
994 from mpi4py
import MPI
998 return MPI.Comm.f2py(MPI_Comm_c2f(comm))
1003 number of processes in this component
1012 process index in the component
1027 Stores the grid_id and provides further functionality
1029 Base class for Reg2dGrid and UnstructuredGrid
1032 _logger.debug(f
"grid_id={grid_id}")
1037 @see yac_cset_global_index
1039 cdef const int[::1] global_index_view = _np.ascontiguousarray(global_index, dtype=_np.intc)
1040 assert len(global_index_view) == yac_cget_grid_size ( location.value, self.
grid_id ), \
1041 "Wrong number of indices provided"
1042 _logger.debug(f
"set_global_index grid_id={self.grid_id}")
1048 @see yac_cget_grid_size (`int`, read-only)
1050 return yac_cget_grid_size ( Location.CELL.value, self.
grid_id )
1055 @see yac_cget_grid_size (`int`, read-only)
1057 return yac_cget_grid_size ( Location.CORNER.value, self.
grid_id )
1062 @see yac_cget_grid_size (`int`, read-only)
1064 return yac_cget_grid_size ( Location.EDGE.value, self.
grid_id )
1068 @see yac_cset_core_mask
1070 cdef size_t len_is_core = len(is_core)
1072 cdef const int[::1] np_mask = _np.ascontiguousarray(is_core, dtype=_np.intc)
1073 _logger.debug(f
"set_core_mask grid_id={self.grid_id}")
1074 yac_cset_core_mask ( &np_mask[0], location.value, self.
grid_id)
1077 is_valid, name =
None):
1078 cdef int len_is_valid = len(is_valid)
1079 cdef const int[::1] np_mask = _np.ascontiguousarray(is_valid, dtype=_np.int32)
1081 cdef char* c_name = NULL
1082 if name
is not None:
1083 name_enc = name.encode()
1085 _logger.debug(f
"def_mask_named grid_id={self.grid_id}, name={name}")
1086 yac_cdef_mask_named ( self.
grid_id,
1092 return Mask(mask_id)
1096 @see yac_ccompute_grid_cell_areas
1098 if cell_areas
is None:
1100 cdef double[::1] np_cell_areas = _np.ascontiguousarray(cell_areas, dtype=_np.double)
1106 Stores the points_id and provides further functionality
1114 @see yac_cget_points_size (`int`, read-only)
1116 return yac_cget_points_size ( self.
points_id )
1122 cdef size_t len_is_valid = len(is_valid)
1123 assert len_is_valid==self.
size
1124 cdef const int[::1] np_mask = _np.ascontiguousarray(is_valid, dtype=_np.intc)
1125 _logger.debug(f
"set_mask points_id={self.points_id}")
1126 yac_cset_mask ( &np_mask[0],
1133 def __init__(self, grid_name : str, x_vertices, y_vertices,
1134 cyclic = [
False,
False]):
1136 @see yac_cdef_grid_reg2d
1139 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1140 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1141 cdef int[2] cyclic_view = cyclic
1142 _logger.debug(f
"def_grid_reg2d grid_name={grid_name}")
1144 cyclic_view, <double*>&x[0], <double*>&y[0], &grid_id)
1148 x_vertices, y_vertices):
1150 @see yac_cdef_points_reg2d
1153 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1154 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1155 _logger.debug(f
"def_points_reg2d grid_id={self.grid_id}")
1157 location.value, &x[0], &y[0], &points_id)
1158 _logger.debug(f
"points_id={points_id}")
1162 x_vertices, y_vertices):
1164 @see yac_cdef_points_unstruct
1166 assert len(x_vertices) == len(y_vertices)
1168 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1169 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1170 _logger.debug(f
"def_points_unstruct grid_id={self.grid_id}")
1172 location.value, &x[0], &y[0], &points_id)
1173 _logger.debug(f
"points_id={points_id}")
1178 A curvilinear stuctured 2d Grid
1180 def __init__(self, grid_name : str, x_vertices, y_vertices,
1181 cyclic = [
False,
False]):
1183 @see yac_cdef_grid_curve2d
1186 cdef const double[::1] x = _np.ascontiguousarray(x_vertices.flatten(), dtype=_np.double)
1187 cdef const double[::1] y = _np.ascontiguousarray(y_vertices.flatten(), dtype=_np.double)
1188 cdef int[2] cyclic_view = cyclic
1189 _logger.debug(f
"def_grid_curve2d grid_name={grid_name}")
1191 [_np.shape(x_vertices)[1], _np.shape(y_vertices)[0]],
1192 cyclic_view, <double*>&x[0], <double*>&y[0], &grid_id)
1196 x_vertices, y_vertices):
1198 @see yac_cdef_points_curve2d
1200 assert x_vertices.shape == y_vertices.shape
1202 cdef const double[::1] x = _np.ascontiguousarray(x_vertices.flatten(), dtype=_np.double)
1203 cdef const double[::1] y = _np.ascontiguousarray(y_vertices.flatten(), dtype=_np.double)
1204 _logger.debug(f
"def_points_curve2d grid_id={self.grid_id}")
1206 [_np.shape(x_vertices)[1], _np.shape(x_vertices)[0]],
1207 location.value, &x[0], &y[0], &points_id)
1208 _logger.debug(f
"points_id={points_id}")
1212 x_vertices, y_vertices):
1214 @see yac_cdef_points_unstruct
1216 assert len(x_vertices) == len(y_vertices)
1218 cdef const double[::1] x = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1219 cdef const double[::1] y = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1220 _logger.debug(f
"def_points_unstruct grid_id={self.grid_id}")
1222 location.value, &x[0], &y[0], &points_id)
1223 _logger.debug(f
"points_id={points_id}")
1232 x_points, y_points):
1234 @see yac_cdef_points_unstruct
1237 cdef const double[::1] x_points_view = _np.ascontiguousarray(x_points, dtype=_np.double)
1238 cdef const double[::1] y_points_view = _np.ascontiguousarray(y_points, dtype=_np.double)
1239 _logger.debug(f
"yac_cdef_points_unstruct grid_id={self.grid_id}")
1241 &x_points_view[0], &y_points_view[0], &points_id)
1242 _logger.debug(f
"points_id={points_id}")
1247 An unstuctured 2d Grid
1249 def __init__(self, grid_name : str, num_vertices_per_cell,
1250 x_vertices, y_vertices, cell_to_vertex, use_ll_edges=
False):
1252 @see yac_cdef_grid_unstruct and @see yac_cdef_grid_unstruct_ll
1255 cdef const int[::1] num_vertices_per_cell_view = _np.ascontiguousarray(num_vertices_per_cell, dtype=_np.intc)
1256 cdef const double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1257 cdef const double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1258 cdef const int[::1] cell_to_vertex_view = _np.ascontiguousarray(cell_to_vertex, dtype=_np.intc)
1259 assert len(num_vertices_per_cell_view) > 0, \
1260 "UnstrucuredGrid needs at least one cell. Use CloudGrid if you dont need to define cells."
1261 if not use_ll_edges:
1262 _logger.debug(f
"def_grid_unstruct grid_name={grid_name}")
1264 len(num_vertices_per_cell_view),
1265 <int*>&num_vertices_per_cell_view[0],
1266 <double*>&x_vertices_view[0],
1267 <double*>&y_vertices_view[0],
1268 <int*>&cell_to_vertex_view[0], &grid_id)
1270 _logger.debug(f
"def_grid_unstruct_ll grid_name={grid_name}")
1272 len(num_vertices_per_cell_view),
1273 <int*>&num_vertices_per_cell_view[0],
1274 <double*>&x_vertices_view[0],
1275 <double*>&y_vertices_view[0],
1276 <int*>&cell_to_vertex_view[0], &grid_id)
1281 @see yac_cdef_grid_cloud
1283 def __init__(self, grid_name : str, x_vertices, y_vertices):
1285 cdef const double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1286 cdef const double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1287 _logger.debug(f
"def_grid_cloud grid_name={grid_name}")
1288 yac_cdef_grid_cloud (grid_name.encode(),
1289 len(x_vertices_view),
1290 <double*>&x_vertices_view[0],
1291 <double*>&y_vertices_view[0],
1296 return super().
def_points(Location.CORNER, x_points, y_points)
1300 def __init__(self, grid_name : str, num_edges_per_cell,
1301 x_vertices, y_vertices, cell_to_edge, edge_to_vertex,
1302 use_ll_edges=
False):
1304 cdef const int[::1] num_edges_per_cell_view = _np.ascontiguousarray(num_edges_per_cell, dtype=_np.intc)
1305 cdef const double[::1] x_vertices_view = _np.ascontiguousarray(x_vertices, dtype=_np.double)
1306 cdef const double[::1] y_vertices_view = _np.ascontiguousarray(y_vertices, dtype=_np.double)
1307 cdef const int[::1] cell_to_edge_view = _np.ascontiguousarray(cell_to_edge, dtype=_np.intc)
1308 cdef const int[:, ::1] edge_to_vertex_view = _np.ascontiguousarray(edge_to_vertex, dtype=_np.intc)
1309 assert edge_to_vertex_view.shape[1] == 2, \
1310 "dimension 1 of edge_to_vertex must be 2"
1311 assert len(num_edges_per_cell_view) > 0, \
1312 "UnstrucuredGridEdge needs at least one cell. Use CloudGrid if you dont need to define cells."
1313 if not use_ll_edges:
1314 _logger.debug(f
"def_grid_unstruct_edge grid_name={grid_name}")
1316 len(num_edges_per_cell_view),
1317 edge_to_vertex_view.shape[0],
1318 <int*>&num_edges_per_cell_view[0],
1319 <double*>&x_vertices_view[0],
1320 <double*>&y_vertices_view[0],
1321 <int*>&cell_to_edge_view[0],
1322 <int*>&edge_to_vertex_view[0,0],
1325 _logger.debug(f
"def_grid_unstruct_edge_ll grid_name={grid_name}")
1327 len(num_edges_per_cell_view),
1328 edge_to_vertex_view.shape[0],
1329 <int*>&num_edges_per_cell_view[0],
1330 <double*>&x_vertices_view[0],
1331 <double*>&y_vertices_view[0],
1332 <int*>&cell_to_edge_view[0],
1333 <int*>&edge_to_vertex_view[0,0],
1347 def create(cls, field_name : str, comp : Component, points, collection_size,
1348 timestep : str, timeunit : TimeUnit, masks =
None):
1352 from collections.abc
import Iterable
1354 if not isinstance(points, Iterable):
1356 cdef const int[:] point_ids_array = _np.array([p.points_id
for p
in points], dtype=_np.intc)
1357 size = sum(p.size
for p
in points)
1358 cdef const int[:] mask_ids_array
1360 _logger.debug(f
"def_field field_name={field_name}, comp_id={comp.comp_id}, point_ids={[p.points_id for p in points]}")
1362 &point_ids_array[0], len(point_ids_array),
1363 collection_size, timestep.encode(),
TimeUnit(timeunit).value, &field_id)
1365 if not isinstance(masks, Iterable):
1367 mask_ids_array = _np.array([m.mask_id
for m
in masks], dtype=_np.intc)
1368 _logger.debug(f
"def_field_mask field_name={field_name}, comp_id={comp.comp_id}, point_ids={[p.points_id for p in points]}")
1370 &point_ids_array[0], &mask_ids_array[0],
1371 len(point_ids_array),
1372 collection_size, timestep.encode(),
TimeUnit(timeunit).value, &field_id)
1373 _logger.debug(f
"field_id={field_id}")
1374 return Field(field_id, size)
1382 _logger.debug(f
"test field_id={self.field_id}")
1384 _logger.debug(f
"flag={flag}")
1393 _logger.debug(f
"wait field_id={field_id}")
1395 yac_cwait ( field_id )
1400 Coroutine. Blocks until the communication is completed.
1402 while self.
test() == 0:
1405 @cython.boundscheck(False)
1406 def get(self, buf=None, asyn=False):
1410 @param[out] buf receive buffer, if `None` a numpy array of correct size is allocated
1411 @param[in] asyn if True the call returns immidiatly and must be completed
1412 with `test` or `wait`
1420 if buf_in
is not None and buf.base
is None:
1421 _logger.warning(
"get: non-contiguous buffer passed to get. Reallocated memory.")
1422 cdef double[:,::1] buf_view = buf
1426 _logger.debug(f
"get_async_ field_id={self.field_id}")
1427 yac_cget_async_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1429 _logger.debug(f
"get_ field_id={self.field_id}")
1431 yac_cget_(field_id, collection_size, &buf_view[0,0], &info, &ierror)
1433 raise RuntimeError(
"yac_cget returned error number " + str(ierror))
1434 _logger.debug(f
"info={info}")
1439 Coroutine. Executes a get operation.
1441 @see yac_cget_async_
1443 @param[out] buf receive buffer, if `None` a numpy array of correct size is allocated
1445 buf, info = self.
get(buf, asyn=
True)
1449 @cython.boundscheck(False)
1450 def put(self, buf, frac_mask = None):
1457 cdef const double[:,:,::1] frac_mask_view
1460 if frac_mask
is not None:
1461 frac_mask_view = _np.ascontiguousarray(
1463 _logger.debug(f
"put_frac_ field_id={self.field_id}")
1465 yac_cput_frac_(field_id, collection_size, <double*>&buf_view[0,0,0],
1466 <double*>&frac_mask_view[0,0,0], &info, &ierror)
1468 _logger.debug(f
"put_ field_id={self.field_id}")
1470 yac_cput_(field_id, collection_size, <double*>&buf_view[0,0,0], &info, &ierror)
1472 raise RuntimeError(
"yac_cput returned error number " + str(ierror))
1473 _logger.debug(f
"info={info}")
1478 Coroutine. Executes a put operation.
1483 return self.
put(buf, frac_mask)
1489 _logger.debug(f
"update field_id={self.field_id}")
1493 @cython.boundscheck(False)
1494 def exchange(cls, send_field, recv_field, send_buf, recv_buf=None, send_frac_mask=None):
1496 @see yac_cexchange_frac_
1498 assert send_field.collection_size == recv_field.collection_size,
"exchange can only be used with fields of the same collection_size"
1499 cdef int collection_size = send_field.collection_size
1503 cdef const double[:,:,::1] send_buf_view = _np.ascontiguousarray(send_buf.reshape(-1,collection_size,send_field.size), dtype=_np.double)
1504 cdef const double[:,:,::1] frac_mask_view
1505 if recv_buf
is None:
1506 recv_buf = _np.empty((collection_size, recv_field.size), dtype=_np.double)
1507 recv_buf = _np.ascontiguousarray(recv_buf.reshape(collection_size, recv_field.size), dtype=_np.double)
1508 cdef double[:,::1] recv_buf_view = recv_buf
1509 cdef int send_field_id = send_field.field_id
1510 cdef int recv_field_id = recv_field.field_id
1511 if send_frac_mask
is None:
1512 _logger.debug(f
"exchange_ with send_field.field_id={send_field.field_id} and recv_field.field_id={recv_field.field_id}")
1515 <double*>&send_buf_view[0,0,0],
1516 <double*>&recv_buf_view[0,0],
1517 &send_info, &recv_info, &ierror)
1519 _logger.debug(f
"exchange_frac_ with send_field.field_id={send_field.field_id} and recv_field.field_id={recv_field.field_id}")
1520 frac_mask_view = _np.ascontiguousarray(
1521 send_frac_mask.reshape(-1,collection_size,send_field.size), dtype=_np.double)
1524 <double*>&send_buf_view[0,0,0],
1525 <double*>&frac_mask_view[0,0,0],
1526 <double*>&recv_buf_view[0,0],
1527 &send_info, &recv_info, &ierror)
1529 raise RuntimeError(
"yac_cexchange_frac_ returned error number " + str(ierror))
1531 return recv_buf, send_info, recv_info
1536 @see yac_cget_field_name_from_field_id
1538 return bytes.decode(yac_cget_field_name_from_field_id ( self.
field_id ))
1543 @see yac_cget_grid_name_from_field_id
1545 return bytes.decode(yac_cget_grid_name_from_field_id ( self.
field_id ))
1550 @see yac_cget_component_name_from_field_id
1552 return bytes.decode(yac_cget_component_name_from_field_id ( self.
field_id ))
1557 @see yac_cget_role_from_field_id
1564 @see yac_cget_timestep_from_field_id
1566 return bytes.decode(yac_cget_timestep_from_field_id ( self.
field_id ))
1571 @see yac_cget_collection_size_from_field_id
1578 The size of the corresponding points object
1585 @see yac_cget_field_datetime
1592 @see yac_cget_action
1601 @see yac_cget_interp_stack_config
1603 cdef int interp_stack_config_id
1604 _logger.debug(f
"get_interp_stack_config")
1606 _logger.debug(f
"interp_stack_config_id={interp_stack_config_id}")
1611 interp_stack = cls.__new__(cls)
1612 cdef int interp_stack_config_id
1613 _logger.debug(f
"get_interp_stack_config_from_string_yaml: interp_stack_string={interp_stack_string}")
1615 _logger.debug(f
"interp_stack_config_id_from_string_yaml={interp_stack_config_id}")
1616 interp_stack.interp_stack_id = interp_stack_config_id
1621 interp_stack = cls.__new__(cls)
1622 cdef int interp_stack_config_id
1623 _logger.debug(f
"get_interp_stack_config_from_string_json: interp_stack_string={interp_stack_string}")
1625 _logger.debug(f
"interp_stack_config_id_from_string_json={interp_stack_config_id}")
1626 interp_stack.interp_stack_id = interp_stack_config_id
1629 def add_average(self, reduction_type : AverageReductionType, partial_coverage):
1631 @see yac_cadd_interp_stack_config_average
1633 _logger.debug(f
"add_interp_stack_config_average interp_stack_id={self.interp_stack_id}")
1638 def add_ncc(self, reduction_type : NCCReductionType, partial_coverage):
1640 @see yac_cadd_interp_stack_config_ncc
1642 _logger.debug(f
"add_interp_stack_config_ncc interp_stack_id={self.interp_stack_id}")
1647 def add_nnn(self, reduction_type : NNNReductionType, n : int,
1648 max_search_distance : _np.float64, scale : _np.float64):
1650 @see yac_cadd_interp_stack_config_nnn
1652 _logger.debug(f
"add_interp_stack_config_nnn interp_stack_id={self.interp_stack_id}")
1655 n, max_search_distance, scale)
1658 partial_coverage : int, normalisation : ConservNormalizationType):
1660 @see yac_cadd_interp_stack_config_conservative
1662 _logger.debug(f
"add_interp_stack_config_conservative interp_stack_id={self.interp_stack_id}")
1664 order, enforced_conserv,
1668 def add_spmap(self, spread_distance : _np.float64, max_search_distance : _np.float64,
1669 weight_type : SPMAPWeightType, scale_type : SPMAPScaleType,
1670 src_sphere_radius : _np.float64 = 1.0, src_filename : str =
None,
1671 src_varname : str =
None, src_min_global_id : int = 0,
1672 tgt_sphere_radius : _np.float64 = 1.0, tgt_filename : str =
None,
1673 tgt_varname : str =
None, tgt_min_global_id : int = 0):
1675 @see yac_cadd_interp_stack_config_spmap
1677 _logger.debug(f
"add_interp_stack_config_spmap interp_stack_id={self.interp_stack_id}")
1678 cdef char * src_filename_ptr
1679 if src_filename
is None:
1680 src_filename_ptr = NULL
1682 src_filename_bytes = src_filename.encode()
1683 src_filename_ptr = src_filename_bytes
1684 cdef char * src_varname_ptr
1685 if src_varname
is None:
1686 src_varname_ptr = NULL
1688 src_varname_bytes = src_varname.encode()
1689 src_varname_ptr = src_varname_bytes
1690 cdef char * tgt_filename_ptr
1691 if tgt_filename
is None:
1692 tgt_filename_ptr = NULL
1694 tgt_filename_bytes = tgt_filename.encode()
1695 tgt_filename_ptr = tgt_filename_bytes
1696 cdef char * tgt_varname_ptr
1697 if tgt_varname
is None:
1698 tgt_varname_ptr = NULL
1700 tgt_varname_bytes = tgt_varname.encode()
1701 tgt_varname_ptr = tgt_varname_bytes
1703 spread_distance, max_search_distance,
1706 src_sphere_radius, src_filename_ptr,
1707 src_varname_ptr, src_min_global_id,
1708 tgt_sphere_radius, tgt_filename_ptr,
1709 tgt_varname_ptr, tgt_min_global_id)
1713 @see yac_cadd_interp_stack_config_hcsbb
1715 _logger.debug(f
"add_interp_stack_config_hcsbb interp_stack_id={self.interp_stack_id}")
1720 @see yac_cadd_interp_stack_config_user_file
1722 _logger.debug(f
"add_interp_stack_config_user_file interp_stack_id={self.interp_stack_id}")
1728 @see yac_cadd_interp_stack_config_fixed
1730 _logger.debug(f
"add_interp_stack_config_fixed interp_stack_id={self.interp_stack_id}")
1733 def add_check(self, constructor_key : str, do_search_key : str):
1735 @see yac_cadd_interp_stack_config_check
1737 _logger.debug(f
"add_interp_stack_config_check interp_stack_id={self.interp_stack_id}")
1739 constructor_key.encode(), do_search_key.encode())
1743 @see yac_cadd_interp_stack_config_creep
1745 _logger.debug(f
"add_interp_stack_config_creep interp_stack_id={self.interp_stack_id}")
1751 @see yac_cfree_interp_stack_config
1753 _logger.debug(f
"free_interp_stack_config interp_stack_id={self.interp_stack_id}")
1758 @see yac_cget_version
1763if Py_AtExit(yac_cfinalize) < 0:
1766 b
"could not register yac_cfinalize with Py_AtExit()",
1771cdef void yac_python_abort(MPI_Comm comm, const char* msg,
1772 const char* source, int line) noexcept
with gil:
1774 traceback.print_stack()
Refers to YAC_ACTION_NONE, YAC_ACTION_REDUCTION etc.
Reduction type for average interpolation.
Calendar type for use in def_calendar.
__init__(self, str grid_name, x_vertices, y_vertices)
def_points(self, x_points, y_points)
Stores the component_id and provides further functionality.
size(self)
number of processes in this component
rank(self)
process index in the component
Normalization type for conservative interpolation.
A curvilinear stuctured 2d Grid.
def_points_unstruct(self, Location location, x_vertices, y_vertices)
def_points(self, Location location, x_vertices, y_vertices)
__init__(self, str grid_name, x_vertices, y_vertices, cyclic=[False, False])
Exchange type of a field.
put_coro(self, buf, frac_mask=None)
Coroutine.
get_coro(self, buf=None)
Coroutine.
size(self)
The size of the corresponding points object.
wait_coro(self)
Coroutine.
get(self, buf=None, asyn=False)
exchange(cls, send_field, recv_field, send_buf, recv_buf=None, send_frac_mask=None)
create(cls, str field_name, Component comp, points, collection_size, str timestep, TimeUnit timeunit, masks=None)
__init__(self, field_id, size=None)
put(self, buf, frac_mask=None)
Stores the grid_id and provides further functionality.
set_core_mask(self, is_core, Location location)
set_global_index(self, global_index, Location location)
def_mask(self, Location location, is_valid, name=None)
compute_grid_cell_areas(self, cell_areas=None)
add_check(self, str constructor_key, str do_search_key)
add_average(self, AverageReductionType reduction_type, partial_coverage)
add_spmap(self, _np.float64 spread_distance, _np.float64 max_search_distance, SPMAPWeightType weight_type, SPMAPScaleType scale_type, _np.float64 src_sphere_radius=1.0, str src_filename=None, str src_varname=None, int src_min_global_id=0, _np.float64 tgt_sphere_radius=1.0, str tgt_filename=None, str tgt_varname=None, int tgt_min_global_id=0)
add_conservative(self, int order, int enforced_conserv, int partial_coverage, ConservNormalizationType normalisation)
add_creep(self, int creep_distance)
add_fixed(self, _np.float64 value)
from_string_json(cls, str interp_stack_string)
from_string_yaml(cls, str interp_stack_string)
add_nnn(self, NNNReductionType reduction_type, int n, _np.float64 max_search_distance, _np.float64 scale)
add_user_file(self, str filename)
add_ncc(self, NCCReductionType reduction_type, partial_coverage)
Reduction type for ncc interpolation.
Reduction type for nnn interpolation.
Stores the points_id and provides further functionality.
__init__(self, points_id)
Reduction type for the definition of interpolations.
__init__(self, str grid_name, x_vertices, y_vertices, cyclic=[False, False])
def_points(self, Location location, x_vertices, y_vertices)
def_points_unstruct(self, Location location, x_vertices, y_vertices)
Refers to YAC_SPMAP_NONE, YAC_SPMAP_SRCAREA YAC_SPMAP_INVTGTAREA, and YAC_SPMAP_FRACAREA.
Refers to YAC_SPMAP_AVG and YAC_SPMAP_DIST.
Refers to YAC_TIME_UNIT_MILLISECOND, YAC_TIME_UNIT_SECOND etc.
__init__(self, str grid_name, num_edges_per_cell, x_vertices, y_vertices, cell_to_edge, edge_to_vertex, use_ll_edges=False)
__init__(self, str grid_name, num_vertices_per_cell, x_vertices, y_vertices, cell_to_vertex, use_ll_edges=False)
Initializies a YAC instance and provides further functionality.
read_config_yaml(self, str yaml_file)
def_comp(self, str comp_name)
predef_comp(self, str comp_name)
get_grid_metadata(self, str grid_name)
def_component_metadata(self, str comp_name, bytes metadata)
def_couple(self, str src_comp, str src_grid, src_field, str tgt_comp, str tgt_grid, tgt_field, str coupling_timestep, TimeUnit timeunit, Reduction time_reduction, interp_stack, src_lag=0, tgt_lag=0, weight_file=None, mapping_on_source=1, scale_factor=1.0, scale_summand=0.0, src_masks_names=None, tgt_mask_name=None, yaxt_exchanger_name=None)
def_field_metadata(self, str comp_name, str grid_name, str field_name, bytes metadata)
def_grid_metadata(self, str grid_name, bytes metadata)
get_field_metadata(self, str comp_name, str grid_name, str field_name)
get_comps_comm(self, comp_names)
get_field_names(self, str comp_name, str grid_name)
get_field_id(self, str comp_name, str grid_name, str field_name)
def_comps(self, comp_names=[])
get_component_metadata(self, str comp_name)
def_datetime(self, start_datetime, end_datetime)
get_field_role(self, str comp_name, str grid_name, str field_name)
get_field_source(self, str comp_name, str grid_name, str field_name)
enable_field_frac_mask(self, str comp_name, str grid_name, str field_name, _np.float64 frac_mask_fallback_value)
get_comp_grid_names(self, comp_name)
get_field_timestep(self, str comp_name, str grid_name, str field_name)
get_field_frac_mask_fallback_value(self, str comp_name, str grid_name, str field_name)
__init__(self, comm=None, default_instance=False)
get_field_collection_size(self, str comp_name, str grid_name, str field_name)
set_config_output_file(self, str filename, ConfigOutputFormat fileformat, ConfigOutputSyncLoc sync_location, bool include_definitions=False)
def_points(self, Location location, x_points, y_points)
def_calendar(Calendar calendar)
void yac_ccompute_grid_cell_areas(int grid_id, double *cell_areas)
void yac_cadd_interp_stack_config_ncc(int interp_stack_config_id, int weight_type, int partial_coverage)
const char * yac_cget_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cpredef_comp_instance(int yac_instance_id, char const *name, int *comp_id)
char * yac_cget_start_datetime_instance(int yac_instance_id)
void yac_cdef_field_mask(char const *name, int const comp_id, int const *point_ids, int const *mask_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_cset_global_index(int const *global_index, int location, int grid_id)
void yac_cget_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
int yac_cget_nbr_grids_instance(int yac_instance_id)
void yac_cfree_ext_couple_config(int ext_couple_config_id)
const char * yac_cget_grid_metadata_instance(int yac_instance_id, const char *grid_name)
char * yac_cget_end_datetime_instance(int yac_instance_id)
void yac_cset_ext_couple_config_tgt_mask_name(int ext_couple_config_id, char const *tgt_mask_name)
void yac_cdef_grid_curve2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
void yac_cget_grid_names_instance(int yac_instance_id, int nbr_grids, const char **grid_names)
void yac_cset_ext_couple_config_scale_factor(int ext_couple_config_id, double scale_factor)
void yac_cadd_interp_stack_config_creep(int interp_stack_config_id, int creep_distance)
void yac_cput_frac_(int const field_id, int const collection_size, double *send_field, double *send_frac_mask, int *info, int *ierr)
void yac_cget_comp_rank_c2py(int comp_id, int *rank)
void yac_cget_comp_size_c2py(int comp_id, int *size)
int yac_cget_comp_nbr_grids_instance(int yac_instance_id, const char *comp_name)
void yac_cdef_grid_unstruct_ll(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
void yac_csync_def_instance(int yac_instance_id)
void yac_cget_interp_stack_config_from_string_json(char const *interp_stack_config, int *interp_stack_config_id)
void yac_cadd_interp_stack_config_check(int interp_stack_config_id, char const *constructor_key, char const *do_search_key)
void yac_cenddef_instance(int yac_instance_id)
void yac_cset_ext_couple_config_src_mask_names(int ext_couple_config_id, size_t num_src_mask_names, char const *const *src_mask_names)
int yac_cget_nbr_comps_instance(int yac_instance_id)
int yac_cget_nbr_fields_instance(int yac_instance_id, const char *comp_name, const char *grid_name)
void yac_cget_ext_couple_config(int *ext_couple_config_id)
void yac_cdef_grid_unstruct_edge(const char *grid_name, int nbr_vertices, int nbr_cells, int nbr_edges, int *num_edges_per_cell, double *x_vertices, double *y_vertices, int *cell_to_edge, int *edge_to_vertex, int *grid_id)
void yac_cdef_grid_metadata_instance(int yac_instance_id, const char *grid_name, const char *metadata)
void yac_cset_ext_couple_config_weight_file(int ext_couple_config_id, char const *weight_file)
const char * yac_cget_component_metadata_instance(int yac_instance_id, const char *comp_name)
void yac_cread_config_yaml_instance(int yac_instance_id, const char *yaml_filename)
void yac_cset_ext_couple_config_yaxt_exchanger_name(int ext_couple_config_id, char const *yaxt_exchanger_name)
const char * yac_cget_field_timestep_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cset_ext_couple_config_scale_summand(int ext_couple_config_id, double scale_summand)
void yac_cget_comp_comm(int comp_id, MPI_Comm *comp_comm)
const char * yac_cget_field_datetime(int field_id)
void yac_cdef_comp_instance(int yac_instance_id, char const *comp_name, int *comp_id)
void yac_cupdate(int field_id)
void yac_cget_action(int field_id, int *action)
void yac_cexchange_(int const send_field_id, int const recv_field_id, int const collection_size, double *send_field, double *recv_field, int *send_info, int *recv_info, int *ierr)
int yac_cget_collection_size_from_field_id(int field_id)
void yac_cdef_grid_reg2d(const char *grid_name, int nbr_vertices[2], int cyclic[2], double *x_vertices, double *y_vertices, int *grid_id)
void yac_cdef_couple_custom_instance(int yac_instance_id, char const *src_comp_name, char const *src_grid_name, char const *src_field_name, char const *tgt_comp_name, char const *tgt_grid_name, char const *tgt_field_name, char const *coupling_timestep, int time_unit, int time_reduction, int interp_stack_config_id, int src_lag, int tgt_lag, int ext_couple_config_id)
void yac_cset_config_output_file_instance(int yac_instance_id, const char *filename, int fileformat, int sync_location, int include_definitions)
void yac_cdef_points_reg2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
void yac_cinit_comm_instance(MPI_Comm comm, int *yac_instance_id)
void yac_cenable_field_frac_mask_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, double frac_mask_fallback_value)
void yac_cget_interp_stack_config_from_string_yaml(char const *interp_stack_config, int *interp_stack_config_id)
void yac_cadd_interp_stack_config_conservative(int interp_stack_config_id, int order, int enforced_conserv, int partial_coverage, int normalisation)
void yac_cdef_grid_unstruct(const char *grid_name, int nbr_vertices, int nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex, int *grid_id)
void yac_cdef_points_unstruct(int const grid_id, int const nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
char * yac_cget_version(void)
int yac_cget_default_instance_id()
void yac_cadd_interp_stack_config_user_file(int interp_stack_config_id, char const *filename)
void yac_cexchange_frac_(int const send_field_id, int const recv_field_id, int const collection_size, double *send_field, double *send_frac_mask, double *recv_field, int *send_info, int *recv_info, int *ierr)
void yac_cdef_component_metadata_instance(int yac_instance_id, const char *comp_name, const char *metadata)
void yac_cdef_calendar(int calendar)
void yac_cput_(int const field_id, int const collection_size, double *send_field, int *info, int *ierr)
void yac_cget_comp_grid_names_instance(int yac_instance_id, const char *comp_name, int nbr_grids, const char **grid_names)
void yac_cget_async_(int const field_id, int const collection_size, double *recv_field, int *info, int *ierr)
void yac_cadd_interp_stack_config_hcsbb(int interp_stack_config_id)
void yac_cget_comps_comm_instance(int yac_instance_id, char const **comp_names, int num_comps, MPI_Comm *comps_comm)
void yac_cadd_interp_stack_config_fixed(int interp_stack_config_id, double value)
double yac_cget_field_frac_mask_fallback_value_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cget_field_source_instance(int yac_instance_id, const char *tgt_comp_name, const char *tgt_grid_name, const char *tgt_field_name, const char **src_comp_name, const char **src_grid_name, const char **src_field_name)
void yac_cadd_interp_stack_config_spmap(int interp_stack_config_id, double spread_distance, double max_search_distance, int weight_type, int scale_type, double src_sphere_radius, char const *src_filename, char const *src_varname, int src_min_global_id, double tgt_sphere_radius, char const *tgt_filename, char const *tgt_varname, int tgt_min_global_id)
void yac_cdef_grid_unstruct_edge_ll(const char *grid_name, int nbr_vertices, int nbr_cells, int nbr_edges, int *num_edges_per_cell, double *x_vertices, double *y_vertices, int *cell_to_edge, int *edge_to_vertex, int *grid_id)
void yac_cdef_points_curve2d(int const grid_id, int const *nbr_points, int const located, double const *x_points, double const *y_points, int *point_id)
void yac_cset_ext_couple_config_mapping_side(int ext_couple_config_id, int mapping_side)
void yac_ccleanup_instance(int yac_instance_id)
int yac_cget_field_collection_size_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name)
void yac_cfree_interp_stack_config(int interp_stack_config_id)
void yac_cadd_interp_stack_config_nnn(int interp_stack_config_id, int type, size_t n, double max_search_distance, double scale)
size_t yac_cget_grid_size(int located, int grid_id)
void yac_cinit_instance(int *yac_instance_id)
void yac_cget_interp_stack_config(int *interp_stack_config_id)
void yac_cadd_interp_stack_config_average(int interp_stack_config_id, int reduction_type, int partial_coverage)
void yac_cdef_field(char const *name, int const comp_id, int const *point_ids, int const num_pointsets, int collection_size, const char *timestep, int time_unit, int *field_id)
void yac_cdef_field_metadata_instance(int yac_instance_id, const char *comp_name, const char *grid_name, const char *field_name, const char *metadata)
void yac_cget_field_names_instance(int yac_instance_id, const char *comp_name, const char *grid_name, int nbr_fields, const char **field_names)
void yac_cdef_comps_instance(int yac_instance_id, char const **comp_names, int num_comps, int *comp_ids)
void yac_cget_comp_names_instance(int yac_instance_id, int nbr_comps, const char **comp_names)
void yac_cinit_comm(MPI_Comm comm)
yac_abort_func yac_get_abort_handler(void)
void yac_set_abort_handler(yac_abort_func custom_abort)