DropletBoundary Class Reference

Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a random velocity at each time step to each particle therein, increasing the granular temperature (velocity variance). More...

#include <DropletBoundary.h>

+ Inheritance diagram for DropletBoundary:

Classes

struct  Droplet
 

Public Member Functions

 DropletBoundary ()
 
 DropletBoundary (const DropletBoundary &other)
 
 ~DropletBoundary () override
 
DropletBoundarycopy () const override
 Used to create a copy of the object NB: purely virtual function. More...
 
std::string getName () const override
 A purely virtual function. More...
 
void checkBoundaryAfterParticlesMove (ParticleHandler &pH) override
 Runs at the end of each time step. More...
 
void read (std::istream &is) override
 Reads some boundary properties from an std::istream. More...
 
void write (std::ostream &os) const override
 Writes the boundary properties to an std::ostream. More...
 
void setGenerateDroplets (std::function< void(DropletBoundary &)> generateDroplets)
 
void writeVTK (std::fstream &file) override
 
void setRemoveDropletsAtWalls (bool removeDroplets)
 
void setDropletSpecies (const ParticleSpecies *species)
 
void actionsBeforeTimeLoop () override
 Virtual function that does something after DPMBase::setupInitialConditions but before the first time step. More...
 
- Public Member Functions inherited from BaseBoundary
 BaseBoundary ()
 default constructor. More...
 
 BaseBoundary (const BaseBoundary &b)
 copy constructor More...
 
 ~BaseBoundary () override
 destructor More...
 
virtual void createPeriodicParticle (BaseParticle *p UNUSED, ParticleHandler &pH UNUSED)
 Creates a periodic particle in case of periodic boundaries in serial build. More...
 
virtual void createPeriodicParticles (ParticleHandler &pH UNUSED)
 Creates periodic copies of given particle in case of periodic boundaries. More...
 
virtual void checkBoundaryBeforeTimeStep (DPMBase *md)
 Virtual function that does things before each time step. More...
 
virtual void modifyGhostAfterCreation (BaseParticle *particle, int i)
 
void setHandler (BoundaryHandler *handler)
 Sets the boundary's BoundaryHandler. More...
 
BoundaryHandlergetHandler () const
 Returns the boundary's BoundaryHandler. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Public Attributes

std::vector< Dropletdroplets_
 
double dropletVolume = 0
 
double absorbedVolume = 0
 
double lostVolume = 0
 
unsigned checkCount = 3
 

Private Attributes

std::function< void(DropletBoundary &)> generateDroplets_ = [] (DropletBoundary&) {}
 
bool removeDropletsAtWalls_ = true
 
const ParticleSpeciesdropletSpecies_ = nullptr
 

Detailed Description

Supplies a 'constant heat flux' to a cuboidal region (specified by two corner points) by adding a random velocity at each time step to each particle therein, increasing the granular temperature (velocity variance).

Note, you need to create a species for the droplets that has liquidVolumeMax-0, or the contact happens at a non-zero distance

Constructor & Destructor Documentation

◆ DropletBoundary() [1/2]

DropletBoundary::DropletBoundary ( )
inline
54 {}

Referenced by copy().

◆ DropletBoundary() [2/2]

DropletBoundary::DropletBoundary ( const DropletBoundary other)
inline
56  {
57  droplets_ = other.droplets_;
61  }
std::function< void(DropletBoundary &)> generateDroplets_
Definition: DropletBoundary.h:50
bool removeDropletsAtWalls_
Definition: DropletBoundary.h:124
std::vector< Droplet > droplets_
Definition: DropletBoundary.h:38
const ParticleSpecies * dropletSpecies_
Definition: DropletBoundary.h:125

References droplets_, dropletSpecies_, generateDroplets_, and removeDropletsAtWalls_.

◆ ~DropletBoundary()

DropletBoundary::~DropletBoundary ( )
inlineoverride
63  {
64  logger(VERBOSE, "A DropletBoundary has been destroyed.");
65  }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ VERBOSE

References logger, and VERBOSE.

Member Function Documentation

◆ actionsBeforeTimeLoop()

void DropletBoundary::actionsBeforeTimeLoop ( )
inlineoverridevirtual

Virtual function that does something after DPMBase::setupInitialConditions but before the first time step.

Can be used to perform actions before the time loop, but after setupInitialConditions.

Reimplemented from BaseBoundary.

108  {
109  // When no droplet species were set, use the last species from the handler.
110  // This is fine for when the droplets are removed at the walls, if not, a warning is shown.
111  if (!dropletSpecies_)
112  {
115  logger(WARN, "DropletBoundary: Droplets should repel from wall, but no droplet species was set. Using last species from the species handler instead.");
116  }
117 
118  // When droplets should repel from the wall, it requires to be checked every time step.
120  checkCount = 1;
121  }
@ WARN
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:143
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
unsigned checkCount
Definition: DropletBoundary.h:97

References checkCount, dropletSpecies_, BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseHandler< T >::getLastObject(), logger, removeDropletsAtWalls_, DPMBase::speciesHandler, and WARN.

◆ checkBoundaryAfterParticlesMove()

void DropletBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Runs at the end of each time step.

Reimplemented from BaseBoundary.

8 {
9  MercuryBase* dpm = dynamic_cast<MercuryBase*>(getHandler()->getDPMBase());
10  logger.assert_always(dpm,"You can only run DropletBoundary with Mercury2D or Mercury3D, not DPMBase");
11  // generate new droplets
12  generateDroplets_(*this);
13  // integrate Newtons equation of motion
14  Vec3D g = dpm->getGravity();
15  double dt = dpm->getTimeStep();
16  for (auto& d : droplets_) {
18  d.velocity += dt * (d.force + m * g) / m;
19  d.force.setZero();
20  d.position += dt*d.velocity;
21  }
22  // check for interaction with particles; this is costly, so we only do iit every 50 time steps
23  if (dpm->getNumberOfTimeSteps()%checkCount==0) {
25  p.setSpecies(dropletSpecies_);
26  for (auto &d : droplets_) {
27  p.setPosition(d.position);
28  p.setVelocity(d.velocity);
29  p.setRadius(d.radius);
30  auto q = dpm->hGridFindParticleContacts(&p);
31  if (q.size() > 0) {
32  double liquidVolume = std::pow(2.0 * d.radius, 3) * constants::pi / 6.0;
33  for (auto particle : q) {
34  // should that be a static cast?
35  auto lfp = static_cast<LiquidFilmParticle *>(particle);
36  lfp->addLiquidVolume(liquidVolume/q.size());
37  }
38  absorbedVolume += liquidVolume;
39  dropletVolume -= liquidVolume;
40  d.radius = 0;
41  }
42  // check for interactions with walls
43  for (BaseWall* w : dpm->wallHandler) {
44  //Checks if the particle is interacting with the current wall
46  // if there is a wall interacting with the droplet
47  if (i != nullptr) {
49  //set droplet radius to zero
50  double liquidVolume = std::pow(2.0 * d.radius, 3) * constants::pi / 6.0;
51  lostVolume += liquidVolume;
52  dropletVolume -= liquidVolume;
53  d.radius = 0;
54  } else {
55  // For some reason the species have to be set here, otherwise the force is always 0.
56  i->setSpecies(dropletSpecies_);
57  i->computeForce();
58  d.force += i->getForce();
59  }
60  }
61  }
62  }
63  // erase all droplets of radius 0
64  droplets_.erase(std::remove_if(droplets_.begin(), droplets_.end(),
65  [](const Droplet &d) { return d.radius == 0; }), droplets_.end());
66  }
67 }
double Mdouble
Definition: GeneralDefine.h:34
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Basic class for walls.
Definition: BaseWall.h:49
BaseInteraction * getInteractionWith(BaseParticle *p, unsigned timeStamp, InteractionHandler *interactionHandler) override
Returns the interaction between this wall and a given particle, nullptr if there is no interaction.
Definition: BaseWall.cc:367
unsigned int getNumberOfTimeSteps() const
Returns the current counter of time-steps, i.e. the number of time-steps that the simulation has unde...
Definition: DPMBase.cc:824
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1467
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1391
double dropletVolume
Definition: DropletBoundary.h:41
double lostVolume
Definition: DropletBoundary.h:45
double absorbedVolume
Definition: DropletBoundary.h:43
Definition: LiquidFilmParticle.h:36
void addLiquidVolume(Mdouble liquidVolume)
Definition: LiquidFilmParticle.h:113
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:126
virtual std::vector< BaseParticle * > hGridFindParticleContacts(const BaseParticle *obj)=0
Purely virtual function that returns all particles that have a contact with a given particle.
Mdouble getMassFromRadius(Mdouble radius) const
Definition: ParticleSpecies.cc:123
Definition: Vector.h:51
const Mdouble pi
Definition: ExtendedMath.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References absorbedVolume, LiquidFilm< Particle >::addLiquidVolume(), checkCount, droplets_, dropletSpecies_, dropletVolume, generateDroplets_, BaseHandler< T >::getDPMBase(), DPMBase::getGravity(), BaseBoundary::getHandler(), BaseWall::getInteractionWith(), ParticleSpecies::getMassFromRadius(), DPMBase::getNumberOfTimeSteps(), DPMBase::getTimeStep(), MercuryBase::hGridFindParticleContacts(), constants::i, DPMBase::interactionHandler, logger, lostVolume, constants::pi, removeDropletsAtWalls_, and DPMBase::wallHandler.

◆ copy()

DropletBoundary* DropletBoundary::copy ( ) const
inlineoverridevirtual

Used to create a copy of the object NB: purely virtual function.

Implements BaseBoundary.

67  {
68  return new DropletBoundary(*this);
69  }
DropletBoundary()
Definition: DropletBoundary.h:54

References DropletBoundary().

◆ getName()

std::string DropletBoundary::getName ( ) const
inlineoverridevirtual

A purely virtual function.

Implements BaseObject.

71  {
72  return "DropletBoundary";
73  }

◆ read()

void DropletBoundary::read ( std::istream &  is)
overridevirtual

Reads some boundary properties from an std::istream.

Reads a number of boundary properties from the given std::istream.

Parameters
[in,out]isthe istream

Implements BaseBoundary.

74 {
76  std::string dummy;
77  size_t n;
78  Vec3D position, velocity;
79  double radius;
80  is >> dummy >> checkCount;
81  is >> dummy >> n;
82  droplets_.reserve(n);
83  droplets_.resize(0);
84  for (int i = 0; i < n; ++i) {
85  is >> position >> velocity >> radius;
86  droplets_.emplace_back(Droplet{position,velocity,radius});
87  }
88 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
void read(std::istream &is) override=0
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:61

References checkCount, droplets_, constants::i, n, and BaseBoundary::read().

◆ setDropletSpecies()

void DropletBoundary::setDropletSpecies ( const ParticleSpecies species)
inline
103  {
104  dropletSpecies_ = species;
105  }

References dropletSpecies_.

◆ setGenerateDroplets()

void DropletBoundary::setGenerateDroplets ( std::function< void(DropletBoundary &)>  generateDroplets)
inline

◆ setRemoveDropletsAtWalls()

void DropletBoundary::setRemoveDropletsAtWalls ( bool  removeDroplets)
inline
99  {
100  removeDropletsAtWalls_ = removeDroplets;
101  }

References removeDropletsAtWalls_.

◆ write()

void DropletBoundary::write ( std::ostream &  os) const
overridevirtual

Writes the boundary properties to an std::ostream.

Writes the boundary properties to an std::ostream.

Parameters
[out]osthe ostream the properties are to be written to.

Implements BaseBoundary.

95 {
97  os << " checkCount " << checkCount;
98  os << " n " << droplets_.size();
99  for (auto& d : droplets_) {
100  os << " " << d.position;
101  os << " " << d.velocity;
102  os << " " << d.radius;
103  }
104 }
void write(std::ostream &os) const override=0
Adds object's id_ to given ostream NB: purely virtual function, overriding the version of BaseObject.
Definition: BaseBoundary.cc:70

References checkCount, droplets_, and BaseBoundary::write().

◆ writeVTK()

void DropletBoundary::writeVTK ( std::fstream &  file)
overridevirtual

Reimplemented from BaseBoundary.

106  {
107  file << "<Piece NumberOfPoints=\"" << droplets_.size() << "\" NumberOfCells=\"" << 0 << "\">\n";
108  file << "<Points>\n";
109  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
110  for (const auto& d : droplets_) file << '\t' << (float)d.position.X << ' ' << (float)d.position.Y << ' ' << (float)d.position.Z << '\n';
111  file << " </DataArray>\n";
112  file << "</Points>\n";
113  file << "<PointData Vectors=\"vector\">\n";
114  file << " <DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"ascii\">\n";
115  for (const auto& d : droplets_) file << '\t' << (float)d.velocity.X << ' ' << (float)d.velocity.Y << ' ' << (float)d.velocity.Z << '\n';
116  file << " </DataArray>\n";
117  file << " <DataArray type=\"Float32\" Name=\"Radius\" format=\"ascii\">\n";
118  for (const auto& d : droplets_) file << '\t' << (float)d.radius << '\n';
119  file << " </DataArray>\n";
120  file << "</PointData>\n";
121 }

References droplets_.

Member Data Documentation

◆ absorbedVolume

double DropletBoundary::absorbedVolume = 0

◆ checkCount

unsigned DropletBoundary::checkCount = 3

◆ droplets_

◆ dropletSpecies_

const ParticleSpecies* DropletBoundary::dropletSpecies_ = nullptr
private

◆ dropletVolume

double DropletBoundary::dropletVolume = 0

◆ generateDroplets_

std::function<void(DropletBoundary&)> DropletBoundary::generateDroplets_ = [] (DropletBoundary&) {}
private

◆ lostVolume

double DropletBoundary::lostVolume = 0

◆ removeDropletsAtWalls_

bool DropletBoundary::removeDropletsAtWalls_ = true
private

The documentation for this class was generated from the following files: