Block-Structured AMR Software Framework
AMReX_distFcnElement.H
Go to the documentation of this file.
1 #ifndef AMREX_DISTFCNELEMENT_H_
2 #define AMREX_DISTFCNELEMENT_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_RealVect.H>
6 #include <AMReX.H>
7 #include <AMReX_Vector.H>
8 
9 namespace amrex {
10 
11 class distFcnElement2d { // NOLINT(cppcoreguidelines-special-member-functions)
12  public:
14  distFcnElement2d() = default;
15  virtual ~distFcnElement2d() = default;
16 
17  [[nodiscard]] virtual distFcnElement2d* newDistFcnElement2d() const = 0;
18 
19  [[nodiscard]] virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const = 0;
20  [[nodiscard]] virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const = 0;
21  static int solve_thomas (const std::vector<amrex::Real> &a,
22  std::vector<amrex::Real> &b,
23  const std::vector<amrex::Real> &c,
24  std::vector<amrex::Real> &d,
25  std::vector<amrex::Real> &X);
26 };
27 
28 
29 class LineDistFcnElement2d: public distFcnElement2d { // NOLINT(cppcoreguidelines-special-member-functions)
30  public:
31  LineDistFcnElement2d() = default;
32  ~LineDistFcnElement2d() override = default;
33 
34  [[nodiscard]] distFcnElement2d* newDistFcnElement2d() const override;
35 
36  void set_control_points(std::vector<amrex::RealVect> pts);
37 
38  [[nodiscard]] amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const override;
39  [[nodiscard]] amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override;
40 
41  void print_control_points();
42 
43  protected:
44  static void single_seg_cpdist(amrex::RealVect pt,
45  amrex::Real x0, amrex::Real x1,
46  amrex::Real y0, amrex::Real y1,
47  amrex::RealVect& cp,
48  amrex::Real& dist);
49 
50  private:
51  std::vector<amrex::Real> control_points_x;
52  std::vector<amrex::Real> control_points_y;
53 
54 
55 };
56 
57 
58 class SplineDistFcnElement2d: public distFcnElement2d { // NOLINT(cppcoreguidelines-special-member-functions)
59  public:
61  ~SplineDistFcnElement2d() override = default;
62 
63  [[nodiscard]] distFcnElement2d* newDistFcnElement2d() const override;
64 
65 
66  void set_control_points(std::vector<amrex::RealVect> pts);
68 
69  void print_control_points() const;
70  void print_spline() const;
71 
72  void calc_D(bool clamped_bc = false);
73 
74  [[nodiscard]] amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const override;
75  [[nodiscard]] amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override;
76 
77  protected:
78  static amrex::Real eval(amrex::Real t, amrex::Real y0, amrex::Real y1,
79  amrex::Real D0, amrex::Real D1);
80  static void dxbydt(amrex::Real t, amrex::Real y0, amrex::Real y1,
81  amrex::Real D0, amrex::Real D1, amrex::Real& dyf,
82  amrex::Real& d2yf);
83 
85  amrex::Real x0, amrex::Real x1,
86  amrex::Real Dx0, amrex::Real Dx1,
87  amrex::Real y0, amrex::Real y1,
88  amrex::Real Dy0, amrex::Real Dy1,
89  amrex::Real& t, amrex::RealVect& cp,
90  amrex::Real& dist);
91 
92  static amrex::Real dist(amrex::RealVect pt,
93  amrex::Real x0, amrex::Real x1,
94  amrex::Real Dx0, amrex::Real Dx1,
95  amrex::Real y0, amrex::Real y1,
96  amrex::Real Dy0, amrex::Real Dy1,
97  amrex::Real& t,
98  amrex::RealVect& spt);
99 
100  private:
101  std::vector<amrex::Real> control_points_x;
102  std::vector<amrex::Real> control_points_y;
103 
106 
107  std::vector<amrex::Real> Dx;
108  std::vector<amrex::Real> Dy;
109 };
110 
111 }
112 
113 #endif
Definition: AMReX_distFcnElement.H:29
std::vector< amrex::Real > control_points_y
Definition: AMReX_distFcnElement.H:52
amrex::Real cpside(amrex::RealVect pt, amrex::RealVect &cp) const override
Definition: AMReX_distFcnElement.cpp:354
std::vector< amrex::Real > control_points_x
Definition: AMReX_distFcnElement.H:51
distFcnElement2d * newDistFcnElement2d() const override
Definition: AMReX_distFcnElement.cpp:444
static void single_seg_cpdist(amrex::RealVect pt, amrex::Real x0, amrex::Real x1, amrex::Real y0, amrex::Real y1, amrex::RealVect &cp, amrex::Real &dist)
Definition: AMReX_distFcnElement.cpp:413
void set_control_points(std::vector< amrex::RealVect > pts)
Definition: AMReX_distFcnElement.cpp:406
~LineDistFcnElement2d() override=default
void print_control_points()
Definition: AMReX_distFcnElement.cpp:436
amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect &cp) const override
Definition: AMReX_distFcnElement.cpp:334
A Real vector in SpaceDim-dimensional space.
Definition: AMReX_RealVect.H:32
Definition: AMReX_distFcnElement.H:58
distFcnElement2d * newDistFcnElement2d() const override
Definition: AMReX_distFcnElement.cpp:43
static amrex::Real dist(amrex::RealVect pt, amrex::Real x0, amrex::Real x1, amrex::Real Dx0, amrex::Real Dx1, amrex::Real y0, amrex::Real y1, amrex::Real Dy0, amrex::Real Dy1, amrex::Real &t, amrex::RealVect &spt)
Definition: AMReX_distFcnElement.cpp:64
std::vector< amrex::Real > control_points_y
Definition: AMReX_distFcnElement.H:102
static void single_spline_cpdist(amrex::RealVect pt, amrex::Real x0, amrex::Real x1, amrex::Real Dx0, amrex::Real Dx1, amrex::Real y0, amrex::Real y1, amrex::Real Dy0, amrex::Real Dy1, amrex::Real &t, amrex::RealVect &cp, amrex::Real &dist)
Definition: AMReX_distFcnElement.cpp:171
amrex::Real cpside(amrex::RealVect pt, amrex::RealVect &cp) const override
Definition: AMReX_distFcnElement.cpp:107
void print_control_points() const
Definition: AMReX_distFcnElement.cpp:300
void set_control_points(std::vector< amrex::RealVect > pts)
Definition: AMReX_distFcnElement.cpp:285
amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect &cp) const override
Definition: AMReX_distFcnElement.cpp:85
void print_spline() const
Definition: AMReX_distFcnElement.cpp:312
std::vector< amrex::Real > Dx
Definition: AMReX_distFcnElement.H:107
amrex::RealVect bc_pt_start
Definition: AMReX_distFcnElement.H:104
~SplineDistFcnElement2d() override=default
std::vector< amrex::Real > Dy
Definition: AMReX_distFcnElement.H:108
static void dxbydt(amrex::Real t, amrex::Real y0, amrex::Real y1, amrex::Real D0, amrex::Real D1, amrex::Real &dyf, amrex::Real &d2yf)
Definition: AMReX_distFcnElement.cpp:212
std::vector< amrex::Real > control_points_x
Definition: AMReX_distFcnElement.H:101
amrex::RealVect bc_pt_end
Definition: AMReX_distFcnElement.H:105
void calc_D(bool clamped_bc=false)
Definition: AMReX_distFcnElement.cpp:226
static amrex::Real eval(amrex::Real t, amrex::Real y0, amrex::Real y1, amrex::Real D0, amrex::Real D1)
Definition: AMReX_distFcnElement.cpp:54
void set_bc_points(amrex::RealVect start, amrex::RealVect end)
Definition: AMReX_distFcnElement.cpp:293
Definition: AMReX_distFcnElement.H:11
virtual ~distFcnElement2d()=default
virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect &cp) const =0
virtual distFcnElement2d * newDistFcnElement2d() const =0
static int solve_thomas(const std::vector< amrex::Real > &a, std::vector< amrex::Real > &b, const std::vector< amrex::Real > &c, std::vector< amrex::Real > &d, std::vector< amrex::Real > &X)
Definition: AMReX_distFcnElement.cpp:9
distFcnElement2d()=default
Constructor.
virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect &cp) const =0
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 end(BoxND< dim > const &box) noexcept
Definition: AMReX_Box.H:1890