YAC 3.7.0
Yet Another Coupler
Loading...
Searching...
No Matches
interp_method.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifdef HAVE_CONFIG_H
6// Get the definition of the 'restrict' keyword.
7#include "config.h"
8#endif
9
11#include "interp_method_check.h"
13#include "yac_mpi_common.h"
14
16 struct interp_method ** method, struct yac_interp_grid * interp_grid) {
17
19 MPI_Comm interp_grid_comm = yac_interp_grid_get_MPI_Comm(interp_grid);
20 enum yac_location src_field_locations[num_src_fields];
21 for (size_t i = 0; i < num_src_fields; ++i)
22 src_field_locations[i] =
24 struct yac_interp_weights * weights =
26 interp_grid_comm, yac_interp_grid_get_tgt_field_location(interp_grid),
27 src_field_locations, num_src_fields);
28
29 if (*method == NULL) return weights;
30
31 size_t temp_count;
32 size_t * tgt_points;
33 yac_interp_grid_get_tgt_points(interp_grid, &tgt_points, &temp_count);
34
35 size_t final_count = 0;
36 int interpolation_complete = 0;
37 while (*method != NULL) {
38 final_count +=
39 (*method)->vtable->do_search(
40 *method, interp_grid, tgt_points + final_count,
41 temp_count - final_count, weights, &interpolation_complete);
43 MPI_Allreduce(
44 MPI_IN_PLACE, &interpolation_complete, 1, MPI_INT,
45 MPI_MAX, interp_grid_comm), interp_grid_comm);
46 ++method;
47 }
48
49 free(tgt_points);
50
51 return weights;
52}
53
55
56 while (*method != NULL) {
57 struct interp_method * curr_method = *method;
58 curr_method->vtable->delete(curr_method);
59 ++method;
60 }
61}
62
enum yac_location yac_interp_grid_get_tgt_field_location(struct yac_interp_grid *interp_grid)
size_t yac_interp_grid_get_num_src_fields(struct yac_interp_grid *interp_grid)
void yac_interp_grid_get_tgt_points(struct yac_interp_grid *interp_grid, size_t **tgt_indices, size_t *count)
Definition interp_grid.c:99
MPI_Comm yac_interp_grid_get_MPI_Comm(struct yac_interp_grid *interp_grid)
enum yac_location yac_interp_grid_get_src_field_location(struct yac_interp_grid *interp_grid, size_t src_field_idx)
void yac_interp_method_cleanup()
void yac_interp_method_delete(struct interp_method **method)
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
void yac_interp_method_callback_buf_free()
void yac_interp_method_check_buf_free()
struct yac_interp_weights * yac_interp_weights_new(MPI_Comm comm, enum yac_location tgt_location, enum yac_location *src_locations, size_t num_src_fields)
yac_location
Definition location.h:12
void(* delete)(struct interp_method *method)
struct interp_method_vtable * vtable
#define yac_mpi_call(call, comm)