AGX Dynamics  2.35.0.1
SolveAlgorithms.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 #ifndef AGX_SOLVEALGORITHMS_H
18 #define AGX_SOLVEALGORITHMS_H
19 
20 #include <agx/Vector.h>
21 
23 
24 #include <agxData/Array.h>
25 
26 
27 #ifdef _MSC_VER
28 # pragma warning( push )
29 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y
30 #endif
31 
32 namespace agx
33 {
34  // Forward declarations agx.
35  class Solver;
36  class SolveKernel;
37  class SolveJob;
38  class JobGroup;
39 
40  // Forward declarations agx::Physics.
41  namespace Physics
42  {
43  class SolveGroupPtr;
44  class SolveIslandPtr;
45  class SolveGroupData;
46  }
47 
48  // Typedefs.
50 
55  {
56  public:
63 
68  agx::JobGroup* getNewWrapperJob( agx::Solver* solver );
69 
73  agx::SolveJob* getNewSolveJob();
74 
75  protected:
80  };
81 
89  {
90  public:
94  enum Type {
98  HYBRID
99  };
100 
101  public:
111  {
112  public:
117  enum Type { EMPTY, EXIT, SINGLE, GROUP, CUSTOM };
118 
119  public:
124  {
129  };
130 
131  public:
135  Task();
136 
142 
148 
153 
158 
163 
169  virtual agx::SolveKernel* getSolveKernel( agx::Solver* solver ) const;
170 
176  virtual agx::SolveKernel* getSolveKernel( agx::Physics::SolveGroupPtr group ) const;
177 
178  virtual void customSetup(Solver *solver, JobGroup *entry, JobGroup *exit);
179 
180  protected:
186 
190  virtual ~Task();
191 
192  protected:
194 
195  protected:
199  };
200 
202 
203  public:
211 
212  public:
219 
230  void calculateNumTasks( const agx::SolveAlgorithm::Task* task, const agx::SolveAlgorithm::Task::ConditionData& conditionData, agx::UInt& numEmptyTasks, agx::UInt& numSingleTasks, agx::UInt& numGroupTasks, agx::UInt& numCustomTasks ) const;
231 
239  virtual void generateJobs( agx::JobGenerator& generator, const SolveAlgorithm::Task::ConditionData& conditionData, agx::Physics::SolveIslandPtr island, const agx::Physics::SolveGroupData& solveGroup );
240 
241  protected:
245  SolveAlgorithm(Solver *solver);
246 
250  virtual ~SolveAlgorithm();
251 
258  virtual agx::SolveAlgorithm::Task* create(bool useComplexImpactStage) = 0;
259 
270  virtual void generateJobs( agx::SolveAlgorithm::Task* task, const agx::SolveAlgorithm::Task::ConditionData& conditionData, agx::JobGroup* parentJobGroup, agx::JobGroupPtrVector& dependentJobs, agx::JobGenerator& generator, agx::Physics::SolveIslandPtr island, const agx::Physics::SolveGroupData& solveGroup );
271 
275  agx::Solver* getSolver() { return m_solver; }
276 
277  protected:
279  agx::Solver* m_solver;
280  };
281 
283 
288  {
289  public:
293  EmptySolver(Solver *solver);
294 
295  protected:
299  virtual ~EmptySolver();
300 
304  virtual SolveAlgorithm::Task* create(bool useComplexImpactStage) override;
305  };
306 
312  {
313  public:
317  PureIterativeSolver( Solver *solver );
318 
319  protected:
324 
329  virtual SolveAlgorithm::Task* create(bool useComplexImpactStage) override;
330 
331  protected:
335  };
336 
342  {
343  public:
347  PureDirectSolver(Solver *solver);
348 
349  protected:
353  virtual ~PureDirectSolver();
354 
359  virtual SolveAlgorithm::Task* create(bool useComplexImpactStage) override;
360  };
361 
367  {
368  public:
372  HybridSolver( agx::Solver *solver );
373 
374  protected:
378  virtual ~HybridSolver();
379 
384  virtual SolveAlgorithm::Task* create(bool useComplexImpactStage) override;
385 
386  protected:
391  };
392 }
393 
394 #ifdef _MSC_VER
395 # pragma warning( pop )
396 #endif
397 
398 #endif
#define AGXPHYSICS_EXPORT
Algorithm for an island without solve models.
virtual SolveAlgorithm::Task * create(bool useComplexImpactStage) override
Creates tree structure for an empty solver.
EmptySolver(Solver *solver)
Construct empty solver.
virtual ~EmptySolver()
Reference counted.
Algorithm for hybrid solve.
agx::UInt m_numRestingIterations
HybridSolver(agx::Solver *solver)
Construct a hybrid solve algorithm based on a previous solver (use same settings)
virtual SolveAlgorithm::Task * create(bool useComplexImpactStage) override
Creates tree structure of this type of solver.
agx::UInt m_numImpactIterations
agx::UInt m_numDryFrictionIterations
virtual ~HybridSolver()
Reference counted.
agx::UInt m_numPPGSIterations
Utility class used to generate jobs for ALL islands.
agx::UInt m_wrapperJobCounter
agxData::Array< agx::SolveJob > m_solveJobs
JobGenerator(agxData::Array< agx::JobGroup > &wrapperJobs, agxData::Array< agx::SolveJob > &solveJobs)
Construct generator given allocated arrays of group- and solve jobs.
agxData::Array< agx::JobGroup > m_wrapperJobs
agx::JobGroup * getNewWrapperJob(agx::Solver *solver)
Initializes, increments internal counter and returns a new group/wrapper job.
agx::SolveJob * getNewSolveJob()
Increments internal counter and returns a new solve job.
agx::UInt m_solveJobCounter
A group of jobs to be executed.
Definition: Job.h:341
Pointer to a entity instance of type Physics.SolveGroup.
Pointer to a entity instance of type Physics.SolveIsland.
Algorithm for pure direct solve.
virtual ~PureDirectSolver()
Reference counted.
virtual SolveAlgorithm::Task * create(bool useComplexImpactStage) override
Creates tree structure of this type of solver.
PureDirectSolver(Solver *solver)
Construct pure direct solver.
Algorithm for pure iterative solve.
virtual SolveAlgorithm::Task * create(bool useComplexImpactStage) override
Creates tree structure of this type of solver.
virtual ~PureIterativeSolver()
Reference counted.
PureIterativeSolver(Solver *solver)
Construct pure iterative solver.
Base class providing referencing counted objects.
Definition: Referenced.h:114
Algorithm task either empty, single or group type.
Task(agx::SolveAlgorithm::Task::Type type)
Construct given type.
virtual agx::SolveAlgorithm::Task::Type getType(const agx::SolveAlgorithm::Task::ConditionData &conditionData) const
void addChild(agx::SolveAlgorithm::Task *child)
Add child task.
virtual agx::SolveKernel * getSolveKernel(agx::Physics::SolveGroupPtr group) const
Callback for solve algorithms task type GROUP.
agx::SolveAlgorithm::Task * getParent() const
virtual ~Task()
Reference counted object - protected virtual destructor.
agx::SolveAlgorithm::Task::SolveAlgorithmTaskContainer m_children
agx::SolveAlgorithm::Task::Type m_type
agx::Vector< agx::ref_ptr< SolveAlgorithm::Task > > SolveAlgorithmTaskContainer
Task()
Default constructor, type set to EMPTY.
virtual agx::SolveKernel * getSolveKernel(agx::Solver *solver) const
Callback for solve algorithms task type SINGLE.
virtual void customSetup(Solver *solver, JobGroup *entry, JobGroup *exit)
Type
Task type either EMPTY branch (no callback), EXIT branch (no callback, traversal of this branch will ...
agx::UInt getNumChildren() const
agx::SolveAlgorithm::Task * getChild(agx::UInt i) const
agx::SolveAlgorithm::Task * m_parent
Parent class for solve algorithms compatible with the constraint framework.
virtual void generateJobs(agx::SolveAlgorithm::Task *task, const agx::SolveAlgorithm::Task::ConditionData &conditionData, agx::JobGroup *parentJobGroup, agx::JobGroupPtrVector &dependentJobs, agx::JobGenerator &generator, agx::Physics::SolveIslandPtr island, const agx::Physics::SolveGroupData &solveGroup)
Recursive part of generateJobs.
SolveAlgorithm(Solver *solver)
Protected constructor for pure virtual object.
agx::ref_ptr< SolveAlgorithm::Task > TaskRef
virtual ~SolveAlgorithm()
Reference counted object, protected destructor.
agx::SolveAlgorithm::TaskRef m_root
void calculateNumTasks(const agx::SolveAlgorithm::Task *task, const agx::SolveAlgorithm::Task::ConditionData &conditionData, agx::UInt &numEmptyTasks, agx::UInt &numSingleTasks, agx::UInt &numGroupTasks, agx::UInt &numCustomTasks) const
After create method, this recursive method can be called to pre-calculate the number of types in the ...
agx::Solver * getSolver()
virtual agx::SolveAlgorithm::Task * instantiate()
Initializes a solve algorithm and/or returns the root task.
Type
Solve algorithm type "guessed" by findSolveAlgorithm.
@ EMPTY
Solver for islands with zero models.
@ PURE_DIRECT
Only direct constraints.
@ PURE_ITERATIVE
Only iterative constraints.
agx::Solver * m_solver
virtual agx::SolveAlgorithm::Task * create(bool useComplexImpactStage)=0
Create method called one time during first call to getOrCreateRoot.
static agx::SolveAlgorithm::Type findSolveAlgorithm(agx::Physics::SolveIslandPtr island, UInt numZones)
Static method to find the optimal solve algorithm for an island.
virtual void generateJobs(agx::JobGenerator &generator, const SolveAlgorithm::Task::ConditionData &conditionData, agx::Physics::SolveIslandPtr island, const agx::Physics::SolveGroupData &solveGroup)
Generate jobs given the tree structure built by the implemented solve algorithm.
Vector containing 'raw' data.
Definition: agx/Vector.h:246
Templated vector class.
Definition: agx/Vector.h:53
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition: Integer.h:48
uint32_t UInt
Definition: Integer.h:34
agx::ref_ptr< SolveAlgorithm > SolveAlgorithmRef
agx::VectorPOD< agx::JobGroup * > JobGroupPtrVector
The type of tasks may depend on the data in this structure.