MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XY.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 #ifndef XY_H
26 #define XY_H
27 
28 #include <GeneralDefine.h>
29 #include <iostream>
30 #include "Math/Vector.h"
31 #include "Base_XY_XZ_YZ.h"
32 #include <vector>
33 #include <array>
34 
35 class BaseParticle;
36 
37 class BaseInteraction;
38 
39 class DPMBase;
40 
41 namespace CGCoordinates
42 {
43 
50 class XY : public Base_XY_XZ_YZ
51 {
52 public:
53 
57  static void writeNames(std::ostream& os);
58 
62  void write(std::ostream& os) const;
63 
68  static Mdouble getVolumeOfAveragedDimensions(const Vec3D& min, const Vec3D& max);
69 
74  Mdouble getDistanceSquared(const Vec3D& p) const;
75 
79  static Mdouble getLength(const Vec3D& p);
80 
85  void setXY(Mdouble x, Mdouble y);
86 
92  Mdouble getINormal(const BaseInteraction& c, const Vec3D& normal) const;
93 
99  Mdouble getPNormal(const BaseInteraction& c, const Vec3D& normal) const;
100 
106  Mdouble getCNormal(const BaseInteraction& c, const Vec3D& normal) const;
107 
113  Mdouble getTangentialSquared(const BaseInteraction& c, Mdouble pNormal) const;
114 
115  static bool isResolvedIn(unsigned i) {return i==2?false:true;}
116 
117  static std::string getName();
118 
119 protected:
120 
129 };
130 
134 template<typename T>
135 typename std::enable_if<std::is_base_of<CGCoordinates::XY, typename T::CoordinatesType>::value, void>::type
136 spaceEvenly(Vec3D min, Vec3D max, std::vector<std::size_t> nAll, std::vector<T>& points)
137 {
138  std::size_t n0 = nAll[0];
139  std::size_t n1 = nAll[1];
140  Mdouble delta0 = (max.X - min.X) / n0;
141  Mdouble delta1 = (max.Y - min.Y) / n1;
142  Mdouble start0 = min.X + 0.5 * delta0;
143  Mdouble start1 = min.Y + 0.5 * delta1;
144  points.resize(n0 * n1);
145  for (std::size_t i = 0; i < n0; i++)
146  {
147  for (std::size_t j = 0; j < n1; j++)
148  {
149  points[i * n1 + j].coordinates.setXY(start0 + delta0 * i, start1 + delta1 * j);
150  }
151  }
152 }
153 
154 }
155 #endif
void setXY(Mdouble x, Mdouble y)
Returns the position of the current CGPoint, in the non-averaged directions.
Definition: XY.cc:48
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
Mdouble X
the vector components
Definition: Vector.h:65
Defines the non-averaged directions on which spatial coarse-graining is applied (the x- and y-directi...
Definition: XY.h:50
Mdouble y_
Definition: XY.h:128
double Mdouble
Definition: GeneralDefine.h:34
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
std::enable_if< std::is_base_of< CGCoordinates::O, typename T::CoordinatesType >::value, void >::type spaceEvenly(Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
Definition: O.h:101
Stores information about interactions between two interactable objects; often particles but could be ...
Mdouble getDistanceSquared(const Vec3D &p) const
Returns the square of the distance between the particle p and the current CGPoint, in the non-averaged directions.
Definition: XY.cc:54
Mdouble getINormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: XY.cc:69
static Mdouble getLength(const Vec3D &p)
Returns the length of the input vector in the non-averaged directions.
Definition: XY.cc:64
Mdouble Y
Definition: Vector.h:65
Mdouble x_
Definition: XY.h:124
Mdouble getCNormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: XY.cc:81
Mdouble getTangentialSquared(const BaseInteraction &c, Mdouble pNormal) const
For the Interaction between particles/walls P and I, this function returns the square of the minimum ...
Definition: XY.cc:87
static Mdouble getVolumeOfAveragedDimensions(const Vec3D &min, const Vec3D &max)
returns the factor the CGFunction has to be divided by, due to integrating the variables over the ave...
Definition: XY.cc:43
Contains common member functions of the XY, XZ, and YZ classes.
Definition: Base_XY_XZ_YZ.h:48
Definition: Vector.h:49
static bool isResolvedIn(unsigned i)
Definition: XY.h:115
static void writeNames(std::ostream &os)
Writes the coordinate names in human-readable form to an ostream.
Definition: XY.cc:32
Mdouble getPNormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: XY.cc:75
void write(std::ostream &os) const
Writes the coordinates in human-readable form to an ostream.
Definition: XY.cc:37
static std::string getName()
Definition: XY.cc:94