Date: 2021-03-03T22:27:37+00:00

Actual source code: MyEB.H
petsc-3.14.5 2021-03-03
Report Typos and Errors

      1: #ifndef MY_EB_H_
      2: #define MY_EB_H_

      4: #include <AMReX_Array.H>
      5: #include <AMReX_EB2_IF_Base.H>

      7: #include <cmath>
      8: #include <algorithm>

     10: // For all implicit functions, >0: body; =0: boundary; <0: fluid

     12: class FlowerIF
     13:     : amrex::GPUable
     14: {
     15: public:

     17:     FlowerIF (amrex::Real a_radius, amrex::Real a_delta, int a_npetals,
     18:               const amrex::RealArray& a_center, bool a_inside)
     19:         : m_r(a_radius),
     20:           m_dr(a_delta),
     21:           m_npetals(a_npetals),
     22:           m_center(amrex::makeXDim3(a_center)),
     23:           m_inside(a_inside),
     24:           m_sign(a_inside ? 1.0 : -1.0)
     25:         {}

     27:     ~FlowerIF () {}
     28:
     29:     FlowerIF (const FlowerIF& rhs) noexcept = default;
     30:     FlowerIF (FlowerIF&& rhs) noexcept = default;
     31:     FlowerIF& operator= (const FlowerIF& rhs) = delete;
     32:     FlowerIF& operator= (FlowerIF&& rhs) = delete;

     34:     AMREX_GPU_HOST_DEVICE inline
     35:     amrex::Real operator() (AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z))
     36:         const noexcept
     37:     {
     38:         amrex::Real posx = x - m_center.x;
     39:         amrex::Real posy = y - m_center.y;
     40:         amrex::Real r = std::hypot(posx, posy);
     41:         amrex::Real theta = std::atan2(posy, posx);
     42:         return m_sign*(r - m_r - m_dr * std::cos(m_npetals*theta));
     43:     }

     45:     inline amrex::Real operator() (const amrex::RealArray& p) const noexcept
     46:     {
     47:         return this->operator() (AMREX_D_DECL(p[0], p[1], p[2]));
     48:     }

     50: protected:
     51:     amrex::Real      m_r;
     52:     amrex::Real      m_dr;
     53:     amrex::Real      m_npetals;
     54:     amrex::XDim3     m_center;
     55:     bool             m_inside;
     56:     //
     57:     amrex::Real      m_sign;
     58: };

     60: #endif