AGX Dynamics  2.37.3.2
AddedMassDb.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_ADDEDMASSDB_H
18 #define AGXMODEL_ADDEDMASSDB_H
19 
20 #include <agxModel/export.h>
21 
22 #include <agx/Vec6.h>
23 #include <agx/agx_valarray_types.h>
24 
25 #include <agxCollide/Mesh.h>
26 
29 #include <agxStream/InputArchive.h>
30 
31 namespace agxModel
32 {
33  namespace dense
34  {
36  {
37  public:
39 
40  public:
41  Vector();
42  Vector( agx::UInt size );
43 
44  agx::UInt size() const;
45 
46  void resize( agx::UInt size );
47 
48  DataType& getData();
49  const DataType& getData() const;
50 
51  agx::Real& operator()( const agx::UInt i );
52  const agx::Real& operator()( const agx::UInt i ) const;
53 
54  private:
55  DataType m_data;
56  };
57 
59  {
60  public:
61  SquareMatrix( agx::UInt size );
62 
63  agx::UInt getSize() const;
64  agx::Bool isFactored() const;
65  agx::Bool factorize();
67 
68  agx::Real operator()( agx::UInt i, agx::UInt j ) const;
69  agx::Real& operator()( agx::UInt i, agx::UInt j );
70 
71  private:
72  void solveL( Vector& x ) const;
73  void solveU( Vector& x ) const;
74 
75  private:
76  agx::RealValarray m_data;
77  agx::UInt m_n;
78  agx::Bool m_factored;
79  };
80 
82  {
83  return (agx::UInt)m_data.size();
84  }
85 
87  {
88  return m_data[ i ];
89  }
90 
92  {
93  return m_data[ i ];
94  }
95 
97  {
98  agxAssert( !m_factored );
99  return m_data[ m_n * i + j ];
100  }
102  {
103  agxAssert( !m_factored );
104  return m_data[ m_n * i + j ];
105  }
106  }
107 
109 
114  {
115  public:
120 
121  public:
126  static agxModel::AddedMassStorage::Identifier createIdentifier( const agx::String& name );
127 
132 
133  public:
138  {
139  Report( agx::Bool validIn, agx::Real executionTimeIn ) : valid( validIn ), executionTime( executionTimeIn ) {}
142  };
143 
144  public:
148  agxModel::AddedMassStorage::Report create( const agxCollide::Mesh* mesh, const agx::Vec3& localCenterOfMassPosition );
149 
154 
159 
163  agx::Bool equals( const agxModel::AddedMassStorage* other, agx::Real threshold = agx::Real( 0 ) ) const;
164 
168  const agxModel::AddedMassStorage::PhiContainer& getFlowData() const;
169 
173  const agxModel::AddedMassStorage::NormalTangentContainer& getNormalTangentData() const;
174 
178  agxModel::AddedMassStorage::Identifier getIdentifier() const;
179 
180  protected:
181  friend class AddedMassDb;
186 
190  virtual ~AddedMassStorage();
191 
195  void allocate( agx::UInt numElements );
196 
197  private:
198  PhiContainer m_phi;
199  NormalTangentContainer m_normalsTangents;
200  Identifier m_id;
201  };
202 
204 
209  {
210  public:
219  static agxModel::AddedMassStorageRef createStorage( const agxModel::WindAndWaterParameters* parameters,
221 
222  public:
226  AddedMassDb();
227 
233 
241  agxModel::AddedMassStorage* getOrCreateStorage( const agx::String& filename, const agxModel::WindAndWaterParameters* parameters );
242 
247  agxModel::AddedMassStorage* load( const agx::String& filename );
248 
253  agx::Bool save( agxModel::AddedMassStorage* storage, const agx::String& filename );
254 
258  virtual void store( agxStream::OutputArchive& out ) const;
259 
263  virtual void restore( agxStream::InputArchive& in );
264 
265  protected:
267 
268  protected:
272  virtual ~AddedMassDb();
273 
274  private:
275  AddedMassStorageContainer m_storage;
276  };
277 
279 
281 }
282 
283 #endif // AGXMODEL_ADDEDMASSDB_H
agx::ref_ptr< AddedMassStorage > AddedMassStorageRef
Definition: AddedMassDb.h:203
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
Report from creation, store and restore.
Definition: AddedMassDb.h:137
agx::Real operator()(agx::UInt i, agx::UInt j) const
Definition: AddedMassDb.h:96
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Definition: Mesh.h:69
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive...
bool Bool
Definition: Integer.h:48
agx::HashVector< AddedMassStorage::Identifier, AddedMassStorageRef > AddedMassStorageContainer
Definition: AddedMassDb.h:266
agx::Vector< Phi > PhiContainer
Definition: AddedMassDb.h:117
agx::ref_ptr< AddedMassDb > AddedMassDbRef
Definition: AddedMassDb.h:278
#define AGX_FORCE_INLINE
Definition: Object.h:59
agxModel::dense::Vector Phi
Definition: AddedMassDb.h:116
agx::UInt size() const
Definition: AddedMassDb.h:81
Storage that holds data needed for added mass calculations.
Definition: AddedMassDb.h:113
Base class providing referencing counted objects.
Definition: Referenced.h:119
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
AGXMODEL_EXPORT agx::Vec3 getCenter(const agxCollide::Mesh::Triangle &triangle)
uint32_t UInt
Definition: Integer.h:34
Class for more intuitive access to the Mesh&#39;s mesh data.
Definition: Mesh.h:78
Report(agx::Bool validIn, agx::Real executionTimeIn)
Definition: AddedMassDb.h:139
agx::Real & operator()(const agx::UInt i)
Definition: AddedMassDb.h:86
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
#define agxAssert(expr)
Definition: debug.h:143
agx::VectorPOD< agx::Vec6 > NormalTangentContainer
Definition: AddedMassDb.h:118
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
AGXTERRAIN_EXPORT TimingStorage & getStorage()
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agx::RealValarray DataType
Definition: AddedMassDb.h:38
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
Holder/manager of added mass storages.
Definition: AddedMassDb.h:208
uint32_t UInt32
Definition: Integer.h:40