19 void * component_, MPI_Comm comm) {
26 "yac_couple_config_component_get_pack_size",
27 component->
name, comm, 1);
31 void * component_,
void *
buffer,
int buffer_size,
32 int * position, MPI_Comm comm) {
38 "yac_couple_config_component_pack", component->
name,
39 buffer, buffer_size, position, comm, 1);
43 void *
buffer,
int buffer_size,
int * position,
void * component_,
56 void const * a_,
void const * b_) {
60 a->
name != NULL && b->
name != NULL,
"invalid name (NULL is not allowed)");
65 void * a_,
void * b_, MPI_Comm comm) {
80 "component metadata", (
char **)&(a->
metadata), comm);
94 "invalid name (NULL or empty string is not allowed)")
107 (components != NULL) && (
num_components != NULL),
"invalid argument")
110 (
name != NULL) && (
name[0] !=
'\0'),
111 "invalid name (NULL or empty string is not allowed)")
114 if (!strcmp((*components)[i].
name,
name))
return i;
127 for (
size_t i = 0; i < component->
num_fields; ++i) {
133 free((
void*)(component->
name));
134 component->
name = NULL;
162 size_t * old_to_new_idx;
168 couples, num_couples, comp_idx, old_to_new_idx);
170 free(old_to_new_idx);
178 size_t * old_to_new_idx;
179 void * p_components = *components;
184 sizeof((*components)[0]),
186 *components = p_components;
189 for (
size_t couple_idx = 0; couple_idx < num_couples;
192 couples + couple_idx;
195 free(old_to_new_idx);
199 for (
size_t comp_idx = 0; comp_idx < *
num_components; ++comp_idx) {
200 merge_fields(*components, comp_idx, couples, num_couples, comm);
220 "invalid metadata for component \"%s\" (NULL is not allowed)",
224 "metadata for component \"%s\" has already been set (\"%s\" != \"%s\")",
234 YAC_ASSERT(component != NULL,
"invalid argument")
236 return component->
name;
250 size_t grid_idx,
char const * field_name) {
256 field != NULL,
"field \"%s\" not found (component: %s, grid_idx %zu)",
264 size_t grid_idx,
char const * field_name) {
274 size_t grid_idx,
char const * field_name) {
294 size_t grid_idx,
char const * field_name) {
315 char const * field_name,
size_t grid_idx,
331 size_t grid_idx,
char const * field_name) {
338 .frac_mask_fallback_value = 0.0,
339 .collection_size = 0,
347#define CHECK_FIELD_IDX() \
349 field_idx < component->num_fields, \
350 "invalid field_idx %zu (num_fields: %zu)", \
351 field_idx, component->num_fields)
359 component->
fields[field_idx].
name,
"Field name undefined for field idx %zu",
375 size_t const * old_to_new_idx) {
377 for (
size_t field_idx = 0; field_idx < component->
num_fields; ++field_idx) {
389 component->
fields + field_idx;
410 component->
fields + field_idx);
415 size_t grid_idx,
char const * field_name) {
442 char const * field_name,
size_t grid_idx,
451 return (
size_t)(field - component->
fields);
unsigned component_idx[3]
#define YAC_ASSERT(exp, msg)
static void yac_couple_config_component_unpack(void *buffer, int buffer_size, int *position, void *component_, MPI_Comm comm)
static void yac_couple_config_component_merge(void *a_, void *b_, MPI_Comm comm)
char const * yac_couple_config_component_get_field_metadata(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
static void merge_fields(struct yac_couple_config_component *components, size_t comp_idx, struct yac_couple_config_couple *couples, size_t num_couples, MPI_Comm comm)
int yac_couple_config_component_field_is_valid(struct yac_couple_config_component const *component, size_t field_idx)
size_t yac_couple_config_component_update_or_append_field(struct yac_couple_config_component *component, char const *field_name, size_t grid_idx, char const *timestep, size_t collection_size)
static void yac_couple_config_component_free_(void *component)
char const * yac_couple_config_component_get_name(struct yac_couple_config_component const *component)
size_t yac_couple_config_component_append(struct yac_couple_config_component **components, size_t *num_components, char const *name)
#define CHECK_FIELD_IDX()
static void yac_couple_config_component_init(struct yac_couple_config_component *component, char const *name)
char const * yac_couple_config_component_get_field_name(struct yac_couple_config_component const *component, size_t field_idx)
static int yac_couple_config_component_compare(void const *a_, void const *b_)
char const * yac_couple_config_component_get_field_timestep(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
void yac_couple_config_component_update_all_grid_idx(struct yac_couple_config_component *component, size_t const *old_to_new_idx)
double yac_couple_config_component_get_field_frac_mask_fallback_value(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
char const * yac_couple_config_component_get_field_timestep_by_idx(struct yac_couple_config_component const *component, size_t field_idx)
static void yac_couple_config_component_pack(void *component_, void *buffer, int buffer_size, int *position, MPI_Comm comm)
void yac_couple_config_components_merge(struct yac_couple_config_component **components, size_t *num_components, struct yac_couple_config_couple *couples, size_t num_couples, MPI_Comm comm)
struct yac_couple_config_field * yac_couple_config_component_find_field(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
static struct yac_dist_merge_vtable dist_merge_vtable_component
void yac_couple_config_component_set_field_metadata(struct yac_couple_config_component *component, size_t grid_idx, char const *field_name, char const *metadata)
double yac_couple_config_component_get_field_frac_mask_fallback_value_by_idx(struct yac_couple_config_component const *component, size_t field_idx)
void yac_couple_config_set_component_metadata_value(struct yac_couple_config_component *component, char const *metadata)
size_t yac_couple_config_component_get_field_collection_size(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
void yac_couple_config_components_free(struct yac_couple_config_component **components, size_t *num_components)
static size_t yac_couple_config_component_get_pack_size(void *component_, MPI_Comm comm)
size_t yac_couple_config_component_get_field_collection_size_by_idx(struct yac_couple_config_component const *component, size_t field_idx)
static size_t yac_couple_config_component_append_field(struct yac_couple_config_component *component, char const *field_name, size_t grid_idx, char const *timestep, size_t collection_size)
static struct yac_couple_config_field * yac_couple_config_component_get_field(struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
size_t yac_couple_config_component_get_field_grid_idx(struct yac_couple_config_component const *component, size_t field_idx)
static void yac_couple_config_component_free(struct yac_couple_config_component *component)
void yac_couple_config_component_set_field_frac_mask_fallback_value(struct yac_couple_config_component *component, size_t grid_idx, char const *field_name, double value)
void yac_couple_config_couple_update_field_indices(struct yac_couple_config_couple *couples, size_t num_couples, size_t comp_idx, size_t const *old_to_new_idx)
void yac_couple_config_couple_update_component_indices(struct yac_couple_config_couple *couple, size_t const *old_to_new_idx)
void yac_couple_config_set_field_metadata_value(struct yac_couple_config_field *field, char const *metadata)
char const * yac_couple_config_field_get_timestep(struct yac_couple_config_field const *field)
void yac_couple_config_field_set_frac_mask_fallback_value(struct yac_couple_config_field *field, double value)
struct yac_couple_config_field * yac_couple_config_field_find(size_t num_fields, struct yac_couple_config_field *fields, struct yac_couple_config_field const *field)
void yac_couple_config_field_set_timestep(struct yac_couple_config_field *field, char const *timestep)
void yac_couple_config_field_init(struct yac_couple_config_field *field, char const *name, size_t grid_idx, char const *timestep, size_t collection_size)
void yac_couple_config_fields_merge(size_t *num_fields, struct yac_couple_config_field **fields, MPI_Comm comm, size_t **old_to_new_idx)
void yac_couple_config_field_set_collection_size(struct yac_couple_config_field *field, size_t collection_size)
void yac_couple_config_field_free(struct yac_couple_config_field *field)
size_t yac_couple_config_field_get_collection_size(struct yac_couple_config_field const *field)
double yac_couple_config_field_get_frac_mask_fallback_value(struct yac_couple_config_field const *field)
int yac_couple_config_field_has_valid_definition(struct yac_couple_config_field const *field)
char const * yac_couple_config_field_get_metadata(struct yac_couple_config_field const *field)
void yac_couple_config_sync_string(char const *string_name, char **string, MPI_Comm comm)
void yac_dist_merge(size_t *count, void **array, size_t element_size, MPI_Comm comm, struct yac_dist_merge_vtable *vtable, size_t **idx_old_to_new)
#define xrealloc(ptr, size)
struct yac_couple_config_field * fields
size_t(* get_pack_size)(void *element, MPI_Comm comm)
#define YAC_ASSERT_F(exp, format,...)
size_t yac_string_get_pack_size(char const *caller, char const *string, MPI_Comm comm, int allow_null)
Compute number of bytes required to pack a string for MPI transport.
char * yac_string_unpack(void const *buffer, int buffer_size, int *position, MPI_Comm comm)
Unpack a C string from a buffer packed with yac_string_pack.
void yac_string_pack(char const *caller, char const *string, void *buffer, int buffer_size, int *position, MPI_Comm comm, int allow_null)
Pack a C string into a provided buffer using MPI_Pack semantics.