| 1 | /*
 | 
|---|
| 2 |  * detail.hpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: Jun 12, 2016
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | 
 | 
|---|
| 9 | #ifndef FRAGMENTATION_SUMMATION_SETVALUES_DETAIL_HPP_
 | 
|---|
| 10 | #define FRAGMENTATION_SUMMATION_SETVALUES_DETAIL_HPP_
 | 
|---|
| 11 | 
 | 
|---|
| 12 | // include config.h
 | 
|---|
| 13 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 14 | #include <config.h>
 | 
|---|
| 15 | #endif
 | 
|---|
| 16 | 
 | 
|---|
| 17 | #include <vector>
 | 
|---|
| 18 | 
 | 
|---|
| 19 | namespace detail {
 | 
|---|
| 20 | 
 | 
|---|
| 21 |   /** This class represents a force, i.e. a vector with three components.
 | 
|---|
| 22 |    *
 | 
|---|
| 23 |    * This is used as a specific type with the necessary summation functions
 | 
|---|
| 24 |    * for IndexedValue.
 | 
|---|
| 25 |    */
 | 
|---|
| 26 |   struct force : public std::vector<double> {
 | 
|---|
| 27 |     //!> typedef for a single vector
 | 
|---|
| 28 |     typedef std::vector<double> vector_t;
 | 
|---|
| 29 | 
 | 
|---|
| 30 |     /** Default constructor for a force vector.
 | 
|---|
| 31 |      *
 | 
|---|
| 32 |      * We assure that we have always three components.
 | 
|---|
| 33 |      */
 | 
|---|
| 34 |     force() :
 | 
|---|
| 35 |       std::vector<double>(FixedSize, 0.)
 | 
|---|
| 36 |     {}
 | 
|---|
| 37 | 
 | 
|---|
| 38 |     /** Constructor for a force vector.
 | 
|---|
| 39 |      *
 | 
|---|
| 40 |      * \param _c1 first component
 | 
|---|
| 41 |      * \param _c2 second component
 | 
|---|
| 42 |      * \param _c3 third component
 | 
|---|
| 43 |      */
 | 
|---|
| 44 |     force(const double &_c1, const double &_c2, const double &_c3);
 | 
|---|
| 45 | 
 | 
|---|
| 46 |     /** Constructor for a force vector.
 | 
|---|
| 47 |      *
 | 
|---|
| 48 |      * \param _components vector of three components
 | 
|---|
| 49 |      */
 | 
|---|
| 50 |     force(const vector_t &_components);
 | 
|---|
| 51 | 
 | 
|---|
| 52 |     /** Assignment operator for the force components.
 | 
|---|
| 53 |      *
 | 
|---|
| 54 |      * \param _c1 first component
 | 
|---|
| 55 |      * \param _c2 second component
 | 
|---|
| 56 |      * \param _c3 third component
 | 
|---|
| 57 |      */
 | 
|---|
| 58 |     force& operator()(const double &_c1, const double &_c2, const double &_c3);
 | 
|---|
| 59 | 
 | 
|---|
| 60 |     /** Assignment operator for the force components.
 | 
|---|
| 61 |      *
 | 
|---|
| 62 |      * \param _components vector of three components
 | 
|---|
| 63 |      */
 | 
|---|
| 64 |     force& operator()(const vector_t &_components);
 | 
|---|
| 65 | 
 | 
|---|
| 66 |     /** Sum operator.
 | 
|---|
| 67 |      *
 | 
|---|
| 68 |      * \param _components vector of three components
 | 
|---|
| 69 |      */
 | 
|---|
| 70 |     force& operator+=(const vector_t &_components);
 | 
|---|
| 71 | 
 | 
|---|
| 72 |     /** Subtraction operator.
 | 
|---|
| 73 |      *
 | 
|---|
| 74 |      * \param _components vector of three components
 | 
|---|
| 75 |      */
 | 
|---|
| 76 |     force& operator-=(const vector_t &_components);
 | 
|---|
| 77 | 
 | 
|---|
| 78 |     /** Summation operator for two force vectors.
 | 
|---|
| 79 |      *
 | 
|---|
| 80 |      * \param other other force vector
 | 
|---|
| 81 |      * \param prefactor prefactor to use in summation (e.g. -1 gives a subtraction)
 | 
|---|
| 82 |      */
 | 
|---|
| 83 |     void superposeOtherIndexedVectors(const force &other, const double prefactor);
 | 
|---|
| 84 | 
 | 
|---|
| 85 |     //!> fixed size of all value
 | 
|---|
| 86 |     static const size_t FixedSize;
 | 
|---|
| 87 |     //!> static instance representing a null vector
 | 
|---|
| 88 |     static const vector_t nullvector;
 | 
|---|
| 89 |   };
 | 
|---|
| 90 | };
 | 
|---|
| 91 | 
 | 
|---|
| 92 | 
 | 
|---|
| 93 | #endif /* FRAGMENTATION_SUMMATION_SETVALUES_DETAIL_HPP_ */
 | 
|---|