MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConstantMassFlowMaserBoundary.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 CONSTANTMASSFLOWMASERBOUNDARY_H
28 #define CONSTANTMASSFLOWMASERBOUNDARY_H
29 
30 #include <map>
31 
35 #include "Math/Vector.h"
36 #include "Particles/BaseParticle.h"
37 
38 class ParticleSpecies;
39 
96 
101  periodicBoundary);
102 
105  ConstantMassFlowMaserBoundary* copy() const override;
106 
110  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
111 
114  void read(std::istream& is) override;
115 
118  void write(std::ostream& os) const override;
119 
122  std::string getName() const override;
123 
127  void createPeriodicParticle(BaseParticle* p, ParticleHandler& pH) override;
128 
129  void createPeriodicParticles(ParticleHandler& pH) override;
130 
137 
142 
146 
150 
154  bool isMaserParticle(BaseParticle* p) const;
155 
159  bool isNormalParticle(BaseParticle* p) const;
160 
165  void actionsBeforeTimeLoop() override;
166 
170  void activateMaser();
171 
174  void closeMaser();
175 
179  bool isActivated() const;
180 
184  void turnOnCopying();
185 
189  void turnOffCopying();
190 
194  bool isCopying() const;
195 
196  Mdouble getDistanceLeft() const;
197 
198  Mdouble getDistanceRight() const;
199 
200  Mdouble getGapSize() const;
201 
202 private:
203 
207  void shiftPosition(BaseParticle* p) const;
208 
213 
219  bool isClosestToRightBoundary(const BaseParticle* const p) const
220  {
221  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
222  return (distanceRight_ - distance < distance - distanceLeft_);
223  }
224 
232  {
233  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
234  return std::min(distance - distanceLeft_, distanceRight_ - distance);
235  }
236 
241 
246 
251 
266 
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
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
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...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
double Mdouble
Definition: GeneralDefine.h:34
bool isActivated() const
Returns whether the Maser is activated or not.
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Defines a pair of periodic walls. Inherits from BaseBoundary.
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
void turnOffCopying()
Stop copying particles.
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
Variation on the PeriodicBoundary which also has an outflow part.
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Evaluates what the particles have to do after they have changed position.
bool isClosestToRightBoundary(const BaseParticle *const p) const
Returns whether the given particle is closer to the right boundary of the periodic part...
void read(std::istream &is) override
reads boundary properties from istream
bool maserIsCopying_
Flag whether or not the Maser is copying particles.
void write(std::ostream &os) const override
writes boundary properties to ostream
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Sets all boundary properties at once and adds particles of the handler to the maser.
void turnOnCopying()
Start copying particles.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
ConstantMassFlowMaserBoundary()
MaserBoundary constructor.
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
Container to store all BaseParticle.
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
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
void closeMaser()
Stops copying particles (and act merely as a chute)
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
void createPeriodicParticles(ParticleHandler &pH) override
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain...
std::string getName() const override
Returns the name of the object.
Definition: Vector.h:49
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
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 actionsBeforeTimeLoop() override
Does everything that needs to be done for this boundary between setupInitialConditions and the time l...
ConstantMassFlowMaserBoundary * copy() const override
Creates a copy of this maser on the heap.
bool isCopying() const
Returns whether the Maser is copying particles or not.