AGX Dynamics  2.35.0.1
WindAndWaterUtils.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 
70 
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:
118  Vector( agx::UInt size );
119 
120  agx::UInt size() const;
121 
122  void resize( agx::UInt size );
123 
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:
138 
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 
158  {
159  return (agx::UInt)m_data.size();
160  }
161 
163  {
164  return m_data[ i ];
165  }
166 
168  {
169  return m_data[ i ];
170  }
171 
173  {
174  agxAssert( !m_factored );
175  return m_data[ m_n * i + j ];
176  }
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
#define AGXMODEL_EXPORT
agx::Bool isFactored() const
agx::Real operator()(agx::UInt i, agx::UInt j) const
agx::Bool solve(agxModel::dense::Vector &x)
agx::RealValarray DataType
agx::Real & operator()(const agx::UInt i)
void resize(agx::UInt size)
const DataType & getData() const
Vector(agx::UInt size)
#define agxAssert(expr)
Definition: debug.h:143
#define AGX_FORCE_INLINE
Definition: macros.h:58
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
int32_t Int32
Definition: Integer.h:45
bool Bool
Definition: Integer.h:48
AGXCORE_EXPORT const Real REAL_SQRT_EPSILON
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Global triangle data (mapped with agxCollide::Mesh object) holding vertex indices.
agx::Vector< GlobalTriangleData > Container
agxModel::TriangleData::Container clipped
Container with clipped triangles if this global triangle has been clipped.
Triangle data for a normal or a clipped triangle.
agx::Int32 state
Current state of this triangle.
agx::Bool isBelowSurface() const
agx::Bool isClipped() const
agx::Vec3 worldNormal
Normal to this triangle given in world coordinate system.
agx::VectorPOD< TriangleData > Container
agx::Real area
Area of this triangle.
agx::Bool isCalculationsEnable() const
agx::Vec3 calculateNormal() const
agx::Real calculateArea() const
Vertex data for all global vertices in a mesh.
agx::Real heightFromSurface
Height from surface, negative if below the surface.
agx::VectorPOD< VertexData > Container
agx::Real pressure
Hydro- or aerostatic pressure.
agx::Vec3 worldPosition
World position of this vertex.
agx::Bool isBelowSurface() const
agx::Vec3 worldVelocityOfMedium
Velocity of the medium this vertex is in (water current or wind velocity).
agx::Vec3 worldVelocity
Velocity of this vertex given in world coordinate system.
agx::Bool isOnSurface(agx::Real threshold=agx::REAL_SQRT_EPSILON) const