SPH
ParticleJobs.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "run/Job.h"
4 
6 
7 class JoinParticlesJob : public IParticleJob {
8 private:
9  Vector offset = Vector(0._f);
10  Vector velocity = Vector(0._f);
11  bool moveToCom = false;
12  bool uniqueFlags = true;
13 
14 public:
15  explicit JoinParticlesJob(const std::string& name)
16  : IParticleJob(name) {}
17 
18  virtual std::string className() const override {
19  return "join";
20  }
21 
23  return {
24  { "particles A", JobType::PARTICLES },
25  { "particles B", JobType::PARTICLES },
26  };
27  }
28 
29  virtual VirtualSettings getSettings() override;
30 
31  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
32 };
33 
35 private:
36  Float a = 1.e6_f;
37  Float e = 0._f;
38  Float v = 0._f;
39 
40 public:
41  explicit OrbitParticlesJob(const std::string& name)
42  : IParticleJob(name) {}
43 
44  virtual std::string className() const override {
45  return "orbit";
46  }
47 
49  return {
50  { "particles A", JobType::PARTICLES },
51  { "particles B", JobType::PARTICLES },
52  };
53  }
54 
55  virtual VirtualSettings getSettings() override;
56 
57  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
58 };
59 
61 private:
62  int slotCnt = 3;
63  bool moveToCom = false;
64  bool uniqueFlags = true;
65 
66 public:
67  explicit MultiJoinParticlesJob(const std::string& name)
68  : IParticleJob(name) {}
69 
70  virtual std::string className() const override {
71  return "multi join";
72  }
73 
76  for (int i = 0; i < slotCnt; ++i) {
77  map.insert("particles " + std::to_string(i + 1), JobType::PARTICLES);
78  }
79  return map;
80  }
81 
82  virtual VirtualSettings getSettings() override;
83 
84  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
85 };
86 
88 private:
89  struct {
90  Vector offset = Vector(0._f);
91  Vector angles = Vector(0._f);
92  } positions;
93 
94  struct {
95  Vector offset = Vector(0._f);
96  Float mult = 1.;
97  } velocities;
98 
99  Vector spin = Vector(0._f);
100 
101 public:
102  explicit TransformParticlesJob(const std::string& name)
103  : IParticleJob(name) {}
104 
105  virtual std::string className() const override {
106  return "transform";
107  }
108 
110  return { { "particles", JobType::PARTICLES } };
111  }
112 
113  virtual VirtualSettings getSettings() override;
114 
115  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
116 };
117 
119 private:
120  bool centerPositions = true;
121  bool centerVelocities = false;
122 
123 public:
124  explicit CenterParticlesJob(const std::string& name)
125  : IParticleJob(name) {}
126 
127  virtual std::string className() const override {
128  return "center";
129  }
130 
132  return { { "particles", JobType::PARTICLES } };
133  }
134 
135  virtual VirtualSettings getSettings() override;
136 
137  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
138 };
139 
141  ALL,
142  MATERIAL_ID,
144 };
145 
147 private:
149  int matId = 0;
150 
151 public:
152  explicit ChangeMaterialJob(const std::string& name)
153  : IParticleJob(name) {}
154 
155  virtual std::string className() const override {
156  return "change material";
157  }
158 
160  requires() const override {
162  { "particles", JobType::PARTICLES },
163  { "material", JobType::MATERIAL },
164  };
166  map.insert("domain", JobType::GEOMETRY);
167  }
168  return map;
169  }
170 
172  return { { "particles", JobType::PARTICLES },
173  { "material", JobType::MATERIAL },
174  { "domain", JobType::GEOMETRY } };
175  }
176 
177  virtual VirtualSettings getSettings() override;
178 
179  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
180 };
181 
182 
185  IMPACT_ANGLE,
186 
188  IMPACT_SPEED,
189 
193 
198 
202 };
203 
205 
207 private:
208  CollisionGeometrySettings geometry;
209 
210 public:
211  explicit CollisionGeometrySetup(const std::string& name,
212  const CollisionGeometrySettings& overrides = EMPTY_SETTINGS);
213 
214  virtual std::string className() const override {
215  return "collision setup";
216  }
217 
219  return { { "target", JobType::PARTICLES }, { "impactor", JobType::PARTICLES } };
220  }
221 
222  virtual VirtualSettings getSettings() override;
223 
224  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
225 };
226 
228 enum class HandoffRadius {
230  EQUAL_VOLUME,
231 
234 };
235 
237 private:
239 
243  Float radiusMultiplier = 0.333_f;
244 
245 public:
246  explicit SmoothedToSolidHandoff(const std::string& name)
247  : IParticleJob(name) {}
248 
249  virtual std::string className() const override {
250  return "smoothed-to-solid handoff";
251  }
252 
254  return { { "particles", JobType::PARTICLES } };
255  }
256 
257  virtual VirtualSettings getSettings() override;
258 
259  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
260 };
261 
263 private:
264  int componentIdx = 0;
265  Float factor = 1.5_f;
266  bool center = false;
267 
268 public:
269  explicit ExtractComponentJob(const std::string& name)
270  : IParticleJob(name) {}
271 
272  virtual std::string className() const override {
273  return "extract component";
274  }
275 
277  return { { "particles", JobType::PARTICLES } };
278  }
279 
280  virtual VirtualSettings getSettings() override;
281 
282  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
283 };
284 
285 
287 private:
288  bool removeDamaged = true;
289  bool removeExpanded = false;
290  Float damageLimit = 1._f;
291  Float energyLimit = 1.e6_f;
292 
293 
294 public:
295  explicit RemoveParticlesJob(const std::string& name)
296  : IParticleJob(name) {}
297 
298  virtual std::string className() const override {
299  return "remove particles";
300  }
301 
303  return { { "particles", JobType::PARTICLES } };
304  }
305 
306  virtual VirtualSettings getSettings() override;
307 
308  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
309 };
310 
311 enum class ConnectivityEnum {
312  OVERLAP,
314 };
315 
317 private:
318  Float factor = 1.5_f;
320 
321 public:
322  explicit MergeComponentsJob(const std::string& name)
323  : IParticleJob(name) {}
324 
325  virtual std::string className() const override {
326  return "merge components";
327  }
328 
330  return { { "particles", JobType::PARTICLES } };
331  }
332 
333  virtual VirtualSettings getSettings() override;
334 
335  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
336 };
337 
339 private:
340  bool center = false;
341 
342 public:
343  explicit ExtractParticlesInDomainJob(const std::string& name)
344  : IParticleJob(name) {}
345 
346  virtual std::string className() const override {
347  return "extract particles in domain";
348  }
349 
351  return { { "particles", JobType::PARTICLES }, { "domain", JobType::GEOMETRY } };
352  }
353 
354  virtual VirtualSettings getSettings() override;
355 
356  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
357 };
358 
360 private:
361  Float factor = 1.5_f;
362 
363 public:
364  explicit EmplaceComponentsAsFlagsJob(const std::string& name)
365  : IParticleJob(name) {}
366 
367  virtual std::string className() const override {
368  return "emplace components";
369  }
370 
372  return {
373  { "fragments", JobType::PARTICLES },
374  { "original", JobType::PARTICLES },
375  };
376  }
377 
378  virtual VirtualSettings getSettings() override;
379 
380  virtual void evaluate(const RunSettings& global, IRunCallbacks& callbacks) override;
381 };
382 
383 class SubsampleJob : public IParticleJob {
384 private:
385  Float fraction = 0.5_f;
386 
387 public:
388  explicit SubsampleJob(const std::string& name)
389  : IParticleJob(name) {}
390 
391  virtual std::string className() const override {
392  return "subsampler";
393  }
394 
396  return { { "particles", JobType::PARTICLES } };
397  }
398 
399  virtual VirtualSettings getSettings() override;
400 
401  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
402 };
403 
404 enum class CompareMode {
407 };
408 
409 class CompareJob : public IParticleJob {
411  Float eps = 1.e-4_f;
412  Float fraction = 0.2_f;
413  Float maxDeviation = 0.5_f;
414 
415 public:
416  explicit CompareJob(const std::string& name)
417  : IParticleJob(name) {}
418 
419  virtual std::string className() const override {
420  return "compare";
421  }
422 
424  return {
425  { "test particles", JobType::PARTICLES },
426  { "reference particles", JobType::PARTICLES },
427  };
428  }
429 
430  virtual VirtualSettings getSettings() override;
431 
432  virtual void evaluate(const RunSettings& global, IRunCallbacks& UNUSED(callbacks)) override;
433 };
434 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
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.
@ MATERIAL
Job providing a material.
@ PARTICLES
Job providing particles.
#define UNUSED(x)
Definition: Object.h:37
#define NAMESPACE_SPH_END
Definition: Object.h:12
@ MATERIAL_ID
ID of material, indexed from 0 to (#bodies - 1).
ConnectivityEnum
Definition: ParticleJobs.h:311
ChangeMaterialSubset
Definition: ParticleJobs.h:140
CollisionGeometrySettingsId
Definition: ParticleJobs.h:183
@ IMPACT_ANGLE
Impact angle in degrees, i.e. angle between velocity vector and normal at the impact point.
@ IMPACT_SPEED
Impact speed in m/s.
HandoffRadius
Determines how to compute the radii of the spheres.
Definition: ParticleJobs.h:228
@ EQUAL_VOLUME
The created sphere has the same volume as the SPH particles (=mass/density)
@ SMOOTHING_LENGTH
The radius is proportional to the smoothing length of the particles.
CompareMode
Definition: ParticleJobs.h:404
@ LARGE_PARTICLES_ONLY
BasicVector< Float > Vector
Definition: Vector.h:539
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:131
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:127
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
CenterParticlesJob(const std::string &name)
Definition: ParticleJobs.h:124
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: ParticleJobs.h:171
virtual void evaluate(const RunSettings &global, IRunCallbacks &callbacks) override
Runs the operation provided by the job.
virtual UnorderedMap< std::string, ExtJobType > requires() const override
List of slots that need to be connected to evaluate the job.
Definition: ParticleJobs.h:160
ChangeMaterialJob(const std::string &name)
Definition: ParticleJobs.h:152
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:155
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 &UNUSED(callbacks)) override
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:218
CollisionGeometrySetup(const std::string &name, const CollisionGeometrySettings &overrides=EMPTY_SETTINGS)
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: ParticleJobs.h:214
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
CompareJob(const std::string &name)
Definition: ParticleJobs.h:416
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:419
virtual void evaluate(const RunSettings &global, IRunCallbacks &UNUSED(callbacks)) override
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:423
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: ParticleJobs.h:367
EmplaceComponentsAsFlagsJob(const std::string &name)
Definition: ParticleJobs.h:364
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:371
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: ParticleJobs.h:272
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:276
virtual VirtualSettings getSettings() override
Returns a settings object which allows to query and modify the state of the job.
ExtractComponentJob(const std::string &name)
Definition: ParticleJobs.h:269
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.
Definition: ParticleJobs.h:350
ExtractParticlesInDomainJob(const std::string &name)
Definition: ParticleJobs.h:343
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: ParticleJobs.h:346
Base class for all jobs providing particle data.
Definition: Job.h:242
Callbacks executed by the simulation to provide feedback to the user.
Definition: IRun.h:27
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:18
JoinParticlesJob(const std::string &name)
Definition: ParticleJobs.h:15
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.
Definition: ParticleJobs.h:22
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: ParticleJobs.h:329
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:325
MergeComponentsJob(const std::string &name)
Definition: ParticleJobs.h:322
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: ParticleJobs.h:70
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 UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:74
MultiJoinParticlesJob(const std::string &name)
Definition: ParticleJobs.h:67
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:44
OrbitParticlesJob(const std::string &name)
Definition: ParticleJobs.h:41
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 UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:48
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:298
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.
Definition: ParticleJobs.h:302
RemoveParticlesJob(const std::string &name)
Definition: ParticleJobs.h:295
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").
Definition: ParticleJobs.h:249
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:253
SmoothedToSolidHandoff(const std::string &name)
Definition: ParticleJobs.h:246
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 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: ParticleJobs.h:391
virtual UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:395
SubsampleJob(const std::string &name)
Definition: ParticleJobs.h:388
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 UnorderedMap< std::string, ExtJobType > getSlots() const override
Lists all potential inputs of the job.
Definition: ParticleJobs.h:109
virtual std::string className() const override
Name representing the type of the job (e.e. "SPH").
Definition: ParticleJobs.h:105
TransformParticlesJob(const std::string &name)
Definition: ParticleJobs.h:102
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
Definition: UnorderedMap.h:51
Holds a map of virtual entries, associated with a unique name.
const EmptySettingsTag EMPTY_SETTINGS
Definition: Settings.h:32
Wrapper of an enum.
Definition: Settings.h:37