32 return NaN<
decltype(this->src_vec[0])>();
34 double left = this->src_mesh->fullMesh.axis[0]->at(
i0_lo), right = this->src_mesh->fullMesh.axis[0]->at(
i0_hi),
35 bottom = this->src_mesh->fullMesh.axis[1]->at(
i1_lo), top = this->src_mesh->fullMesh.axis[1]->at(
i1_hi);
36 double d0 = right - left,
38 double x0 = (p.c0 - left) /
d0,
39 x1 = (p.c1 - bottom) /
d1;
42 double hl = ( 2.*
x0 - 3.) *
x0*
x0 + 1.,
78 return this->flags.postprocess(this->dst_mesh->at(index),
91 return NaN<
decltype(this->src_vec[0])>();
101 p_lo.c0 = this->src_mesh->fullMesh.axis[0]->at(
i0_lo);
104 if (
i0_hi == this->src_mesh->fullMesh.axis[0]->size()) --
i0_hi;
105 p_hi.c0 = this->src_mesh->fullMesh.axis[0]->at(
i0_hi);
107 if (p.c1 <
p_lo.c1) {
112 p_lo.c1 = this->src_mesh->fullMesh.axis[1]->at(
i1_lo);
115 if (
i1_hi == this->src_mesh->fullMesh.axis[1]->size()) --
i1_hi;
116 p_hi.c1 = this->src_mesh->fullMesh.axis[1]->at(
i1_hi);
126 double hl = ( 2.*
x0 - 3.) *
x0*
x0 + 1.,
135 size_t idx[] = {this->src_mesh->index(
i0_lo,
i1_lo),
149 typename std::remove_const<SrcT>::type
vals[4];
155 typename std::remove_const<SrcT>::type
175 return this->flags.postprocess(this->dst_mesh->at(index),
result);
186 return NaN<
decltype(this->src_vec[0])>();
188 double back = this->src_mesh->fullMesh.axis[0]->at(
i0_lo), front = this->src_mesh->fullMesh.axis[0]->at(
i0_hi),
189 left = this->src_mesh->fullMesh.axis[1]->at(
i1_lo), right = this->src_mesh->fullMesh.axis[1]->at(
i1_hi),
190 bottom = this->src_mesh->fullMesh.axis[2]->at(
i2_lo), top = this->src_mesh->fullMesh.axis[2]->at(
i2_hi);
209 double d0 = front - back,
212 double x0 = (p.c0 - back) /
d0,
213 x1 = (p.c1 - left) /
d1,
214 x2 = (p.c2 - bottom) /
d2;
268 return this->flags.postprocess(this->dst_mesh->at(index),
291 return NaN<
decltype(this->src_vec[0])>();
296 if (p.c0 <
p_lo.c0) {
301 p_lo.c0 = this->src_mesh->fullMesh.axis[0]->at(
i0_lo);
304 if (
i0_hi == this->src_mesh->fullMesh.axis[0]->size()) --
i0_hi;
305 p_hi.c0 = this->src_mesh->fullMesh.axis[0]->at(
i0_hi);
307 if (p.c1 <
p_lo.c1) {
312 p_lo.c1 = this->src_mesh->fullMesh.axis[1]->at(
i1_lo);
315 if (
i1_hi == this->src_mesh->fullMesh.axis[1]->size()) --
i1_hi;
316 p_hi.c1 = this->src_mesh->fullMesh.axis[1]->at(
i1_hi);
318 if (p.c2 <
p_lo.c2) {
323 p_lo.c2 = this->src_mesh->fullMesh.axis[2]->at(
i2_lo);
326 if (
i2_hi == this->src_mesh->fullMesh.axis[2]->size()) --
i2_hi;
327 p_hi.c2 = this->src_mesh->fullMesh.axis[2]->at(
i2_hi);
385 typename std::remove_const<SrcT>::type
vals[8];
395 typename std::remove_const<SrcT>::type
419 return this->flags.postprocess(this->dst_mesh->at(index),
436namespace masked_hyman {
437 template <
typename DataT,
typename IndexF>
438 static void computeDiffs(
DataT*
diffs,
int ax,
const shared_ptr<MeshAxis>& axis,
441 const std::size_t n1 = axis->size() - 1;
443 for (std::size_t i = 1; i != n1; ++i) {
444 const std::size_t idx = index(i);
446 const double da = axis->at(i) - axis->at(i-1),
447 db = axis->at(i+1) - axis->at(i);
448 size_t idxm = index(i-1), idxp = index(i+1);
453 sb = (data[idxp] - data[idx]) /
db;
461 const size_t i0 = index(0),
i1 = index(1), in = index(n1),
in1 = index(n1-1);
468 db0 = axis->at(1) - axis->at(0);
493 dan = axis->at(n1) - axis->at(n1-1);
495 dbn = - axis->at(n1);
523 const shared_ptr<
const MeshD<2>>& dst_mesh,
525 BaseT(src_mesh, src_vec, dst_mesh, flags) {
526 const size_t n0 =
src_mesh->fullMesh.axis[0]->size(), n1 =
src_mesh->fullMesh.axis[1]->size();
528 if (
n0 == 0 || n1 == 0)
529 throw BadMesh(
"interpolate",
"source mesh empty");
532 for (
size_t i1 = 0;
i1 < n1; ++
i1)
533 masked_hyman::computeDiffs<SrcT>(this->
diff0.
data(), 0, src_mesh->fullMesh.axis[0],
src_vec.
data(),
534 [&
src_mesh,
i1](
size_t i0) ->
size_t { return src_mesh->index(i0, i1); },
540 masked_hyman::computeDiffs<SrcT>(this->
diff1.
data(), 1, src_mesh->fullMesh.axis[1],
src_vec.
data(),
541 [&
src_mesh,
i0](
size_t i1) ->
size_t { return src_mesh->index(i0, i1); },
552 const shared_ptr<
const MeshD<3>>& dst_mesh,
554 BaseT(src_mesh, src_vec, dst_mesh, flags) {
555 const size_t n0 =
src_mesh->fullMesh.axis[0]->size(), n1 =
src_mesh->fullMesh.axis[1]->size(), n2 =
src_mesh->fullMesh.axis[2]->size();
557 if (
n0 == 0 || n1 == 0 || n2 == 0)
558 throw BadMesh(
"interpolate",
"source mesh empty");
561 for (
size_t i2 = 0;
i2 < n2; ++
i2) {
562 for (
size_t i1 = 0;
i1 < n1; ++
i1) {
563 masked_hyman::computeDiffs<SrcT>(this->
diff0.
data(), 0, src_mesh->fullMesh.axis[0],
src_vec.
data(),
564 [&
src_mesh,
i2,
i1](
size_t i0) ->
size_t { return src_mesh->index(i0, i1, i2); },
572 for (
size_t i2 = 0;
i2 < n2; ++
i2) {
573 for (
size_t i0 = 0;
i0 <
n0; ++
i0) {
574 masked_hyman::computeDiffs<SrcT>(this->
diff1.
data(), 1, src_mesh->fullMesh.axis[1],
src_vec.
data(),
575 [&
src_mesh,
i2,
i0](
size_t i1) ->
size_t { return src_mesh->index(i0, i1, i2); },
583 for (
size_t i1 = 0;
i1 < n1; ++
i1) {
584 for (
size_t i0 = 0;
i0 <
n0; ++
i0) {
585 masked_hyman::computeDiffs<SrcT>(this->
diff2.
data(), 2, src_mesh->fullMesh.axis[2],
src_vec.
data(),
586 [&
src_mesh,
i1,
i0](
size_t i2) ->
size_t { return src_mesh->index(i0, i1, i2); },