MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseSpecies.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 "BaseSpecies.h"
27 #include "SpeciesHandler.h"
28 #include "DPMBase.h"
30 #include<cmath>
31 
32 class BaseParticle;
33 class BaseInteractable;
34 
36 : BaseObject()
37 {
38  handler_ = 0;
39 #ifdef DEBUG_CONSTRUCTOR
40  std::cout << "BaseSpecies::BaseSpecies() finished" << std::endl;
41 #endif
42 }
43 
48 : BaseObject(p)
49 {
50  handler_ = p.handler_;
51 #ifdef DEBUG_CONSTRUCTOR
52  std::cout << "BaseSpecies::BaseSpecies(const BaseSpecies &p) finished" << std::endl;
53 #endif
54 }
55 
57 {
58 #ifdef DEBUG_DESTRUCTOR
59  std::cout << "BaseSpecies::~BaseSpecies() finished" << std::endl;
60 #endif
61 }
62 
67 {
68  handler_ = handler;
69 }
70 
75 {
76  return handler_;
77 }
78 
86 {
87  //the second algorithm seems to have a better accuracy, at least for the case average(2e5,2e5)
88  //return (a + b) != 0.0 ? (2. * (a * b) / (a + b)) : 0;
89  return (a + b) != 0.0 ? (2./(1.0/a+1.0/b)) : 0.0;
90 }
91 
92 
93 
Container to store all ParticleSpecies.
BaseSpecies is the class from which all other species are derived.
Definition: BaseSpecies.h:44
virtual ~BaseSpecies()
The default destructor.
Definition: BaseSpecies.cc:56
It is an abstract base class due to the purely virtual functions declared below. Even if the function...
Definition: BaseObject.h:49
double Mdouble
SpeciesHandler * getHandler() const
Returns the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:74
SpeciesHandler * handler_
A pointer to the handler to which this species belongs. It is initialized to nullptr and gets set whe...
Definition: BaseSpecies.h:134
Mdouble average(Mdouble a, Mdouble b)
defines the average of two variables by the harmonic mean.
Definition: BaseSpecies.cc:85
void setHandler(SpeciesHandler *handler)
Sets the pointer to the handler to which this species belongs.
Definition: BaseSpecies.cc:66
BaseSpecies()
The default constructor.
Definition: BaseSpecies.cc:35
Defines the basic properties that a interactable object can have.