AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
NlSolveDataH5.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
20#include <agx/Referenced.h>
21
22#include <array>
23
24namespace 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
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
75namespace agx
76{
77 class AGXCORE_EXPORT NlSolveDataH5 : public INlSolveDataH5
78 {
79 public:
80 enum IterationDataEntryName : agx::UInt
81 {
82 LOWER_BOUND,
83 UPPER_BOUND,
84 NORMAL_FORCE,
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
#define AGXCORE_EXPORT
virtual void endSolve()=0
virtual agx::String getFilename() const =0
virtual void write(DataType dataType, const Data &data)=0
virtual void beginSolve()=0
virtual void endIteration()=0
virtual void close()=0
virtual void endSimulationStep()=0
virtual void beginIteration()=0
virtual void beginSimulationStep()=0
Base class providing referencing counted objects.
Definition: Referenced.h:120
bool AGXPHYSICS_EXPORT write(const std::string &filename, const agxStream::Serializable *data)
Write a Serializable object to a file.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint64_t UInt
Definition: Integer.h:27
double Real
Definition: Real.h:41
Data(agx::Real lowerBound, agx::Real upperBound, agx::Real normalForce, agx::Real frictionCoefficient)
Definition: NlSolveDataH5.h:31