Alamo
NodeBilinear.H
Go to the documentation of this file.
1//
2// Provide an interpolator function that can work with templated fields.
3//
4// :bdg-danger-line:`Warning: This is a low-level class used to add templating functionality to unerlying AMReX classes. Edit at your own risk!`
5//
6//
7
8
9#ifndef NUMERIC_INTERPOLATOR_NODEBILINEAR_H
10#define NUMERIC_INTERPOLATOR_NODEBILINEAR_H
11
12#include <AMReX_Box.H>
13#include <AMReX_BCRec.H>
14#include <AMReX_REAL.H>
15#include <AMReX_GpuControl.H>
16#include <AMReX_Interp_C.H>
17#include <AMReX_Interpolater.H>
18
19namespace Numeric
20{
21namespace Interpolator
22{
23
24template <class T>
25class NodeBilinear: public amrex::NodeBilinear
26{
27public:
28 void interp(const amrex::BaseFab<T>& crse,
29 int crse_comp,
30 amrex::BaseFab<T>& fine,
31 int fine_comp,
32 int ncomp,
33 const amrex::Box& fine_region,
34 const amrex::IntVect& ratio,
35 const amrex::Geometry& /*crse_geom */,
36 const amrex::Geometry& /*fine_geom */,
37 amrex::Vector<amrex::BCRec> const& /*bcr*/,
38 int /*actual_comp*/,
39 int /*actual_state*/,
40 amrex::RunOn runon)
41 {
42 // bool run_on_gpu = (runon == amrex::RunOn::Gpu && amrex::Gpu::inLaunchRegion());
43
44 int num_slope = ncomp * (AMREX_D_TERM(2, *2, *2) - 1);
45 const amrex::Box cslope_bx = amrex::enclosedCells(CoarseBox(fine_region, ratio));
46 amrex::BaseFab<T> slopefab(cslope_bx, num_slope);
47 // amrex::Elixir slopeeli;
48 // if (run_on_gpu) slopeeli = slopefab.elixir();
49
50 amrex::Array4<T const> const& crsearr = crse.const_array();
51 amrex::Array4<T> const& finearr = fine.array();
52 amrex::Array4<T> const& slopearr = slopefab.array();
53
54 AMREX_LAUNCH_HOST_DEVICE_LAMBDA_FLAG(runon, cslope_bx, tbx,
55 {
56 amrex::nodebilin_slopes<T>(tbx, slopearr, crsearr, crse_comp, ncomp, ratio);
57 });
58
59 AMREX_LAUNCH_HOST_DEVICE_LAMBDA_FLAG(runon, fine_region, tbx,
60 {
61 amrex::nodebilin_interp<T>(tbx, finearr, fine_comp, ncomp, slopearr, crsearr, crse_comp, ratio);
62 });
63 }
64 virtual void interp_face(const amrex::BaseFab<T>& /*crse*/,
65 const int /*crse_comp*/,
66 amrex::BaseFab<T>& /*fine*/,
67 const int /*fine_comp*/,
68 const int /*ncomp*/,
69 const amrex::Box& /*fine_region*/,
70 const amrex::IntVect& /*ratio*/,
71 const amrex::IArrayBox& /*solve_mask*/,
72 const amrex::Geometry& /*crse_geom*/,
73 const amrex::Geometry& /*fine_geom*/,
74 amrex::Vector<amrex::BCRec> const& /*bcr*/,
75 const int /*bccomp*/,
76 amrex::RunOn /*gpu_or_cpu*/)
77 {
78 Util::Abort("The version of this Interpolater for face-based data is not implemented or does not apply. Call 'interp' instead.");
79 }
80private:
81 using amrex::NodeBilinear::interp;
82 using amrex::NodeBilinear::interp_face;
83
84};
85}
86}
87
88#endif
void interp(const amrex::BaseFab< T > &crse, int crse_comp, amrex::BaseFab< T > &fine, int fine_comp, int ncomp, const amrex::Box &fine_region, const amrex::IntVect &ratio, const amrex::Geometry &, const amrex::Geometry &, amrex::Vector< amrex::BCRec > const &, int, int, amrex::RunOn runon)
virtual void interp_face(const amrex::BaseFab< T > &, const int, amrex::BaseFab< T > &, const int, const int, const amrex::Box &, const amrex::IntVect &, const amrex::IArrayBox &, const amrex::Geometry &, const amrex::Geometry &, amrex::Vector< amrex::BCRec > const &, const int, amrex::RunOn)
This namespace contains some numerical tools.
Definition Function.H:6
void Abort(const char *msg)
Definition Util.cpp:170