xc
ASDShellQ4LocalCoordinateSystem.h
1 /* ****************************************************************** **
2 ** OpenSees - Open System for Earthquake Engineering Simulation **
3 ** Pacific Earthquake Engineering Research Center **
4 ** **
5 ** **
6 ** (C) Copyright 1999, The Regents of the University of California **
7 ** All Rights Reserved. **
8 ** **
9 ** Commercial use of this program without express permission of the **
10 ** University of California, Berkeley, is strictly prohibited. See **
11 ** file 'COPYRIGHT' in main directory for information on usage and **
12 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
13 ** **
14 ** Developed by: **
15 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
16 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
17 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
18 ** **
19 ** ****************************************************************** */
20 
21 // $Revision: 1.10 $
22 // $Date: 2020/05/18 22:51:21 $
23 
24 // Original implementation: Massimo Petracca (ASDEA)
25 //
26 // Implementation of a local coordinate system for 4-node shells
27 //
28 
29 #ifndef ASDShellQ4LocalCoordinateSystem_h
30 #define ASDShellQ4LocalCoordinateSystem_h
31 
32 #include "ASDMath.h"
33 #include <array>
34 #include <vector>
35 
36 namespace XC {
37 
42  {
43 
44 public:
45 
47 
49 
50  typedef std::vector<Vector3Type> Vector3ContainerType;
51 
52  typedef Matrix MatrixType;
53 
54 public:
55 
57  const Vector3Type& P1global,
58  const Vector3Type& P2global,
59  const Vector3Type& P3global,
60  const Vector3Type& P4global,
61  double alpha = 0.0)
62  : m_P(4)
63  , m_orientation(3, 3)
64  {
65  // compute the central point
66  m_center = P1global;
67  m_center += P2global;
68  m_center += P3global;
69  m_center += P4global;
70  m_center *= 0.25;
71 
72  // compute the diagonal vectors
73  Vector3Type d13 = P3global - P1global;
74  Vector3Type d24 = P4global - P2global;
75 
76  // compute the Normal vector at the element center
77  // as the cross product of the 2 diagonals.
78  // While normalizing the normal vector save its norm to compute the area.
79  // Note: the norm should be divided by 2 because it's computed from the
80  // cross product of the diagonals, which gives twice the area!
81  Vector3Type e3 = d13.cross(d24);
82  m_area = e3.normalize();
83  m_area /= 2.0;
84 
85  // compute the local X direction parallel to the projection of the side 1-2 onto
86  // the local xy plane.
87  Vector3Type e1 = P2global - P1global;
88  double e1_dot_e3 = e1.dot(e3);
89  e1 -= e1_dot_e3 * e3;
90 
91  // if user defined local rotation is included...
92  if (std::abs(alpha) > 0.0)
93  QuaternionType::FromAxisAngle(e3(0), e3(1), e3(2), alpha).rotateVector(e1);
94 
95  e1.normalize();
96 
97  // finally compute the local Y direction to be orthogonal to both X and Z local directions
98  Vector3Type e2 = e3.cross(e1);
99  e2.normalize();
100 
101  // form the 3x3 transformation matrix (the transposed actually...)
102  for (int i = 0; i < 3; i++)
103  {
104  m_orientation(0, i) = e1(i);
105  m_orientation(1, i) = e2(i);
106  m_orientation(2, i) = e3(i);
107  }
108 
109  // transform global coordinates to the local coordinate system
110  for (int i = 0; i < 3; i++)
111  {
112  m_P[0](i) = m_orientation(i, 0) * (P1global(0) - m_center(0)) + m_orientation(i, 1) * (P1global(1) - m_center(1)) + m_orientation(i, 2) * (P1global(2) - m_center(2));
113  m_P[1](i) = m_orientation(i, 0) * (P2global(0) - m_center(0)) + m_orientation(i, 1) * (P2global(1) - m_center(1)) + m_orientation(i, 2) * (P2global(2) - m_center(2));
114  m_P[2](i) = m_orientation(i, 0) * (P3global(0) - m_center(0)) + m_orientation(i, 1) * (P3global(1) - m_center(1)) + m_orientation(i, 2) * (P3global(2) - m_center(2));
115  m_P[3](i) = m_orientation(i, 0) * (P4global(0) - m_center(0)) + m_orientation(i, 1) * (P4global(1) - m_center(1)) + m_orientation(i, 2) * (P4global(2) - m_center(2));
116  }
117  }
118 
119 public:
120 
121  inline const Vector3ContainerType& Nodes()const { return m_P; }
122 
123  inline const Vector3Type& P1()const { return m_P[0]; }
124  inline const Vector3Type& P2()const { return m_P[1]; }
125  inline const Vector3Type& P3()const { return m_P[2]; }
126  inline const Vector3Type& P4()const { return m_P[3]; }
127  inline const Vector3Type& Center()const { return m_center; }
128 
129  inline double X1()const { return m_P[0][0]; }
130  inline double X2()const { return m_P[1][0]; }
131  inline double X3()const { return m_P[2][0]; }
132  inline double X4()const { return m_P[3][0]; }
133 
134  inline double Y1()const { return m_P[0][1]; }
135  inline double Y2()const { return m_P[1][1]; }
136  inline double Y3()const { return m_P[2][1]; }
137  inline double Y4()const { return m_P[3][1]; }
138 
139  inline double Z1()const { return m_P[0][2]; }
140  inline double Z2()const { return m_P[1][2]; }
141  inline double Z3()const { return m_P[2][2]; }
142  inline double Z4()const { return m_P[3][2]; }
143 
144  inline double X(size_t i)const { return m_P[i][0]; }
145  inline double Y(size_t i)const { return m_P[i][1]; }
146  inline double Z(size_t i)const { return m_P[i][2]; }
147 
148  inline double Area()const { return m_area; }
149 
150  inline const MatrixType& Orientation()const { return m_orientation; }
151 
152  inline Vector3Type Vx()const { return Vector3Type(m_orientation(0, 0), m_orientation(0, 1), m_orientation(0, 2)); }
153  inline Vector3Type Vy()const { return Vector3Type(m_orientation(1, 0), m_orientation(1, 1), m_orientation(1, 2)); }
154  inline Vector3Type Vz()const { return Vector3Type(m_orientation(2, 0), m_orientation(2, 1), m_orientation(2, 2)); }
155 
156  inline double WarpageFactor()const { return Z1(); }
157  inline bool IsWarped()const { return std::abs(WarpageFactor()) > 0.0; }
158 
159  inline void ComputeTotalRotationMatrix(MatrixType& R)const
160  {
161  constexpr size_t mat_size = 24;
162  if (R.noRows() != mat_size || R.noCols() != mat_size)
163  R.resize(mat_size, mat_size);
164 
165  R.Zero();
166 
167  for (size_t k = 0; k < 8; k++)
168  {
169  size_t i = k * 3;
170  R(i, i) = m_orientation(0, 0); R(i, i + 1) = m_orientation(0, 1); R(i, i + 2) = m_orientation(0, 2);
171  R(i + 1, i) = m_orientation(1, 0); R(i + 1, i + 1) = m_orientation(1, 1); R(i + 1, i + 2) = m_orientation(1, 2);
172  R(i + 2, i) = m_orientation(2, 0); R(i + 2, i + 1) = m_orientation(2, 1); R(i + 2, i + 2) = m_orientation(2, 2);
173  }
174  }
175 
176  inline void ComputeTotalWarpageMatrix(MatrixType& W, double wf)const
177  {
178  constexpr size_t mat_size = 24;
179  if (W.noRows() != mat_size || W.noCols() != mat_size)
180  W.resize(mat_size, mat_size);
181 
182  W.Zero();
183  for (size_t i = 0; i < mat_size; i++)
184  W(i, i) = 1.0;
185 
186  W(0, 4) = -wf;
187  W(1, 3) = wf;
188 
189  W(6, 10) = wf;
190  W(7, 9) = -wf;
191 
192  W(12, 16) = -wf;
193  W(13, 15) = wf;
194 
195  W(18, 22) = wf;
196  W(19, 21) = -wf;
197  }
198 
199  inline void ComputeTotalWarpageMatrix(MatrixType& W)const
200  {
201  ComputeTotalWarpageMatrix(W, WarpageFactor());
202  }
203 
204 private:
205 
206  Vector3ContainerType m_P;
207  Vector3Type m_center;
208  MatrixType m_orientation;
209  double m_area;
210 
211 };
212 
213 template<class TStream>
214 inline static TStream& operator << (TStream& s, const ASDShellQ4LocalCoordinateSystem& lc)
215  {
216  s << "Points:\n";
217  s << "[";
218  for (size_t i = 0; i < 4; i++) {
219  s << " (" << lc.X(i) << ", " << lc.Y(i) << ") ";
220  }
221  s << "]";
222  s << "Normal: " << lc.Vz() << "\n";
223  return s;
224  }
225 } // end of XC namespace
226 
227 #endif // !ASDShellQ4LocalCoordinateSystem_h
void Zero(void)
Zero&#39;s out the Matrix.
Definition: Matrix.cpp:226
int noCols() const
Returns the number of columns, numCols, of the Matrix.
Definition: Matrix.h:273
This class represent the local coordinate system of any element whose geometry is a 4-node Quadrilate...
Definition: ASDShellQ4LocalCoordinateSystem.h:41
void rotateVector(const TVector3_A &a, TVector3_B &b) const
Rotates a vector using this quaternion.
Definition: ASDMath.h:556
T normalize()
makes this vector a unit vector.
Definition: ASDMath.h:210
T dot(const ASDVector3 &b) const
Returns the dot product this vector with another vector.
Definition: ASDMath.h:226
ASDVector3 cross(const ASDVector3 &b) const
Returns the cross product this vector with another vector.
Definition: ASDMath.h:239
int noRows() const
Returns the number of rows, numRows, of the Matrix.
Definition: Matrix.h:269
static ASDQuaternion FromAxisAngle(T x, T y, T z, T radians)
Returns a ASDQuaternion that represents a rotation of an angle &#39;radians&#39; around the axis (x...
Definition: ASDMath.h:622
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Matrix of floats.
Definition: Matrix.h:111
ASDQuaternion A simple class that implements the main features of quaternion algebra.
Definition: ASDMath.h:328