DeletionBoundary.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef DELETIONBOUNDARY_H
6 #define DELETIONBOUNDARY_H
7 
8 #include "BaseBoundary.h"
9 #include "Math/Vector.h"
10 
11 class ParticleHandler;
12 
13 class BaseParticle;
14 
23 {
24 public:
29 
38 
42  ~DeletionBoundary() override;
43 
47  DeletionBoundary* copy() const override;
48 
52  void set(const Vec3D& normal, Mdouble distance);
53 
57  void move(Mdouble position);
58 
63  virtual Mdouble getDistance(const Vec3D& position) const;
64 
70 
75 
79  unsigned int getNumberOfParticlesDeleted() const;
80 
81  double getMassOfParticlesDeleted() const;
82 
83  double getVolumeOfParticlesDeleted() const;
84 
85  void reset();
86 
87 
91  void activate();
92 
96  void deactivate();
97 
102 
107  void setTrackerCustom(std::function<void(std::ofstream&, BaseParticle*)> trackerCustom)
108  {
109  trackOutflow_ = false;
110  trackerCustom_ = trackerCustom;
111  }
112 
116  void read(std::istream& is) override;
117 
122  void oldRead(std::istream& is);
123 
127  void write(std::ostream& os) const override;
128 
132  std::string getName() const override;
133 
134 private:
139 
149 
154 
159  double massDeleted_;
162 
168 
170 
171  std::ofstream tracker;
172  std::function<void(std::ofstream&, BaseParticle*)> trackerCustom_ = [] (std::ofstream&, BaseParticle*) {};
173 };
174 
175 #endif
double Mdouble
Definition: GeneralDefine.h:13
#define MERCURYDPM_DEPRECATED
Definition: GeneralDefine.h:16
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseBoundary.h:28
Definition: BaseParticle.h:33
Used for removing particles from the problem. Inherits from BaseBoundary. By default,...
Definition: DeletionBoundary.h:23
Mdouble distance_
The boundary's distance from the origin.
Definition: DeletionBoundary.h:153
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Definition: DeletionBoundary.h:148
unsigned int getNumberOfParticlesDeleted() const
Gets the number of particles deleted by the boundary.
Definition: DeletionBoundary.cc:277
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Checks if particle is inside the boundary, and deletes the particle if so.
Definition: DeletionBoundary.cc:103
void reset()
Definition: DeletionBoundary.cc:210
double volumeDeleted_
Definition: DeletionBoundary.h:161
void read(std::istream &is) override
Reads some boundary properties from an std::istream.
Definition: DeletionBoundary.cc:221
std::ofstream tracker
Definition: DeletionBoundary.h:171
std::function< void(std::ofstream &, BaseParticle *)> trackerCustom_
Definition: DeletionBoundary.h:172
void activate()
Turns on the DeletionBoundary.
Definition: DeletionBoundary.cc:282
double trackMassDeleted_
Definition: DeletionBoundary.h:160
unsigned int numberOfParticlesDeleted_
Number of particles that have been deleted by this boundary.
Definition: DeletionBoundary.h:158
DeletionBoundary()
default constructor
Definition: DeletionBoundary.cc:18
Vec3D normal_
outward unit normal vector
Definition: DeletionBoundary.h:138
void move(Mdouble position)
Sets the boundary's distance property to the given one.
Definition: DeletionBoundary.cc:77
~DeletionBoundary() override
destructor
Definition: DeletionBoundary.cc:35
bool isActivated_
The DeletionBoundary is activated by default. If the DeletionBoundary is deactivated,...
Definition: DeletionBoundary.h:167
void trackOutflow(bool trackOutflow=true)
Turns on the outflow tracker.
Definition: DeletionBoundary.h:101
void deactivate()
Turns off the DeletionBoundary.
Definition: DeletionBoundary.cc:287
std::string getName() const override
Returns the name of the object.
Definition: DeletionBoundary.cc:267
void setTrackerCustom(std::function< void(std::ofstream &, BaseParticle *)> trackerCustom)
Sets a custom function for tracking the outflow.
Definition: DeletionBoundary.h:107
virtual Mdouble getDistance(const Vec3D &position) const
Returns a negative value if and only if the particle is inside the boundary (and therefore to be dele...
Definition: DeletionBoundary.cc:88
double getVolumeOfParticlesDeleted() const
Definition: DeletionBoundary.cc:205
bool trackOutflow_
Definition: DeletionBoundary.h:169
double massDeleted_
Definition: DeletionBoundary.h:159
void write(std::ostream &os) const override
Writes the boundary properties to an std::ostream.
Definition: DeletionBoundary.cc:250
DeletionBoundary * copy() const override
Copy method; creates copy on the heap and returns a pointer to it.
Definition: DeletionBoundary.cc:46
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Definition: DeletionBoundary.cc:182
double getMassOfParticlesDeleted() const
Definition: DeletionBoundary.cc:200
MERCURYDPM_DEPRECATED void oldRead(std::istream &is)
Deprecated read method. use DeletionBoundary::read() instead.
Definition: DeletionBoundary.cc:240
DeletionBoundary(DeletionBoundary const &d)
default copy constructor
Definition: DeletionBoundary.h:33
void set(const Vec3D &normal, Mdouble distance)
Sets boundary position based on a normal and distance.
Definition: DeletionBoundary.cc:65
Container to store pointers to all particles.
Definition: ParticleHandler.h:28
Definition: Kernel/Math/Vector.h:30
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286