HeaterBoundary 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 <HeaterBoundary.h>

+ Inheritance diagram for HeaterBoundary:

Public Member Functions

 HeaterBoundary ()
 
 HeaterBoundary (const HeaterBoundary &other)
 
 ~HeaterBoundary () override
 
HeaterBoundarycopy () const override
 Used to create a copy of the object NB: purely virtual function. More...
 
void set (Vec3D posMin, Vec3D posMax, Vec3D specificHeatStrength)
 
void set2D (Vec3D posMin, Vec3D posMax, Mdouble specificHeatStrength)
 
void set3D (Vec3D posMin, Vec3D posMax, Mdouble specificHeatStrength)
 
void setStrength (Vec3D specificHeatStrength)
 
void setStrength2D (Mdouble specificHeatStrength)
 
void setStrength3D (Mdouble specificHeatStrength)
 
Mdouble getVolume () const
 Returns the volume of the HeaterBoundary cuboid. More...
 
Mdouble getDistance (const Vec3D &position) const
 Returns a negative value if and only if the position is inside the boundary (and therefore the particle to be heated). More...
 
void checkBoundaryAfterParticlesMove (ParticleHandler &pH) override
 Runs at the end of each time step. More...
 
bool checkBoundaryAfterParticleMoved (BaseParticle *p, ParticleHandler &pH)
 Checks if a given particle is inside the HeaterBoundary. If so, heats it. 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...
 
std::string getName () const 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)
 
virtual void writeVTK (std::fstream &file)
 
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
 

Private Attributes

Vec3D posMin_
 
Vec3D posMax_
 
Vec3D specificHeatStrength_
 The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic heating, take a vector proportional to (s/3, s/3, s/3). More...
 

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).

Constructor & Destructor Documentation

◆ HeaterBoundary() [1/2]

HeaterBoundary::HeaterBoundary ( )
30  : BaseBoundary()
31 {
32  posMin_ = Vec3D(0, 0, 0);
33  posMax_ = Vec3D(0, 0, 0);
34  specificHeatStrength_ = Vec3D(0, 0, 0);
35 }
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
Definition: HeaterBoundary.h:113
Vec3D posMin_
Definition: HeaterBoundary.h:107
Vec3D posMax_
Definition: HeaterBoundary.h:107
Definition: Vector.h:51

References posMax_, posMin_, and specificHeatStrength_.

Referenced by copy().

◆ HeaterBoundary() [2/2]

HeaterBoundary::HeaterBoundary ( const HeaterBoundary other)
37  : BaseBoundary(other)
38 {
39  posMin_ = other.posMin_;
40  posMax_ = other.posMax_;
42 }

References posMax_, posMin_, and specificHeatStrength_.

◆ ~HeaterBoundary()

HeaterBoundary::~HeaterBoundary ( )
override
45 {
46  logger(VERBOSE, "A HeaterBoundary has been destroyed.");
47 }
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

◆ checkBoundaryAfterParticleMoved()

bool HeaterBoundary::checkBoundaryAfterParticleMoved ( BaseParticle p,
ParticleHandler pH 
)

Checks if a given particle is inside the HeaterBoundary. If so, heats it.

Todo:
JMFT: Make a 2D version of this
132 {
133  if (!(p->isFixed()) && (getDistance(p->getPosition()) < 0))
134  {
135  // fprintf(stderr, "heating a particle\n");
136  // Mdouble noise = heatStrength_ / p->getMass() * pow(pH.getDPMBase()->getTimeStep(),0.5) ;
137  // We need a factor of sqrt(3) in front because we are generating random
138  // numbers using a uniformly distributed random variable, not a normal one.
139  Mdouble noiseX = sqrt(2. * pH.getDPMBase()->getTimeStep() * specificHeatStrength_.X);
140  Mdouble noiseY = sqrt(2. * pH.getDPMBase()->getTimeStep() * specificHeatStrength_.Y);
141  Mdouble noiseZ = sqrt(2. * pH.getDPMBase()->getTimeStep() * specificHeatStrength_.Z);
142 
143  Vec3D brownianMotion = Vec3D(
144  noiseX * pH.getDPMBase()->random.getRandomNumber(-1, 1),
145  noiseY * pH.getDPMBase()->random.getRandomNumber(-1, 1),
146  noiseZ * pH.getDPMBase()->random.getRandomNumber(-1, 1));
147  p->setVelocity(p->getVelocity() + brownianMotion);
148  }
149  return true;
150 }
double Mdouble
Definition: GeneralDefine.h:34
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:93
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1432
Mdouble getDistance(const Vec3D &position) const
Returns a negative value if and only if the position is inside the boundary (and therefore the partic...
Definition: HeaterBoundary.cc:103
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66

References getDistance(), BaseHandler< T >::getDPMBase(), BaseInteractable::getPosition(), RNG::getRandomNumber(), DPMBase::getTimeStep(), BaseInteractable::getVelocity(), BaseParticle::isFixed(), DPMBase::random, BaseInteractable::setVelocity(), specificHeatStrength_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by checkBoundaryAfterParticlesMove().

◆ checkBoundaryAfterParticlesMove()

void HeaterBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Runs at the end of each time step.

Reimplemented from BaseBoundary.

122 {
123  for (auto p = pH.begin(); p != pH.end(); ++p)
125 }
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:704
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Checks if a given particle is inside the HeaterBoundary. If so, heats it.
Definition: HeaterBoundary.cc:131

References BaseHandler< T >::begin(), checkBoundaryAfterParticleMoved(), and BaseHandler< T >::end().

◆ copy()

HeaterBoundary * HeaterBoundary::copy ( ) const
overridevirtual

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

Implements BaseBoundary.

50 {
51  return new HeaterBoundary(*this);
52 }
HeaterBoundary()
Definition: HeaterBoundary.cc:30

References HeaterBoundary().

◆ getDistance()

Mdouble HeaterBoundary::getDistance ( const Vec3D position) const

Returns a negative value if and only if the position is inside the boundary (and therefore the particle to be heated).

Todo:
JMFT: Calculate the distance properly, not just 1 or -1.
104 {
105  // std::cerr << "Checking a particle position " << position << " against " << posMin_ << " and " << posMax_ << std::endl;
106  if (posMin_.X <= position.X && position.X <= posMax_.X
107  && posMin_.Y <= position.Y && position.Y <= posMax_.Y
108  && posMin_.Z <= position.Z && position.Z <= posMax_.Z
109  )
110  {
111  // std::cerr << "Yes\n";
112  return -1;
113  }
114  else
115  {
116  // std::cerr << "No\n";
117  return 1;
118  }
119 }

References posMax_, posMin_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by checkBoundaryAfterParticleMoved().

◆ getName()

std::string HeaterBoundary::getName ( ) const
overridevirtual

Returns the object's class name (i.e. 'HeaterBoundary').

Returns
the object's class name

Implements BaseObject.

182 {
183  return "HeaterBoundary";
184 }

◆ getVolume()

Mdouble HeaterBoundary::getVolume ( ) const
inline

Returns the volume of the HeaterBoundary cuboid.

96 {
97  return ((posMax_.X - posMin_.X) * (posMax_.Y - posMin_.Y) * (posMax_.Z - posMin_.Z));
98 }

References posMax_, posMin_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

◆ read()

void HeaterBoundary::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.

157 {
158  BaseBoundary::read(is);
159  std::string dummy;
160  is >> dummy >> posMin_
161  >> dummy >> posMax_
162  >> dummy >> specificHeatStrength_;
163 }
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 posMax_, posMin_, BaseBoundary::read(), and specificHeatStrength_.

◆ set()

void HeaterBoundary::set ( Vec3D  posMin,
Vec3D  posMax,
Vec3D  specificHeatStrength 
)
55 {
56  posMin_ = posMin;
57  posMax_ = posMax;
58  setStrength(specificHeatStrength);
59 }
void setStrength(Vec3D specificHeatStrength)
Definition: HeaterBoundary.cc:76

References posMax_, posMin_, and setStrength().

◆ set2D()

void HeaterBoundary::set2D ( Vec3D  posMin,
Vec3D  posMax,
Mdouble  specificHeatStrength 
)
63 {
64  posMin_ = posMin;
65  posMax_ = posMax;
66  setStrength2D(specificHeatStrength);
67 }
void setStrength2D(Mdouble specificHeatStrength)
Definition: HeaterBoundary.cc:81

References posMax_, posMin_, and setStrength2D().

◆ set3D()

void HeaterBoundary::set3D ( Vec3D  posMin,
Vec3D  posMax,
Mdouble  specificHeatStrength 
)
70 {
71  posMin_ = posMin;
72  posMax_ = posMax;
73  setStrength3D(specificHeatStrength);
74 }
void setStrength3D(Mdouble specificHeatStrength)
Definition: HeaterBoundary.cc:88

References posMax_, posMin_, and setStrength3D().

Referenced by HeaterBoundaryTest::setupInitialConditions().

◆ setStrength()

void HeaterBoundary::setStrength ( Vec3D  specificHeatStrength)
77 {
78  specificHeatStrength_ = specificHeatStrength;
79 }

References specificHeatStrength_.

Referenced by set().

◆ setStrength2D()

void HeaterBoundary::setStrength2D ( Mdouble  specificHeatStrength)
82 {
83  specificHeatStrength_.X = specificHeatStrength / sqrt(2.);
84  specificHeatStrength_.Y = specificHeatStrength / sqrt(2.);
86 }

References specificHeatStrength_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by set2D().

◆ setStrength3D()

void HeaterBoundary::setStrength3D ( Mdouble  specificHeatStrength)
89 {
90  specificHeatStrength_.X = specificHeatStrength / sqrt(3.);
91  specificHeatStrength_.Y = specificHeatStrength / sqrt(3.);
92  specificHeatStrength_.Z = specificHeatStrength / sqrt(3.);
93 }

References specificHeatStrength_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

Referenced by set3D().

◆ write()

void HeaterBoundary::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.

170 {
172  os << " posMin " << posMin_
173  << " posMax " << posMax_
174  << " specificHeatStrength " << specificHeatStrength_;
175 }
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 posMax_, posMin_, specificHeatStrength_, and BaseBoundary::write().

Member Data Documentation

◆ posMax_

Vec3D HeaterBoundary::posMax_
private

◆ posMin_

Vec3D HeaterBoundary::posMin_
private

◆ specificHeatStrength_

Vec3D HeaterBoundary::specificHeatStrength_
private

The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic heating, take a vector proportional to (s/3, s/3, s/3).

Referenced by checkBoundaryAfterParticleMoved(), HeaterBoundary(), read(), setStrength(), setStrength2D(), setStrength3D(), and write().


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