AGX Dynamics  2.37.2.0
WindAndWaterUtils.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXMODEL_WINDANDWATERUTILS_H
18 #define AGXMODEL_WINDANDWATERUTILS_H
19 
20 #include <agxModel/export.h>
21 
22 #include <agx/debug.h>
23 #include <agx/Vector.h>
24 #include <agx/Vec3.h>
25 #include <agx/agx_valarray_types.h>
26 
27 #include <agxCollide/Convex.h>
28 
29 namespace agxModel
30 {
35  {
37 
41  agx::Bool isBelowSurface() const;
42  agx::Bool isOnSurface( agx::Real threshold = agx::REAL_SQRT_EPSILON ) const;
43 
49  };
50 
55  {
57 
58  enum State
59  {
60  BELOW_SURFACE = 1 << 0,
61  ABOVE_SURFACE = 1 << 1,
62  CLIPPED = 1 << 2,
63  CALCULATIONS_ENABLE = 1 << 3
64  };
65 
69  agx::Real calculateArea() const;
70 
74  agx::Vec3 calculateNormal() const;
75 
79  agx::Bool isClipped() const;
80 
84  agx::Bool isBelowSurface() const;
85 
89  agx::Bool isCalculationsEnable() const;
90 
91  agxModel::VertexData vertices[ 3 ];
96  };
97 
102  {
104 
105  agx::UInt vertexIndices[ 3 ];
107  };
108 
109  namespace dense
110  {
112  {
113  public:
115 
116  public:
117  Vector();
118  Vector( agx::UInt size );
119 
120  agx::UInt size() const;
121 
122  void resize( agx::UInt size );
123 
124  DataType& getData();
125  const DataType& getData() const;
126 
127  agx::Real& operator()( const agx::UInt i );
128  const agx::Real& operator()( const agx::UInt i ) const;
129 
130  private:
131  DataType m_data;
132  };
133 
135  {
136  public:
137  SquareMatrix( agx::UInt size );
138 
139  agx::UInt getSize() const;
140  agx::Bool isFactored() const;
141  agx::Bool factorize();
143 
144  agx::Real operator()( agx::UInt i, agx::UInt j ) const;
145  agx::Real& operator()( agx::UInt i, agx::UInt j );
146 
147  private:
148  void solveL( Vector& x ) const;
149  void solveU( Vector& x ) const;
150 
151  private:
152  agx::RealValarray m_data;
153  agx::UInt m_n;
154  agx::Bool m_factored;
155  };
156 
157  AGX_FORCE_INLINE agx::UInt Vector::size() const
158  {
159  return (agx::UInt)m_data.size();
160  }
161 
162  AGX_FORCE_INLINE agx::Real& Vector::operator()( const agx::UInt i )
163  {
164  return m_data[ i ];
165  }
166 
167  AGX_FORCE_INLINE const agx::Real& Vector::operator()( const agx::UInt i ) const
168  {
169  return m_data[ i ];
170  }
171 
172  AGX_FORCE_INLINE agx::Real SquareMatrix::operator()( agx::UInt i, agx::UInt j ) const
173  {
174  agxAssert( !m_factored );
175  return m_data[ m_n * i + j ];
176  }
177  AGX_FORCE_INLINE agx::Real& SquareMatrix::operator()( agx::UInt i, agx::UInt j )
178  {
179  agxAssert( !m_factored );
180  return m_data[ m_n * i + j ];
181  }
182  }
183 
185  {
186  return heightFromSurface < agx::Real( 0 );
187  }
188 
189  AGX_FORCE_INLINE agx::Bool VertexData::isOnSurface( agx::Real threshold /* = agx::REAL_SQRT_EPSILON */ ) const
190  {
191  return heightFromSurface > -threshold && heightFromSurface < threshold;
192  }
193 
195  {
196  return (state & BELOW_SURFACE) != 0;
197  }
198 
200  {
201  return (state & CLIPPED) != 0;
202  }
203 
205  {
206  return (state & CALCULATIONS_ENABLE) != 0;
207  }
208 }
209 
210 #endif // AGXMODEL_WINDANDWATERUTILS_H
agx::Real area
Area of this triangle.
agx::Bool isClipped() const
int32_t Int32
Definition: Integer.h:45
bool Bool
Definition: Integer.h:48
agx::Bool isCalculationsEnable() const
agx::Vec3 worldPosition
World position of this vertex.
#define AGX_FORCE_INLINE
Definition: Object.h:59
Global triangle data (mapped with agxCollide::Mesh object) holding vertex indices.
agx::Bool isOnSurface(agx::Real threshold=agx::REAL_SQRT_EPSILON) const
agx::Vector< GlobalTriangleData > Container
agx::Int32 state
Current state of this triangle.
agx::VectorPOD< VertexData > Container
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
uint32_t UInt
Definition: Integer.h:34
agx::Vec3 worldNormal
Normal to this triangle given in world coordinate system.
agx::Vec3 worldVelocityOfMedium
Velocity of the medium this vertex is in (water current or wind velocity).
AGXCORE_EXPORT const Real REAL_SQRT_EPSILON
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
agx::VectorPOD< TriangleData > Container
agx::Vec3 worldVelocity
Velocity of this vertex given in world coordinate system.
agx::Bool isBelowSurface() const
#define agxAssert(expr)
Definition: debug.h:143
agx::Real heightFromSurface
Height from surface, negative if below the surface.
agx::Real pressure
Hydro- or aerostatic pressure.
agxModel::TriangleData::Container clipped
Container with clipped triangles if this global triangle has been clipped.
agx::Bool isBelowSurface() const
agx::RealValarray DataType
Vertex data for all global vertices in a mesh.
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
Triangle data for a normal or a clipped triangle.