revision: v0.14
FluxBoundary Class Reference

Used for measuring flow rates through a given plane; acts like a pair of scales Inherits from BaseBoundary. Can measure forward, backward and net fluxes. More...

#include <FluxBoundary.h>

Inheritance diagram for FluxBoundary:

## Public Member Functions

FluxBoundary ()
default constructor More...

~FluxBoundary () override
destructor More...

FluxBoundarycopy () const override
Copy method; creates copy on the heap and returns a pointer to it. More...

void set (const Vec3D &normal, Mdouble distance)
Sets boundary position based on a normal and distance. More...

void reset ()
Resets the counts to zero. More...

void move (Mdouble position)
Sets the boundary's distance property to the given one. More...

Mdouble getDistance (const Vec3D &position) const
Returns the shortest distance between the boundary and given position. More...

void checkBoundaryAfterParticlesMove (ParticleHandler &pH) override
Runs at the end of each time step. More...

bool checkBoundaryAfterParticleMoved (BaseParticle *p, ParticleHandler &pH)
Checks if particle has crossed the boundary and updates the scales if so. More...

unsigned int getNumberOfParticlesCrossedForw () const
Gets the number of particles that have crossed the boundary. More...

unsigned int getNumberOfParticlesCrossedBack () const

unsigned int getNumberOfParticlesCrossedNet () const

double getMassOfParticlesCrossedForw () const

double getMassOfParticlesCrossedBack () const

double getMassOfParticlesCrossedNet () const

double getVolumeOfParticlesCrossedForw () const

double getVolumeOfParticlesCrossedBack () const

double getVolumeOfParticlesCrossedNet () const

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
Returns the name of the object. 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 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 normal_
outward unit normal vector More...

Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors. More...

Mdouble distance_
The boundary's distance from the origin. More...

unsigned int numberOfParticlesCrossedForw_
Number of particles that have been deleted by this boundary. More...

unsigned int numberOfParticlesCrossedBack_

double massCrossedForw_

double massCrossedBack_

double volumeCrossedForw_

double volumeCrossedBack_

## Detailed Description

Used for measuring flow rates through a given plane; acts like a pair of scales Inherits from BaseBoundary. Can measure forward, backward and net fluxes.

## ◆ FluxBoundary()

 FluxBoundary::FluxBoundary ( )

default constructor

Default constructor (calls the parent-constructor of BaseBoundary as well)

36  : BaseBoundary()
37 {
38  distance_ = std::numeric_limits<double>::quiet_NaN();
39  scaleFactor_ = std::numeric_limits<double>::quiet_NaN();
42  massCrossedForw_ = 0;
43  massCrossedBack_ = 0;
46 #ifdef DEBUG_CONSTRUCTOR
47  std::cout<<"FluxBoundary::FluxBoundary() finished"<<std::endl;
48 #endif
49 }

Referenced by copy().

## ◆ ~FluxBoundary()

 FluxBoundary::~FluxBoundary ( )
override

destructor

Destructor

55 {
56 #ifdef DEBUG_DESTRUCTOR
57  std::cout<<"FluxBoundary::~FluxBoundary() finished"<<std::endl;
58 #endif
59 }

## ◆ checkBoundaryAfterParticleMoved()

 bool FluxBoundary::checkBoundaryAfterParticleMoved ( BaseParticle * p, ParticleHandler & pH )

Checks if particle has crossed the boundary and updates the scales if so.

Checks if particle has passed the boundary, and if so, counts it.

Parameters
 [in] p pointer to the particle which is to be checked [out] pH the particle's ParticleHandler
Returns
FALSE, since the particle is not deleted by this boundary
138 {
139  if (getDistance(p->getPosition() - p->getDisplacement()) > 0 && getDistance(p->getPosition()) < 0)
140  {
142  massCrossedForw_ += p->getMass();
144  }
145  else if (getDistance(p->getPosition() - p->getDisplacement()) < 0 && getDistance(p->getPosition()) > 0)
146  {
148  massCrossedBack_ += p->getMass();
150  }
151
152  return false;
153 }

Referenced by checkBoundaryAfterParticlesMove().

## ◆ checkBoundaryAfterParticlesMove()

 void FluxBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler & pH )
overridevirtual

Runs at the end of each time step.

Reimplemented from BaseBoundary.

125 {
126  for (auto p = pH.begin(); p != pH.end(); ++p)
128 }

## ◆ copy()

 FluxBoundary * FluxBoundary::copy ( ) const
overridevirtual

Copy method; creates copy on the heap and returns a pointer to it.

Copy function, which creates a copy and returns a pointer to that copy (on the heap)

Returns
pointer to the copy

Implements BaseBoundary.

67 {
68  return new FluxBoundary(*this);
69 }

References FluxBoundary().

## ◆ getDistance()

 Mdouble FluxBoundary::getDistance ( const Vec3D & position ) const

Returns the shortest distance between the boundary and given position.

Calculates the shortest distance between the wall and given position.

Parameters
 [in] position the position of which the distance should be calculated.
120 {
121  return distance_ - Vec3D::dot(position, normal_);
122 }

References distance_, Vec3D::dot(), and normal_.

Referenced by checkBoundaryAfterParticleMoved().

## ◆ getMassOfParticlesCrossedBack()

 double FluxBoundary::getMassOfParticlesCrossedBack ( ) const
183 {
184  return massCrossedBack_ * 0.5;
185 }

References massCrossedBack_.

## ◆ getMassOfParticlesCrossedForw()

 double FluxBoundary::getMassOfParticlesCrossedForw ( ) const
168 {
169  return massCrossedForw_ * 0.5;
170 }

References massCrossedForw_.

## ◆ getMassOfParticlesCrossedNet()

 double FluxBoundary::getMassOfParticlesCrossedNet ( ) const
198 {
199  return (massCrossedForw_ - massCrossedBack_) * 0.5;
200 }

References massCrossedBack_, and massCrossedForw_.

Referenced by BoundariesSelfTest::actionsAfterTimeStep().

## ◆ getName()

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

Returns the name of the object.

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

Returns
the object's class name

Implements BaseObject.

248 {
249  return "FluxBoundary";
250 }

## ◆ getNumberOfParticlesCrossedBack()

 unsigned int FluxBoundary::getNumberOfParticlesCrossedBack ( ) const
178 {
180 }

References numberOfParticlesCrossedBack_.

## ◆ getNumberOfParticlesCrossedForw()

 unsigned int FluxBoundary::getNumberOfParticlesCrossedForw ( ) const

Gets the number of particles that have crossed the boundary.

Returns the number of particles that have crossed in either direction. All of these quantities have to be divided by two, because DPMBase.cc calls DPMBase::checkInteractionWithBoundaries() TWICE in each time step. (The intention is that the first round resolves InsertionBoundaries and the second resolves DeletionBoundaries, but this means FluxBoundaries are updated twice.)

163 {
165 }

References numberOfParticlesCrossedForw_.

## ◆ getNumberOfParticlesCrossedNet()

 unsigned int FluxBoundary::getNumberOfParticlesCrossedNet ( ) const

## ◆ getVolumeOfParticlesCrossedBack()

 double FluxBoundary::getVolumeOfParticlesCrossedBack ( ) const
188 {
189  return volumeCrossedBack_ * 0.5;
190 }

References volumeCrossedBack_.

## ◆ getVolumeOfParticlesCrossedForw()

 double FluxBoundary::getVolumeOfParticlesCrossedForw ( ) const
173 {
174  return volumeCrossedForw_ * 0.5;
175 }

References volumeCrossedForw_.

## ◆ getVolumeOfParticlesCrossedNet()

 double FluxBoundary::getVolumeOfParticlesCrossedNet ( ) const
203 {
204  return (volumeCrossedForw_ - volumeCrossedBack_) * 0.5;
205 }

References volumeCrossedBack_, and volumeCrossedForw_.

Referenced by BoundariesSelfTest::actionsAfterTimeStep().

## ◆ move()

 void FluxBoundary::move ( Mdouble distance )

Sets the boundary's distance property to the given one.

Resets the boundary's 'distance' from the origin to be the one given.

Parameters
111 {
112  distance_ = distance * scaleFactor_;
113 }

References distance_, and scaleFactor_.

 void FluxBoundary::oldRead ( std::istream & is )

the deprecated version of the read-method. Should not be used by new users!

Deprecated:
226 {
227  std::string dummy;
228  is >> dummy >> normal_ >> dummy >> scaleFactor_ >> dummy >> distance_;
229 }

References distance_, normal_, and scaleFactor_.

 void FluxBoundary::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] is the istream

Implements BaseBoundary.

212 {
214  std::string dummy;
215  is >> dummy >> normal_
216  >> dummy >> scaleFactor_
217  >> dummy >> distance_;
218 }

References distance_, normal_, BaseBoundary::read(), and scaleFactor_.

## ◆ reset()

 void FluxBoundary::reset ( )

Resets the counts to zero.

Resets the various counts to zero.

96 {
99  massCrossedForw_ = 0;
100  massCrossedBack_ = 0;
101  volumeCrossedForw_ = 0;
102  volumeCrossedBack_ = 0;
103 }

## ◆ set()

 void FluxBoundary::set ( const Vec3D & normal, Mdouble distance )

Sets boundary position based on a normal and distance.

Defines the placing of the (2D) boundary based on the given normal and distance.

Parameters
 [in] normal boundary normal vector [in] distance 'distance' between the origin and the boundary, such that the following relation is satisfied: $\mathbf{r} \cdot \mathbf{\hat{n}} = d$ in which $$\mathbf{\hat{n}}$$ and $$d$$ are the given normal vector and distance, respectively. NB: If the distance is the ACTUAL distance from the origin, the normal vector must be of UNIT LENGTH for the placing of the boundary to be done correctly.
86 {
87  scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
88  normal_ = normal * scaleFactor_;
89  distance_ = distance * scaleFactor_;
90 }

References distance_, Vec3D::dot(), normal_, and scaleFactor_.

## ◆ write()

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

Writes the boundary properties to an std::ostream.

Writes the boundary properties to an std::ostream.

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

Implements BaseBoundary.

236 {
238  os << " normal " << normal_
239  << " scaleFactor " << scaleFactor_
240  << " distance " << distance_;
241 }

References distance_, normal_, scaleFactor_, and BaseBoundary::write().

## ◆ distance_

 Mdouble FluxBoundary::distance_
private

The boundary's distance from the origin.

## ◆ massCrossedBack_

 double FluxBoundary::massCrossedBack_
private

## ◆ massCrossedForw_

 double FluxBoundary::massCrossedForw_
private

## ◆ normal_

 Vec3D FluxBoundary::normal_
private

outward unit normal vector

## ◆ numberOfParticlesCrossedBack_

 unsigned int FluxBoundary::numberOfParticlesCrossedBack_
private

## ◆ numberOfParticlesCrossedForw_

 unsigned int FluxBoundary::numberOfParticlesCrossedForw_
private

Number of particles that have been deleted by this boundary.

## ◆ scaleFactor_

 Mdouble FluxBoundary::scaleFactor_
private

This is the factor to rescale the given normal vector to a unit vectors.

NB: Not only the normal vector is rescaled by this factor, also the 'distance' from the origin of the boundary is scaled by this factor! Also, once the boundary position is set with FluxBoundary::set(), the arguments of any reset of the distance_ property (i.e. usage of FluxBoundary::move()) will be rescaled by the same factor!

## ◆ volumeCrossedBack_

 double FluxBoundary::volumeCrossedBack_
private

## ◆ volumeCrossedForw_

 double FluxBoundary::volumeCrossedForw_
private

The documentation for this class was generated from the following files:
FluxBoundary::scaleFactor_
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Definition: FluxBoundary.h:144
FluxBoundary::volumeCrossedBack_
double volumeCrossedBack_
Definition: FluxBoundary.h:158
Vec3D::dot
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
BaseBoundary::write
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
FluxBoundary::normal_
Vec3D normal_
outward unit normal vector
Definition: FluxBoundary.h:135
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:61
BaseParticle::getVolume
virtual Mdouble getVolume() const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
Definition: BaseParticle.cc:141
FluxBoundary::numberOfParticlesCrossedBack_
unsigned int numberOfParticlesCrossedBack_
Definition: FluxBoundary.h:154
FluxBoundary::getDistance
Mdouble getDistance(const Vec3D &position) const
Returns the shortest distance between the boundary and given position.
Definition: FluxBoundary.cc:119
BaseParticle::getDisplacement
const Vec3D & getDisplacement() const
Returns the particle's displacement relative to the previous time step.
Definition: BaseParticle.h:395
FluxBoundary::checkBoundaryAfterParticleMoved
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Checks if particle has crossed the boundary and updates the scales if so.
Definition: FluxBoundary.cc:137
FluxBoundary::massCrossedForw_
double massCrossedForw_
Definition: FluxBoundary.h:155
FluxBoundary::numberOfParticlesCrossedForw_
unsigned int numberOfParticlesCrossedForw_
Number of particles that have been deleted by this boundary.
Definition: FluxBoundary.h:153
FluxBoundary::distance_
Mdouble distance_
The boundary's distance from the origin.
Definition: FluxBoundary.h:148
FluxBoundary::massCrossedBack_
double massCrossedBack_
Definition: FluxBoundary.h:156
BaseHandler::begin
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
FluxBoundary::volumeCrossedForw_
double volumeCrossedForw_
Definition: FluxBoundary.h:157
FluxBoundary::FluxBoundary
FluxBoundary()
default constructor
Definition: FluxBoundary.cc:35
BaseBoundary::BaseBoundary
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
BaseParticle::getMass
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
BaseHandler::end
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
BaseInteractable::getPosition
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218