psim  1.0
Generalized 2D phonon transport using a Monte Carlo method
compositeSurface.h
Go to the documentation of this file.
1 #ifndef PSIM_COMPOSITESURFACE_H
2 #define PSIM_COMPOSITESURFACE_H
3 
4 #include "geometry.h"// for Line, Point
5 #include "surface.h"// for Surface, EmitSurface, TransitionSurface
6 #include <exception>// for exception
7 #include <iosfwd>// for ostream
8 #include <string>// for string
9 #include <string_view>// for string_view
10 #include <vector>// for vector
11 
12 class Cell;
13 class Material;
14 class Phonon;
15 
16 
18 public:
21 
22  explicit CompositeSurface(Surface&& main_surface);
23 
24  [[nodiscard]] const Line& getSurfaceLine() const noexcept {
25  return main_surface_.getSurfaceLine();
26  }
27  [[nodiscard]] bool contains(const Point& point) const noexcept {
28  return main_surface_.contains(point);
29  }
30  [[nodiscard]] const auto& getEmitSurfaces() const noexcept {
31  return emit_sub_surfaces_;
32  }
33  void updateEmitSurfaceTables() noexcept;
34 
35  [[nodiscard]] bool addEmitSurface(const Line&,
36  Cell&,
37  const Material&,
38  double temp,
39  int norm_sign,
40  double duration,
41  double start_time);
42  [[nodiscard]] bool addTransitionSurface(const Line& surface_line, Cell& cell, int norm_sign);
43 
44  void handlePhonon(Phonon& p, const Point& poi, double step_time) const noexcept;// NOLINT
45 
46  friend std::ostream& operator<<(std::ostream& os, const CompositeSurface& surface);// NOLINT
47 
48 private:
49  Surface main_surface_;
50  // TODO: std::variant<EmitSurface, TransitionSurface> seems like it would be good here
51  // Don't see a compelling reason to use a heterogeneous container here.
52  // Number of sub-surfaces should not increase in the foreseeable future.
53  std::vector<TransitionSurface> transition_sub_surfaces_;
54  std::vector<EmitSurface> emit_sub_surfaces_;
62  [[nodiscard]] bool verifySurfaceLine(const Line& surface_line) const;// can throw
63 };
64 
65 class CompositeSurfaceError : public std::exception {
66 public:
68  [[nodiscard]] const char* what() const noexcept override {
69  return message_.c_str();
70  }
71 
72 protected:
73  void setMessage(std::string_view message) {
74  message_ = message;
75  }
76 
77 private:
78  std::string message_;
79  Geometry::Line main_;
80  Geometry::Line inc_;
81 };
82 
83 
84 #endif// PSIM_COMPOSITESURFACE_H
Geometry::Point Point
Definition: cell.cpp:18
Geometry::Line Line
Definition: cell.cpp:17
Definition: cell.h:19
Definition: compositeSurface.h:65
const char * what() const noexcept override
Definition: compositeSurface.h:68
void setMessage(std::string_view message)
Definition: compositeSurface.h:73
Definition: compositeSurface.h:17
void updateEmitSurfaceTables() noexcept
Definition: compositeSurface.cpp:22
bool addTransitionSurface(const Line &surface_line, Cell &cell, int norm_sign)
Definition: compositeSurface.cpp:43
const auto & getEmitSurfaces() const noexcept
Definition: compositeSurface.h:30
const Line & getSurfaceLine() const noexcept
Definition: compositeSurface.h:24
void handlePhonon(Phonon &p, const Point &poi, double step_time) const noexcept
Definition: compositeSurface.cpp:53
CompositeSurface(Surface &&main_surface)
Definition: compositeSurface.cpp:18
bool contains(const Point &point) const noexcept
Definition: compositeSurface.h:27
bool addEmitSurface(const Line &, Cell &, const Material &, double temp, int norm_sign, double duration, double start_time)
Definition: compositeSurface.cpp:26
Definition: surface.h:70
Definition: material.h:15
Definition: phonon.h:16
Definition: surface.h:14
bool contains(const Point &point) const noexcept
Definition: surface.h:33
const Line & getSurfaceLine() const noexcept
Definition: surface.h:30
Definition: surface.h:104
int main(int argc, char *argv[])
Definition: main.cpp:14
Definition: geometry.h:39
Definition: geometry.h:23