psim  1.0
Generalized 2D phonon transport using a Monte Carlo method
phononBuilder.h
Go to the documentation of this file.
1 #ifndef PSIM_PHONONBUILDER_H
2 #define PSIM_PHONONBUILDER_H
3 
4 #include "phonon.h"// for Phonon
5 #include <cstddef>// for size_t
6 #include <stack>// for stack
7 #include <utility>// for pair
8 
9 class Cell;
10 class EmitSurface;
11 
12 // TODO: is abstract class necessary here - using variants in ModelSimulator
14 public:
15  constexpr PhononBuilder() noexcept = default;
16  virtual ~PhononBuilder() = default;
17  constexpr PhononBuilder(const PhononBuilder&) = default;
18  constexpr PhononBuilder(PhononBuilder&&) noexcept = default;
19  PhononBuilder& operator=(const PhononBuilder&) = default;
20  PhononBuilder& operator=(PhononBuilder&&) = default;
27  [[nodiscard]] virtual Phonon operator()(double t_eq) noexcept = 0;
28  [[nodiscard]] virtual bool hasPhonons() const noexcept = 0;
29 
30  [[nodiscard]] std::size_t totalPhonons() const noexcept {
31  return total_phonons_;
32  }
33 
34 protected:
35  std::size_t total_phonons_{ 0 };
36 };
37 
39 public:
40  CellOriginBuilder() = default;
41 
42  [[nodiscard]] Phonon operator()(double t_eq) noexcept override;
43  [[nodiscard]] bool hasPhonons() const noexcept override {
44  return !cells_.empty();
45  }
46 
47  void addCellPhonons(Cell* cell, std::size_t num_phonons) noexcept;
48 
49 private:
50  std::stack<std::pair<Cell*, std::size_t>> cells_;
51 };
52 
54 public:
55  SurfaceOriginBuilder(Cell& cell, const EmitSurface& surface, std::size_t num_phonons);
56 
57  [[nodiscard]] Phonon operator()(double t_eq) noexcept override;
58  [[nodiscard]] bool hasPhonons() const noexcept override {
59  return total_phonons_ > 0;
60  }
61 
62 private:
63  Cell& cell_;
64 
65 protected:
67 };
68 
70 public:
72 
73  [[nodiscard]] Phonon operator()(double t_eq) noexcept override;
74 };
75 
76 #endif// PSIM_PHONONBUILDER_H
Definition: phononBuilder.h:38
bool hasPhonons() const noexcept override
Definition: phononBuilder.h:43
void addCellPhonons(Cell *cell, std::size_t num_phonons) noexcept
Definition: phononBuilder.cpp:24
CellOriginBuilder()=default
Phonon operator()(double t_eq) noexcept override
Definition: phononBuilder.cpp:12
Definition: cell.h:19
Definition: surface.h:70
Definition: phononBuilder.h:69
Phonon operator()(double t_eq) noexcept override
Definition: phononBuilder.cpp:48
Definition: phononBuilder.h:13
std::size_t totalPhonons() const noexcept
Definition: phononBuilder.h:30
virtual bool hasPhonons() const noexcept=0
std::size_t total_phonons_
Definition: phononBuilder.h:35
constexpr PhononBuilder() noexcept=default
Definition: phonon.h:16
Definition: phononBuilder.h:53
bool hasPhonons() const noexcept override
Definition: phononBuilder.h:58
Phonon operator()(double t_eq) noexcept override
Definition: phononBuilder.cpp:37
SurfaceOriginBuilder(Cell &cell, const EmitSurface &surface, std::size_t num_phonons)
Definition: phononBuilder.cpp:31
const EmitSurface & surface_
Definition: phononBuilder.h:66