YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
interp_operator_fixed.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#include <string.h>
6
8#include "interp_operator.h"
9#include "utils_core.h"
13
15 struct yac_interp_operator * interp);
17 struct yac_interp_operator * interp);
19 struct yac_interp_operator * interp,
20 double *** src_fields, double *** src_frac_masks, double ** tgt_field,
21 double frac_mask_fallback_value, double scale_factor, double scale_summand);
23 struct yac_interp_operator * interp,
24 double *** src_fields, double *** src_frac_masks,
25 int is_target, double frac_mask_fallback_value,
26 double scale_factor, double scale_summand);
28 struct yac_interp_operator * interp, double ** tgt_field,
29 double frac_mask_fallback_value, double scale_factor, double scale_summand);
31 struct yac_interp_operator * interp, double ** tgt_field,
32 double frac_mask_fallback_value, double scale_factor, double scale_summand);
34 struct yac_interp_operator * interp);
36 struct yac_interp_operator * interp);
38 struct yac_interp_operator * interp);
40 struct yac_interp_operator * interp);
41
55
57
59
61
62 double value;
63 size_t * pos;
64 size_t count;
65
67};
68
70 struct yac_collection_selection const * collection_selection,
71 double value, size_t count, size_t const * pos) {
72
73 struct yac_interp_operator_fixed * fixed = xmalloc(1 * sizeof(*fixed));
74
76 fixed->collection_size =
78 fixed->value = value;
79 fixed->count = count;
80 fixed->pos = COPY_DATA(pos, count);
81 fixed->ref_count = 1;
82
83 return (struct yac_interp_operator *)fixed;
84}
85
87 struct yac_interp_operator * interp) {
88 UNUSED(interp);
89
90 return 0;
91}
92
94 struct yac_interp_operator * interp) {
95 return ((struct yac_interp_operator_fixed*)interp)->count > 0;
96}
97
99 struct yac_interp_operator * interp, double ** tgt_field) {
100 struct yac_interp_operator_fixed * fixed =
101 (struct yac_interp_operator_fixed*)interp;
102
103 double const value = fixed->value;
104 size_t * restrict pos = fixed->pos;
105 size_t const count = fixed->count;
106
107 size_t const collection_size = fixed->collection_size;
108
109 for (size_t l = 0; l < collection_size; ++l) {
110 for (size_t j = 0; j < count; ++j) {
111 tgt_field[l][pos[j]] = value;
112 }
113 }
114}
115
117 struct yac_interp_operator * interp, double ** tgt_field,
118 double frac_mask_fallback_value, double scale_factor, double scale_summand) {
119
120 UNUSED(frac_mask_fallback_value);
121 UNUSED(scale_factor);
122 UNUSED(scale_summand);
123
125}
126
128 struct yac_interp_operator * interp, double ** tgt_field,
129 double frac_mask_fallback_value, double scale_factor, double scale_summand) {
130
132 interp, tgt_field, frac_mask_fallback_value, scale_factor, scale_summand);
133}
134
136 struct yac_interp_operator * interp,
137 double *** src_fields, double *** src_frac_masks, double ** tgt_field,
138 double frac_mask_fallback_value, double scale_factor, double scale_summand) {
139
140 UNUSED(src_fields);
141 UNUSED(src_frac_masks);
142 UNUSED(frac_mask_fallback_value);
143 UNUSED(scale_factor);
144 UNUSED(scale_summand);
145
147}
148
150 struct yac_interp_operator * interp,
151 double *** src_fields, double *** src_frac_masks,
152 int is_target, double frac_mask_fallback_value,
153 double scale_factor, double scale_summand) {
154
155 UNUSED(interp);
156 UNUSED(src_fields);
157 UNUSED(src_frac_masks);
158 UNUSED(is_target);
159 UNUSED(frac_mask_fallback_value);
160 UNUSED(scale_factor);
161 UNUSED(scale_summand);
162 return;
163}
164
170
172 struct yac_interp_operator * interp) {
173 UNUSED(interp);
174 return;
175}
176
178 struct yac_interp_operator * interp) {
179 struct yac_interp_operator_fixed * fixed =
180 (struct yac_interp_operator_fixed*)interp;
181
182 fixed->ref_count++;
183
184 return interp;
185}
186
188 struct yac_interp_operator * interp) {
189 if (interp == NULL) return;
190
191 struct yac_interp_operator_fixed * fixed =
192 (struct yac_interp_operator_fixed*)interp;
193
194 if(--(fixed->ref_count)) return;
195
196 free(fixed->pos);
197 free(fixed);
198}
#define UNUSED(x)
Definition core.h:72
size_t yac_collection_selection_get_collection_size(struct yac_collection_selection const *collection_selection)
Get the size of the collection selection.
struct yac_interp_operator * yac_interp_operator_fixed_new(struct yac_collection_selection const *collection_selection, double value, size_t count, size_t const *pos)
Create a fixed-value interpolation operator.
struct @23::@24 value
Internal structures for interpolation operators (vtable-based).
YAC_INTERP_TEST_STATUS
@ YAC_INTERP_COMPLETE
static enum YAC_INTERP_TEST_STATUS yac_interp_operator_fixed_execute_test(struct yac_interp_operator *interp)
static void yac_interp_operator_fixed_execute_get_(struct yac_interp_operator *interp, double **tgt_field)
static void yac_interp_operator_fixed_execute_get(struct yac_interp_operator *interp, double **tgt_field, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static void yac_interp_operator_fixed_execute_get_async(struct yac_interp_operator *interp, double **tgt_field, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static void yac_interp_operator_fixed_delete(struct yac_interp_operator *interp)
static int yac_interp_operator_fixed_is_target(struct yac_interp_operator *interp)
static void yac_interp_operator_fixed_execute_put(struct yac_interp_operator *interp, double ***src_fields, double ***src_frac_masks, int is_target, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static struct yac_interp_operator * yac_interp_operator_fixed_copy(struct yac_interp_operator *interp)
static void yac_interp_operator_fixed_execute_wait(struct yac_interp_operator *interp)
static struct yac_interp_operator_vtable const interpolation_fixed_vtable
static void yac_interp_operator_fixed_execute(struct yac_interp_operator *interp, double ***src_fields, double ***src_frac_masks, double **tgt_field, double frac_mask_fallback_value, double scale_factor, double scale_summand)
static int yac_interp_operator_fixed_is_source(struct yac_interp_operator *interp)
Fixed-value interpolation operator in YAC.
Utility macros and functions for interpolation operators. This file contains utility macros for targe...
#define xmalloc(size)
Definition ppm_xfuncs.h:66
struct yac_interp_operator_vtable const * vtable
Virtual function table for interpolation operators.
int(* is_source)(struct yac_interp_operator *interp)
Abstract interpolation operator type.
int collection_size
#define COPY_DATA(data, count)
Definition utils_core.h:270