SPH
GeometryJobs.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "run/Job.h"
4 
6 
7 class SphereJob : public IGeometryJob {
8 private:
9  Float radius = 1.e5_f;
10 
11 public:
12  explicit SphereJob(const std::string& name);
13 
14  virtual std::string className() const override;
15 
16  virtual UnorderedMap<std::string, ExtJobType> getSlots() const override;
17 
18  virtual VirtualSettings getSettings() override;
19 
20  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
21 };
22 
23 class BlockJob : public IGeometryJob {
24 private:
25  Vector center = Vector(0._f);
26  Vector dimensions = Vector(1.e5_f);
27 
28 public:
29  explicit BlockJob(const std::string& name)
30  : IGeometryJob(name) {}
31 
32  virtual std::string className() const override {
33  return "block";
34  }
35 
37  return {};
38  }
39 
40  virtual VirtualSettings getSettings() override;
41 
42  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
43 };
44 
45 class EllipsoidJob : public IGeometryJob {
46 private:
47  Vector semiaxes = Vector(2.e5_f, 1.e5_f, 1.e5_f);
48 
49 public:
50  explicit EllipsoidJob(const std::string& name)
51  : IGeometryJob(name) {}
52 
53  virtual std::string className() const override {
54  return "ellipsoid";
55  }
56 
58  return {};
59  }
60 
61  virtual VirtualSettings getSettings() override;
62 
63  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
64 };
65 
66 class CylinderJob : public IGeometryJob {
67 private:
68  Float radius = 1.e5_f;
69  Float height = 2.e5_f;
70 
71 public:
72  explicit CylinderJob(const std::string& name);
73 
74  virtual std::string className() const override;
75 
76  virtual UnorderedMap<std::string, ExtJobType> getSlots() const override;
77 
78  virtual VirtualSettings getSettings() override;
79 
80  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
81 };
82 
84 private:
85  Float semimajorAxis = 1.e5_f;
86  Float spinRate = 0._f;
87  Float density = 2700._f;
88 
89 public:
90  explicit MaclaurinSpheroidJob(const std::string& name)
91  : IGeometryJob(name) {}
92 
93  virtual std::string className() const override {
94  return "Maclaurin spheroid";
95  }
96 
98  return {};
99  }
100 
101  virtual VirtualSettings getSettings() override;
102 
103  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
104 };
105 
106 class HalfSpaceJob : public IGeometryJob {
107 public:
108  explicit HalfSpaceJob(const std::string& name)
109  : IGeometryJob(name) {}
110 
111  virtual std::string className() const override {
112  return "half space";
113  }
114 
116  return {};
117  }
118 
119  virtual VirtualSettings getSettings() override;
120 
121  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
122 };
123 
125 private:
126  Float radius = 1.e5_f;
127  Float beta = 0.2_f;
128  int seed = 1337;
129 
130 public:
131  explicit GaussianSphereJob(const std::string& name)
132  : IGeometryJob(name) {}
133 
134  virtual std::string className() const override {
135  return "Gaussian sphere";
136  }
137 
139  return {};
140  }
141 
142  virtual VirtualSettings getSettings() override;
143 
144  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
145 };
146 
147 
149 private:
150  Path path = Path("file.ply");
151  Float scale = 1._f;
152  bool precompute = false;
153 
154 public:
155  explicit MeshGeometryJob(const std::string& name);
156 
157  virtual std::string className() const override;
158 
159  virtual UnorderedMap<std::string, ExtJobType> getSlots() const override;
160 
161  virtual VirtualSettings getSettings() override;
162 
163  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
164 };
165 
167 private:
168  Float resolution = 1.e3_f;
169  Float surfaceLevel = 0.15_f;
170  Float smoothingMult = 1._f;
171 
172 public:
173  explicit ParticleGeometryJob(const std::string& name)
174  : IGeometryJob(name) {}
175 
176  virtual std::string className() const override {
177  return "particle geometry";
178  }
179 
181  return { { "particles", JobType::PARTICLES } };
182  }
183 
184  virtual VirtualSettings getSettings() override;
185 
186  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
187 };
188 
190 public:
191  explicit SpheresGeometryJob(const std::string& name)
192  : IGeometryJob(name) {}
193 
194  virtual std::string className() const override {
195  return "spheres geometry";
196  }
197 
199  return { { "spheres", JobType::PARTICLES } };
200  }
201 
202  virtual VirtualSettings getSettings() override;
203 
204  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
205 };
206 
208 public:
209  explicit InvertGeometryJob(const std::string& name)
210  : IGeometryJob(name) {}
211 
212  virtual std::string className() const override {
213  return "invert geometry";
214  }
215 
217  return { { "geometry", JobType::GEOMETRY } };
218  }
219 
220  virtual VirtualSettings getSettings() override;
221 
222  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
223 };
224 
226 private:
227  Vector scaling = Vector(1._f);
228  Vector offset = Vector(0._f);
229 
230 public:
231  explicit TransformGeometryJob(const std::string& name)
232  : IGeometryJob(name) {}
233 
234  virtual std::string className() const override {
235  return "transform geometry";
236  }
237 
239  return { { "geometry", JobType::GEOMETRY } };
240  }
241 
242  virtual VirtualSettings getSettings() override;
243 
244  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
245 };
246 
247 enum class BooleanEnum {
248  UNION,
249  DIFFERENCE,
250  INTERSECTION,
251 };
252 static RegisterEnum<BooleanEnum> sBoolean({
253  { BooleanEnum::UNION, "union", "union" },
254  { BooleanEnum::INTERSECTION, "intersection", "intersection" },
255  { BooleanEnum::DIFFERENCE, "difference", "difference" },
256 });
257 
258 
260  EnumWrapper mode;
261  Vector offset = Vector(0._f);
262 
263 public:
264  BooleanGeometryJob(const std::string& name)
265  : IGeometryJob(name) {
267  }
268 
269  virtual std::string className() const override {
270  return "boolean";
271  }
272 
274  return { { "operand A", JobType::GEOMETRY }, { "operand B", JobType::GEOMETRY } };
275  }
276 
277  virtual VirtualSettings getSettings() override;
278 
279  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
280 };
281 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
BooleanEnum
Definition: GeometryJobs.h:247
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
@ GEOMETRY
Job providing geometry.
@ PARTICLES
Job providing particles.
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
BasicVector< Float > Vector
Definition: Vector.h:539
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:32
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:36
BlockJob(const std::string &name)
Definition: GeometryJobs.h:29
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:273
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
BooleanGeometryJob(const std::string &name)
Definition: GeometryJobs.h:264
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:269
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
CylinderJob(const std::string &name)
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
EllipsoidJob(const std::string &name)
Definition: GeometryJobs.h:50
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:57
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:53
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:134
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
GaussianSphereJob(const std::string &name)
Definition: GeometryJobs.h:131
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:138
HalfSpaceJob(const std::string &name)
Definition: GeometryJobs.h:108
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:115
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:111
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
Base class for jobs providing a geometric shape.
Definition: Job.h:284
Callbacks executed by the simulation to provide feedback to the user.
Definition: IRun.h:27
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:216
InvertGeometryJob(const std::string &name)
Definition: GeometryJobs.h:209
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:212
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
MaclaurinSpheroidJob(const std::string &name)
Definition: GeometryJobs.h:90
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:97
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:93
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
MeshGeometryJob(const std::string &name)
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
ParticleGeometryJob(const std::string &name)
Definition: GeometryJobs.h:173
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:180
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:176
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
Object representing a path on a filesystem.
Definition: Path.h:17
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
SphereJob(const std::string &name)
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
SpheresGeometryJob(const std::string &name)
Definition: GeometryJobs.h:191
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:194
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:198
TransformGeometryJob(const std::string &name)
Definition: GeometryJobs.h:231
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: GeometryJobs.h:238
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: GeometryJobs.h:234
Holds a map of virtual entries, associated with a unique name.
Wrapper of an enum.
Definition: Settings.h:37
Helper class for adding individual enums to the enum map.
Definition: EnumMap.h:175