ConstantMassFlowMaserBoundary.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef CONSTANTMASSFLOWMASERBOUNDARY_H
6 #define CONSTANTMASSFLOWMASERBOUNDARY_H
7 
8 #include <map>
9 
13 #include "Math/Vector.h"
14 #include "Particles/BaseParticle.h"
15 
16 class ParticleSpecies;
17 
74 
79  periodicBoundary);
80 
83  ConstantMassFlowMaserBoundary* copy() const override;
84 
89  void set(Vec3D normal, Vec3D planewiseShift, Mdouble distanceLeft, Mdouble distanceRight);
90 
95  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
96 
101  void setPlanewiseShift(Vec3D planewiseShift);
102 
107  void setShift(Vec3D shift);
108 
112  void read(std::istream& is) override;
113 
116  void write(std::ostream& os) const override;
117 
120  std::string getName() const override;
121 
126 
127  void createPeriodicParticles(ParticleHandler& pH) override;
128 
135 
140 
144 
148 
152  bool isMaserParticle(BaseParticle* p) const;
153 
157  bool isNormalParticle(BaseParticle* p) const;
158 
163  void actionsBeforeTimeLoop() override;
164 
168  void activateMaser();
169 
172  void closeMaser();
173 
177  bool isActivated() const;
178 
182  void turnOnCopying();
183 
187  void turnOffCopying();
188 
192  bool isCopying() const;
193 
194  Mdouble getDistanceLeft() const;
195 
196  Mdouble getDistanceRight() const;
197 
198  Mdouble getGapSize() const;
199 
200 private:
201 
205  void shiftPosition(BaseParticle* p) const;
206 
211 
217  bool isClosestToRightBoundary(const BaseParticle* const p) const
218  {
219  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
220  return (distanceRight_ - distance < distance - distanceLeft_);
221  }
222 
230  {
231  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
232  return std::min(distance - distanceLeft_, distanceRight_ - distance);
233  }
234 
239 
244 
249 
264 
273 
277  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionNormalToMaser_;
278 
282  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionMaserToNormal_;
283 
288 
293 
294 };
295 
296 #endif
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseBoundary.h:28
Definition: BaseParticle.h:33
Variation on the PeriodicBoundary which also has an outflow part.
Definition: ConstantMassFlowMaserBoundary.h:70
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part.
Definition: ConstantMassFlowMaserBoundary.h:217
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
Definition: ConstantMassFlowMaserBoundary.cc:157
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
Definition: ConstantMassFlowMaserBoundary.h:229
void actionsBeforeTimeLoop() override
Does everything that needs to be done for this boundary between setupInitialConditions and the time l...
Definition: ConstantMassFlowMaserBoundary.cc:390
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Definition: ConstantMassFlowMaserBoundary.h:243
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
Definition: ConstantMassFlowMaserBoundary.cc:306
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
Definition: ConstantMassFlowMaserBoundary.cc:227
void turnOffCopying()
Stop copying particles.
Definition: ConstantMassFlowMaserBoundary.cc:472
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH)
Shifts the particle to its 'periodic' position if it is a maser particle and has crossed either of th...
Definition: ConstantMassFlowMaserBoundary.cc:252
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
Definition: ConstantMassFlowMaserBoundary.cc:381
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
Definition: ConstantMassFlowMaserBoundary.h:272
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain.
Definition: ConstantMassFlowMaserBoundary.h:263
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Definition: ConstantMassFlowMaserBoundary.h:248
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Definition: ConstantMassFlowMaserBoundary.h:287
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
Definition: ConstantMassFlowMaserBoundary.cc:355
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Definition: ConstantMassFlowMaserBoundary.h:238
void turnOnCopying()
Start copying particles.
Definition: ConstantMassFlowMaserBoundary.cc:467
void setShift(Vec3D shift)
Sets the shift of the Maser. Usually don't use this directly, use set() or setPlanewiseShift() instea...
Definition: ConstantMassFlowMaserBoundary.cc:89
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Definition: ConstantMassFlowMaserBoundary.h:282
void read(std::istream &is) override
reads boundary properties from istream
Definition: ConstantMassFlowMaserBoundary.cc:98
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
Definition: ConstantMassFlowMaserBoundary.cc:369
Mdouble getDistanceRight() const
Definition: ConstantMassFlowMaserBoundary.cc:491
void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: ConstantMassFlowMaserBoundary.cc:128
void createPeriodicParticles(ParticleHandler &pH) override
Definition: ConstantMassFlowMaserBoundary.cc:212
bool isActivated() const
Returns whether the Maser is activated or not.
Definition: ConstantMassFlowMaserBoundary.cc:462
void setPlanewiseShift(Vec3D planewiseShift)
Sets a planewise direction to the shift. Doesn't change the normal or the positions.
Definition: ConstantMassFlowMaserBoundary.cc:83
std::string getName() const override
Returns the name of the object.
Definition: ConstantMassFlowMaserBoundary.cc:148
bool isCopying() const
Returns whether the Maser is copying particles or not.
Definition: ConstantMassFlowMaserBoundary.cc:478
ConstantMassFlowMaserBoundary * copy() const override
Creates a copy of this maser on the heap.
Definition: ConstantMassFlowMaserBoundary.cc:49
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
Definition: ConstantMassFlowMaserBoundary.cc:403
bool maserIsCopying_
Flag whether or not the Maser is copying particles.
Definition: ConstantMassFlowMaserBoundary.h:292
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
Definition: ConstantMassFlowMaserBoundary.h:277
ConstantMassFlowMaserBoundary()
MaserBoundary constructor.
Definition: ConstantMassFlowMaserBoundary.cc:12
void set(Vec3D normal, Vec3D planewiseShift, Mdouble distanceLeft, Mdouble distanceRight)
Sets all boundary properties at once and adds particles of the handler to the maser....
Definition: ConstantMassFlowMaserBoundary.cc:54
Mdouble getDistanceLeft() const
Definition: ConstantMassFlowMaserBoundary.cc:486
void closeMaser()
Stops copying particles (and act merely as a chute)
Definition: ConstantMassFlowMaserBoundary.cc:437
Mdouble getGapSize() const
Definition: ConstantMassFlowMaserBoundary.cc:496
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Evaluates what the particles have to do after they have changed position.
Definition: ConstantMassFlowMaserBoundary.cc:284
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates periodic particles when the particle is a maser particle and is sufficiently close to one of ...
Definition: ConstantMassFlowMaserBoundary.cc:182
Container to store pointers to all particles.
Definition: ParticleHandler.h:28
Definition: ParticleSpecies.h:16
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:20
Definition: Kernel/Math/Vector.h:30
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:56
#define min(a, b)
Definition: datatypes.h:22
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286