LCOV - code coverage report
Current view: top level - src/BC - BC.H (source / functions) Coverage Total Hit
Test: coverage_merged.info Lines: 38.7 % 31 12
Test Date: 2025-02-27 04:17:48 Functions: 6.8 % 73 5

            Line data    Source code
       1              : //
       2              : // This is the mechanism for impositing boundary conditions on :code:`Set::Field` objects of 
       3              : // scalar type.
       4              : // Typical convention is for :code:`[prefix]` to be given by the field name. For instance,
       5              : // 
       6              : // .. code-block:: make
       7              : // 
       8              : //                 bc.temp.type.xhi = dirichlet dirichlet dirichlet
       9              : //                 bc.temp.val.xhi  = 0.0 1.0 0.0
      10              : //
      11              : // corresponds to the boundary condition for temperature. See the specific integrator
      12              : // for details.
      13              : //
      14              : 
      15              : #ifndef BC_BC_H_
      16              : #define BC_BC_H_
      17              : 
      18              : #include <AMReX_ParallelDescriptor.H>
      19              : #include <AMReX_ParmParse.H>
      20              : #include <AMReX_BCRec.H>
      21              : #include <AMReX_PhysBCFunct.H>
      22              : #include <AMReX_LO_BCTYPES.H>
      23              : #include <AMReX_Mask.H>
      24              : #include <AMReX_Periodicity.H>
      25              : 
      26              : #include "Util/Util.H"
      27              : #include "Set/Set.H"
      28              : 
      29              : /// \brief Collection of boundary condition (BC) objects
      30              : namespace BC
      31              : {
      32              : enum Orientation {
      33              :     All = -1,
      34              :     AMREX_D_DECL(xlo = 0,
      35              :     ylo = 1,
      36              :     zlo = 2),
      37              :     AMREX_D_DECL(xhi = 0 + AMREX_SPACEDIM,
      38              :     yhi = 1 + AMREX_SPACEDIM,
      39              :     zhi = 2 + AMREX_SPACEDIM)
      40              : };
      41              : 
      42              : template<class T>
      43              : class BC
      44              : {
      45              : 
      46              : public:
      47           49 :     virtual ~BC() {};
      48              : 
      49       569917 :     void define(const amrex::Geometry& a_geom) { m_geom = a_geom; };
      50              : 
      51              :     virtual void FillBoundary(amrex::BaseFab<T>& in,
      52              :         const amrex::Box& box,
      53              :         int ngrow, int dcomp, int ncomp,
      54              :         amrex::Real time,
      55              :         Orientation face = Orientation::All,
      56              :         const amrex::Mask* mask = nullptr) = 0;
      57              : 
      58            0 :     virtual void FillBoundary(amrex::FabArray<amrex::BaseFab<T>>& mf,
      59              :         int dcomp, int ncomp,
      60              :         amrex::Real time, int /*bccomp*/)
      61              :     {
      62            0 :         mf.FillBoundary(m_geom.periodicity());
      63            0 :         for (amrex::MFIter mfi(mf, true); mfi.isValid(); ++mfi)
      64              :         {
      65            0 :             const amrex::Box& box = mfi.tilebox();
      66            0 :             amrex::BaseFab<T>& in = mf[mfi];
      67            0 :             FillBoundary(in, box, mf.nGrow(), dcomp, ncomp, time);
      68              :         }
      69            0 :     }
      70              : 
      71            0 :     virtual void FillBoundary(amrex::FabArray<amrex::BaseFab<T>>& mf,
      72              :         int dcomp, int ncomp, amrex::IntVect const& /*nghost*/,
      73              :         amrex::Real time, int bccomp) //override
      74              :     {
      75            0 :         FillBoundary(mf, dcomp, ncomp, time, bccomp);
      76            0 :     }
      77              : 
      78            0 :     void operator () (amrex::FabArray<amrex::BaseFab<T>>& mf,
      79              :         int dcomp, int ncomp, amrex::IntVect const& /*nghost*/,
      80              :         amrex::Real time, int bccomp)
      81              :     {
      82            0 :         FillBoundary(mf, dcomp, ncomp, time, bccomp);
      83            0 :     }
      84              : 
      85              : 
      86              : 
      87              :     template <class Q = T>
      88              :     typename std::enable_if<std::is_same<Q, amrex::Real>::value>::type
      89      1060578 :         FillBoundary(amrex::MultiFab& mf,
      90              :             int dcomp, int ncomp,
      91              :             amrex::Real time, int /*bccomp*/)
      92              :     {
      93      1060578 :         mf.FillBoundary(m_geom.periodicity());
      94     10836930 :         for (amrex::MFIter mfi(mf, true); mfi.isValid(); ++mfi)
      95              :         {
      96      9776353 :             const amrex::Box& box = mfi.tilebox();
      97      9776353 :             amrex::BaseFab<T>& in = mf[mfi];
      98      9776353 :             FillBoundary(in, box, mf.nGrow(), dcomp, ncomp, time);
      99              :         }
     100      1060577 :     }
     101              : 
     102              :     template <class Q = T>
     103              :     typename std::enable_if<std::is_same<Q, amrex::Real>::value>::type
     104      1059855 :         operator () (amrex::MultiFab& mf,
     105              :             int dcomp, int ncomp, amrex::IntVect const& /*nghost*/,
     106              :             amrex::Real time, int bccomp)
     107              :     {
     108      1059855 :         FillBoundary(mf, dcomp, ncomp, time, bccomp);
     109      1059854 :     }
     110              : 
     111              : 
     112              :     virtual amrex::BCRec GetBCRec() = 0;
     113              : 
     114            0 :     virtual amrex::Array<int, AMREX_SPACEDIM> IsPeriodic()
     115              :     {
     116            0 :         return { {AMREX_D_DECL(m_geom.isPeriodic(0),m_geom.isPeriodic(1),m_geom.isPeriodic(2))} };
     117              :     }
     118              : 
     119            0 :     virtual amrex::Periodicity Periodicity() const {
     120            0 :         return m_geom.periodicity();
     121              :     }
     122              : 
     123            0 :     virtual amrex::Periodicity Periodicity(const amrex::Box& b) {
     124            0 :         return m_geom.periodicity(b);
     125              :     }
     126              : 
     127              : 
     128              : protected:
     129              :     amrex::Geometry m_geom;
     130              :     //std::vector<amrex::Geometry> &geom;
     131              :     //int lev=0;
     132              : };
     133              : 
     134              : namespace BCUtil
     135              : {
     136              : int ReadString(std::string bcstring);
     137              : bool IsPeriodic(int bctype);
     138              : bool IsNeumann(int bctype);
     139              : bool IsReflectEven(int bctype);
     140              : bool IsReflectOdd(int bctype);
     141              : bool IsDirichlet(int bctype);
     142              : }
     143              : 
     144              : }
     145              : #endif
        

Generated by: LCOV version 2.0-1