SpeciesHandler.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef SPECIESHANDLER_H
6 #define SPECIESHANDLER_H
7 
8 #include "BaseHandler.h"
10 
14 class SpeciesHandler final : public BaseHandler<ParticleSpecies>
15 {
16 public:
19 
21  SpeciesHandler(const SpeciesHandler& other);
22 
25 
27  ~SpeciesHandler() override;
28 
30  void addObject(ParticleSpecies* S) override;
31 
32  void clear() override
33  {
35  mixedObjects_.clear();
36  }
37 
39  void removeObject(unsigned int index) override;
40 
42  void readAndAddObject(std::istream& is) override;
43 
45  ParticleSpecies* readOldObject(std::istream& is);
46 
48  unsigned int getMixedId(unsigned int id1, unsigned int id2) const;
49 
50  template<typename U>
52  getMixedObject(const U* S, const U* T)
53  {
54  return static_cast<typename U::MixedSpeciesType*>(getMixedObject(S->getIndex(), T->getIndex()));
55  }
56 
58  BaseSpecies* getMixedObject(unsigned int id1, unsigned int id2);
59 
61  const std::vector<BaseSpecies*>& getMixedObjects() const;
62 
64  void updateMixedObjects();
65 
67  virtual void write(std::ostream& os) const;
68 
70  std::string getName() const override;
71 
73  bool useAngularDOFs();
74 
75 private:
77  std::vector<BaseSpecies*> mixedObjects_;
78 };
79 
80 #endif
81 
Container to store the pointers to all objects that one creates in a simulation.
Definition: BaseHandler.h:30
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:536
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:29
Definition: ParticleSpecies.h:16
Container to store all ParticleSpecies.
Definition: SpeciesHandler.h:15
void updateMixedObjects()
Updates the mixed species.
Definition: SpeciesHandler.cc:986
bool useAngularDOFs()
Check if angular DOF have to be used.
Definition: SpeciesHandler.cc:1073
std::string getName() const override
Returns the name of the handler, namely the string "SpeciesHandler".
Definition: SpeciesHandler.cc:1065
void removeObject(unsigned int index) override
Remove the ParticleSpecies with given id.
Definition: SpeciesHandler.cc:1033
void clear() override
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: SpeciesHandler.h:32
SpeciesHandler & operator=(const SpeciesHandler &rhs)
Assignment operator that copies all species and the pointer to the DPMBase from the given SpeciesHand...
Definition: SpeciesHandler.cc:107
std::vector< BaseSpecies * > mixedObjects_
The list of pointers to the mixed species.
Definition: SpeciesHandler.h:77
unsigned int getMixedId(unsigned int id1, unsigned int id2) const
Gets the Id of the behaviour between two given species.
Definition: SpeciesHandler.cc:932
void addObject(ParticleSpecies *S) override
Adds a new ParticleSpecies to the SpeciesHandler.
Definition: SpeciesHandler.cc:1008
void readAndAddObject(std::istream &is) override
Reads Species data into the SpeciesHandler from restart file.
Definition: SpeciesHandler.cc:153
const std::vector< BaseSpecies * > & getMixedObjects() const
Returns a pointer to the vector of all mixed objects.
Definition: SpeciesHandler.cc:941
ParticleSpecies * readOldObject(std::istream &is)
Reads ParticleSpecies into the SpeciesHandler from old-style restart data.
Definition: SpeciesHandler.cc:854
~SpeciesHandler() override
Destructor, it destructs the SpeciesHandler and all ParticleSpecies it contains.
Definition: SpeciesHandler.cc:133
SpeciesHandler()
Default constructor, it creates an empty SpeciesHandler.
Definition: SpeciesHandler.cc:76
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:52
virtual void write(std::ostream &os) const
Write all the species and mixed species to an output stream.
Definition: SpeciesHandler.cc:1047
squared absolute value
Definition: GlobalFunctions.h:87
double U
Swimming speed.
Definition: two_d_variable_diff_adapt.cc:53
type
Definition: compute_granudrum_aor.py:141
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
@ S
Definition: quadtree.h:62