[de061d] | 1 | /*
|
---|
| 2 | * vmg - a versatile multigrid solver
|
---|
| 3 | * Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
|
---|
| 4 | *
|
---|
| 5 | * vmg is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * vmg is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * @file particle.hpp
|
---|
| 21 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
---|
| 22 | * @date Sat Sep 17 14:45:56 2011
|
---|
| 23 | *
|
---|
| 24 | * @brief Class to represent a particle
|
---|
| 25 | *
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #ifndef PARTICLE_HPP_
|
---|
| 29 | #define PARTICLE_HPP_
|
---|
| 30 |
|
---|
| 31 | #include <sstream>
|
---|
| 32 | #include <string>
|
---|
| 33 |
|
---|
| 34 | #include "base/vector.hpp"
|
---|
| 35 |
|
---|
| 36 | namespace VMG
|
---|
| 37 | {
|
---|
| 38 |
|
---|
| 39 | namespace Particle
|
---|
| 40 | {
|
---|
| 41 |
|
---|
| 42 | class Particle
|
---|
| 43 | {
|
---|
| 44 | public:
|
---|
| 45 | Particle() :
|
---|
| 46 | x_(0.0),
|
---|
| 47 | f_(0.0),
|
---|
| 48 | q_(0.0),
|
---|
| 49 | p_(0.0),
|
---|
| 50 | rank_(-1),
|
---|
| 51 | index_(-1)
|
---|
| 52 | {}
|
---|
| 53 |
|
---|
| 54 | Particle(const vmg_float* x, const vmg_float& q) :
|
---|
| 55 | x_(x),
|
---|
| 56 | f_(0.0),
|
---|
| 57 | q_(q),
|
---|
| 58 | p_(0.0),
|
---|
| 59 | rank_(-1),
|
---|
| 60 | index_(-1)
|
---|
| 61 | {}
|
---|
| 62 |
|
---|
| 63 | Particle(const vmg_float* x, const vmg_float& q, const vmg_float& p, const vmg_float* f, const int& rank, const vmg_int& index) :
|
---|
| 64 | x_(x),
|
---|
| 65 | f_(f),
|
---|
| 66 | q_(q),
|
---|
| 67 | p_(p),
|
---|
| 68 | rank_(rank),
|
---|
| 69 | index_(index)
|
---|
| 70 | {}
|
---|
| 71 |
|
---|
| 72 | Particle(const Vector& x, const vmg_float& q, const vmg_float& p, const Vector& f, const int& rank, const vmg_int& index) :
|
---|
| 73 | x_(x),
|
---|
| 74 | f_(f),
|
---|
| 75 | q_(q),
|
---|
| 76 | p_(p),
|
---|
| 77 | rank_(rank),
|
---|
| 78 | index_(index)
|
---|
| 79 | {}
|
---|
| 80 |
|
---|
| 81 | Particle(const Particle& other) :
|
---|
| 82 | x_(other.x_),
|
---|
| 83 | f_(other.f_),
|
---|
| 84 | q_(other.q_),
|
---|
| 85 | p_(other.p_),
|
---|
| 86 | rank_(other.rank_),
|
---|
| 87 | index_(other.index_)
|
---|
| 88 | {}
|
---|
| 89 |
|
---|
| 90 | Vector& Pos() {return x_;}
|
---|
| 91 | const Vector& Pos() const {return x_;}
|
---|
| 92 |
|
---|
| 93 | vmg_float& Charge() {return q_;}
|
---|
| 94 | const vmg_float& Charge() const {return q_;}
|
---|
| 95 |
|
---|
| 96 | vmg_float& Pot() {return p_;}
|
---|
| 97 | const vmg_float& Pot() const {return p_;}
|
---|
| 98 |
|
---|
| 99 | Vector& Field() {return f_;}
|
---|
| 100 | const Vector& Field() const {return f_;}
|
---|
| 101 |
|
---|
| 102 | int& Rank() {return rank_;}
|
---|
| 103 | const int& Rank() const {return rank_;}
|
---|
| 104 |
|
---|
| 105 | vmg_int& Index() {return index_;}
|
---|
| 106 | const vmg_int& Index() const {return index_;}
|
---|
| 107 |
|
---|
| 108 | bool operator==(const Particle& rhs)
|
---|
| 109 | {
|
---|
| 110 | return (this->rank_ == rhs.rank_) && (this->index_ == rhs.index_);
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | bool operator!=(const Particle& rhs)
|
---|
| 114 | {
|
---|
| 115 | return (this->rank_ != rhs.rank_) || (this->index_ != rhs.index_);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | std::string ToString() const
|
---|
| 119 | {
|
---|
| 120 | std::stringstream str;
|
---|
| 121 |
|
---|
| 122 | str << "VMG::Particle::Particle {" << std::endl
|
---|
| 123 | << " Pos: " << x_ << std::endl
|
---|
| 124 | << " Charge: " << q_ << std::endl
|
---|
| 125 | << " Potential: " << p_ << std::endl
|
---|
| 126 | << " Field: " << f_ << std::endl
|
---|
| 127 | << "}";
|
---|
| 128 |
|
---|
| 129 | return str.str();
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | private:
|
---|
| 133 | Vector x_, f_;
|
---|
| 134 | vmg_float q_, p_;
|
---|
| 135 | int rank_;
|
---|
| 136 | vmg_int index_;
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 | std::ostream& operator<<(std::ostream& out, const VMG::Particle::Particle& particle);
|
---|
| 140 |
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | #endif /* PARTICLE_HPP_ */
|
---|