AGX Dynamics  2.38.0.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
agxModel::dense::SquareMatrix::operator()
agx::Real operator()(agx::UInt i, agx::UInt j) const
Definition: AddedMassDb.h:96
agx::UInt
uint64_t UInt
Definition: Integer.h:27
InputArchive.h
agxCollide::Mesh
Mesh is a common base class for triangle meshes, such as Mesh or HeightField.
Definition: Mesh.h:69
agxModel::AddedMassStorage::Phi
agxModel::dense::Vector Phi
Definition: AddedMassDb.h:116
agx::Real
double Real
Definition: Real.h:42
agxModel
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
agxModel::AddedMassStorage::Report::valid
agx::Bool valid
Definition: AddedMassDb.h:140
agx::Vector< Phi >
agxStream::out
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.
Definition: OutputArchive.h:412
export.h
agxModel::AddedMassStorage::Report
Report from creation, store and restore.
Definition: AddedMassDb.h:137
agxModel::AddedMassStorage::Report::executionTime
agx::Real executionTime
Definition: AddedMassDb.h:141
agxModel::AddedMassDb::AddedMassStorageContainer
agx::HashVector< AddedMassStorage::Identifier, AddedMassStorageRef > AddedMassStorageContainer
Definition: AddedMassDb.h:266
agxAssert
#define agxAssert(expr)
Definition: debug.h:143
agxModel::AddedMassStorageRef
agx::ref_ptr< AddedMassStorage > AddedMassStorageRef
Definition: AddedMassDb.h:203
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
agx_valarray_types.h
agxModel::AddedMassStorage::NormalTangentContainer
agx::VectorPOD< agx::Vec6 > NormalTangentContainer
Definition: AddedMassDb.h:118
agxModel::dense::Vector
Definition: AddedMassDb.h:35
agx::VectorPOD< agx::Vec6 >
agxModel::dense::Vector::DataType
agx::RealValarray DataType
Definition: AddedMassDb.h:38
agxModel::AddedMassDbRef
agx::ref_ptr< AddedMassDb > AddedMassDbRef
Definition: AddedMassDb.h:278
agxStream::in
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:399
agxModel::dense::Vector::operator()
agx::Real & operator()(const agx::UInt i)
Definition: AddedMassDb.h:86
agxModel::AddedMassStorage::Report::Report
Report(agx::Bool validIn, agx::Real executionTimeIn)
Definition: AddedMassDb.h:139
agxModel::AddedMassStorage
Storage that holds data needed for added mass calculations.
Definition: AddedMassDb.h:113
agxModel::WindAndWaterParameters
Definition: WindAndWaterParameters.h:28
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxTerrain::Profiler::getStorage
AGXTERRAIN_EXPORT TimingStorage & getStorage()
agxModel::dense::Vector::size
agx::UInt size() const
Definition: AddedMassDb.h:81
agxCollide::Mesh::Triangle
Class for more intuitive access to the Mesh's mesh data.
Definition: Mesh.h:78
Vec6.h
agxModel::getCenter
AGXMODEL_EXPORT agx::Vec3 getCenter(const agxCollide::Mesh::Triangle &triangle)
agx::RealValarray
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Definition: agx_valarray_types.h:27
agxModel::AddedMassDb
Holder/manager of added mass storages.
Definition: AddedMassDb.h:208
agxModel::AddedMassStorage::PhiContainer
agx::Vector< Phi > PhiContainer
Definition: AddedMassDb.h:117
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:50
agxModel::AddedMassStorage::Identifier
agx::UInt32 Identifier
Definition: AddedMassDb.h:119
Mesh.h
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
agx::Bool
bool Bool
Definition: Integer.h:40
agxModel::dense::SquareMatrix
Definition: AddedMassDb.h:58
AGXMODEL_EXPORT
#define AGXMODEL_EXPORT
Definition: agxModel/export.h:42
agx::AgXString< std::string >
OutputArchive.h
agx::Vec3T< Real >
agx::UInt32
uint32_t UInt32
Definition: Integer.h:32
agx::HashVector< AddedMassStorage::Identifier, AddedMassStorageRef >
StorageStream.h
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58