AGXDynamics  2.35.0.2
MergeSplitParallelReferencedDataKernel.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 
20 
21 #include <agx/Kernel.h>
22 
23 namespace agxSDK
24 {
25  template<typename T>
27  {
28  public:
29  void execute( const T* data,
30  const agxSDK::MergeSplitHandler& handler,
31  const agxSDK::MergeSplitPostSolveData& postSolveData );
32 
33  protected:
34  virtual void onPreExecute();
35  virtual void onEntityPtr( agxData::EntityPtr ptr,
36  const agxSDK::MergeSplitHandler& handler,
37  const agxSDK::MergeSplitPostSolveData& postSolveData ) = 0;
38  virtual void onPostExecute();
39 
40  protected:
42 
43  agx::UInt getNumElements() const;
44  const T* getData() const;
45 
46  using agx::Task::execute;
47 
48  private:
49  void executeJob( const agx::RangeJob& job );
50 
51  private:
54 
55  private:
56  const T* m_data;
57  const MergeSplitHandler* m_handler;
58  const MergeSplitPostSolveData* m_postSolveData;
59  };
60 
61  template<typename T>
63  : LambdaKernel( name,
64  std::bind( &MergeSplitParallelReferencedDataKernel<T>::executeJob, this, std::placeholders::_1 ),
65  std::bind( &MergeSplitParallelReferencedDataKernel<T>::getNumElements, this ) ),
66  m_data( nullptr ),
67  m_handler( nullptr ),
68  m_postSolveData( nullptr )
69  {
70  }
71 
72  template<typename T>
74  {
75  return m_data != nullptr ? m_data->instance.size() : 0u;
76  }
77 
78  template<typename T>
80  {
81  return m_data;
82  }
83 
84  template<typename T>
86  {
87  }
88 
89  template<typename T>
91  const MergeSplitHandler& handler,
92  const MergeSplitPostSolveData& postSolveData )
93  {
94  m_data = data;
95  if ( m_data != nullptr ) {
96  m_handler = &handler;
97  m_postSolveData = &postSolveData;
98 
99  this->onPreExecute();
101  this->onPostExecute();
102  }
103 
104 
105  m_data = nullptr;
106  m_handler = nullptr;
107  m_postSolveData = nullptr;
108  }
109 
110  template<typename T>
112  {
113  }
114 
115  template<typename T>
117  {
118  for ( agx::UInt i = job.range().begin(), end = job.range().end(); i != end; ++i )
119  onEntityPtr( m_data->instance[ i ], *m_handler, *m_postSolveData );
120  }
121 }
agxSDK::MergeSplitParallelReferencedDataKernel::getData
const T * getData() const
Definition: MergeSplitParallelReferencedDataKernel.h:79
agx::end
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Definition: LinearProbingHashSet.h:612
Kernel.h
agx::Task::execute
void execute()
Execute the task.
agxSDK::MergeSplitPostSolveData
Definition: MergeSplitPostSolveData.h:37
agxSDK::MergeSplitParallelReferencedDataKernel::onPostExecute
virtual void onPostExecute()
Definition: MergeSplitParallelReferencedDataKernel.h:111
agx::LambdaKernel
Definition: Kernel.h:173
agx::RangeJob::range
IndexRange & range()
Definition: Job.h:631
agxSDK::MergeSplitParallelReferencedDataKernel::onEntityPtr
virtual void onEntityPtr(agxData::EntityPtr ptr, const agxSDK::MergeSplitHandler &handler, const agxSDK::MergeSplitPostSolveData &postSolveData)=0
agxSDK::MergeSplitParallelReferencedDataKernel::getNumElements
agx::UInt getNumElements() const
Definition: MergeSplitParallelReferencedDataKernel.h:73
agxSDK::MergeSplitHandler
Base class for a merge split algorithm handling a set of merged bodies.
Definition: MergeSplitHandler.h:34
agx::RangeJob
A range job executes a kernel implementation on a subset of the data.
Definition: Job.h:283
agxSDK::MergeSplitParallelReferencedDataKernel::onPreExecute
virtual void onPreExecute()
Definition: MergeSplitParallelReferencedDataKernel.h:85
agx::Name
Representation of a name string.
Definition: Name.h:32
agxSDK::MergeSplitParallelReferencedDataKernel::MergeSplitParallelReferencedDataKernel
MergeSplitParallelReferencedDataKernel(const agx::Name &name)
Definition: MergeSplitParallelReferencedDataKernel.h:62
agx::IndexRangeT::begin
T & begin()
Definition: IndexRange.h:214
agxSDK::MergeSplitParallelReferencedDataKernel
Definition: MergeSplitParallelReferencedDataKernel.h:26
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agxSDK
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
agx::IndexRangeT::end
T & end()
Definition: IndexRange.h:217
MergeSplitPostSolveData.h
agxData::EntityPtr
Accessor to a entity instance stored in a EntityStorage, to allow SOA (structure of arrays) data to b...
Definition: EntityPtr.h:51