YAC 3.18.0
Yet Another Coupler
Loading...
Searching...
No Matches
couple_config_component.c File Reference
#include <stdint.h>
#include <string.h>
#include "couple_config_internal.h"
#include "couple_config_component.h"
#include "couple_config_couple.h"
#include "couple_config_field.h"
#include "yac_mpi_common.h"
#include "yac_mpi_internal.h"
#include "dist_merge.h"
#include "utils_core.h"
Include dependency graph for couple_config_component.c:

Go to the source code of this file.

Macros

#define CHECK_FIELD_IDX(COMPONENT, FIELD_IDX, ROUTINE)
 

Functions

static size_t yac_couple_config_component_get_pack_size (void *component_, MPI_Comm comm)
 
static void yac_couple_config_component_pack (void *component_, void *buffer, int buffer_size, int *position, MPI_Comm comm)
 
static void yac_couple_config_component_unpack (void *buffer, int buffer_size, int *position, void *component_, MPI_Comm comm)
 
static int yac_couple_config_component_compare (void const *a_, void const *b_)
 
static void yac_couple_config_component_merge (void *a_, void *b_, MPI_Comm comm)
 
static void yac_couple_config_component_init (struct yac_couple_config_component *component, char const *name)
 
size_t yac_couple_config_component_append (struct yac_couple_config_component **components, size_t *num_components, char const *name)
 
static void yac_couple_config_component_free (struct yac_couple_config_component *component)
 
static void yac_couple_config_component_free_ (void *component)
 
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)
 
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)
 
void yac_couple_config_components_free (struct yac_couple_config_component **components, size_t *num_components)
 
void yac_couple_config_set_component_metadata_value (struct yac_couple_config_component *component, char const *metadata)
 
char const * yac_couple_config_component_get_name (struct yac_couple_config_component const *component)
 
static struct yac_couple_config_fieldyac_couple_config_component_get_field (struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
 
char const * yac_couple_config_component_get_field_metadata (struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
 
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)
 
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)
 
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)
 
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)
 
struct yac_couple_config_fieldyac_couple_config_component_find_field (struct yac_couple_config_component const *component, size_t grid_idx, char const *field_name)
 
char const * yac_couple_config_component_get_field_name (struct yac_couple_config_component const *component, size_t field_idx)
 
size_t yac_couple_config_component_get_field_grid_idx (struct yac_couple_config_component const *component, size_t field_idx)
 
void yac_couple_config_component_update_all_grid_idx (struct yac_couple_config_component *component, size_t const *old_to_new_idx)
 
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_get_field_collection_size_by_idx (struct yac_couple_config_component const *component, size_t field_idx)
 
double yac_couple_config_component_get_field_frac_mask_fallback_value_by_idx (struct yac_couple_config_component const *component, size_t field_idx)
 
char const * yac_couple_config_component_get_field_timestep (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)
 
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)
 
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)
 

Variables

static struct yac_dist_merge_vtable dist_merge_vtable_component
 

Macro Definition Documentation

◆ CHECK_FIELD_IDX

#define CHECK_FIELD_IDX ( COMPONENT,
FIELD_IDX,
ROUTINE )
Value:
(FIELD_IDX) < (COMPONENT)->num_fields, \
"ERROR(%s:%d:%s): invalid field_idx", \
__FILE__, __LINE__, (ROUTINE))
unsigned num_fields
#define YAC_ASSERT_F(exp, format,...)
Definition yac_assert.h:30

Definition at line 360 of file couple_config_component.c.

Function Documentation

◆ merge_fields()

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 )
static

Definition at line 158 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_append()

size_t yac_couple_config_component_append ( struct yac_couple_config_component ** components,
size_t * num_components,
char const * name )

Append a component with the given name to the array, or return the index of an existing component with the same name (deduplication).

Parameters
[in,out]componentsComponent array pointer.
[in,out]num_componentsArray length.
[in]nameComponent name.
Returns
Index of the (new or existing) component.

Definition at line 104 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_append_field()

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

Append a new field to a component.

Parameters
[in,out]componentComponent to append to.
[in]field_nameField name.
[in]grid_idxGrid index.
[in]timestepTimestep string.
[in]collection_sizeCollection size.
Returns
Index of the appended field.

Definition at line 326 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_compare()

static int yac_couple_config_component_compare ( void const * a_,
void const * b_ )
static

Definition at line 55 of file couple_config_component.c.

◆ yac_couple_config_component_field_is_valid()

int yac_couple_config_component_field_is_valid ( struct yac_couple_config_component const * component,
size_t field_idx )

Check whether a field identified by index is fully defined (has a timestep and a collection size).

Parameters
[in]componentComponent.
[in]field_idxField index.
Returns
Non-zero if the field is valid.

Definition at line 394 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_find_field()

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 )

Search for a field by grid index and name within a component.

Parameters
[in]componentComponent to search in.
[in]grid_idxGrid index of the field.
[in]field_nameName of the field.
Returns
Pointer to the matching field, or NULL if not found.

Definition at line 342 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_free()

static void yac_couple_config_component_free ( struct yac_couple_config_component * component)
static

Definition at line 128 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_free_()

static void yac_couple_config_component_free_ ( void * component)
static

Definition at line 143 of file couple_config_component.c.

Here is the call graph for this function:

◆ yac_couple_config_component_get_field()

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 )
static

Return the field identified by grid index and field name.

Parameters
[in]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
Returns
Pointer to the matching field.

Definition at line 257 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_collection_size()

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 )

Return the collection size of a field.

Parameters
[in]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
Returns
Collection size.

Definition at line 305 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_collection_size_by_idx()

size_t yac_couple_config_component_get_field_collection_size_by_idx ( struct yac_couple_config_component const * component,
size_t field_idx )

Return the collection size of a field identified by index.

Parameters
[in]componentComponent.
[in]field_idxField index.
Returns
Collection size.

Definition at line 406 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_frac_mask_fallback_value()

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 )

Return the fractional mask fallback value of a field.

Parameters
[in]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
Returns
Fractional mask fallback value.

Definition at line 285 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_frac_mask_fallback_value_by_idx()

double yac_couple_config_component_get_field_frac_mask_fallback_value_by_idx ( struct yac_couple_config_component const * component,
size_t field_idx )

Return the fractional mask fallback value of a field identified by index.

Parameters
[in]componentComponent.
[in]field_idxField index.
Returns
Fractional mask fallback value.

Definition at line 417 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_grid_idx()

size_t yac_couple_config_component_get_field_grid_idx ( struct yac_couple_config_component const * component,
size_t field_idx )

Return the grid index of a field identified by index.

Parameters
[in]componentComponent.
[in]field_idxField index.
Returns
Grid index.

Definition at line 375 of file couple_config_component.c.

Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_metadata()

char const * yac_couple_config_component_get_field_metadata ( struct yac_couple_config_component const * component,
size_t grid_idx,
char const * field_name )

Return the metadata for a field identified by grid index and field name.

Parameters
[in]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
Returns
Field metadata string, or NULL if metadata is not set.

Definition at line 275 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_name()

char const * yac_couple_config_component_get_field_name ( struct yac_couple_config_component const * component,
size_t field_idx )

Return the name of a field identified by index.

Parameters
[in]componentComponent.
[in]field_idxField index.
Returns
Field name.

Definition at line 366 of file couple_config_component.c.

Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_timestep()

char const * yac_couple_config_component_get_field_timestep ( struct yac_couple_config_component const * component,
size_t grid_idx,
char const * field_name )

Return the timestep of a field identified by grid index and field name.

Parameters
[in]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
Returns
Timestep string, or NULL if not yet set.

Definition at line 430 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_field_timestep_by_idx()

char const * yac_couple_config_component_get_field_timestep_by_idx ( struct yac_couple_config_component const * component,
size_t field_idx )

Return the timestep of a field identified by index.

Parameters
[in]componentComponent.
[in]field_idxField index.
Returns
Timestep string, or NULL if not yet set.

Definition at line 439 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_get_name()

char const * yac_couple_config_component_get_name ( struct yac_couple_config_component const * component)

Return the name of a component.

Parameters
[in]componentComponent.
Returns
Component name.

Definition at line 238 of file couple_config_component.c.

Here is the caller graph for this function:

◆ yac_couple_config_component_get_pack_size()

static size_t yac_couple_config_component_get_pack_size ( void * component_,
MPI_Comm comm )
static

Definition at line 18 of file couple_config_component.c.

Here is the call graph for this function:

◆ yac_couple_config_component_init()

static void yac_couple_config_component_init ( struct yac_couple_config_component * component,
char const * name )
static

Initialise a component with the given name and zero fields.

Parameters
[in,out]componentComponent to initialise.
[in]nameComponent name (will be duplicated).

Definition at line 90 of file couple_config_component.c.

Here is the caller graph for this function:

◆ yac_couple_config_component_merge()

static void yac_couple_config_component_merge ( void * a_,
void * b_,
MPI_Comm comm )
static

Definition at line 65 of file couple_config_component.c.

Here is the call graph for this function:

◆ yac_couple_config_component_pack()

static void yac_couple_config_component_pack ( void * component_,
void * buffer,
int buffer_size,
int * position,
MPI_Comm comm )
static

Definition at line 30 of file couple_config_component.c.

Here is the call graph for this function:

◆ yac_couple_config_component_set_field_frac_mask_fallback_value()

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 )

Set the fractional mask fallback value of a field.

Parameters
[in,out]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
[in]valueFractional mask fallback value to set.

Definition at line 295 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_set_field_metadata()

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 )

Set the metadata of a field identified by grid index and field name.

Parameters
[in,out]componentComponent.
[in]grid_idxGrid index.
[in]field_nameField name.
[in]metadataMetadata string (NULL clears it).

Definition at line 449 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_component_unpack()

static void yac_couple_config_component_unpack ( void * buffer,
int buffer_size,
int * position,
void * component_,
MPI_Comm comm )
static

Definition at line 42 of file couple_config_component.c.

Here is the call graph for this function:

◆ yac_couple_config_component_update_all_grid_idx()

void yac_couple_config_component_update_all_grid_idx ( struct yac_couple_config_component * component,
size_t const * old_to_new_idx )

Update all fields' grid indices using an old-to-new grid index mapping.

Parameters
[in,out]componentComponent.
[in]old_to_new_idxMapping from old to new grid indices.

Definition at line 384 of file couple_config_component.c.

Here is the caller graph for this function:

◆ yac_couple_config_component_update_or_append_field()

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 )

Update an existing field's timestep and collection size, or append it if it does not yet exist.

Parameters
[in,out]componentComponent.
[in]field_nameField name.
[in]grid_idxGrid index.
[in]timestepTimestep string.
[in]collection_sizeCollection size.
Returns
Index of the updated or appended field.

Definition at line 459 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_components_free()

void yac_couple_config_components_free ( struct yac_couple_config_component ** components,
size_t * num_components )

Free all components and their dynamic data from a coupling configuration.

Parameters
[in,out]componentsComponent array.
[in,out]num_componentsNumber of components.

Definition at line 208 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_components_merge()

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 )

Synchronize and merge all components (including their fields) across ranks in the provided communicator.

Parameters
[in,out]componentsComponent array.
[in,out]num_componentsNumber of components.
[in,out]couplesCouple array.
[in]num_couplesNumber of couples.
[in]commMPI communicator.

Definition at line 177 of file couple_config_component.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yac_couple_config_set_component_metadata_value()

void yac_couple_config_set_component_metadata_value ( struct yac_couple_config_component * component,
char const * metadata )

Set the metadata of a component.

Parameters
[in,out]componentComponent.
[in]metadataMetadata string (NULL is not allowed).

Definition at line 219 of file couple_config_component.c.

Here is the caller graph for this function:

Variable Documentation

◆ dist_merge_vtable_component

struct yac_dist_merge_vtable dist_merge_vtable_component
static
Initial value:
=
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)
static void yac_couple_config_component_free_(void *component)
static int yac_couple_config_component_compare(void const *a_, void const *b_)
static void yac_couple_config_component_pack(void *component_, void *buffer, int buffer_size, int *position, MPI_Comm comm)
static size_t yac_couple_config_component_get_pack_size(void *component_, MPI_Comm comm)

Definition at line 150 of file couple_config_component.c.