Chaste  Build::
DimensionalChastePoint.hpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4  All rights reserved.
5 
6  University of Oxford means the Chancellor, Masters and Scholars of the
7  University of Oxford, having an administrative office at Wellington
8  Square, Oxford OX1 2JD, UK.
9 
10  This file is part of Chaste.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34  */
35 
36 #ifndef DIMENSIONALCHASTEPOINT_HPP_
37 #define DIMENSIONALCHASTEPOINT_HPP_
38 
39 #include <vector>
40 #include "ChasteSerialization.hpp"
41 #include "SmartPointers.hpp"
42 #include "UblasVectorInclude.hpp"
43 #include "UnitCollection.hpp"
44 #include "BaseUnits.hpp"
45 
50 template<unsigned DIM>
52 {
57 
63  template<class Archive>
64  void serialize(Archive & ar, const unsigned int version)
65  {
66  ar & mReferenceLength;
67  ar & mLocation;
68  ar & mIndex;
69  }
70 
71 protected:
72 
76  c_vector<double, DIM> mLocation;
77 
84  units::quantity<unit::length> mReferenceLength;
85 
89  unsigned mIndex;
90 
91 public:
92 
101  DimensionalChastePoint(double x= 0.0, double y = 0.0, double z = 0.0, units::quantity<unit::length> referenceLength = 1.e-6*unit::metres);
102 
108  DimensionalChastePoint(c_vector<double, DIM> coords, units::quantity<unit::length> referenceLength);
109 
117  static boost::shared_ptr<DimensionalChastePoint<DIM> > Create(double x, double y, double z, units::quantity<unit::length> referenceLength);
118 
124  static boost::shared_ptr<DimensionalChastePoint<DIM> > Create(c_vector<double, DIM> coords, units::quantity<unit::length> referenceLength);
125 
129  virtual ~DimensionalChastePoint();
130 
136  units::quantity<unit::length> GetDistance(const DimensionalChastePoint<DIM>& rLocation) const;
137 
142  unsigned GetIndex();
143 
150 
155  units::quantity<unit::length> GetNorm2();
156 
161  units::quantity<unit::length> GetReferenceLengthScale() const;
162 
168  c_vector<double, DIM> GetLocation(units::quantity<unit::length> scale);
169 
175  const c_vector<double, DIM> GetLocation(units::quantity<unit::length> scale) const;
176 
181  c_vector<double, DIM> GetUnitVector() const;
182 
188  c_vector<double, DIM> GetUnitTangent(const DimensionalChastePoint<DIM>& rLocation) const;
189 
195  bool IsCoincident(const DimensionalChastePoint<DIM>& rLocation) const;
196 
203  DimensionalChastePoint<DIM>& operator/=(double factor);
204 
211  DimensionalChastePoint<DIM>& operator*=(double factor);
212 
220 
228 
235  void RotateAboutAxis(c_vector<double, 3> axis, double angle);
236 
243  void SetReferenceLengthScale(units::quantity<unit::length> lenthScale);
244 
249  void SetIndex(unsigned index);
250 
256 
262 
263 };
264 
272 template<unsigned DIM>
273 inline DimensionalChastePoint<DIM> operator/(DimensionalChastePoint<DIM> lhs, double factor)
274 {
275  lhs /= factor;
276  return lhs;
277 }
278 
286 template<unsigned DIM>
287 inline DimensionalChastePoint<DIM> operator*(DimensionalChastePoint<DIM> lhs, double factor)
288 {
289  lhs *= factor;
290  return lhs;
291 }
292 
300 template<unsigned DIM>
302 {
303  lhs += rLocation;
304  return lhs;
305 }
306 
314 template<unsigned DIM>
316 {
317  lhs -= rLocation;
318  return lhs;
319 }
320 
321 #endif /*DIMENSIONALCHASTEPOINT_HPP_*/
DimensionalChastePoint(double x=0.0, double y=0.0, double z=0.0, units::quantity< unit::length > referenceLength=1.e-6 *unit::metres)
c_vector< double, DIM > GetUnitTangent(const DimensionalChastePoint< DIM > &rLocation) const
DimensionalChastePoint< DIM > & operator-=(const DimensionalChastePoint< DIM > &rLocation)
bool IsCoincident(const DimensionalChastePoint< DIM > &rLocation) const
void serialize(Archive &ar, const unsigned int version)
units::quantity< unit::length > GetReferenceLengthScale() const
DimensionalChastePoint< DIM > GetMidPoint(const DimensionalChastePoint< DIM > &rLocation) const
units::quantity< unit::length > GetDistance(const DimensionalChastePoint< DIM > &rLocation) const
DimensionalChastePoint< DIM > & operator*=(double factor)
void TranslateTo(DimensionalChastePoint< DIM > rPoint)
c_vector< double, DIM > GetUnitVector() const
friend class boost::serialization::access
c_vector< double, DIM > GetLocation(units::quantity< unit::length > scale)
units::quantity< unit::length > mReferenceLength
void RotateAboutAxis(c_vector< double, 3 > axis, double angle)
units::quantity< unit::length > GetNorm2()
void SetReferenceLengthScale(units::quantity< unit::length > lenthScale)
static boost::shared_ptr< DimensionalChastePoint< DIM > > Create(double x, double y, double z, units::quantity< unit::length > referenceLength)
DimensionalChastePoint< DIM > & operator/=(double factor)
void Translate(DimensionalChastePoint< DIM > rVector)
c_vector< double, DIM > mLocation
DimensionalChastePoint< DIM > & operator+=(const DimensionalChastePoint< DIM > &rLocation)