MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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).

Definition at line 49 of file HeaterBoundary.h.

Constructor & Destructor Documentation

HeaterBoundary::HeaterBoundary ( )

Definition at line 30 of file HeaterBoundary.cc.

References posMax_, posMin_, and specificHeatStrength_.

Referenced by copy().

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

Definition at line 37 of file HeaterBoundary.cc.

References posMax_, posMin_, and specificHeatStrength_.

37  : BaseBoundary(other)
38 {
39  posMin_ = other.posMin_;
40  posMax_ = other.posMax_;
42 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
HeaterBoundary::~HeaterBoundary ( )
override

Definition at line 44 of file HeaterBoundary.cc.

References logger, and VERBOSE.

45 {
46  logger(VERBOSE, "A HeaterBoundary has been destroyed.");
47 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

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

Definition at line 131 of file HeaterBoundary.cc.

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

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 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble X
the vector components
Definition: Vector.h:65
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Mdouble getDistance(const Vec3D &position) const
Returns a negative value if and only if the position is inside the boundary (and therefore the partic...
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 Y
Definition: Vector.h:65
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:1324
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
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
Mdouble Z
Definition: Vector.h:65
void HeaterBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Runs at the end of each time step.

Reimplemented from BaseBoundary.

Definition at line 121 of file HeaterBoundary.cc.

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

122 {
123  for (auto p = pH.begin(); p != pH.end(); ++p)
125 }
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
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
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Checks if a given particle is inside the HeaterBoundary. If so, heats it.
HeaterBoundary * HeaterBoundary::copy ( ) const
overridevirtual

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

Implements BaseBoundary.

Definition at line 49 of file HeaterBoundary.cc.

References HeaterBoundary().

50 {
51  return new HeaterBoundary(*this);
52 }
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.

Definition at line 103 of file HeaterBoundary.cc.

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

Referenced by checkBoundaryAfterParticleMoved().

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 }
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble Y
Definition: Vector.h:65
Mdouble Z
Definition: Vector.h:65
std::string HeaterBoundary::getName ( ) const
overridevirtual

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

Returns
the object's class name

Implements BaseObject.

Definition at line 181 of file HeaterBoundary.cc.

182 {
183  return "HeaterBoundary";
184 }
Mdouble HeaterBoundary::getVolume ( ) const
inline

Returns the volume of the HeaterBoundary cuboid.

Definition at line 95 of file HeaterBoundary.cc.

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

96 {
97  return ((posMax_.X - posMin_.X) * (posMax_.Y - posMin_.Y) * (posMax_.Z - posMin_.Z));
98 }
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble Y
Definition: Vector.h:65
Mdouble Z
Definition: Vector.h:65
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.

Definition at line 156 of file HeaterBoundary.cc.

References posMax_, posMin_, BaseBoundary::read(), and specificHeatStrength_.

157 {
158  BaseBoundary::read(is);
159  std::string dummy;
160  is >> dummy >> posMin_
161  >> dummy >> posMax_
162  >> dummy >> specificHeatStrength_;
163 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
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
void HeaterBoundary::set ( Vec3D  posMin,
Vec3D  posMax,
Vec3D  specificHeatStrength 
)

Definition at line 54 of file HeaterBoundary.cc.

References posMax_, posMin_, and setStrength().

55 {
56  posMin_ = posMin;
57  posMax_ = posMax;
58  setStrength(specificHeatStrength);
59 }
void setStrength(Vec3D specificHeatStrength)
void HeaterBoundary::set2D ( Vec3D  posMin,
Vec3D  posMax,
Mdouble  specificHeatStrength 
)

Definition at line 62 of file HeaterBoundary.cc.

References posMax_, posMin_, and setStrength2D().

63 {
64  posMin_ = posMin;
65  posMax_ = posMax;
66  setStrength2D(specificHeatStrength);
67 }
void setStrength2D(Mdouble specificHeatStrength)
void HeaterBoundary::set3D ( Vec3D  posMin,
Vec3D  posMax,
Mdouble  specificHeatStrength 
)

Definition at line 69 of file HeaterBoundary.cc.

References posMax_, posMin_, and setStrength3D().

70 {
71  posMin_ = posMin;
72  posMax_ = posMax;
73  setStrength3D(specificHeatStrength);
74 }
void setStrength3D(Mdouble specificHeatStrength)
void HeaterBoundary::setStrength ( Vec3D  specificHeatStrength)

Definition at line 76 of file HeaterBoundary.cc.

References specificHeatStrength_.

Referenced by set().

77 {
78  specificHeatStrength_ = specificHeatStrength;
79 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
void HeaterBoundary::setStrength2D ( Mdouble  specificHeatStrength)

Definition at line 81 of file HeaterBoundary.cc.

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

Referenced by set2D().

82 {
83  specificHeatStrength_.X = specificHeatStrength / sqrt(2.);
84  specificHeatStrength_.Y = specificHeatStrength / sqrt(2.);
86 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble Y
Definition: Vector.h:65
Mdouble Z
Definition: Vector.h:65
void HeaterBoundary::setStrength3D ( Mdouble  specificHeatStrength)

Definition at line 88 of file HeaterBoundary.cc.

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

Referenced by set3D().

89 {
90  specificHeatStrength_.X = specificHeatStrength / sqrt(3.);
91  specificHeatStrength_.Y = specificHeatStrength / sqrt(3.);
92  specificHeatStrength_.Z = specificHeatStrength / sqrt(3.);
93 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble Y
Definition: Vector.h:65
Mdouble Z
Definition: Vector.h:65
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.

Definition at line 169 of file HeaterBoundary.cc.

References posMax_, posMin_, specificHeatStrength_, and BaseBoundary::write().

170 {
172  os << " posMin " << posMin_
173  << " posMax " << posMax_
174  << " specificHeatStrength " << specificHeatStrength_;
175 }
Vec3D specificHeatStrength_
The specific heat strengths have units of energy (mass)^{-1} (time)^{-1) = m^2 s^{-3} For isotropic h...
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

Member Data Documentation

Vec3D HeaterBoundary::posMax_
private

Definition at line 107 of file HeaterBoundary.h.

Referenced by getDistance(), getVolume(), HeaterBoundary(), read(), set(), set2D(), set3D(), and write().

Vec3D HeaterBoundary::posMin_
private

Definition at line 107 of file HeaterBoundary.h.

Referenced by getDistance(), getVolume(), HeaterBoundary(), read(), set(), set2D(), set3D(), and write().

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

Definition at line 113 of file HeaterBoundary.h.

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


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