ConstantMassFlowMaserBoundary.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 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 
111  void set(Vec3D normal, Vec3D planewiseShift, Mdouble distanceLeft, Mdouble distanceRight);
112 
117  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
118 
123  void setPlanewiseShift(Vec3D planewiseShift);
124 
129  void setShift(Vec3D shift);
130 
134  void read(std::istream& is) override;
135 
138  void write(std::ostream& os) const override;
139 
142  std::string getName() const override;
143 
147  void createPeriodicParticle(BaseParticle* p, ParticleHandler& pH) override;
148 
149  void createPeriodicParticles(ParticleHandler& pH) override;
150 
157 
162 
166 
170 
174  bool isMaserParticle(BaseParticle* p) const;
175 
179  bool isNormalParticle(BaseParticle* p) const;
180 
185  void actionsBeforeTimeLoop() override;
186 
190  void activateMaser();
191 
194  void closeMaser();
195 
199  bool isActivated() const;
200 
204  void turnOnCopying();
205 
209  void turnOffCopying();
210 
214  bool isCopying() const;
215 
216  Mdouble getDistanceLeft() const;
217 
218  Mdouble getDistanceRight() const;
219 
220  Mdouble getGapSize() const;
221 
222 private:
223 
227  void shiftPosition(BaseParticle* p) const;
228 
233 
239  bool isClosestToRightBoundary(const BaseParticle* const p) const
240  {
241  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
242  return (distanceRight_ - distance < distance - distanceLeft_);
243  }
244 
252  {
253  const Mdouble distance = Vec3D::dot(p->getPosition(), normal_);
254  return std::min(distance - distanceLeft_, distanceRight_ - distance);
255  }
256 
261 
266 
271 
286 
295 
299  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionNormalToMaser_;
300 
304  std::map<const ParticleSpecies*, const ParticleSpecies*> speciesConversionMaserToNormal_;
305 
310 
315 
316 };
317 
318 #endif
Definition: BaseBoundary.h:49
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Definition: BaseParticle.h:54
Variation on the PeriodicBoundary which also has an outflow part.
Definition: ConstantMassFlowMaserBoundary.h:92
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:239
void shiftPosition(BaseParticle *p) const
Shifts the particle to its 'periodic' position.
Definition: ConstantMassFlowMaserBoundary.cc:179
Mdouble getDistance(BaseParticle *p) const
Returns the distance of the wall to the particle.
Definition: ConstantMassFlowMaserBoundary.h:251
void actionsBeforeTimeLoop() override
Does everything that needs to be done for this boundary between setupInitialConditions and the time l...
Definition: ConstantMassFlowMaserBoundary.cc:412
Mdouble distanceLeft_
position of left boundary wall, s.t. normal*x=position_left
Definition: ConstantMassFlowMaserBoundary.h:265
void addParticleToMaser(BaseParticle *p)
Converts a 'normal' particle into a maser particle.
Definition: ConstantMassFlowMaserBoundary.cc:328
BaseParticle * createGhostCopy(BaseParticle *p) const
Creates a copy of the input particle, that gets removed again in DPMBase::removeDuplicatePeriodicPart...
Definition: ConstantMassFlowMaserBoundary.cc:249
void turnOffCopying()
Stop copying particles.
Definition: ConstantMassFlowMaserBoundary.cc:494
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:274
bool isNormalParticle(BaseParticle *p) const
Returns true if the particle is a Normal particle, and false otherwise.
Definition: ConstantMassFlowMaserBoundary.cc:403
Vec3D shift_
Direction in which particles are to be shifted when they cross the boundary.
Definition: ConstantMassFlowMaserBoundary.h:294
Mdouble gapSize_
distance between the right side of the periodic domain and the start of the outflow domain.
Definition: ConstantMassFlowMaserBoundary.h:285
Mdouble distanceRight_
position of right boundary wall, s.t. normal*x=position_right
Definition: ConstantMassFlowMaserBoundary.h:270
bool maserIsActivated_
Flag whether or not the gap is created and particles transformed already.
Definition: ConstantMassFlowMaserBoundary.h:309
void removeParticleFromMaser(BaseParticle *p)
Convert a maser particle into a 'normal' particle.
Definition: ConstantMassFlowMaserBoundary.cc:377
Vec3D normal_
Normal unit vector of both maser walls. Points in the flowing direction.
Definition: ConstantMassFlowMaserBoundary.h:260
void turnOnCopying()
Start copying particles.
Definition: ConstantMassFlowMaserBoundary.cc:489
void setShift(Vec3D shift)
Sets the shift of the Maser. Usually don't use this directly, use set() or setPlanewiseShift() instea...
Definition: ConstantMassFlowMaserBoundary.cc:111
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionMaserToNormal_
List of 'maser' particles' species, and their normal counterparts.
Definition: ConstantMassFlowMaserBoundary.h:304
void read(std::istream &is) override
reads boundary properties from istream
Definition: ConstantMassFlowMaserBoundary.cc:120
bool isMaserParticle(BaseParticle *p) const
Returns true if the particle is a Maser particle, and false otherwise.
Definition: ConstantMassFlowMaserBoundary.cc:391
Mdouble getDistanceRight() const
Definition: ConstantMassFlowMaserBoundary.cc:513
void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: ConstantMassFlowMaserBoundary.cc:150
void createPeriodicParticles(ParticleHandler &pH) override
Definition: ConstantMassFlowMaserBoundary.cc:234
bool isActivated() const
Returns whether the Maser is activated or not.
Definition: ConstantMassFlowMaserBoundary.cc:484
void setPlanewiseShift(Vec3D planewiseShift)
Sets a planewise direction to the shift. Doesn't change the normal or the positions.
Definition: ConstantMassFlowMaserBoundary.cc:105
std::string getName() const override
Returns the name of the object.
Definition: ConstantMassFlowMaserBoundary.cc:170
bool isCopying() const
Returns whether the Maser is copying particles or not.
Definition: ConstantMassFlowMaserBoundary.cc:500
ConstantMassFlowMaserBoundary * copy() const override
Creates a copy of this maser on the heap.
Definition: ConstantMassFlowMaserBoundary.cc:71
void activateMaser()
Opens the gap, and transforms particles to maser particles. Also calls turnOnCopying().
Definition: ConstantMassFlowMaserBoundary.cc:425
bool maserIsCopying_
Flag whether or not the Maser is copying particles.
Definition: ConstantMassFlowMaserBoundary.h:314
std::map< const ParticleSpecies *, const ParticleSpecies * > speciesConversionNormalToMaser_
List of 'normal' particles' species, and their maser counterparts.
Definition: ConstantMassFlowMaserBoundary.h:299
ConstantMassFlowMaserBoundary()
MaserBoundary constructor.
Definition: ConstantMassFlowMaserBoundary.cc:34
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:76
Mdouble getDistanceLeft() const
Definition: ConstantMassFlowMaserBoundary.cc:508
void closeMaser()
Stops copying particles (and act merely as a chute)
Definition: ConstantMassFlowMaserBoundary.cc:459
Mdouble getGapSize() const
Definition: ConstantMassFlowMaserBoundary.cc:518
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Evaluates what the particles have to do after they have changed position.
Definition: ConstantMassFlowMaserBoundary.cc:306
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:204
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
Definition: Vector.h:51
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76