LCOV - code coverage report
Current view: top level - src/Numeric/Interpolator - NodeBilinear.H (source / functions) Hit Total Coverage
Test: coverage_merged.info Lines: 10 13 76.9 %
Date: 2024-11-18 05:28:54 Functions: 5 72 6.9 %

          Line data    Source code
       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             : 
      19             : namespace Numeric
      20             : {
      21             : namespace Interpolator
      22             : {
      23             : 
      24             : template <class T>
      25             : class NodeBilinear: public amrex::NodeBilinear
      26             : {
      27             : public:
      28         321 :     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         321 :         int num_slope = ncomp * (AMREX_D_TERM(2, *2, *2) - 1);
      45         321 :         const amrex::Box cslope_bx = amrex::enclosedCells(CoarseBox(fine_region, ratio));
      46         321 :         amrex::BaseFab<T> slopefab(cslope_bx, num_slope);
      47             :         // amrex::Elixir slopeeli;
      48             :         // if (run_on_gpu) slopeeli = slopefab.elixir();
      49             : 
      50         321 :         amrex::Array4<T const> const& crsearr = crse.const_array();
      51         321 :         amrex::Array4<T> const& finearr = fine.array();
      52         321 :         amrex::Array4<T> const& slopearr = slopefab.array();
      53             : 
      54         321 :         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         642 :         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         321 :     }
      64           0 :     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           0 :         Util::Abort("The version of this Interpolater for face-based data is not implemented or does not apply. Call 'interp' instead.");
      79           0 :     }
      80             : private:
      81             :     using amrex::NodeBilinear::interp;
      82             :     using amrex::NodeBilinear::interp_face;
      83             : 
      84             : };
      85             : }
      86             : }
      87             : 
      88             : #endif

Generated by: LCOV version 1.14