Molecular Dynamics Simulation  1.0
Public Member Functions | Private Attributes | List of all members
GlobalDownwardsGravity Class Reference

Class to calculate the global downwards gravity force. More...

#include <GlobalDownwardsGravity.h>

Inheritance diagram for GlobalDownwardsGravity:
Inheritance graph
Collaboration diagram for GlobalDownwardsGravity:
Collaboration graph

Public Member Functions

 GlobalDownwardsGravity (double g)
 Constructor for the GlobalDownwardsGravity class. More...
 
std::array< double, 3UL > calculateForce (Particle &p) const override
 Calculates the downwards gravity force on a particle using the given gravitational acceleration. More...
 
 operator std::string () const override
 Returns "Gravity" as name of the force. More...
 
void setGravitationalAcceleration (double g)
 Sets the gravitational acceleration. More...
 
- Public Member Functions inherited from SimpleForceSource
virtual ~SimpleForceSource ()=default
 Virtual destructor for correct cleanup of derived classes. More...
 

Private Attributes

double g
 

Detailed Description

Class to calculate the global downwards gravity force.

Definition at line 8 of file GlobalDownwardsGravity.h.

Constructor & Destructor Documentation

◆ GlobalDownwardsGravity()

GlobalDownwardsGravity::GlobalDownwardsGravity ( double  g)
explicit

Constructor for the GlobalDownwardsGravity class.

Parameters
gGravitational acceleration

Definition at line 3 of file GlobalDownwardsGravity.cpp.

Member Function Documentation

◆ calculateForce()

std::array< double, 3UL > GlobalDownwardsGravity::calculateForce ( Particle p) const
overridevirtual

Calculates the downwards gravity force on a particle using the given gravitational acceleration.

Parameters
pParticle
Returns
std::array<double, 3UL> Force vector

Implements SimpleForceSource.

Definition at line 5 of file GlobalDownwardsGravity.cpp.

5 { return {0.0, -p.getM() * g, 0.0}; }
double getM() const
Gets the mass of the particle.
Definition: Particle.h:177

◆ operator std::string()

GlobalDownwardsGravity::operator std::string ( ) const
explicitoverridevirtual

Returns "Gravity" as name of the force.

Implements SimpleForceSource.

Definition at line 7 of file GlobalDownwardsGravity.cpp.

7 { return "GlobalDownwardsGravity: g=" + std::to_string(g); }
std::string to_string(const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"})
Definition: ArrayUtils.h:97

◆ setGravitationalAcceleration()

void GlobalDownwardsGravity::setGravitationalAcceleration ( double  g)

Sets the gravitational acceleration.

Parameters
gGravitational acceleration

Definition at line 9 of file GlobalDownwardsGravity.cpp.

9 { this->g = g; }

Member Data Documentation

◆ g

double GlobalDownwardsGravity::g
private

Definition at line 10 of file GlobalDownwardsGravity.h.


The documentation for this class was generated from the following files: