YetAnotherCoupler 3.2.0_a
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
interp_method_spmap.c File Reference
#include "config.h"
#include <float.h>
#include <string.h>
#include "interp_method_internal.h"
#include "interp_method_spmap.h"
#include "ensure_array_size.h"
#include "area.h"
Include dependency graph for interp_method_spmap.c:

Go to the source code of this file.

Data Structures

struct  interp_method_spmap
 

Macros

#define COMPUTE_CELL_AREA(PREFIX, IDX)
 
#define NO_COMPUTE_CELL_AREA(PREFIX, IDX)
 
#define SCALE_WEIGHTS(COMPUTE_SRC_CELL_AREA, COMPUTE_TGT_CELL_AREA, SRC_CELL_AREA, TGT_CELL_AREA)
 

Functions

static size_t do_search_spmap (struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights)
 
static void delete_spmap (struct interp_method *method)
 
static int compare_size_t (const void *a, const void *b)
 
static int lists_overlap (size_t *list_a, size_t count_a, size_t *list_b, size_t count_b)
 
static void merge_lists (size_t *list, size_t *list_size, size_t *insert, size_t insert_size)
 
static void check_spread_distance (yac_const_coordinate_pointer tgt_field_coords, double max_distance, size_t tgt_start_point, size_t *tgt_points, size_t *count)
 
static void remove_disconnected_points (struct yac_interp_grid *interp_grid, size_t tgt_start_point, size_t *from_tgt_points, size_t *to_tgt_points, size_t *count, int *flag, size_t *temp_cell_edges, size_t **edges_buffer, size_t *edges_buffer_array_size)
 
static size_t check_tgt_result_points (struct yac_interp_grid *interp_grid, double spread_distance, size_t num_src_points, size_t const *const tgt_result_points, size_t *num_tgt_per_src, size_t *spread_tgt_result_points)
 
static void check_max_search_distance (struct yac_interp_grid *interp_grid, double max_search_distance, size_t *num_src_points_, size_t *src_points, yac_coordinate_pointer src_coords, size_t *tgt_result_points)
 
static double * compute_weights (struct yac_interp_grid *interp_grid, enum yac_interp_spmap_weight_type weight_type, size_t num_src_points, size_t const *const src_points, size_t const *const num_tgt_per_src, size_t total_num_tgt, size_t const *const spread_tgt_result_points)
 
static void scale_weights (struct yac_interp_grid *interp_grid, enum yac_interp_spmap_scale_type scale_type, double src_area_scale, double tgt_area_scale, size_t num_src_points, size_t const *src_points, size_t const *num_tgt_per_src, size_t const *tgt_points, double *weights)
 
static void spread_src_data (struct yac_interp_grid *interp_grid, double spread_distance, enum yac_interp_spmap_weight_type weight_type, enum yac_interp_spmap_scale_type scale_type, double src_area_scale, double tgt_area_scale, size_t num_src_points, size_t **src_points_, size_t **tgt_result_points_, double **weights_, size_t *total_num_weights_)
 
struct interp_methodyac_interp_method_spmap_new (double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, enum yac_interp_spmap_scale_type scale_type, double src_sphere_radius, double tgt_sphere_radius)
 

Variables

static struct interp_method_vtable interp_method_spmap_vtable
 

Macro Definition Documentation

◆ COMPUTE_CELL_AREA

#define COMPUTE_CELL_AREA (   PREFIX,
  IDX 
)
Value:
PREFIX ## _basic_grid_data, PREFIX ## _points[IDX], &grid_cell); \
double PREFIX ## _cell_area = yac_huiliers_area(grid_cell) * PREFIX ## _area_scale; \
YAC_ASSERT_F( \
PREFIX ## _cell_area > YAC_AREA_TOL, \
"ERROR(scale_weights): " \
"area of %s cell (global id %"XT_INT_FMT") is close to zero (%e)", \
# PREFIX, \
PREFIX ## _basic_grid_data->ids[YAC_LOC_CELL][PREFIX ## _points[IDX]], \
PREFIX ## _cell_area)
double yac_huiliers_area(struct yac_grid_cell cell)
Area calculation on a unit sphere taken from ESMF based on L'Huilier's Theorem.
Definition area.c:396
#define YAC_AREA_TOL
Definition area.h:23
void yac_const_basic_grid_data_get_grid_cell(struct yac_const_basic_grid_data *grid_data, size_t cell_idx, struct yac_grid_cell *buffer_cell)
Definition dist_grid.c:2996
@ YAC_LOC_CELL
Definition location.h:14

◆ NO_COMPUTE_CELL_AREA

#define NO_COMPUTE_CELL_AREA (   PREFIX,
  IDX 
)

◆ SCALE_WEIGHTS

#define SCALE_WEIGHTS (   COMPUTE_SRC_CELL_AREA,
  COMPUTE_TGT_CELL_AREA,
  SRC_CELL_AREA,
  TGT_CELL_AREA 
)
Value:
{ \
for (size_t i = 0, offset = 0; i < num_src_points; ++i) { \
COMPUTE_SRC_CELL_AREA(src, i) \
size_t curr_num_tgt = num_tgt_per_src[i]; \
for (size_t j = 0; j < curr_num_tgt; ++j, ++offset) { \
COMPUTE_TGT_CELL_AREA(tgt, offset) \
weights[offset] *= SRC_CELL_AREA / TGT_CELL_AREA; \
} \
} \
}
Definition __init__.py:1

Function Documentation

◆ check_max_search_distance()

static void check_max_search_distance ( struct yac_interp_grid interp_grid,
double  max_search_distance,
size_t *  num_src_points_,
size_t *  src_points,
yac_coordinate_pointer  src_coords,
size_t *  tgt_result_points 
)
static

Definition at line 240 of file interp_method_spmap.c.

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

◆ check_spread_distance()

static void check_spread_distance ( yac_const_coordinate_pointer  tgt_field_coords,
double  max_distance,
size_t  tgt_start_point,
size_t *  tgt_points,
size_t *  count 
)
static

Definition at line 87 of file interp_method_spmap.c.

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

◆ check_tgt_result_points()

static size_t check_tgt_result_points ( struct yac_interp_grid interp_grid,
double  spread_distance,
size_t  num_src_points,
size_t const *const  tgt_result_points,
size_t *  num_tgt_per_src,
size_t *  spread_tgt_result_points 
)
static

Definition at line 176 of file interp_method_spmap.c.

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

◆ compare_size_t()

static int compare_size_t ( const void *  a,
const void *  b 
)
inlinestatic

Definition at line 41 of file interp_method_spmap.c.

Here is the caller graph for this function:

◆ compute_weights()

static double * compute_weights ( struct yac_interp_grid interp_grid,
enum yac_interp_spmap_weight_type  weight_type,
size_t  num_src_points,
size_t const *const  src_points,
size_t const *const  num_tgt_per_src,
size_t  total_num_tgt,
size_t const *const  spread_tgt_result_points 
)
static

Definition at line 265 of file interp_method_spmap.c.

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

◆ delete_spmap()

static void delete_spmap ( struct interp_method method)
static

Definition at line 670 of file interp_method_spmap.c.

◆ do_search_spmap()

static size_t do_search_spmap ( struct interp_method method,
struct yac_interp_grid interp_grid,
size_t *  tgt_points,
size_t  count,
struct yac_interp_weights weights 
)
static

Definition at line 495 of file interp_method_spmap.c.

Here is the call graph for this function:

◆ lists_overlap()

static int lists_overlap ( size_t *  list_a,
size_t  count_a,
size_t *  list_b,
size_t  count_b 
)
static

Definition at line 48 of file interp_method_spmap.c.

Here is the caller graph for this function:

◆ merge_lists()

static void merge_lists ( size_t *  list,
size_t *  list_size,
size_t *  insert,
size_t  insert_size 
)
static

Definition at line 66 of file interp_method_spmap.c.

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

◆ remove_disconnected_points()

static void remove_disconnected_points ( struct yac_interp_grid interp_grid,
size_t  tgt_start_point,
size_t *  from_tgt_points,
size_t *  to_tgt_points,
size_t *  count,
int *  flag,
size_t *  temp_cell_edges,
size_t **  edges_buffer,
size_t *  edges_buffer_array_size 
)
static

Definition at line 104 of file interp_method_spmap.c.

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

◆ scale_weights()

static void scale_weights ( struct yac_interp_grid interp_grid,
enum yac_interp_spmap_scale_type  scale_type,
double  src_area_scale,
double  tgt_area_scale,
size_t  num_src_points,
size_t const *  src_points,
size_t const *  num_tgt_per_src,
size_t const *  tgt_points,
double *  weights 
)
static

Definition at line 339 of file interp_method_spmap.c.

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

◆ spread_src_data()

static void spread_src_data ( struct yac_interp_grid interp_grid,
double  spread_distance,
enum yac_interp_spmap_weight_type  weight_type,
enum yac_interp_spmap_scale_type  scale_type,
double  src_area_scale,
double  tgt_area_scale,
size_t  num_src_points,
size_t **  src_points_,
size_t **  tgt_result_points_,
double **  weights_,
size_t *  total_num_weights_ 
)
static

Definition at line 412 of file interp_method_spmap.c.

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

◆ yac_interp_method_spmap_new()

struct interp_method * yac_interp_method_spmap_new ( double  spread_distance,
double  max_search_distance,
enum yac_interp_spmap_weight_type  weight_type,
enum yac_interp_spmap_scale_type  scale_type,
double  src_sphere_radius,
double  tgt_sphere_radius 
)

Constructor for a interpolation method of type interp_method_spmap
This method searches for each unmasked source point the closest unmasked target point.
If the maximum search distance is > 0.0, only target points that are within this distance from the source points are being considered. If spread_distance is > 0.0, the method uses the previously found target points as a starting point. Around each starting point, a bounding circle is generated. Afterwards for each starting point all target cells whose bounding circles intersect with the generated one are put into a list. Out of this list all target cells connected directly or indirectly through other cells from this list to the target cell of the starting are selected for the interpolation. Then a weighting method is applied to the selected target cells to generate the weights. Afterwards the weights are scaled.

Parameters
[in]spread_distancespreading distance
[in]max_search_distancemaximum search distance
[in]weight_typeweighting type
[in]scale_typescaling type
[in]src_sphere_radiussphere radius used for source cell area computation
[in]tgt_sphere_radiussphere radius used for target cell area computation
Remarks
the unit for the spread and maximum search distance is Radian
Examples
test_interp_method_spmap_parallel.c.

Definition at line 631 of file interp_method_spmap.c.

Here is the caller graph for this function:

Variable Documentation

◆ interp_method_spmap_vtable

struct interp_method_vtable interp_method_spmap_vtable
static
Initial value:
= {
.do_search = do_search_spmap,
.delete = delete_spmap
}
static void delete_spmap(struct interp_method *method)
static size_t do_search_spmap(struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights)

Definition at line 25 of file interp_method_spmap.c.