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 Mdouble &distanceFromOrigin, const Vec3D &position) const
 Returns the shortest distance between the boundary at a given separation from the origin and given position. More...
 
Mdouble getDistance (const Vec3D &position) const
 Returns the shortest distance between the boundary and given position. More...
 
Mdouble getPreviousDistance (const Vec3D &position) const
 Returns the shortest distance between the boundary and given position as it was in the previous timestep. 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
 
void read (std::istream &is) override
 Reads some boundary properties from an std::istream. More...
 
MERCURYDPM_DEPRECATED void oldRead (std::istream &is)
 Deprecated read method. use FluxBoundary::read() instead. 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...
 
void setPrescribedDistance (std::function< Mdouble(double)> prescribedDistance)
 Sets the prescribed distance function. 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...
 
Mdouble previousDistance_
 The boundary's distance from the origin in the previous timestep). 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_
 
std::function< Mdouble(double)> prescribedDistance_
 A function which sets the distance of the boundary from the origin. More...
 

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.

Constructor & Destructor Documentation

◆ FluxBoundary()

FluxBoundary::FluxBoundary ( )

default constructor

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

15  : BaseBoundary()
16 {
17  distance_ = std::numeric_limits<double>::quiet_NaN();
18  previousDistance_ = std::numeric_limits<double>::quiet_NaN();
19  scaleFactor_ = std::numeric_limits<double>::quiet_NaN();
22  massCrossedForw_ = 0;
23  massCrossedBack_ = 0;
26  prescribedDistance_ = nullptr;
27 #ifdef DEBUG_CONSTRUCTOR
28  std::cout<<"FluxBoundary::FluxBoundary() finished"<<std::endl;
29 #endif
30 }
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:11
Mdouble previousDistance_
The boundary's distance from the origin in the previous timestep).
Definition: FluxBoundary.h:163
Mdouble distance_
The boundary's distance from the origin.
Definition: FluxBoundary.h:156
double massCrossedBack_
Definition: FluxBoundary.h:171
Mdouble scaleFactor_
This is the factor to rescale the given normal vector to a unit vectors.
Definition: FluxBoundary.h:151
unsigned int numberOfParticlesCrossedBack_
Definition: FluxBoundary.h:169
double volumeCrossedBack_
Definition: FluxBoundary.h:173
double volumeCrossedForw_
Definition: FluxBoundary.h:172
unsigned int numberOfParticlesCrossedForw_
Number of particles that have been deleted by this boundary.
Definition: FluxBoundary.h:168
std::function< Mdouble(double)> prescribedDistance_
A function which sets the distance of the boundary from the origin.
Definition: FluxBoundary.h:178
double massCrossedForw_
Definition: FluxBoundary.h:170

References distance_, massCrossedBack_, massCrossedForw_, numberOfParticlesCrossedBack_, numberOfParticlesCrossedForw_, prescribedDistance_, previousDistance_, scaleFactor_, volumeCrossedBack_, and volumeCrossedForw_.

Referenced by copy().

◆ ~FluxBoundary()

FluxBoundary::~FluxBoundary ( )
override

destructor

Destructor

36 {
37 #ifdef DEBUG_DESTRUCTOR
38  std::cout<<"FluxBoundary::~FluxBoundary() finished"<<std::endl;
39 #endif
40 }

Member Function Documentation

◆ 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]ppointer to the particle which is to be checked
[out]pHthe particle's ParticleHandler
Returns
FALSE, since the particle is not deleted by this boundary
131 {
132  if (getPreviousDistance(p->getPreviousPosition()) >= 0 && getDistance(p->getPosition()) < 0)
133  {
135  massCrossedForw_ += p->getMass();
136  volumeCrossedForw_ += p->getVolume();
137  }
138  else if (getPreviousDistance(p->getPreviousPosition()) < 0 && getDistance(p->getPosition()) >= 0)
139  {
141  massCrossedBack_ += p->getMass();
142  volumeCrossedBack_ += p->getVolume();
143  }
144 
145  return false;
146 }
float * p
Definition: Tutorial_Map_using.cpp:9
Mdouble getDistance(const Mdouble &distanceFromOrigin, const Vec3D &position) const
Returns the shortest distance between the boundary at a given separation from the origin and given po...
Definition: FluxBoundary.cc:103
Mdouble getPreviousDistance(const Vec3D &position) const
Returns the shortest distance between the boundary and given position as it was in the previous times...
Definition: FluxBoundary.h:75

References getDistance(), getPreviousDistance(), massCrossedBack_, massCrossedForw_, numberOfParticlesCrossedBack_, numberOfParticlesCrossedForw_, p, volumeCrossedBack_, and volumeCrossedForw_.

Referenced by checkBoundaryAfterParticlesMove().

◆ checkBoundaryAfterParticlesMove()

void FluxBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Runs at the end of each time step.

Reimplemented from BaseBoundary.

109 {
111  {
112  distance_ = prescribedDistance_(getHandler()->getDPMBase()->getTime());
113  }
114 
115  for (auto p = pH.begin(); p != pH.end(); ++p)
117 
118  // Set the current distance as previous distance for the next timestep
120 }
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:122
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:698
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:712
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Checks if particle has crossed the boundary and updates the scales if so.
Definition: FluxBoundary.cc:130

References BaseHandler< T >::begin(), checkBoundaryAfterParticleMoved(), distance_, BaseHandler< T >::end(), BaseBoundary::getHandler(), p, prescribedDistance_, and previousDistance_.

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

48 {
49  return new FluxBoundary(*this);
50 }
FluxBoundary()
default constructor
Definition: FluxBoundary.cc:14

References FluxBoundary().

◆ getDistance() [1/2]

Mdouble FluxBoundary::getDistance ( const Mdouble distanceFromOrigin,
const Vec3D position 
) const

Returns the shortest distance between the boundary at a given separation from the origin and given position.

104 {
105  return distanceFromOrigin - Vec3D::dot(position, normal_);
106 }
Vec3D normal_
outward unit normal vector
Definition: FluxBoundary.h:141
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56

References Vec3D::dot(), and normal_.

Referenced by checkBoundaryAfterParticleMoved(), getDistance(), and getPreviousDistance().

◆ getDistance() [2/2]

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

Returns the shortest distance between the boundary and given position.

Parameters
[in]positionthe position of which the distance should be calculated.
66  {
67  return getDistance(distance_, position);
68  }

References distance_, and getDistance().

◆ getMassOfParticlesCrossedBack()

double FluxBoundary::getMassOfParticlesCrossedBack ( ) const

◆ getMassOfParticlesCrossedForw()

double FluxBoundary::getMassOfParticlesCrossedForw ( ) const

◆ getMassOfParticlesCrossedNet()

double FluxBoundary::getMassOfParticlesCrossedNet ( ) const
188 {
190 }

References massCrossedBack_, and massCrossedForw_.

Referenced by BoundariesSelfTest::actionsAfterTimeStep(), and main().

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

256 {
257  return "FluxBoundary";
258 }

◆ getNumberOfParticlesCrossedBack()

unsigned int FluxBoundary::getNumberOfParticlesCrossedBack ( ) const

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

153 {
155 }

References numberOfParticlesCrossedForw_.

Referenced by FluxAndPeriodicBoundarySelfTest::actionsAfterTimeStep(), FluxBoundarySelfTest::actionsAfterTimeStep(), and main().

◆ getNumberOfParticlesCrossedNet()

unsigned int FluxBoundary::getNumberOfParticlesCrossedNet ( ) const

◆ getPreviousDistance()

Mdouble FluxBoundary::getPreviousDistance ( const Vec3D position) const
inline

Returns the shortest distance between the boundary and given position as it was in the previous timestep.

Parameters
[in]positionthe position of which the distance should be calculated.
76  {
77  return getDistance(previousDistance_, position);
78  }

References getDistance(), and previousDistance_.

Referenced by checkBoundaryAfterParticleMoved().

◆ getVolumeOfParticlesCrossedBack()

double FluxBoundary::getVolumeOfParticlesCrossedBack ( ) const

◆ getVolumeOfParticlesCrossedForw()

double FluxBoundary::getVolumeOfParticlesCrossedForw ( ) const

◆ getVolumeOfParticlesCrossedNet()

double FluxBoundary::getVolumeOfParticlesCrossedNet ( ) const

◆ 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
[in]distancethe new 'distance' between boundary and origin. see also comments of FluxBoundary::set().
93 {
94  distance_ = distance * scaleFactor_;
95 }

References distance_, and scaleFactor_.

◆ oldRead()

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

Deprecated read method. use FluxBoundary::read() instead.

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

Deprecated:
Should be gone by Mercury 2.0. Use FluxBoundary::read() instead.
227 {
228  std::string dummy;
229  is >> dummy >> normal_ >> dummy >> scaleFactor_ >> dummy >> distance_;
230 }
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References distance_, normal_, scaleFactor_, and oomph::Global_string_for_annotation::string().

◆ read()

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]isthe istream

Implements BaseBoundary.

207 {
208  BaseBoundary::read(is);
209  std::string dummy;
210  bool hadPrescribedDistance;
211  is >> dummy >> normal_
212  >> dummy >> scaleFactor_
213  >> dummy >> distance_
214  >> dummy >> previousDistance_
215  >> dummy >> hadPrescribedDistance;
216 
217  if (hadPrescribedDistance)
218  logger(WARN, "FluxBoundary had described distance. The function can not be read from the restart file. Make sure you set it again.");
219 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ WARN
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:40

References distance_, logger, normal_, previousDistance_, BaseBoundary::read(), scaleFactor_, oomph::Global_string_for_annotation::string(), and WARN.

◆ reset()

void FluxBoundary::reset ( )

Resets the counts to zero.

Resets the various counts to zero.

References massCrossedBack_, massCrossedForw_, numberOfParticlesCrossedBack_, numberOfParticlesCrossedForw_, volumeCrossedBack_, and volumeCrossedForw_.

◆ 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]normalboundary 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.
67 {
70  distance_ = distance * scaleFactor_;
72 }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65

References distance_, Vec3D::dot(), WallFunction::normal(), normal_, previousDistance_, scaleFactor_, and sqrt().

Referenced by BoundariesSelfTest::BoundariesSelfTest(), FluxAndPeriodicBoundarySelfTest::FluxAndPeriodicBoundarySelfTest(), FluxBoundarySelfTest::FluxBoundarySelfTest(), FluxBoundaryPrescribedDistanceUnitTest::setupInitialConditions(), and FluxBoundaryUnitTest::setupInitialConditions().

◆ setPrescribedDistance()

void FluxBoundary::setPrescribedDistance ( std::function< Mdouble(double)>  prescribedDistance)

Sets the prescribed distance function.

198 {
199  prescribedDistance_ = prescribedDistance;
200 }

References prescribedDistance_.

Referenced by FluxBoundaryPrescribedDistanceUnitTest::setupInitialConditions().

◆ 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]osthe ostream the properties are to be written to.

Implements BaseBoundary.

237 {
239  os << " normal " << normal_
240  << " scaleFactor " << scaleFactor_
241  << " distance " << distance_
242  << " previousDistance " << previousDistance_;
243  os << " prescribedDistance ";
245  os << true;
246  else
247  os << false;
248 
249 }
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:49

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

Member Data Documentation

◆ distance_

Mdouble FluxBoundary::distance_
private

The boundary's distance from the origin.

Referenced by checkBoundaryAfterParticlesMove(), FluxBoundary(), getDistance(), move(), oldRead(), read(), set(), and write().

◆ massCrossedBack_

◆ massCrossedForw_

◆ normal_

Vec3D FluxBoundary::normal_
private

outward unit normal vector

Referenced by getDistance(), oldRead(), read(), set(), and write().

◆ numberOfParticlesCrossedBack_

◆ numberOfParticlesCrossedForw_

unsigned int FluxBoundary::numberOfParticlesCrossedForw_
private

Number of particles that have been deleted by this boundary.

Referenced by checkBoundaryAfterParticleMoved(), FluxBoundary(), getNumberOfParticlesCrossedForw(), getNumberOfParticlesCrossedNet(), and reset().

◆ prescribedDistance_

std::function<Mdouble(double)> FluxBoundary::prescribedDistance_
private

A function which sets the distance of the boundary from the origin.

Referenced by checkBoundaryAfterParticlesMove(), FluxBoundary(), setPrescribedDistance(), and write().

◆ previousDistance_

Mdouble FluxBoundary::previousDistance_
private

The boundary's distance from the origin in the previous timestep).

This is necessary to catch transitions from particles, if the Boundary is moving

Referenced by checkBoundaryAfterParticlesMove(), FluxBoundary(), getPreviousDistance(), read(), set(), and write().

◆ 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!

Referenced by FluxBoundary(), move(), oldRead(), read(), set(), and write().

◆ volumeCrossedBack_

◆ volumeCrossedForw_


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