23 #if AMREX_SPACEDIM == 3
24 template <
class Level>
29 template <
class Level>
35 template <
class Level>
39 template <
class Level>
43 template <
class Level>
47 template <
class Level>
51 #if AMREX_SPACEDIM == 3
52 template <
class Level>
56 template <
class Level>
60 template <
class Level>
64 template <
class Level>
68 template <
class Level>
72 template <
class Level>
76 template <
class Level>
80 template <
class Level>
88 template <
class Level>
94 template <
class Level>
98 typename Level::umap_t& ,
106 template <
class Level>
109 typename Level::umap_t& map,
116 switch ( this->nPoints_m - 1 ) {
119 this->crseQuadratic_m(iv, map, scale, dir, shift, rfab, riv, mglevel);
122 this->crseLinear_m(iv, map, scale, dir, shift, rfab, riv, mglevel);
126 "Not implemented interpolation");
131 template <
class Level>
134 typename Level::umap_t& map,
140 switch ( this->nPoints_m - 1 ) {
143 this->fineQuadratic_m(iv, map, scale, dir, shift, mglevel);
146 this->fineLinear_m(iv, map, scale, dir, shift, mglevel);
150 "Not implemented interpolation");
155 template <
class Level>
158 typename Level::umap_t& map,
169 map[mglevel->serialize(tmp)] += 2.0 * scale;
173 map[mglevel->serialize(tmp)] -= scale;
177 template <
class Level>
180 typename Level::umap_t& map,
188 map[mglevel->serialize(tmp)] += 2.0 / 3.0 * scale;
192 map[mglevel->serialize(tmp)] -= 0.2 * scale;
196 template <
class Level>
199 typename Level::umap_t& map,
205 #if AMREX_SPACEDIM == 2
206 bool top = (riv[(dir+1)%AMREX_SPACEDIM] % 2 == 1);
210 niv[(dir+1)%AMREX_SPACEDIM ] += 1;
214 miv[(dir+1)%AMREX_SPACEDIM ] -= 1;
219 if ( mglevel->isValid(niv) && rfab(niv) != Level::Refined::YES ) {
221 map[mglevel->serialize(iv)] += fac * lookup2a_ms[top];
222 map[mglevel->serialize(niv)] += fac * lookup1a_ms[top];
224 }
else if ( mglevel->isValid(miv) && rfab(miv) != Level::Refined::YES ) {
226 map[mglevel->serialize(iv)] += fac * lookup2a_ms[top];
227 map[mglevel->serialize(miv)] += fac * lookup1a_ms[top];
230 throw OpalException(
"AmrLagrangeInterpolater::crseLinear_m()",
231 "No valid interpolation scenario found!");
233 #elif AMREX_SPACEDIM == 3
255 lo_t d1 = (dir+1)%AMREX_SPACEDIM;
256 lo_t d2 = (dir+2)%AMREX_SPACEDIM;
262 for (
int i = -1; i < 2; ++i) {
264 for (
int j = -1; j < 2; ++j) {
268 area[bit] = ( mglevel->isValid(tmp) && rfab(tmp) );
278 qpattern_t::const_iterator pit =
std::begin(this->lpattern_ms);
280 while ( pit !=
std::end(this->lpattern_ms) ) {
281 if ( *pit == (area & lbits_t(*pit)).to_ulong() )
290 lo_t top1 = riv[d1] % 2;
293 lo_t top2 = riv[d2] % 2;
299 case this->lpattern_ms[0]:
302 L[0] = lookup1a_ms[top1];
303 L[1] = lookup2a_ms[top1];
307 K[0] = lookup1a_ms[top2];
308 K[1] = lookup2a_ms[top2];
313 case this->lpattern_ms[1]:
316 L[0] = lookup2b_ms[top1];
317 L[1] = lookup1b_ms[top1];
321 K[0] = lookup1a_ms[top2];
322 K[1] = lookup2a_ms[top2];
327 case this->lpattern_ms[2]:
330 L[0] = lookup2b_ms[top1];
331 L[1] = lookup1b_ms[top1];
335 K[0] = lookup2b_ms[top2];
336 K[1] = lookup1b_ms[top2];
341 case this->lpattern_ms[3]:
344 L[0] = lookup1a_ms[top1];
345 L[1] = lookup2a_ms[top1];
349 K[0] = lookup2b_ms[top2];
350 K[1] = lookup1b_ms[top2];
356 throw OpalException(
"AmrLagrangeInterpolater::crseLinear_m()",
357 "No valid interpolation scenario found!");
364 for (
int i =
begin[0]; i <=
end[0]; ++i) {
366 for (
int j =
begin[1]; j <=
end[1]; ++j) {
370 if ( !mglevel->applyBoundary(niv, rfab, map, value) )
371 map[mglevel->serialize(niv)] += value;
380 #error Lagrange interpolation: Only 2D and 3D are supported!
386 template <
class Level>
389 typename Level::umap_t& map,
395 #if AMREX_SPACEDIM == 2
397 bool top = (riv[(dir+1)%AMREX_SPACEDIM] % 2 == 1);
401 niv[(dir+1)%AMREX_SPACEDIM ] += 1;
405 miv[(dir+1)%AMREX_SPACEDIM ] -= 1;
409 n2iv[(dir+1)%AMREX_SPACEDIM ] += 1;
413 m2iv[(dir+1)%AMREX_SPACEDIM ] -= 1;
431 bool rub = rfab(niv);
437 bool rub2 = rfab(n2iv);
440 bool lf2 = rfab(m2iv);
450 map[mglevel->serialize(iv)] += 0.5 * scale;
453 scalar_t value = scale * ((top) ? 1.0 / 12.0 : -0.05);
454 if ( !mglevel->applyBoundary(niv, rfab, map, value) )
455 map[mglevel->serialize(niv)] += value;
458 value = scale * ((top) ? -0.05 : 1.0 / 12.0);
459 if ( !mglevel->applyBoundary(miv, rfab, map, value) )
460 map[mglevel->serialize(miv)] += value;
462 }
else if ( rub && rub2 ) {
467 scalar_t value = scale * ((top) ? 7.0 / 20.0 : 0.75);
468 map[mglevel->serialize(iv)] += value;
471 value = scale * ((top) ? 7.0 / 30.0 : -0.3);
472 if ( !mglevel->applyBoundary(niv, rfab, map, value) )
473 map[mglevel->serialize(niv)] += value;
476 value = scale * ((top) ? -0.05 : 1.0 / 12.0);
477 if ( !mglevel->applyBoundary(n2iv, rfab, map, value) )
478 map[mglevel->serialize(n2iv)] += value;
480 }
else if ( lf && lf2 ) {
485 scalar_t value = scale * ((top) ? 0.75 : 7.0 / 20.0);
486 map[mglevel->serialize(iv)] += value;
489 value = scale * ((top) ? -0.3 : 7.0 / 30);
490 if ( !mglevel->applyBoundary(miv, rfab, map, value) )
491 map[mglevel->serialize(miv)] += value;
494 value = scale * ((top) ? 1.0 / 12.0 : -0.05);
495 if ( !mglevel->applyBoundary(m2iv, rfab, map, value) )
496 map[mglevel->serialize(m2iv)] += value;
502 this->crseLinear_m(iv, map, scale, dir, shift, rfab, riv, mglevel);
505 #elif AMREX_SPACEDIM == 3
533 lo_t d1 = (dir+1)%AMREX_SPACEDIM;
534 lo_t d2 = (dir+2)%AMREX_SPACEDIM;
540 for (
int i = -2; i < 3; ++i) {
542 for (
int j = -2; j < 3; ++j) {
546 area[bit] = ( mglevel->isValid(tmp) && rfab(tmp) );
556 qpattern_t::const_iterator pit =
std::begin(this->qpattern_ms);
558 while ( pit !=
std::end(this->qpattern_ms) ) {
559 if ( *pit == (area & qbits_t(*pit)).to_ulong() )
568 lo_t top1 = riv[d1] % 2;
571 lo_t top2 = riv[d2] % 2;
577 case this->qpattern_ms[0]:
580 L[0] = lookup3_ms[top1];
582 L[2] = lookup3r_ms[top1];
586 K[0] = lookup3_ms[top2];
588 K[2] = lookup3r_ms[top2];
593 case this->qpattern_ms[1]:
596 L[0] = lookup3r_ms[top1];
597 L[1] = lookup4_ms[top1];
598 L[2] = lookup5r_ms[top1];
602 K[0] = lookup3_ms[top2];
604 K[2] = lookup3r_ms[top2];
609 case this->qpattern_ms[2]:
612 L[0] = lookup3_ms[top1];
614 L[2] = lookup3r_ms[top1];
618 K[0] = lookup3r_ms[top2];
619 K[1] = lookup4_ms[top2];
620 K[2] = lookup5r_ms[top2];
625 case this->qpattern_ms[3]:
628 L[0] = lookup5_ms[top1];
629 L[1] = lookup4r_ms[top1];
630 L[2] = lookup3_ms[top1];
634 K[0] = lookup3_ms[top2];
636 K[2] = lookup3r_ms[top2];
641 case this->qpattern_ms[4]:
644 L[0] = lookup3_ms[top1];
646 L[2] = lookup3r_ms[top1];
650 K[0] = lookup5_ms[top2];
651 K[1] = lookup4r_ms[top2];
652 K[2] = lookup3_ms[top2];
657 case this->qpattern_ms[5]:
660 L[0] = lookup3r_ms[top1];
661 L[1] = lookup4_ms[top1];
662 L[2] = lookup5r_ms[top1];
666 K[0] = lookup5_ms[top2];
667 K[1] = lookup4r_ms[top2];
668 K[2] = lookup3_ms[top2];
673 case this->qpattern_ms[6]:
676 L[0] = lookup3r_ms[top1];
677 L[1] = lookup4_ms[top1];
678 L[2] = lookup5r_ms[top1];
682 K[0] = lookup3r_ms[top2];
683 K[1] = lookup4_ms[top2];
684 K[2] = lookup5r_ms[top2];
689 case this->qpattern_ms[7]:
692 L[0] = lookup5_ms[top1];
693 L[1] = lookup4r_ms[top1];
694 L[2] = lookup3_ms[top1];
698 K[0] = lookup3r_ms[top2];
699 K[1] = lookup4_ms[top2];
700 K[2] = lookup5r_ms[top2];
705 case this->qpattern_ms[8]:
708 L[0] = lookup5_ms[top1];
709 L[1] = lookup4r_ms[top1];
710 L[2] = lookup3_ms[top1];
714 K[0] = lookup5_ms[top2];
715 K[1] = lookup4r_ms[top2];
716 K[2] = lookup3_ms[top2];
726 this->crseLinear_m(iv, map, scale, dir, shift, rfab, riv, mglevel);
735 for (
int i =
begin[0]; i <=
end[0]; ++i) {
737 for (
int j =
begin[1]; j <=
end[1]; ++j) {
741 if ( !mglevel->applyBoundary(tmp1, rfab, map, value) )
742 map[mglevel->serialize(tmp1)] += value;
752 #error Lagrange interpolation: Only 2D and 3D are supported!
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
amr::AmrIntVect_t AmrIntVect_t
Level::basefab_t basefab_t
AmrLagrangeInterpolater(Order order)
void fine(const AmrIntVect_t &iv, umap_t &map, const scalar_t &scale, lo_t dir, lo_t shift, Level *mglevel)
void crseLinear_m(const AmrIntVect_t &iv, umap_t &map, const scalar_t &scale, lo_t dir, lo_t shift, const basefab_t &rfab, const AmrIntVect_t &riv, Level *mglevel)
void fineLinear_m(const AmrIntVect_t &iv, umap_t &map, const scalar_t &scale, lo_t dir, lo_t shift, Level *mglevel)
void crseQuadratic_m(const AmrIntVect_t &iv, umap_t &map, const scalar_t &scale, lo_t dir, lo_t shift, const basefab_t &rfab, const AmrIntVect_t &riv, Level *mglevel)
void coarse(const AmrIntVect_t &iv, umap_t &map, const scalar_t &scale, lo_t dir, lo_t shift, const basefab_t &rfab, const AmrIntVect_t &riv, Level *mglevel)
void fineQuadratic_m(const AmrIntVect_t &iv, umap_t &map, const scalar_t &scale, lo_t dir, lo_t shift, Level *mglevel)
void stencil(const AmrIntVect_t &iv, const basefab_t &fab, umap_t &map, const scalar_t &scale, Level *mglevel)
The base class for all OPAL exceptions.