34 "invalid latitude for bounding circle center (%lf) "
35 "(has to be in the range of [-M_PI_2;M_PI_2])",
center_lat);
38 "invalid angle for bounding circle (%lf) "
39 "(has to be in the range of [0;M_PI[)",
inc_angle);
42 xmalloc(1 *
sizeof(*point_select));
62 point_select_copy = NULL;
73 return point_select_copy;
84 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &int_pack_size), comm);
89 size_t pack_size = int_pack_size;
98 MPI_Pack_size(1, MPI_DOUBLE, comm, &dble_pack_size), comm);
99 pack_size += dble_pack_size +
110 void *
buffer,
int buffer_size,
int * position, MPI_Comm comm) {
113 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &int_pack_size), comm);
118 MPI_Pack(&
type, 1, MPI_INT,
buffer, buffer_size, position, comm), comm);
128 buffer, buffer_size, position, comm), comm);
132 buffer, buffer_size, position, comm), comm);
136 buffer, buffer_size, position, comm), comm);
142 void const *
buffer,
int buffer_size,
int * position, MPI_Comm comm) {
147 buffer, buffer_size, position, &
type, 1, MPI_INT, comm), comm);
161 MPI_DOUBLE, comm), comm);
165 MPI_DOUBLE, comm), comm);
169 MPI_DOUBLE, comm), comm);
185 int ret = (type_a > type_b) - (type_a < type_b);
222 int *
flag,
size_t false_count) {
228 for (
size_t i = 0, j = false_count; i < false_count; ++i) {
232 for (;
flag[j]; ++j);
234 double temp_coord[3];
235 memcpy(temp_coord, array_coord[i],
sizeof(temp_coord));
236 memcpy(array_coord[i], array_coord[j],
sizeof(temp_coord));
237 memcpy(array_coord[j], temp_coord,
sizeof(temp_coord));
238 size_t temp_size_t = array_size_t[i];
239 array_size_t[i] = array_size_t[j];
240 array_size_t[j] = temp_size_t;
250 size_t num_points,
size_t * num_selected_points) {
258 *num_selected_points = 0;
268 double sin_inc_angle, cos_inc_angle;
271 &sin_inc_angle, &cos_inc_angle);
274 int * match_flag =
xmalloc(num_points *
sizeof(*match_flag));
277 size_t match_count = 0;
278 for (
size_t i = 0; i < num_points; ++i) {
280 int point_in_bounding_circle =
282 (
double*)(point_coords[i]), &bnd_circle);
283 match_flag[i] = point_in_bounding_circle;
284 if (point_in_bounding_circle) ++match_count;
289 point_indices, point_coords, match_flag, num_points - match_count);
292 *num_selected_points = match_count;
307 double * center_lon,
double * center_lat,
double *
inc_angle) {
333 CENTER_LON_HAS_DEFAULT = 0,
334 CENTER_LAT_HAS_DEFAULT = 0,
335 INC_ANGLE_HAS_DEFAULT = 0,
337 int const is_defined = point_selection != NULL;
338 double const center_lon_min = - 4.0 * M_PI;
339 double const center_lon_max = 4.0 * M_PI;
340 double const center_lat_min = -M_PI_2;
341 double const center_lat_max = M_PI_2;
342 double const inc_angle_min = 0.0;
343 double const inc_angle_max = M_PI - 0.00000001;
348 center_lon_min, center_lon_min, center_lon_max,
349 CENTER_LON_HAS_DEFAULT, is_defined);
353 center_lat_min, center_lat_min, center_lat_max,
354 CENTER_LAT_HAS_DEFAULT, is_defined);
356 struct yac_param * center_sub_params[] = {
362 "center", center_sub_params,
363 sizeof(center_sub_params) /
sizeof(center_sub_params[0]));
368 inc_angle_min, inc_angle_min, inc_angle_max,
369 INC_ANGLE_HAS_DEFAULT, is_defined);
371 struct yac_param * bnd_circle_sub_params[] = {
377 "bounding_circle", bnd_circle_sub_params,
378 sizeof(bnd_circle_sub_params) /
sizeof(bnd_circle_sub_params[0]));
386 char const *
name,
void ** obj,
387 struct yac_param ** param,
int * is_default) {
400 (*point_selection_ptr == NULL),
"point_selection pointer is not NULL");
413 type != INT_MAX,
"invalid point selection type \"%s\"",
name);
421 double const center_lon_default = 0.0;
422 double const center_lat_default = 0.0;
423 double const inc_angle_default = 0.0;
427 center_lon_default, center_lat_default, inc_angle_default);
433 *point_selection_ptr = point_selection;
443 YAC_ASSERT(param_name != NULL,
"param_name is NULL");
444 YAC_ASSERT(param_name[0] !=
'\0',
"param_name is empty");
445 YAC_ASSERT(point_selection,
"point_selection is NULL");
451 (*point_selection == NULL));
#define YAC_ASSERT(exp, msg)
static void compute_sin_cos(double angle, double *sin_value, double *cos_value)
static int yac_point_in_bounding_circle_vec(double point_vector[3], struct bounding_circle *bnd_circle)
static struct sin_cos_angle sin_cos_angle_new(double sin, double cos)
int yac_name_type_pair_get_type(struct yac_name_type_pair const *pairs, size_t count, char const *name)
#define DEF_NAME_TYPE_PAIR(NAME, TYPE)
#define DEF_NAME_TYPE_PAIRS(NAME,...)
struct yac_param * yac_param_angle_new(const char *name, double *value_ptr, double default_value, double value_min, double value_max, int has_default, int is_defined)
Create an angle parameter (stored in radians)
struct yac_param * yac_param_distance_new(const char *name, double *value_ptr, double default_value, double value_min, double value_max, int has_default, int is_defined)
Create a distance parameter (stored in radians)
#define YAC_PARAM_ASSERT(COND,...)
struct yac_param * yac_param_oneof_new(const char *name, yac_param_oneof_factory_ptr default_factory, void **value_ptr, struct yac_param *subparam, int subparam_is_default)
Create a new one-of struct parameter with a given name and a default_factory.
struct yac_param * yac_param_struct_new(const char *name, struct yac_param **subparams, size_t subparam_count)
Create a new struct parameter with a given name and subparameters.
struct yac_param * yac_point_selection_get_param(char const *param_name, struct yac_point_selection **point_selection)
int yac_point_selection_compare(struct yac_point_selection const *a, struct yac_point_selection const *b)
struct yac_point_selection * yac_point_selection_bnd_circle_new(double center_lon, double center_lat, double inc_angle)
struct yac_point_selection * yac_point_selection_unpack(void const *buffer, int buffer_size, int *position, MPI_Comm comm)
static int point_selection_get_param_factory(char const *name, void **obj, struct yac_param **param, int *is_default)
struct yac_point_selection * yac_point_selection_copy(struct yac_point_selection const *point_select)
void yac_point_selection_apply(struct yac_point_selection const *point_select, yac_coordinate_pointer point_coords, size_t *point_indices, size_t num_points, size_t *num_selected_points)
void yac_point_selection_pack(struct yac_point_selection const *point_select, void *buffer, int buffer_size, int *position, MPI_Comm comm)
size_t yac_point_selection_get_pack_size(struct yac_point_selection const *point_select, MPI_Comm comm)
static struct yac_param * point_selection_build_param(struct yac_point_selection *point_selection)
void yac_point_selection_delete(struct yac_point_selection *point_select)
void yac_point_selection_bnd_circle_get_config(struct yac_point_selection const *point_selection, double *center_lon, double *center_lat, double *inc_angle)
enum yac_point_selection_type yac_point_selection_get_type(struct yac_point_selection const *point_select)
static void flag_sort(size_t *array_size_t, yac_coordinate_pointer array_coord, int *flag, size_t false_count)
@ YAC_POINT_SELECTION_TYPE_BND_CIRCLE
@ YAC_POINT_SELECTION_TYPE_EMPTY
struct sin_cos_angle inc_angle
angle between the middle point and the boundary of the spherical cap
enum yac_point_selection_type type
struct yac_point_selection::@50::@51 bnd_circle
union yac_point_selection::@50 data
static void LLtoXYZ(double lon, double lat, double p_out[])
#define YAC_ASSERT_F(exp, format,...)
#define YAC_UNREACHABLE_DEFAULT(msg)
#define yac_mpi_call(call, comm)
double(* yac_coordinate_pointer)[3]