SubcriticalMaserBoundary.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 SUBCRITICALMASERBOUNDARY_H
6 #define SUBCRITICALMASERBOUNDARY_H
7 
8 #include <map>
9 
10 #include "Particles/BaseParticle.h"
14 #include "Math/Vector.h"
15 
16 class ParticleSpecies;
17 
56 {
57 public:
62 
66  explicit SubcriticalMaserBoundary(const PeriodicBoundary& periodicBoundary);
67 
71  SubcriticalMaserBoundary* copy() const override;
72 
77  void set(Vec3D normal, Vec3D planewiseShift, Mdouble distanceLeft, Mdouble distanceRight);
78 
83  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
84 
89  void setPlanewiseShift(Vec3D planewiseShift);
90 
95  void setShift(Vec3D shift);
96 
100  void read(std::istream& is) override;
101 
105  void write(std::ostream& os) const override;
106 
110  std::string getName() const override;
111 
117 
118  void createPeriodicParticles(ParticleHandler& pH) override;
119 
126 
131 
136 
141 
145  bool isMaserParticle(BaseParticle* p) const;
146 
150  bool isNormalParticle(BaseParticle* p) const;
151 
156  void actionsBeforeTimeLoop() override;
157 
161  void activateMaser();
162 
166  void deactivateMaser();
167 
168  Mdouble getDistanceLeft() const;
169 
170  Mdouble getDistanceRight() const;
171 
172 protected:
173 
177  void shiftPosition(BaseParticle* p) const;
178 
183 
189  bool isClosestToRightBoundary(const BaseParticle* const p) const
190  {
191  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
192  return (distanceRight_ - distance < distance - distanceLeft_);
193  }
194 
202  {
203  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
204  return std::min(distance - distanceLeft_, distanceRight_ - distance);
205  }
206 
211 
216 
221 
230 
234  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionNormalToMaser_;
235 
239  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionMaserToNormal_;
240 
245 
246 };
247 
248 #endif
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseBoundary.h:28
Definition: BaseParticle.h:33
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
Variation on the PeriodicBoundary which also has an outflow part.
Definition: SubcriticalMaserBoundary.h:56
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Definition: SubcriticalMaserBoundary.h:239
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
Definition: SubcriticalMaserBoundary.h:201
void setShift(Vec3D shift)
Sets the shift of the Maser. Usually don't use this directly, use set() or setPlanewiseShift() instea...
Definition: SubcriticalMaserBoundary.cc:85
Mdouble getDistanceLeft() const
Definition: SubcriticalMaserBoundary.cc:428
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
Definition: SubcriticalMaserBoundary.cc:363
void actionsBeforeTimeLoop() override
Does everything that needs to be done for this boundary between setupInitialConditions and the time l...
Definition: SubcriticalMaserBoundary.cc:372
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH) const
Shifts the particle to its 'periodic' position if it is a maser particle and has crossed either of th...
Definition: SubcriticalMaserBoundary.cc:249
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part.
Definition: SubcriticalMaserBoundary.h:189
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Definition: SubcriticalMaserBoundary.h:210
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
Definition: SubcriticalMaserBoundary.h:229
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
Definition: SubcriticalMaserBoundary.cc:351
void deactivateMaser()
Stops copying particles (and act merely as a chute)
Definition: SubcriticalMaserBoundary.cc:408
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: SubcriticalMaserBoundary.cc:176
Mdouble getDistanceRight() const
Definition: SubcriticalMaserBoundary.cc:433
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
Definition: SubcriticalMaserBoundary.cc:341
void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: SubcriticalMaserBoundary.cc:122
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: SubcriticalMaserBoundary.cc:51
void setPlanewiseShift(Vec3D planewiseShift)
Sets a planewise direction to the shift. Doesn't change the normal or the positions.
Definition: SubcriticalMaserBoundary.cc:79
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Definition: SubcriticalMaserBoundary.h:220
void createPeriodicParticles(ParticleHandler &pH) override
Definition: SubcriticalMaserBoundary.cc:209
SubcriticalMaserBoundary * copy() const override
Creates a copy of this maser on the heap.
Definition: SubcriticalMaserBoundary.cc:46
SubcriticalMaserBoundary()
MaserBoundary constructor.
Definition: SubcriticalMaserBoundary.cc:11
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Definition: SubcriticalMaserBoundary.h:215
void read(std::istream &is) override
reads boundary properties from istream
Definition: SubcriticalMaserBoundary.cc:94
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
Definition: SubcriticalMaserBoundary.cc:293
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Evaluates what the particles have to do after they have changed position.
Definition: SubcriticalMaserBoundary.cc:275
std::string getName() const override
Returns the name of the object.
Definition: SubcriticalMaserBoundary.cc:141
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
Definition: SubcriticalMaserBoundary.h:234
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
Definition: SubcriticalMaserBoundary.cc:384
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
Definition: SubcriticalMaserBoundary.cc:224
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
Definition: SubcriticalMaserBoundary.cc:150
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Definition: SubcriticalMaserBoundary.h:244
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