MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 
- 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 actionsBeforeTimeLoop ()
 Virtual function that does something after DPMBase::setupInitialConditions but before the first 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_
 

Private Attributes

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

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

Definition at line 25 of file DropletBoundary.h.

Constructor & Destructor Documentation

DropletBoundary::DropletBoundary ( )
inline

Definition at line 44 of file DropletBoundary.h.

Referenced by copy().

44 {}
DropletBoundary::DropletBoundary ( const DropletBoundary other)
inline

Definition at line 46 of file DropletBoundary.h.

References droplets_, and generateDroplets_.

46  {
47  droplets_ = other.droplets_;
49  }
std::vector< Droplet > droplets_
std::function< void(DropletBoundary &)> generateDroplets_
DropletBoundary::~DropletBoundary ( )
inlineoverride

Definition at line 51 of file DropletBoundary.h.

References logger, and VERBOSE.

51  {
52  logger(VERBOSE, "A DropletBoundary has been destroyed.");
53  }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

void DropletBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Runs at the end of each time step.

Reimplemented from BaseBoundary.

Definition at line 7 of file DropletBoundary.cc.

References LiquidFilmParticle::addLiquidVolume(), droplets_, generateDroplets_, BaseHandler< T >::getDPMBase(), DPMBase::getGravity(), BaseBoundary::getHandler(), BaseHandler< T >::getLastObject(), DPMBase::getNumberOfTimeSteps(), DPMBase::getTimeStep(), MercuryBase::hGridFindParticleContacts(), logger, constants::pi, BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), and DPMBase::speciesHandler.

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 // logger(INFO,"Droplets: %",droplets_.size());
14  // integrate Newtons equation of motion
15  Vec3D g = dpm->getGravity();
16  double dt = dpm->getTimeStep();
17  for (auto& d : droplets_) {
18  d.velocity += dt*g;
19  d.position += dt*d.velocity;
20  }
21  // check for interaction with particles; this is costly, so we only do iit every 50 time steps
22  if (dpm->getNumberOfTimeSteps()%50==0) {
25  for (auto &d : droplets_) {
26  p.setPosition(d.position);
27  p.setRadius(d.radius);
28  auto q = dpm->hGridFindParticleContacts(&p);
29  if (q.size() > 0) {
30  double liquidVolume = std::pow(d.radius, 3) * constants::pi / 6.0 / q.size();
31  for (auto particle : q) {
32  auto lfp = static_cast<LiquidFilmParticle *>(particle);
33  lfp->addLiquidVolume(liquidVolume);
34  }
35  d.radius = 0;
36  }
37 
38  }
39  droplets_.erase(std::remove_if(droplets_.begin(), droplets_.end(),
40  [](const Droplet &d) { return d.radius == 0; }), droplets_.end());
41  }
42 }
void addLiquidVolume(Mdouble liquidVolume)
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
std::vector< Droplet > droplets_
void setSpecies(const ParticleSpecies *species)
std::function< void(DropletBoundary &)> generateDroplets_
virtual std::vector< BaseParticle * > hGridFindParticleContacts(const BaseParticle *obj)=0
Purely virtual function that returns all particles that have a contact with a given particle...
This is the base class for both Mercury2D and Mercury3D. Note the actually abstract grid is defined i...
Definition: MercuryBase.h:125
const Mdouble pi
Definition: ExtendedMath.h:45
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:813
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1351
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1319
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
Definition: Vector.h:49
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1211
DropletBoundary* DropletBoundary::copy ( ) const
inlineoverridevirtual

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

Implements BaseBoundary.

Definition at line 55 of file DropletBoundary.h.

References DropletBoundary().

55  {
56  return new DropletBoundary(*this);
57  }
std::string DropletBoundary::getName ( ) const
inlineoverridevirtual

A purely virtual function.

Implements BaseObject.

Definition at line 59 of file DropletBoundary.h.

59  {
60  return "DropletBoundary";
61  }
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.

Definition at line 48 of file DropletBoundary.cc.

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

49 {
51  std::string dummy;
52  size_t n;
53  Vec3D position, velocity;
54  double radius;
55  is >> dummy >> n;
56  droplets_.reserve(n);
57  droplets_.resize(0);
58  for (int i = 0; i < n; ++i) {
59  is >> position >> velocity >> radius;
60  droplets_.emplace_back(Droplet{position,velocity,radius});
61  }
62 }
std::vector< Droplet > droplets_
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
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
Definition: Vector.h:49
void DropletBoundary::setGenerateDroplets ( std::function< void(DropletBoundary &)>  generateDroplets)
inline

Definition at line 78 of file DropletBoundary.h.

References generateDroplets_.

78  {
79  generateDroplets_=generateDroplets;
80  }
std::function< void(DropletBoundary &)> generateDroplets_
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.

Definition at line 68 of file DropletBoundary.cc.

References droplets_, and BaseBoundary::write().

69 {
71  os << " n " << droplets_.size();
72  for (auto& d : droplets_) {
73  os << " " << d.position;
74  os << " " << d.velocity;
75  os << " " << d.radius;
76  }
77 }
std::vector< Droplet > droplets_
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
void DropletBoundary::writeVTK ( std::fstream &  file)
overridevirtual

Reimplemented from BaseBoundary.

Definition at line 79 of file DropletBoundary.cc.

References droplets_.

79  {
80  file << "<Piece NumberOfPoints=\"" << droplets_.size() << "\" NumberOfCells=\"" << 0 << "\">\n";
81  file << "<Points>\n";
82  file << " <DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">\n";
83  for (const auto& d : droplets_) file << '\t' << d.position << '\n';
84  file << " </DataArray>\n";
85  file << "</Points>\n";
86  file << "<PointData Vectors=\"vector\">\n";
87  file << " <DataArray type=\"Float32\" Name=\"Velocity\" NumberOfComponents=\"3\" format=\"ascii\">\n";
88  for (const auto& d : droplets_) file << '\t' << d.velocity << '\n';
89  file << " </DataArray>\n";
90  file << " <DataArray type=\"Float32\" Name=\"Radius\" format=\"ascii\">\n";
91  for (const auto& d : droplets_) file << '\t' << d.radius << '\n';
92  file << " </DataArray>\n";
93  file << "</PointData>\n";
94 }
std::vector< Droplet > droplets_

Member Data Documentation

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

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