YAC 3.18.0
Yet Another Coupler
Loading...
Searching...
No Matches
interp_method_config_internal.h
Go to the documentation of this file.
1// Copyright (c) 2026 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef INTERP_METHOD_CONFIG_INTERNAL_H
6#define INTERP_METHOD_CONFIG_INTERNAL_H
7
8#include <mpi.h>
10
12struct interp_method;
13
23 void (*delete)(struct yac_interp_method_config *config);
24
30 struct yac_interp_method_config *(*copy)
31 (struct yac_interp_method_config const *config);
32
39 int (*compare)(void const *a, void const *b);
40
47 size_t (*get_pack_size)(
48 struct yac_interp_method_config const *config, MPI_Comm comm);
49
58 void (*pack)(
59 struct yac_interp_method_config const *config,
60 void *buffer, int buffer_size, int *position, MPI_Comm comm);
61
67 enum yac_interpolation_list (*get_type)(void);
68
74 struct yac_param *(*get_param)
75 (struct yac_interp_method_config const *config);
76
82 struct interp_method *(*generate)(struct yac_interp_method_config const *config);
83};
84
88
89// Comparison helper macros
90#define CHECK_BASIC(FIELD) \
91 if ((a->FIELD) != (b->FIELD)) \
92 return ((a->FIELD) > (b->FIELD)) - ((a->FIELD) < (b->FIELD))
93
94#define CHECK_INT CHECK_BASIC
95#define CHECK_SIZE_T CHECK_BASIC
96#define CHECK_DOUBLE CHECK_BASIC
97#define CHECK_ENUM CHECK_BASIC
98
99#define CHECK_ANGLE(FIELD) \
100 if (fabs((a->FIELD) - (b->FIELD)) > yac_angle_tol) \
101 return ((a->FIELD) > (b->FIELD)) - ((a->FIELD) < (b->FIELD))
102
103#define RETURN_ON_DIFFERENT(expr) \
104 do { int ret; if ((ret = (expr))) return ret; } while(0)
105
106// Use memcmp for correct handling of NaNs in fixed values
107#define CHECK_DOUBLE_NAN(FIELD) \
108 RETURN_ON_DIFFERENT(memcmp(&(a->FIELD), &(b->FIELD), sizeof(a->FIELD)))
109
110#define CHECK_STRUCT(PTR_FIELD, CMP_ROUTINE) \
111 RETURN_ON_DIFFERENT(CMP_ROUTINE(a->PTR_FIELD, b->PTR_FIELD))
112
113#define CHECK_NULL_POINTER(FIELD) \
114 RETURN_ON_DIFFERENT((a->FIELD == NULL) - (b->FIELD == NULL))
115
116#define CHECK_STRING(FIELD) \
117 do { \
118 CHECK_NULL_POINTER(FIELD); \
119 if (a->FIELD != NULL) RETURN_ON_DIFFERENT(strcmp(a->FIELD, b->FIELD)); \
120 } while(0)
121
122#define DEF_INTERP_METHOD_CONFIG_TYPE(TYPE) \
123 const struct yac_interp_method_config_ ## TYPE *config_ ## TYPE = \
124 (const struct yac_interp_method_config_ ## TYPE *)config;
125
126#define DEF_INTERP_METHOD_CONFIG_COMPARE_TYPE(TYPE) \
127 const struct yac_interp_method_config_ ## TYPE *a = \
128 (const struct yac_interp_method_config_ ## TYPE *)a_; \
129 const struct yac_interp_method_config_ ## TYPE *b = \
130 (const struct yac_interp_method_config_ ## TYPE *)b_;
131
132#endif // INTERP_METHOD_CONFIG_INTERNAL_H
yac_interpolation_list
void(* pack)(struct yac_interp_method_config const *config, void *buffer, int buffer_size, int *position, MPI_Comm comm)
int(* compare)(void const *a, void const *b)
enum yac_interpolation_list(* get_type)(void)
size_t(* get_pack_size)(struct yac_interp_method_config const *config, MPI_Comm comm)
struct yac_interp_method_config_vtable const * vtable
static struct yac_interp_method_config * config
double * buffer