MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseWall.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, 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 "BaseWall.h"
27 #include "DPMBase.h"
28 #include "WallHandler.h"
30 
32 {
33  handler_ = nullptr;
34  logger(DEBUG, "BaseWall::BaseWall() finished");
35 }
36 
41  : BaseInteractable(w)
42 {
43  handler_ = w.handler_;
44  logger(DEBUG, "BaseWall::BaseWall(const BaseWall &p) finished");
45 }
46 
48 {
49  logger(DEBUG, "BaseWall::~BaseWall() finished");
50 }
51 
53 {
54  logger(WARN, "BaseWall::clear(), this function shouldn't be called");
55 }
56 
60 void BaseWall::read(std::istream& is)
61 {
63 }
64 
68 void BaseWall::write(std::ostream& os) const
69 {
71 }
72 
77 {
78  handler_ = handler;
79  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
80 }
81 
86 {
87  return handler_;
88 }
89 
93 void BaseWall::setIndSpecies(unsigned int indSpecies)
94 {
95  if(handler_!=nullptr)
96  {
97  setSpecies(getHandler()->getDPMBase()->speciesHandler.getObject(getIndSpecies()));
98  }
99  else
100  {
102  }
103 }
104 
111 {
113 
114  //set pointer to the handler, which is needed to retrieve species information
115  if (getHandler() == nullptr)
116  {
117  SpeciesHandler* sH = species->getHandler();
118  if (sH != nullptr)
119  {
120  DPMBase* dB = sH->getDPMBase();
121  if (dB != nullptr)
122  setHandler(&dB->wallHandler);
123  }
124  }
125 }
Container to store all ParticleSpecies.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual MERCURY_DEPRECATED void clear()
A function that removes all data from this BaseWall, so sets handler_ to nullptr. ...
Definition: BaseWall.cc:52
void setIndSpecies(unsigned int indSpecies)
Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase...
Definition: BaseWall.cc:93
void setHandler(WallHandler *handler)
A function which sets the WallHandler for this BaseWall.
Definition: BaseWall.cc:76
WallHandler * handler_
Definition: BaseWall.h:117
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:74
WallHandler * getHandler() const
A function which returns the WallHandler that handles this BaseWall.
Definition: BaseWall.cc:85
void setSpecies(const ParticleSpecies *species)
Sets the species of this BaseInteractable.
virtual void read(std::istream &is)=0
Reads a BaseInteractable from an input stream.
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
BaseWall()
Default constructor. It makes an empty BaseWall.
Definition: BaseWall.cc:31
Basic class for walls.
Definition: BaseWall.h:39
virtual void setIndSpecies(unsigned int indSpecies)
Sets the index of the Species of this BaseInteractable.
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:883
Container to store all BaseWall.
Definition: WallHandler.h:42
Defines the basic properties that a interactable object can have.
unsigned int getIndSpecies() const
Returns the index of the Species of this BaseInteractable.
virtual void write(std::ostream &os) const =0
Write a BaseInteractable to an output stream.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
void write(std::ostream &os) const
Function that writes a BaseWall to an output stream, usually a restart file.
Definition: BaseWall.cc:68
virtual ~BaseWall()
Default destructor.
Definition: BaseWall.cc:47
void read(std::istream &is)
Function that reads a BaseWall from an input stream, usually a restart file.
Definition: BaseWall.cc:60
void setSpecies(const ParticleSpecies *species)
Define the species of this wall.
Definition: BaseWall.cc:110