AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
GranularImpactDataWriter.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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#ifndef AGX_GRANULARIMPACTANALYSIS_H
18 #define AGX_GRANULARIMPACTANALYSIS_H
19
22#include <agx/Journal.h>
24#include <agxSDK/Simulation.h>
25#include <agx/AnalysisBox.h>
26#include <agx/BitState.h>
27#include <iostream>
28
29namespace agx
30{
31 // Detail namespace
32 namespace detail
33 {
34 // Container for contact information
39
40 // Container for contact information
45
46 // Container for information about the accumulated impacts experienced by a pellet.
54
59 {
60 public:
61 // Constructor
63
65 IndexHashSet getDestroyedParticles() const;
66
67 protected:
68 virtual void onParticleDestroyed(agx::Index id) = 0;
69
70 virtual void onParticleCreated(agx::Index id) = 0;
71
73
75
76 private:
77 void triggerParticleDestroyed(agx::Index id);
78
79 void triggerParticleCreated(agx::Index id);
80
82 // Internal classes
84 AGX_DECLARE_POINTER_TYPES(ParticleStorageListener);
85 class ParticleStorageListener : public agxData::EntityStorage::EventListener, public agx::Referenced
86 {
87 public:
88 ParticleStorageListener(ParticleEventListener* listener);
89
90 virtual void destroyCallback(agxData::EntityStorage* storage) override;
91 virtual void createInstanceCallback(agxData::EntityStorage* storage, agxData::EntityPtr instance) override;
92 virtual void createInstancesCallback(agxData::EntityStorage* storage, agxData::EntityRange range) override;
93 virtual void destroyInstanceCallback(agxData::EntityStorage* storage, agxData::EntityPtr instance) override;
94 virtual void destroyInstancesCallback(agxData::EntityStorage* storage, agxData::Array<agxData::EntityPtr> instances) override;
95 virtual void createInstancesCallback(agxData::EntityStorage* storage, agxData::Array<agxData::EntityPtr> instances) override;
96 virtual void destroyInstancesCallback(agxData::EntityStorage* storage, agxData::EntityRange instances) override;
97
98 protected:
99 virtual ~ParticleStorageListener();
100
102 // Variables
104 protected:
105 ParticleEventListener * m_listener;
106 };
107
108 protected:
111 // Variables
113 private:
115 ParticleStorageListenerRef m_particleStorageListener;
116 IndexHashSet m_destroyedIds;
117 };
118
120 }
121
129 {
130 public:
131#ifndef SWIG
132 // Simulation buffer names for the data that the ImpactDataWriter records into the simulation
133 static const char* const IMPACT_BUFFER;
134 static const char* const ACCUMULATED_IMPACT_BUFFER;
135 static const char* const PARTICLEPAIRCONTACT_BUFFER;
136 static const char* const PARTICLEGEOMETRYCONTACT_BUFFER;
137 static const char* const CONTACTENERGY_BUFFER;
138#endif
139
140 public:
146
147 AGX_DECLARE_POINTER_TYPES(ImpactDataSimulationWriter);
148 public:
156
158 virtual void pre(const agx::TimeStamp& /*t*/) override;
159
161 virtual void post(const agx::TimeStamp&) override;
162
167 virtual void addNotification() override;
168
172 virtual void removeNotification() override;
173
175
176 protected:
178
179 protected:
180
181
182 private:
184
186 // Variables
188 protected:
196 };
197
198 /*
199 Internal class that writes the contact and particle data to simulation under the specified GranularBodySystem.
200 */
201 class AGXPHYSICS_EXPORT GranularImpactDataWriter::ImpactDataSimulationWriter : public agx::Referenced
202 {
203 public:
210
213
216
219
222
225
228
229 ImpactDataSimulationWriter& operator=(const ImpactDataSimulationWriter&) = delete;
230 protected:
232
234
236
239
241
243 // Variables
245 protected:
250 };
251}
252
253#endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition EntityPtr.h:52
Data storage for a collection of entity instances of a specified EntityModel.
Only use as member allocated variable.
Definition Value.h:285
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Derive from this class to implement a listener for simulation step events.
T CallbackType
Definition Event.h:37
ImpactDataSimulationWriter & operator=(const ImpactDataSimulationWriter &)=delete
agxData::EntityStorageRef m_particlePairStorage
void writeContactInformation(const detail::ParticlePairContactInformation &contact)
Writes data from a contact to the granular body system.
ParticleGeometryTimeTable m_activeParticleGeometryPairs
virtual void pre(const agx::TimeStamp &) override
Pre-step of the GranularImpactDataWriter.
GranularImpactDataWriter(agx::Physics::GranularBodySystem *system, agx::Real recordThreshold=1E-3)
Constructor for the GranularImpactDataWriter.
agx::HashTable< agx::Physics::GranularBody::GranularGranularPair, agx::TimeStamp > ParticlePairTimeTable
virtual void post(const agx::TimeStamp &) override
Post-step of the GranularImpactDataWriter.
void addNotification(agxSDK::Simulation *simulation)
Function that will trigger when attached to a simulation.
void createJournalBindings(agx::Journal *journal)
Initializes the journal bindings.
agxData::EntityStorageRef m_particleGeometryStorage
agx::Physics::GranularBody::GranularGranularPair ParticlePairKey
ImpactDataSimulationWriterRef m_impactDataSimulationWriter
static const char *const PARTICLEPAIRCONTACT_BUFFER
size_t getNumParticlePairImpacts() const
Returns the particle pair impacts.
static const char *const CONTACTENERGY_BUFFER
void writeParticleContactInfo(agx::Index id, agx::Real contactEnergy)
virtual void removeNotification() override
Called when this listener is removed from the simulation.
ImpactDataSimulationWriter(agx::Physics::GranularBodySystem *system)
Constructor for the ImpactDataSimulationWriter.
static const char *const PARTICLEGEOMETRYCONTACT_BUFFER
void removeNotification(agxSDK::Simulation *simulation)
Function that will trigger when attached to a simulation.
static const char *const ACCUMULATED_IMPACT_BUFFER
agx::Physics::GranularBodySystem * m_system
void journalAttachedCallback(agxSDK::Simulation *simulation, agx::Journal *journal)
void writeContactInformation(const detail::ParticleGeometryContactInformation &contact)
Writes data from a contact to the granular body system.
virtual void addNotification() override
Called when this listener is added to the simulation.
agxSDK::Simulation::JournalAttachEvent::CallbackType m_journalAttachedCallback
agx::Physics::GranularBody::GranularGeometryPair ParticleGeometryKey
agx::HashTable< agx::Physics::GranularBody::GranularGeometryPair, agx::TimeStamp > ParticleGeometryTimeTable
size_t getNumParticleGeometryImpacts() const
Returns the particle geometry impacts.
Inheritance with partial specialization due to bug with ref_ptr containers.
Pointer to a entity instance of type Physics.ParticleGeometryContact.
Pointer to a entity instance of type Physics.ParticlePairContact.
Base class providing referencing counted objects.
Definition Referenced.h:120
A std::pair, with both elements of the same type, and symmetric so (a, b) == (b, a)
Particle EventListener that can be inherited and overridden in order to listen to particle events.
virtual void onParticleDestroyed(agx::Index id)=0
ParticleEventListener(agx::Physics::GranularBodySystem *system)
bool particleIsDestroyed(agx::Index id)
virtual void onParticleCreated(agx::Index id)=0
IndexHashSet getDestroyedParticles() const
Returns the currently destroyed particles registered from the coupled GranularBodySystem.
#define AGX_FORCE_INLINE
Definition macros.h:58
std::pair< GranularBodyPtr, GeometryPtr > GranularGeometryPair
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition Real.h:42
agx::Real TimeStamp
Definition TimeStamp.h:26
UInt32 Index
Definition Integer.h:44
agx::Physics::ParticleGeometryContactPtr contactPtr
agx::Physics::ParticlePairContactPtr contactPtr