MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SubcriticalMaserBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 
98  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
99 
103  void read(std::istream& is) override;
104 
108  void write(std::ostream& os) const override;
109 
113  std::string getName() const override;
114 
119  void createPeriodicParticle(BaseParticle* p, ParticleHandler& pH) override;
120 
121  void createPeriodicParticles(ParticleHandler& pH) override;
122 
129 
134 
139 
144 
148  bool isMaserParticle(BaseParticle* p) const;
149 
153  bool isNormalParticle(BaseParticle* p) const;
154 
159  void actionsBeforeTimeLoop() override;
160 
164  void activateMaser();
165 
169  void deactivateMaser();
170 
171  Mdouble getDistanceLeft() const;
172 
173  Mdouble getDistanceRight() const;
174 
175 private:
176 
180  void shiftPosition(BaseParticle* p) const;
181 
186 
192  bool isClosestToRightBoundary(const BaseParticle* const p) const
193  {
194  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
195  return (distanceRight_ - distance < distance - distanceLeft_);
196  }
197 
205  {
206  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
207  return std::min(distance - distanceLeft_, distanceRight_ - distance);
208  }
209 
214 
219 
224 
231 
235  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionNormalToMaser_;
236 
240  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionMaserToNormal_;
241 
246 
247 };
248 
249 #endif
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
void actionsBeforeTimeLoop() override
Does everything that needs to be done for this boundary between setupInitialConditions and the time l...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
double Mdouble
Definition: GeneralDefine.h:34
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Variation on the PeriodicBoundary which also has an outflow part.
SubcriticalMaserBoundary()
MaserBoundary constructor.
Defines a pair of periodic walls. Inherits from BaseBoundary.
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part...
SubcriticalMaserBoundary * copy() const override
Creates a copy of this maser on the heap.
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Evaluates what the particles have to do after they have changed position.
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Sets all boundary properties at once and adds particles of the handler to the maser.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
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...
Container to store all BaseParticle.
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates periodic particles when the particle is a maser particle and is sufficiently close to one of ...
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
void write(std::ostream &os) const override
writes boundary properties to ostream
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
void read(std::istream &is) override
reads boundary properties from istream
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Definition: Vector.h:49
void deactivateMaser()
Stops copying particles (and act merely as a chute)
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
void createPeriodicParticles(ParticleHandler &pH) override
std::string getName() const override
Returns the name of the object.