AGX Dynamics  2.37.2.0
NlSolveDataH5.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 #pragma once
18 
19 #include <agx/config/AGX_USE_HDF5.h>
20 #include <agx/Referenced.h>
21 
22 #include <array>
23 
24 namespace agx
25 {
27  {
28  public:
29  struct Data
30  {
31  Data( agx::Real lowerBound,
32  agx::Real upperBound,
33  agx::Real normalForce,
34  agx::Real frictionCoefficient )
35  : lowerBound( lowerBound ),
36  upperBound( upperBound ),
37  normalForce( normalForce ),
38  frictionCoefficient( frictionCoefficient )
39  {
40  }
41 
46  };
47 
48  enum DataType
49  {
50  CONTACT_POINT = 0,
52  OTHER = 128
53  };
54 
55  public:
56  virtual void beginSimulationStep() = 0;
57  virtual void endSimulationStep() = 0;
58 
59  virtual void beginSolve() = 0;
60  virtual void endSolve() = 0;
61 
62  virtual void beginIteration() = 0;
63  virtual void endIteration() = 0;
64 
65  virtual void write( DataType dataType, const Data& data ) = 0;
66 
67  virtual agx::String getFilename() const = 0;
68  virtual void close() = 0;
69  };
70 }
71 
72 #if AGX_USE_HDF5()
73 #include <agx/AgxH5.h>
74 
75 namespace agx
76 {
77  class AGXCORE_EXPORT NlSolveDataH5 : public INlSolveDataH5
78  {
79  public:
80  enum IterationDataEntryName : agx::UInt
81  {
82  LOWER_BOUND,
83  UPPER_BOUND,
85  FRICTION_COEFFICIENT,
86  NUM_ITERATION_DATA_ENTRIES
87  };
88 
89  using IterationDataEntry = VectorPOD<Real>;
90  using IterationData = std::array<IterationDataEntry, NUM_ITERATION_DATA_ENTRIES>;
91 
92  struct IterationNode
93  {
94  IterationNode( DataType type )
95  : type( type )
96  {
97  }
98 
99  DataType type;
100  IterationData data;
101  };
102 
103  using IterationNodeVector = Vector<IterationNode>;
104 
105  public:
106  NlSolveDataH5( const agx::String& filename );
107 
108  virtual void beginSimulationStep() override;
109  virtual void endSimulationStep() override;
110 
111  virtual void beginSolve() override;
112  virtual void endSolve() override;
113 
114  virtual void beginIteration() override;
115  virtual void endIteration() override;
116 
117  virtual void write( DataType dataType, const Data& data ) override;
118 
119  virtual agx::String getFilename() const override;
120  virtual void close() override;
121 
122  protected:
123  virtual ~NlSolveDataH5();
124 
125  private:
126  agx::String m_filename;
127  IterationNodeVector m_iterationNodes;
128  H5::H5File* m_file;
129  H5::Group m_root;
130  H5::Group m_simulationStepGroup;
131  agx::UInt m_simulationStepCounter;
132  agx::UInt m_solveCounter;
133  agx::UInt m_iterationCounter;
134  agx::UInt m_iterationDataCounter;
135  };
136 }
137 #endif
Data(agx::Real lowerBound, agx::Real upperBound, agx::Real normalForce, agx::Real frictionCoefficient)
Definition: NlSolveDataH5.h:31
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
uint32_t UInt
Definition: Integer.h:34
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool AGXPHYSICS_EXPORT write(const std::string &filename, const agxStream::Serializable *data)
Write a Serializable object to a file.
double Real
Definition: Real.h:42
#define AGXCORE_EXPORT