AGXDynamics  2.35.0.3
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 
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 
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
agxModel::dense::SquareMatrix::operator()
agx::Real operator()(agx::UInt i, agx::UInt j) const
Definition: WindAndWaterUtils.h:172
agx::REAL_SQRT_EPSILON
const AGXCORE_EXPORT Real REAL_SQRT_EPSILON
agxModel::TriangleData::pfrIndex
agx::UInt pfrIndex
Definition: WindAndWaterUtils.h:95
agxModel::TriangleData::worldNormal
agx::Vec3 worldNormal
Normal to this triangle given in world coordinate system.
Definition: WindAndWaterUtils.h:92
agx::Real
double Real
Definition: Real.h:42
Vector.h
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agx::Vector< GlobalTriangleData >
agxModel::VertexData::worldPosition
agx::Vec3 worldPosition
World position of this vertex.
Definition: WindAndWaterUtils.h:44
export.h
agxModel::VertexData::isOnSurface
agx::Bool isOnSurface(agx::Real threshold=agx::REAL_SQRT_EPSILON) const
Definition: WindAndWaterUtils.h:189
agxModel::VertexData
Vertex data for all global vertices in a mesh.
Definition: WindAndWaterUtils.h:34
agxModel::TriangleData::isBelowSurface
agx::Bool isBelowSurface() const
Definition: WindAndWaterUtils.h:194
agxAssert
#define agxAssert(expr)
Definition: debug.h:143
agx_valarray_types.h
agxModel::GlobalTriangleData
Global triangle data (mapped with agxCollide::Mesh object) holding vertex indices.
Definition: WindAndWaterUtils.h:101
agxModel::dense::Vector
Definition: WindAndWaterUtils.h:111
agx::VectorPOD< VertexData >
agxModel::dense::Vector::DataType
agx::RealValarray DataType
Definition: WindAndWaterUtils.h:114
agxModel::VertexData::Container
agx::VectorPOD< VertexData > Container
Definition: WindAndWaterUtils.h:36
agxModel::TriangleData::State
State
Definition: WindAndWaterUtils.h:58
agxModel::dense::Vector::operator()
agx::Real & operator()(const agx::UInt i)
Definition: WindAndWaterUtils.h:162
agxModel::GlobalTriangleData::Container
agx::Vector< GlobalTriangleData > Container
Definition: WindAndWaterUtils.h:103
Vec3.h
agxModel::VertexData::worldVelocityOfMedium
agx::Vec3 worldVelocityOfMedium
Velocity of the medium this vertex is in (water current or wind velocity).
Definition: WindAndWaterUtils.h:46
agxModel::TriangleData::state
agx::Int32 state
Current state of this triangle.
Definition: WindAndWaterUtils.h:94
agxModel::dense::Vector::size
agx::UInt size() const
Definition: WindAndWaterUtils.h:157
agxModel::TriangleData::BELOW_SURFACE
@ BELOW_SURFACE
Definition: WindAndWaterUtils.h:60
agxModel::TriangleData::Container
agx::VectorPOD< TriangleData > Container
Definition: WindAndWaterUtils.h:56
agxModel::TriangleData::CALCULATIONS_ENABLE
@ CALCULATIONS_ENABLE
Definition: WindAndWaterUtils.h:63
Convex.h
agx::RealValarray
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Definition: agx_valarray_types.h:27
agxModel::VertexData::worldVelocity
agx::Vec3 worldVelocity
Velocity of this vertex given in world coordinate system.
Definition: WindAndWaterUtils.h:45
agxModel::TriangleData::area
agx::Real area
Area of this triangle.
Definition: WindAndWaterUtils.h:93
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::Bool
bool Bool
Definition: Integer.h:48
agxModel::VertexData::pressure
agx::Real pressure
Hydro- or aerostatic pressure.
Definition: WindAndWaterUtils.h:48
agxModel::dense::SquareMatrix
Definition: WindAndWaterUtils.h:134
agxModel::TriangleData::isClipped
agx::Bool isClipped() const
Definition: WindAndWaterUtils.h:199
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agxModel::VertexData::heightFromSurface
agx::Real heightFromSurface
Height from surface, negative if below the surface.
Definition: WindAndWaterUtils.h:47
agxModel::TriangleData::isCalculationsEnable
agx::Bool isCalculationsEnable() const
Definition: WindAndWaterUtils.h:204
agx::Vec3T< Real >
agxModel::VertexData::isBelowSurface
agx::Bool isBelowSurface() const
Definition: WindAndWaterUtils.h:184
agx::Int32
int32_t Int32
Definition: Integer.h:45
agxModel::TriangleData
Triangle data for a normal or a clipped triangle.
Definition: WindAndWaterUtils.h:54
agxModel::GlobalTriangleData::clipped
agxModel::TriangleData::Container clipped
Container with clipped triangles if this global triangle has been clipped.
Definition: WindAndWaterUtils.h:106
agxModel::TriangleData::CLIPPED
@ CLIPPED
Definition: WindAndWaterUtils.h:62
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
debug.h