SubcriticalMaserBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 
27 #ifndef SUBCRITICALMASERBOUNDARY_H
28 #define SUBCRITICALMASERBOUNDARY_H
29 
30 #include <map>
31 
32 #include "Particles/BaseParticle.h"
36 #include "Math/Vector.h"
37 
38 class ParticleSpecies;
39 
78 {
79 public:
84 
88  explicit SubcriticalMaserBoundary(const PeriodicBoundary& periodicBoundary);
89 
93  SubcriticalMaserBoundary* copy() const override;
94 
99  void set(Vec3D normal, Vec3D planewiseShift, Mdouble distanceLeft, Mdouble distanceRight);
100 
105  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
106 
111  void setPlanewiseShift(Vec3D planewiseShift);
112 
117  void setShift(Vec3D shift);
118 
122  void read(std::istream& is) override;
123 
127  void write(std::ostream& os) const override;
128 
132  std::string getName() const override;
133 
138  void createPeriodicParticle(BaseParticle* p, ParticleHandler& pH) override;
139 
140  void createPeriodicParticles(ParticleHandler& pH) override;
141 
148 
153 
158 
163 
167  bool isMaserParticle(BaseParticle* p) const;
168 
172  bool isNormalParticle(BaseParticle* p) const;
173 
178  void actionsBeforeTimeLoop() override;
179 
183  void activateMaser();
184 
188  void deactivateMaser();
189 
190  Mdouble getDistanceLeft() const;
191 
192  Mdouble getDistanceRight() const;
193 
194 protected:
195 
199  void shiftPosition(BaseParticle* p) const;
200 
205 
211  bool isClosestToRightBoundary(const BaseParticle* const p) const
212  {
213  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
214  return (distanceRight_ - distance < distance - distanceLeft_);
215  }
216 
224  {
225  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
226  return std::min(distance - distanceLeft_, distanceRight_ - distance);
227  }
228 
233 
238 
243 
252 
256  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionNormalToMaser_;
257 
261  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionMaserToNormal_;
262 
267 
268 };
269 
270 #endif
Definition: BaseBoundary.h:49
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Definition: BaseParticle.h:54
Container to store all BaseParticle.
Definition: ParticleHandler.h:48
Definition: ParticleSpecies.h:37
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
Variation on the PeriodicBoundary which also has an outflow part.
Definition: SubcriticalMaserBoundary.h:78
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Definition: SubcriticalMaserBoundary.h:261
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
Definition: SubcriticalMaserBoundary.h:223
void setShift(Vec3D shift)
Sets the shift of the Maser. Usually don't use this directly, use set() or setPlanewiseShift() instea...
Definition: SubcriticalMaserBoundary.cc:107
Mdouble getDistanceLeft() const
Definition: SubcriticalMaserBoundary.cc:450
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
Definition: SubcriticalMaserBoundary.cc:385
void actionsBeforeTimeLoop() override
Does everything that needs to be done for this boundary between setupInitialConditions and the time l...
Definition: SubcriticalMaserBoundary.cc:394
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:271
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:211
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Definition: SubcriticalMaserBoundary.h:232
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
Definition: SubcriticalMaserBoundary.h:251
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
Definition: SubcriticalMaserBoundary.cc:373
void deactivateMaser()
Stops copying particles (and act merely as a chute)
Definition: SubcriticalMaserBoundary.cc:430
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:198
Mdouble getDistanceRight() const
Definition: SubcriticalMaserBoundary.cc:455
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
Definition: SubcriticalMaserBoundary.cc:363
void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: SubcriticalMaserBoundary.cc:144
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:73
void setPlanewiseShift(Vec3D planewiseShift)
Sets a planewise direction to the shift. Doesn't change the normal or the positions.
Definition: SubcriticalMaserBoundary.cc:101
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Definition: SubcriticalMaserBoundary.h:242
void createPeriodicParticles(ParticleHandler &pH) override
Definition: SubcriticalMaserBoundary.cc:231
SubcriticalMaserBoundary * copy() const override
Creates a copy of this maser on the heap.
Definition: SubcriticalMaserBoundary.cc:68
SubcriticalMaserBoundary()
MaserBoundary constructor.
Definition: SubcriticalMaserBoundary.cc:33
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Definition: SubcriticalMaserBoundary.h:237
void read(std::istream &is) override
reads boundary properties from istream
Definition: SubcriticalMaserBoundary.cc:116
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
Definition: SubcriticalMaserBoundary.cc:315
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Evaluates what the particles have to do after they have changed position.
Definition: SubcriticalMaserBoundary.cc:297
std::string getName() const override
Returns the name of the object.
Definition: SubcriticalMaserBoundary.cc:163
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
Definition: SubcriticalMaserBoundary.h:256
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
Definition: SubcriticalMaserBoundary.cc:406
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
Definition: SubcriticalMaserBoundary.cc:246
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
Definition: SubcriticalMaserBoundary.cc:172
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Definition: SubcriticalMaserBoundary.h:266
Definition: Vector.h:51
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76