DropletBoundary.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 DROPLETBOUNDARY_H
6 #define DROPLETBOUNDARY_H
7 
8 #include "DPMBase.h"
9 #include "BaseBoundary.h"
10 #include "Math/Vector.h"
11 #include "Math/RNG.h"
12 
13 class DPMBase;
14 
15 class ParticleHandler;
16 
17 class BaseParticle;
18 
19 class RNG;
20 
30 {
31 public:
32 
33  struct Droplet {
34  Droplet(const Vec3D& position, const Vec3D& velocity, double radius, double liquidVolume) :
36 
39  double radius;
40  double liquidVolume;
41 
42  // Used for when to repel droplet at walls.
44  };
45 
47 
49  droplets_ = other.droplets_;
54  lostVolume_ = other.lostVolume_;
59  }
60 
61  ~DropletBoundary() override {
62  logger(VERBOSE, "A DropletBoundary has been destroyed.");
63  }
64 
65  DropletBoundary* copy() const override {
66  return new DropletBoundary(*this);
67  }
68 
69  std::string getName() const override {
70  return "DropletBoundary";
71  }
72 
77 
81  void read(std::istream& is) override;
82 
86  void write(std::ostream& os) const override;
87 
88  void setGenerateDroplets(std::function<void(DropletBoundary&)> generateDroplets) {
89  generateDroplets_=generateDroplets;
90  }
91 
92  void setRemoveDroplets(std::function<bool(const Droplet&)> removeDroplets) {
93  removeDroplets_ = removeDroplets;
94  }
95 
96  void writeVTK(std::fstream& file) override;
97 
98  // this is the number of timesteps between checks whether the droplet is in contact with a particle or wall.
99  unsigned checkCount = 3;
100 
101  void setRemoveDropletsAtWalls(bool removeDroplets) {
102  removeDropletsAtWalls_ = removeDroplets;
103  }
104 
105  void setDropletSpecies(const ParticleSpecies* species) {
106  dropletSpecies_ = species;
107  }
108 
109  void setDropletTemperature(double temperature) {
110  dropletTemperature_ = temperature;
111  }
112 
113  void actionsBeforeTimeLoop() override
114  {
115  // When no droplet species were set, use the last species from the handler.
116  // This is fine for when the droplets are removed at the walls, if not, a warning is shown.
117  if (!dropletSpecies_)
118  {
121  logger(WARN, "DropletBoundary: Droplets should repel from wall, but no droplet species was set. Using last species from the species handler instead.");
122  }
123 
124  // When droplets should repel from the wall, it requires to be checked every time step.
126  checkCount = 1;
127 
129  logger(ERROR, "DropletBoundary: The heat capacity of the droplet species is 0. For proper heat transfer, make sure the droplets have the correct species and the heat capacity is set.");
130  }
131 
132  void addDroplet(const Vec3D& position, const Vec3D& velocity, double radius)
133  {
134  double liquidVolume = std::pow(radius, 3) * constants::pi * 4.0 / 3.0;
135  addDroplet(position, velocity, radius, liquidVolume);
136  }
137 
138  void addDroplet(const Vec3D& position, const Vec3D& velocity, double radius, double liquidVolume)
139  {
140  droplets_.emplace_back(position, velocity, radius, liquidVolume);
141  dropletVolume_ += liquidVolume;
142  }
143 
144  std::vector<Droplet>& getDroplets() {
145  return droplets_;
146  }
147 
148  double getDropletVolume() const {
149  return dropletVolume_;
150  }
151 
152  double getAbsorbedVolume() const {
153  return absorbedVolume_;
154  }
155 
156  double getLostVolume() const {
157  return lostVolume_;
158  }
159 
160  double getTotalInsertedVolume() const {
162  }
163 
167  void setLiquidFilmVolumeMaxFraction(double volumeFraction) {
168  logger.assert_always(volumeFraction > 0.0, "Error in DropletBoundary::setLiquidFilmVolumeFraction(%), volumeFraction must > 0.", volumeFraction);
169  liquidFilmVolumeMaxFraction_ = volumeFraction;
170  }
171 
177  logger.assert_always(radiusFraction > 0.0, "Error in DropletBoundary::setLiquidFilmVolumeFractionFromRadiusFraction(%), radiusFraction must > 0.", radiusFraction);
178  liquidFilmVolumeMaxFraction_ = std::pow(1.0 + radiusFraction, 3) - 1.0;
179  }
180 
181 private:
182  std::function<void(DropletBoundary&)> generateDroplets_ = [] (DropletBoundary&) {};
183  std::function<bool(const Droplet&)> removeDroplets_ = [] (const Droplet&) { return false; };
184 
185  void addHeatTransfer(BaseParticle* particle, double liquidVolume);
186  double getSpeciesHeatCapacity(const ParticleSpecies* species) const;
187 
188 private:
189  std::vector<Droplet> droplets_;
190 
191  // volume of liquid stored in droplets
192  double dropletVolume_ = 0;
193  // volume of liquid absorbed by particles
194  double absorbedVolume_ = 0;
195  // volume of liquid lost at walls
196  double lostVolume_ = 0;
197 
200 
201  double dropletTemperature_ = -1.0; // Default negative, means no heat transfer.
202 
203  // Indicates the maximum liquid volume of a particle, depending on it's size. By default infinite, so no limit.
204  // This prevents a droplet from adding all its liquid to only one or a few particles, and instead only fills the
205  // particles to their max. The droplet itself has a volume property, which is used to track the remaining available
206  // liquid. I.e. the droplet size does not change.
207  // Added as a property here and not in LiquidFilmParticle, because then the complete liquid migration codes must
208  // work with that as well. This would require a fundamental overhaul of the code, which seems like overkill for a
209  // safeguard that's only needed here.
211 };
212 
213 #endif
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ WARN
@ ERROR
@ VERBOSE
Definition: BaseBoundary.h:28
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:122
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
Definition: BaseParticle.h:33
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:56
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a ran...
Definition: DropletBoundary.h:30
void addHeatTransfer(BaseParticle *particle, double liquidVolume)
Definition: DropletBoundary.cc:143
std::vector< Droplet > & getDroplets()
Definition: DropletBoundary.h:144
double lostVolume_
Definition: DropletBoundary.h:196
double getSpeciesHeatCapacity(const ParticleSpecies *species) const
Definition: DropletBoundary.cc:165
double getAbsorbedVolume() const
Definition: DropletBoundary.h:152
DropletBoundary(const DropletBoundary &other)
Definition: DropletBoundary.h:48
double liquidFilmVolumeMaxFraction_
Definition: DropletBoundary.h:210
double getTotalInsertedVolume() const
Definition: DropletBoundary.h:160
void write(std::ostream &os) const override
Writes the boundary properties to an std::ostream.
Definition: DropletBoundary.cc:231
double getLostVolume() const
Definition: DropletBoundary.h:156
std::function< void(DropletBoundary &)> generateDroplets_
Definition: DropletBoundary.h:182
void setRemoveDropletsAtWalls(bool removeDroplets)
Definition: DropletBoundary.h:101
double dropletTemperature_
Definition: DropletBoundary.h:201
DropletBoundary * copy() const override
Used to create a copy of the object NB: purely virtual function.
Definition: DropletBoundary.h:65
bool removeDropletsAtWalls_
Definition: DropletBoundary.h:198
void setDropletTemperature(double temperature)
Definition: DropletBoundary.h:109
double dropletVolume_
Definition: DropletBoundary.h:192
double getDropletVolume() const
Definition: DropletBoundary.h:148
DropletBoundary()
Definition: DropletBoundary.h:46
void setRemoveDroplets(std::function< bool(const Droplet &)> removeDroplets)
Definition: DropletBoundary.h:92
void setLiquidFilmVolumeMaxFraction(double volumeFraction)
Sets the fraction of the particle volume that indicates the maximum amount of liquid a particle may h...
Definition: DropletBoundary.h:167
void setDropletSpecies(const ParticleSpecies *species)
Definition: DropletBoundary.h:105
void setLiquidFilmVolumeMaxFractionFromRadiusFraction(double radiusFraction)
Sets the fraction of the particle volume that indicates the maximum amount of liquid a particle may h...
Definition: DropletBoundary.h:176
double absorbedVolume_
Definition: DropletBoundary.h:194
void addDroplet(const Vec3D &position, const Vec3D &velocity, double radius, double liquidVolume)
Definition: DropletBoundary.h:138
void read(std::istream &is) override
Reads some boundary properties from an std::istream.
Definition: DropletBoundary.cc:192
~DropletBoundary() override
Definition: DropletBoundary.h:61
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Runs at the end of each time step.
Definition: DropletBoundary.cc:19
std::string getName() const override
A purely virtual function.
Definition: DropletBoundary.h:69
std::function< bool(const Droplet &)> removeDroplets_
Definition: DropletBoundary.h:183
unsigned checkCount
Definition: DropletBoundary.h:99
std::vector< Droplet > droplets_
Definition: DropletBoundary.h:189
void addDroplet(const Vec3D &position, const Vec3D &velocity, double radius)
Definition: DropletBoundary.h:132
void setGenerateDroplets(std::function< void(DropletBoundary &)> generateDroplets)
Definition: DropletBoundary.h:88
void writeVTK(std::fstream &file) override
Definition: DropletBoundary.cc:249
const ParticleSpecies * dropletSpecies_
Definition: DropletBoundary.h:199
void actionsBeforeTimeLoop() override
Virtual function that does something after DPMBase::setupInitialConditions but before the first time ...
Definition: DropletBoundary.h:113
Container to store pointers to all particles.
Definition: ParticleHandler.h:28
Definition: ParticleSpecies.h:16
This is a class that generates random numbers i.e. named the Random Number Generator (RNG).
Definition: RNG.h:32
Definition: Kernel/Math/Vector.h:30
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107
radius
Definition: UniformPSDSelfTest.py:15
const Mdouble pi
Definition: ExtendedMath.h:23
const Mdouble inf
Definition: GeneralDefine.h:23
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
Definition: DropletBoundary.h:33
double radius
Definition: DropletBoundary.h:39
double liquidVolume
Definition: DropletBoundary.h:40
Vec3D force
Definition: DropletBoundary.h:43
Droplet(const Vec3D &position, const Vec3D &velocity, double radius, double liquidVolume)
Definition: DropletBoundary.h:34
Vec3D velocity
Definition: DropletBoundary.h:38
Vec3D position
Definition: DropletBoundary.h:37