PICSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: PICSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-D Particle-in-Cell (PIC) implementation.
6 > Created Time: 2017/09/12
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_PIC_SOLVER3_H
10 #define CUBBYFLOW_PIC_SOLVER3_H
11 
15 
16 namespace CubbyFlow
17 {
29  {
30  public:
31  class Builder;
32 
34  PICSolver3();
35 
37  PICSolver3(
38  const Size3& resolution,
39  const Vector3D& gridSpacing,
40  const Vector3D& gridOrigin);
41 
43  virtual ~PICSolver3();
44 
47 
50 
53 
55  void SetParticleEmitter(const ParticleEmitter3Ptr& newEmitter);
56 
58  static Builder GetBuilder();
59 
60  protected:
64 
66  void OnInitialize() override;
67 
69  void OnBeginAdvanceTimeStep(double timeIntervalInSeconds) override;
70 
72  void ComputeAdvection(double timeIntervalInSeconds) override;
73 
75  ScalarField3Ptr GetFluidSDF() const override;
76 
78  virtual void TransferFromParticlesToGrids();
79 
81  virtual void TransferFromGridsToParticles();
82 
84  virtual void MoveParticles(double timeIntervalInSeconds);
85 
86  private:
87  size_t m_signedDistanceFieldID;
88  ParticleSystemData3Ptr m_particles;
89  ParticleEmitter3Ptr m_particleEmitter;
90 
91  void ExtrapolateVelocityToAir() const;
92 
93  void BuildSignedDistanceField();
94 
95  void UpdateParticleEmitter(double timeIntervalInSeconds) const;
96  };
97 
99  using PICSolver3Ptr = std::shared_ptr<PICSolver3>;
100 
104  class PICSolver3::Builder final : public GridFluidSolverBuilderBase3<PICSolver3::Builder>
105  {
106  public:
108  PICSolver3 Build() const;
109 
111  PICSolver3Ptr MakeShared() const;
112  };
113 }
114 
115 #endif
3-D vector class.
Definition: Vector3.h:26
void OnBeginAdvanceTimeStep(double timeIntervalInSeconds) override
Invoked before a simulation time-step begins.
Array3< char > m_vMarkers
Definition: PICSolver3.h:62
std::shared_ptr< ParticleEmitter3 > ParticleEmitter3Ptr
Shared pointer for the ParticleEmitter3 type.
Definition: ParticleEmitter3.h:71
virtual void MoveParticles(double timeIntervalInSeconds)
Moves particles.
std::shared_ptr< ScalarField3 > ScalarField3Ptr
Shared pointer for the ScalarField3 type.
Definition: ScalarField3.h:44
std::shared_ptr< ParticleSystemData3 > ParticleSystemData3Ptr
Shared pointer type of ParticleSystemData3.
Definition: ParticleSystemData3.h:250
virtual ~PICSolver3()
Default destructor.
void OnInitialize() override
Initializes the simulator.
3-D Particle-in-Cell (PIC) implementation.
Definition: PICSolver3.h:28
virtual void TransferFromGridsToParticles()
Transfers velocity field from grids to particles.
3-D point class.
Definition: Point3.h:26
std::shared_ptr< ScalarGrid3 > ScalarGrid3Ptr
Shared pointer for the ScalarGrid3 type.
Definition: ScalarGrid3.h:179
Base class for grid-based fluid solver builder.
Definition: GridFluidSolver3.h:303
Front-end to create PICSolver3 objects step by step.
Definition: PICSolver3.h:104
PICSolver3()
Default constructor.
Definition: pybind11Utils.h:24
Abstract base class for grid-based 3-D fluid solver.
Definition: GridFluidSolver3.h:33
Array3< char > m_uMarkers
Definition: PICSolver3.h:61
virtual void TransferFromParticlesToGrids()
Transfers velocity field from particles to grids.
std::shared_ptr< PICSolver3 > PICSolver3Ptr
Shared pointer type for the PICSolver3.
Definition: PICSolver3.h:99
ScalarGrid3Ptr GetSignedDistanceField() const
Returns the signed-distance field of particles.
3-D array class.
Definition: Array3.h:45
const ParticleEmitter3Ptr & GetParticleEmitter() const
Returns the particle emitter.
const ParticleSystemData3Ptr & GetParticleSystemData() const
Returns the particle system data.
Array3< char > m_wMarkers
Definition: PICSolver3.h:63
ScalarField3Ptr GetFluidSDF() const override
Returns the signed-distance field of the fluid.
static Builder GetBuilder()
Returns builder fox PICSolver3.
void SetParticleEmitter(const ParticleEmitter3Ptr &newEmitter)
Sets the particle emitter.
void ComputeAdvection(double timeIntervalInSeconds) override
Computes the advection term of the fluid solver.
PICSolver3Ptr MakeShared() const
Builds shared pointer of PICSolver3 instance.
PICSolver3 Build() const
Builds PICSolver3.