version 3.11-dev
particle.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_PARTICLES_PARTICLE_HH
13#define DUMUX_PARTICLES_PARTICLE_HH
14
15#include <dune/common/fvector.hh>
16
17namespace Dumux::Particles {
18
23template<int dimWorld, class ctype = double>
25{
26public:
27 static constexpr int coordDimension = dimWorld;
28 using CoordScalar = ctype;
29 using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>;
30
31 Particle(std::size_t id, const GlobalPosition& p, bool active = true)
32 : id_(id), position_(p), active_(active) {}
33
34 Particle(std::size_t id, bool active = true)
35 : Particle(id, GlobalPosition(0.0), active) {}
36
37 const GlobalPosition& position() const
38 { return position_; }
39
40 std::size_t id() const
41 { return id_; }
42
43 bool isActive() const
44 { return active_; }
45
47 void setPosition(const GlobalPosition& pos)
48 { position_ = pos; }
49
51 void move(const CoordScalar length, const GlobalPosition& direction)
52 { position_.axpy(length, direction); }
53
55 { active_ = false; }
56
57 void activate()
58 { active_ = true; }
59
60private:
61 std::size_t id_;
62 GlobalPosition position_;
63 bool active_;
64};
65
66} // end namespace Dumux::Particles
67
68#endif
a basic particle
Definition: particle.hh:25
bool isActive() const
Definition: particle.hh:43
Dune::FieldVector< CoordScalar, dimWorld > GlobalPosition
Definition: particle.hh:29
void setPosition(const GlobalPosition &pos)
set a new global position
Definition: particle.hh:47
const GlobalPosition & position() const
Definition: particle.hh:37
void move(const CoordScalar length, const GlobalPosition &direction)
move by length in direction
Definition: particle.hh:51
Particle(std::size_t id, bool active=true)
Definition: particle.hh:34
void activate()
Definition: particle.hh:57
ctype CoordScalar
Definition: particle.hh:28
Particle(std::size_t id, const GlobalPosition &p, bool active=true)
Definition: particle.hh:31
std::size_t id() const
Definition: particle.hh:40
static constexpr int coordDimension
Definition: particle.hh:27
void deactivate()
Definition: particle.hh:54
Definition: fokkerplanck.hh:31