67 bool increasing =
true;
69 interp_wgts.jjm = int1d(
"jjm", nout);
70 interp_wgts.jjp = int1d(
"jjp", nout);
71 interp_wgts.wgts = real1d(
"wgts", nout);
72 interp_wgts.wgtn = real1d(
"wgtn", nout);
74 parallel_for(SimpleBounds<1>(n_in-1), YAKL_LAMBDA (
int j)
76 if(yin(j) > yin(j+1)) {
77 printf(
"init: inputs are not monotonic!\n");
85 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
87 interp_wgts.jjm(j) = 0;
88 interp_wgts.jjp(j) = 0;
91 switch (extrap_method) {
98 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
100 if (yout(j) < yin(1)) {
101 interp_wgts.jjm(j) = 1;
102 interp_wgts.jjp(j) = 1;
103 interp_wgts.wgts(j) = 0.;
104 interp_wgts.wgtn(j) = 0.;
106 else if (yout(j) > yin(n_in)) {
107 interp_wgts.jjm(j) = n_in;
108 interp_wgts.jjp(j) = n_in;
109 interp_wgts.wgts(j) = 0.;
110 interp_wgts.wgtn(j) = 0.;
115 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
117 if (yout(j) > yin(1)) {
118 interp_wgts.jjm(j) = 1;
119 interp_wgts.jjp(j) = 1;
120 interp_wgts.wgts(j) = 0.;
121 interp_wgts.wgtn(j) = 0.;
123 else if (yout(j) < yin(n_in)) {
124 interp_wgts.jjm(j) = n_in;
125 interp_wgts.jjp(j) = n_in;
126 interp_wgts.wgts(j) = 0.;
127 interp_wgts.wgtn(j) = 0.;
138 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
140 if (yout(j) <= yin(1)) {
141 interp_wgts.jjm(j) = 1;
142 interp_wgts.jjp(j) = 1;
143 interp_wgts.wgts(j) = 1.;
144 interp_wgts.wgtn(j) = 0.;
146 else if (yout(j) > yin(n_in)) {
147 interp_wgts.jjm(j) = n_in;
148 interp_wgts.jjp(j) = n_in;
149 interp_wgts.wgts(j) = 1.;
150 interp_wgts.wgtn(j) = 0.;
155 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
157 if (yout(j) > yin(1)) {
158 interp_wgts.jjm(j) = 1;
159 interp_wgts.jjp(j) = 1;
160 interp_wgts.wgts(j) = 1.;
161 interp_wgts.wgtn(j) = 0.;
163 else if (yout(j) <= yin(n_in)) {
164 interp_wgts.jjm(j) = n_in;
165 interp_wgts.jjp(j) = n_in;
166 interp_wgts.wgts(j) = 1.;
167 interp_wgts.wgtn(j) = 0.;
177 dyinwrap = yin(1) + (cmax-cmin) - yin(n_in);
178 avgdyin = abs(yin(n_in)-yin(1))/(n_in-1.);
179 auto ratio = dyinwrap/avgdyin;
180 if (ratio < 0.9 || ratio > 1.1) {
181 printf(
"ratio is too large, dyinwrap= %13.6e, avgdyin= %13.6e, yin(1) = %13.6e, yin(n_in)= %13.6e\n",
182 dyinwrap, avgdyin, yin(1), yin(n_in));
186 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
188 if (yout(j) <= yin(1)) {
189 interp_wgts.jjm(j) = n_in;
190 interp_wgts.jjp(j) = 1;
191 interp_wgts.wgts(j) = (yin(1)-yout(j))/dyinwrap;
192 interp_wgts.wgtn(j) = (yout(j)+(cmax-cmin) - yin(n_in))/dyinwrap;
194 else if (yout(j) > yin(n_in)) {
195 interp_wgts.jjm(j) = n_in;
196 interp_wgts.jjp(j) = 1;
197 interp_wgts.wgts(j) = (yin(1)+(cmax-cmin)-yout(j))/dyinwrap;
198 interp_wgts.wgtn(j) = (yout(j)-yin(n_in))/dyinwrap;
203 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
205 if (yout(j) > yin(1)) {
206 interp_wgts.jjm(j) = n_in;
207 interp_wgts.jjp(j) = 1;
208 interp_wgts.wgts(j) = (yin(1)-yout(j))/dyinwrap;
209 interp_wgts.wgtn(j) = (yout(j)+(cmax-cmin) - yin(n_in))/dyinwrap;
211 else if (yout(j) <= yin(n_in)) {
212 interp_wgts.jjm(j) = n_in;
213 interp_wgts.jjp(j) = 1;
214 interp_wgts.wgts(j) = (yin(1)+(cmax-cmin)-yout(j))/dyinwrap;
215 interp_wgts.wgtn(j) = (yout(j)+(cmax-cmin)-yin(n_in))/dyinwrap;
225 parallel_for(SimpleBounds<2>(nout, n_in-1), YAKL_LAMBDA (
int j,
int jj)
227 if (yout(j) > yin(jj) && yout(j) <= yin(jj+1)) {
228 interp_wgts.jjm(j) = jj;
229 interp_wgts.jjp(j) = jj + 1;
230 interp_wgts.wgts(j) = (yin(jj+1)-yout(j))/(yin(jj+1)-yin(jj));
231 interp_wgts.wgtn(j) = (yout(j)-yin(jj))/(yin(jj+1)-yin(jj));
237 parallel_for(SimpleBounds<2>(nout, n_in-1), YAKL_LAMBDA (
int j,
int jj)
239 if (yout(j) <= yin(jj) && yout(j) > yin(jj+1)) {
240 interp_wgts.jjm(j) = jj;
241 interp_wgts.jjp(j) = jj + 1;
242 interp_wgts.wgts(j) = (yin(jj+1)-yout(j))/(yin(jj+1)-yin(jj));
243 interp_wgts.wgtn(j) = (yout(j)-yin(jj))/(yin(jj+1)-yin(jj));
252 parallel_for(SimpleBounds<1>(nout), YAKL_LAMBDA (
int j)
255 amrex::ignore_unused(count);
256 if (interp_wgts.jjm(j) == 0 || interp_wgts.jjp(j) == 0) count += 1;
257 auto frac = interp_wgts.wgts(j) + interp_wgts.wgtn(j);
258 if ((frac < 0.9 || frac > 1.1) && extrap_method != 0)
259 printf(
"interpolation error!\n");