MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CubeDeletionBoundary.cc
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 #include <limits>
27 
28 #include "DeletionBoundary.h"
29 #include "CubeDeletionBoundary.h"
30 #include "ParticleHandler.h"
31 #include "Particles/BaseParticle.h"
32 #include <algorithm>
33 #include "Domain.h"
34 
36 {
37  posMin_ = Vec3D(0, 0, 0);
38  posMax_ = Vec3D(0, 0, 0);
39  logger(DEBUG, "CubeDeletionBoundary::CubeDeletionBoundary() finished");
40 }
41 
43 {
44  logger(DEBUG, "CubeDeletionBoundary::~CubeDeletionBoundary() finished");
45 }
46 
48 {
49  posMin_ = posMin;
50  posMax_ = posMax;
51 }
52 
54 {
55  return new CubeDeletionBoundary(*this);
56 }
57 
62 {
63  if (posMin_.X < position.X && position.X < posMax_.X
64  && posMin_.Y < position.Y && position.Y < posMax_.Y
65  && posMin_.Z < position.Z && position.Z < posMax_.Z
66  )
67  return -1;
68  else
69  return 1;
70 }
71 
72 void CubeDeletionBoundary::read(std::istream& is)
73 {
75  std::string dummy;
76  is >> dummy >> posMin_
77  >> dummy >> posMax_;
78 }
79 
80 void CubeDeletionBoundary::write(std::ostream& os) const
81 {
83  os << " posMin " << posMin_ << " posMax " << posMax_;
84 }
85 
90 std::string CubeDeletionBoundary::getName() const
91 {
92  return "CubeDeletionBoundary";
93 }
94 
void read(std::istream &is) override
reads boundary properties from istream
Mdouble getDistance(const Vec3D &position) const override
Returns a negative value if and only if the particle is inside the boundary.
Mdouble X
the vector components
Definition: Vector.h:65
void read(std::istream &is) override
Reads some boundary properties from an std::istream.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
void set(Vec3D posMin, Vec3D posMax)
Sets boundary position based on two opposite corners.
Used for removing particles from the problem. Inherits from BaseBoundary. By default, a plane that deletes everything past it, but there are derived classes such as CubeDeletionBoundary.
Vec3D posMin_
Minimal and maximal positions defining the boundary's boundaries.
CubeDeletionBoundary * copy() const override
Copy method; creates copy on the heap and returns a pointer to it.
CubeDeletionBoundary()
default constructor
void write(std::ostream &os) const override
Writes the boundary properties to an std::ostream.
void write(std::ostream &os) const override
writes boundary properties to ostream
Mdouble Y
Definition: Vector.h:65
~CubeDeletionBoundary() override
destructor
Definition: Vector.h:49
Mdouble Z
Definition: Vector.h:65
std::string getName() const override
Returns the name of the object.