41 # pragma warning(push) 42 # pragma warning(disable:4355) // Disable warnings about passing the 'this' pointer to base class constructors. 43 # pragma warning( disable : 4251 ) // class X needs to have dll-interface to be used by clients of class Y 57 class DirectSolverData;
71 STORE_CONTACT_FORCES = 0x2,
73 IMPACT_ITERATION = 0x4,
75 SYNCHRONIZE_ITERATIVE = 0x6,
78 ITERATION_INDEX_SHIFT = 8
104 static agx::Solver::NlMcpConfig createDefault();
106 agx::Solver::McpAlgoritmType mcpAlgorithmType;
112 bool indexSetWarmStarting;
122 static agx::String getDescription( agx::Solver::McpAlgoritmType mcpAlgorithm );
130 UInt getNumRestingIterations()
const;
135 void setNumRestingIterations(
UInt numIterations);
140 UInt getNumPPGSRestingIterations()
const;
145 void setNumPPGSRestingIterations(
UInt numPPGSIterations);
150 UInt getNumDryFrictionIterations()
const;
155 void setNumDryFrictionIterations(
UInt numIterations);
161 UInt getNumImpactIterations()
const;
167 void setNumImpactIterations(
UInt numIterations);
172 bool isForceIterative()
const;
177 void setForceIterative(
bool flag);
182 agx::Solver::NlMcpConfig& getNlMcpConfig();
187 agx::Solver::NlMcpConfig getNlMcpConfig()
const;
193 void setMcpAlgorithmType( agx::Solver::McpAlgoritmType mcpType );
198 agx::Solver::McpAlgoritmType getMcpAlgorithmType()
const;
203 void setImpactSpeedThreshold(
agx::Real threshold);
208 Real getImpactSpeedThreshold()
const;
213 agx::Bool isStabilityReportEnable()
const;
218 void setStabilityReportEnable(
agx::Bool enable );
221 void setSolverStatiticsEnable(
bool enable);
222 bool getSolverStatisticsEnable()
const;
229 void setUseParallelPgs(
bool flag);
234 bool useParallelPgs()
const;
239 void setUseGranularWarmStarting(
bool flag);
244 bool useGranularWarmStarting()
const;
249 bool use32bitGranularBodySolver()
const;
258 void setUse32bitGranularBodySolver(
bool flag);
265 void setCalculateIterationResiduals(
bool flag);
270 bool getCalculateIterationResiduals()
const;
285 agx::Real getGlobalRelativeResidual()
const;
292 void enableNlSolveDataH5(
const agx::String& filename );
297 void disableNlSolveDataH5();
302 agx::Bool getEnableNlSolveDataH5()
const;
305 agx::INlSolveDataH5* getNlSolveDataH5() const;
307 MobilitySolver* getMobilitySolver();
308 MobilitySolver* getMobilityReferenceSolver();
309 const SolveKernelRefVector& getKernels() const;
311 SolveKernel* getStoreContactForcesKernel();
312 SolveKernel* getCommitDirectVelocitiesKernel();
314 SolveKernel* getPrepareDirectSolverKernel();
315 SolveKernel* getDirectRhsKernel();
317 SolveKernel* getDirectSolverKernel();
318 SolveKernel* getSynchronizeIterativeSolverKernel();
319 SolveKernel* getUpdateBoundsSolverKernel();
320 SolveKernel* getSynchronizeDirectSolverKernel();
322 SolveKernel* getUpdateIterationCountKernel();
324 void addKernel(SolveKernel* kernel);
325 void removeKernel(SolveKernel* kernel);
328 void generateSolveJobs(
329 agx::Physics::SolveIslandData& solveIsland,
330 agx::Physics::SolveGroupData& solveGroup,
331 agxSDK::Simulation* simulation,
332 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
333 agx::Physics::HierarchicalGrid::ContactZoneDependencyData& zoneDependency,
334 agx::Physics::HierarchicalGrid::ContactZonePtr& iterationStartZone,
335 agx::Physics::HierarchicalGrid::ContactZonePtr& iterationEndZone,
339 agx::Physics::SolveIslandData& getIslands();
340 bool hasIslands() const;
342 DirectSolverData* getSharedSolverData(Physics::SolveIslandPtr island);
343 void registerDirectSolverData(Physics::SolveIslandPtr island, DirectSolverData* data);
344 void clearDirectSolverData();
345 DirectSolverData* getDirectSolverData(Physics::SolveIslandPtr island);
349 void setSimulation(
agxSDK::Simulation* simulation);
350 agxSDK::Simulation* getSimulation();
352 Task* getGranularVelocityIntegrationKernel();
356 void setEnableMobilitySolverDataSharing(
bool flag);
357 bool getEnableMobilitySolverDataSharing() const;
365 friend class
agxSDK::Simulation;
366 void applyCustomParticlePipeline();
369 void prepareKernels();
370 void commitKernels();
371 void updateImpactSpeedThreshold();
379 class IterationStart :
public Job
383 virtual ~IterationStart();
388 virtual void implementation()
override;
391 UInt m_currentIteration;
396 class IterationEnd :
public Job
399 IterationEnd(Solver* solver, Physics::SolveIslandPtr island, IterationStart* iterationStart);
400 virtual ~IterationEnd();
402 void setNumIterations(
UInt numIterations);
403 void setExit(Job* exitJob);
405 virtual void implementation()
override;
407 void printResidual();
408 void verifyIteration();
409 void verifyGranularBodyConstraints(
const Path& path);
410 Real calculateComputeCost();
414 Physics::SolveIslandPtr m_island;
415 UInt m_numIterations;
416 UInt m_currentIteration;
418 IterationStart* m_iterationStart;
423 class JobGraphInstaller :
public Job
426 JobGraphInstaller(Job* startJob, Job* endJob);
427 virtual ~JobGraphInstaller();
428 virtual void implementation();
437 class IterationLoopInstaller :
public Job
440 IterationLoopInstaller(Solver* solver, IterationStart* startJob, IterationEnd* endJob,
UInt numIterations);
441 virtual ~IterationLoopInstaller();
442 virtual void implementation();
447 void initIterationCounters(
const Path& path);
448 void initIterationCounters();
452 IterationStart* m_startJob;
453 IterationEnd* m_endJob;
454 UInt m_numIterations;
459 class JobGraph :
public Referenced
465 Job* storeContactForcesStart;
466 Job* storeContactForcesEnd;
468 IterationStart* iterationStart;
469 IterationEnd* iterationEnd;
470 JobGroup* serialIterationJob;
483 void createZoneIndependentJobs(
484 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
488 SolveKernel* particleParticleKernel,
489 SolveKernel* particleGeometryKernel,
490 SolveKernel* geometryGeometryKernel,
495 void createZoneRhsJobs(
496 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
500 SolveKernel* particleParticleKernel,
501 SolveKernel* particleGeometryKernel,
502 SolveKernel* geometryGeometryKernel
505 void createZoneStoreContactForcesJobs(
506 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
510 SolveKernel* particleParticleKernel,
511 SolveKernel* particleGeometryKernel,
512 SolveKernel* geometryGeometryKernel
515 void createZoneResidualJobs(
516 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
520 SolveKernel* particleParticleKernel,
521 SolveKernel* particleGeometryKernel,
522 SolveKernel* geometryGeometryKernel
526 void createIslandRhsJobs(
532 void createIslandStoreContactForcesJobs(
537 void createZoneIterationJobs(
538 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
539 agx::Physics::HierarchicalGrid::ContactZoneDependencyData& zoneDependency,
544 SolveKernel* particleParticleKernel,
545 SolveKernel* particleGeometryKernel,
546 SolveKernel* geometryGeometryKernel
549 void createIslandIterationJobs(
565 Physics::SolveGroupPtr m_solveGroupPtrs[4];
575 ParallelPGS::JobGraph* generateParallelPgsJobGraph(
578 agx::Physics::HierarchicalGrid::ContactZoneData& zone,
579 agx::Physics::HierarchicalGrid::ContactZoneDependencyData& zoneDependency,
585 ParallelPGS::JobGraph* getParallelPgsJobGraph();
586 void addJobGraphInstaller(Job* loopInstaller);
591 struct SolveJobContext
593 agx::Physics::SolveIslandData* solveIsland;
594 agx::Physics::SolveGroupData* solveGroup;
596 agx::Physics::HierarchicalGrid::ContactZoneData* zone;
597 agx::Physics::HierarchicalGrid::ContactZoneDependencyData* zoneDependency;
603 SolveJobContext m_solveJobContext;
606 SolveKernelRefVector m_kernels;
615 bool m_impactSpeedExplicitlySet;
617 NlMcpConfig m_nlMcpConfig;
620 bool m_calculateIterationResiduals;
622 SolveKernelRef m_storeContactForcesKernel;
623 SolveKernelRef m_commitDirectVelocitiesKernel;
625 SolveKernelRef m_directRhsKernel;
627 SolveKernelRef m_prepareDirectSolverKernel;
628 SolveKernelRef m_directSolverKernel;
629 SolveKernelRef m_synchronizeIterativeSolverKernel;
630 SolveKernelRef m_updateDirectBounds;
631 SolveKernelRef m_synchronizeDirectSolverKernel;
632 SolveKernelRef m_iterationCountKernel;
634 HashSet<Job* > m_visitedJobs;
635 bool m_useParallelPGS;
636 bool m_use32bitGranularSolver;
637 bool m_useGranularWarmStarting;
638 bool m_gatherStatistics;
639 bool m_enableMobilitySolverDataSharing;
641 ParallelPGS::JobGraphRef m_parallelPgsJobGraph;
644 MobilitySolverRefVector m_mobilitySolvers;
645 UInt m_numActiveMobilitySolvers;
654 DirectSolverDataTable m_directSolverDataTable;
660 agx::Physics::SolveIslandData* m_islands;
662 ref_ptr<Referenced> m_nlSolveDataH5;
671 MobilitySolver(Solver* masterSolver,
bool isReference);
673 Solver* getMasterSolver();
674 bool isReferenceSolver()
const;
676 void addKernelCopy(SolveKernel* kernel);
677 void removeKernelCopy(SolveKernel* kernel);
679 SolveKernel* getMobilityKernel(SolveKernel* kernel);
684 void copyFromMaster();
689 virtual ~MobilitySolver();
692 void copy(
bool import);
694 void preSolve(Task* task);
695 void postSolve(Task* task);
701 struct BufferSynchronization
709 Solver* m_masterSolver;
717 Task::ExecutionEvent::CallbackType m_preSolveCallback;
718 Task::ExecutionEvent::CallbackType m_postSolveCallback;
720 typedef HashTable<SolveKernel *, SolveKernel *> KernelTable;
721 KernelTable m_kernelTable;
723 Vector<BufferSynchronization> m_bufferSynchronizations;
731 typedef HashTable<String, SolveModel* > SolveModelTable;
733 class SolveModel :
public Object
738 INVALID_SOLVE_TYPE = -1,
740 DIRECT_AND_ITERATIVE = (1<<1),
747 INVALID_CONSTRAINT_TYPE = -1,
755 static SolveModel::SolveType toSolveType(
const agx::String& str );
756 static SolveModel::ConstraintType toConstraintType(
const agx::String& str );
757 static SolveModel* load(TiXmlElement* eModel,
agx::Device* device);
758 void configure(TiXmlElement* eModel);
761 SolveModel(
const Name& name, SolveType solveType, ConstraintType constraintType);
763 bool isDirect()
const;
764 SolveType getSolveType()
const;
765 ConstraintType getConstraintType()
const;
768 SolveKernel* getPrepareDirectSolveKernel();
769 SolveKernel* getIterativeSolveKernel();
770 SolveKernel* getInternalZoneBeginKernel();
771 SolveKernel* getInternalZoneEndKernel();
772 SolveKernel* getIntegrateVelocitiesKernel();
773 SolveKernel* getUpdateRhsKernel();
774 SolveKernel* getResidualKernel();
775 SolveKernel* getSynchronizeIterativeKernel();
776 SolveKernel* getSynchronizeDirectKernel();
777 SolveKernel* getStoreContactForcesKernel();
779 void setPrepareDirectSolveKernel(SolveKernel* kernel);
780 void setIterativeSolveKernel(SolveKernel* kernel);
781 void setIntegrateVelocitiesKernel(SolveKernel* kernel);
782 void setUpdateRhsKernel(SolveKernel* kernel);
783 void setResidualKernel(SolveKernel* kernel);
784 void setSynchronizeIterativeKernel(SolveKernel* kernel);
785 void setSynchronizeDirectKernel(SolveKernel* kernel);
788 const SolveKernelRefVector& getKernels()
const;
792 virtual ~SolveModel();
796 SolveType m_solveType;
797 ConstraintType m_constraintType;
798 SolveKernelRef m_prepareDirectSolverKernel;
799 SolveKernelRef m_iterativeSolveKernel;
800 SolveKernelRef m_internalZoneBeginKernel;
801 SolveKernelRef m_internalZoneEndKernel;
802 SolveKernelRef m_integrateVelocitiesKernel;
803 SolveKernelRef m_updateRhsKernel;
804 SolveKernelRef m_residualKernel;
805 SolveKernelRef m_storeContactForcesKernel;
806 SolveKernelRef m_synchronizeIterativeKernel;
807 SolveKernelRef m_synchronizeDirectKernel;
808 SolveKernelRefVector m_kernels;
817 typedef agx::Physics::HierarchicalGrid::ContactZoneInstance ContactZoneInstance;
821 agxData::IndexArray interactions_, Physics::SolveIslandPtr island_, Physics::SolveGroupPtr group_,
822 ContactZoneInstance contactZone_ = ContactZoneInstance());
826 Physics::SolveIslandPtr island;
827 Physics::SolveGroupPtr group;
828 ContactZoneInstance contactZone;
836 typedef Callback1<SolveContext> SolveCallback;
840 SolveJob(
const SolveCallback& callback, SolveContext context,
agx::UInt32 cost);
843 void init(
const SolveCallback& callback, SolveContext context,
agx::UInt32 cost);
845 SolveContext& getContext();
848 virtual void implementation()
override;
854 SolveCallback m_solveCallback;
855 SolveContext m_context;
861 class SolveJobT :
public SolveJob
866 virtual ~SolveJobT();
869 virtual void implementation()
override;
878 typedef SolveJob::SolveCallback SolveDispatch;
881 SolveKernel(
const Name& name, SolveDispatch dispatch);
883 const SolveDispatch& getDispatch()
const;
885 virtual void constructJob(SolveJob* job) = 0;
887 virtual ~SolveKernel();
890 SolveDispatch m_dispatch;
898 AGX_FORCE_INLINE UInt Solver::getNumImpactIterations()
const {
return m_numImpactIterations->get(); }
899 AGX_FORCE_INLINE UInt Solver::getNumRestingIterations()
const {
return m_numRestingIterations->get(); }
900 AGX_FORCE_INLINE UInt Solver::getNumPPGSRestingIterations()
const {
return m_numPPGSRestingIterations->get(); }
901 AGX_FORCE_INLINE UInt Solver::getNumDryFrictionIterations()
const {
return m_numDryFrictionIterations->get(); }
902 AGX_FORCE_INLINE bool Solver::isForceIterative()
const {
return m_forceIterative->get(); }
903 AGX_FORCE_INLINE const SolveKernelRefVector& Solver::getKernels()
const {
return m_kernels; }
905 AGX_FORCE_INLINE SolveKernel* Solver::getStoreContactForcesKernel() {
return m_storeContactForcesKernel; }
906 AGX_FORCE_INLINE SolveKernel* Solver::getCommitDirectVelocitiesKernel() {
return m_commitDirectVelocitiesKernel; }
908 AGX_FORCE_INLINE SolveKernel* Solver::getDirectRhsKernel() {
return m_directRhsKernel; }
911 AGX_FORCE_INLINE SolveKernel* Solver::getPrepareDirectSolverKernel() {
return m_prepareDirectSolverKernel; }
912 AGX_FORCE_INLINE SolveKernel* Solver::getDirectSolverKernel() {
return m_directSolverKernel; }
913 AGX_FORCE_INLINE SolveKernel* Solver::getSynchronizeIterativeSolverKernel() {
return m_synchronizeIterativeSolverKernel; }
914 AGX_FORCE_INLINE SolveKernel* Solver::getUpdateBoundsSolverKernel() {
return m_updateDirectBounds; }
915 AGX_FORCE_INLINE SolveKernel* Solver::getSynchronizeDirectSolverKernel() {
return m_synchronizeDirectSolverKernel; }
916 AGX_FORCE_INLINE SolveKernel* Solver::getUpdateIterationCountKernel() {
return m_iterationCountKernel; }
918 AGX_FORCE_INLINE DirectSolverData* Solver::getDirectSolverData(Physics::SolveIslandPtr island)
920 return (DirectSolverData *)m_directSolverDataTable[island.getId()].get();
926 AGX_FORCE_INLINE bool SolveModel::isDirect()
const {
return m_solveType > ITERATIVE; }
927 AGX_FORCE_INLINE SolveModel::SolveType SolveModel::getSolveType()
const {
return m_solveType; }
928 AGX_FORCE_INLINE SolveModel::ConstraintType SolveModel::getConstraintType()
const {
return m_constraintType; }
930 AGX_FORCE_INLINE SolveKernel* SolveModel::getPrepareDirectSolveKernel() {
return m_prepareDirectSolverKernel; }
931 AGX_FORCE_INLINE SolveKernel* SolveModel::getIterativeSolveKernel() {
return m_iterativeSolveKernel; }
932 AGX_FORCE_INLINE SolveKernel* SolveModel::getInternalZoneBeginKernel() {
return m_internalZoneBeginKernel; }
933 AGX_FORCE_INLINE SolveKernel* SolveModel::getInternalZoneEndKernel() {
return m_internalZoneEndKernel; }
934 AGX_FORCE_INLINE SolveKernel* SolveModel::getIntegrateVelocitiesKernel() {
return m_integrateVelocitiesKernel; }
935 AGX_FORCE_INLINE SolveKernel* SolveModel::getUpdateRhsKernel() {
return m_updateRhsKernel; }
936 AGX_FORCE_INLINE SolveKernel* SolveModel::getResidualKernel() {
return m_residualKernel; }
937 AGX_FORCE_INLINE SolveKernel* SolveModel::getStoreContactForcesKernel() {
return m_storeContactForcesKernel; }
938 AGX_FORCE_INLINE SolveKernel* SolveModel::getSynchronizeIterativeKernel() {
return m_synchronizeIterativeKernel; }
939 AGX_FORCE_INLINE SolveKernel* SolveModel::getSynchronizeDirectKernel() {
return m_synchronizeDirectKernel; }
941 AGX_FORCE_INLINE const SolveKernelRefVector& SolveModel::getKernels()
const {
return m_kernels; }
948 Physics::SolveIslandPtr island_,
949 Physics::SolveGroupPtr group_,
950 ContactZoneInstance contactZone_)
951 : interactions(interactions_)
954 , contactZone(contactZone_)
965 this->
init(callback, context, cost);
971 m_solveCallback = callback;
983 SolveJobT<T>::SolveJobT() : SolveJob()
988 SolveJobT<T>::SolveJobT(SolveContext context,
agx::UInt32 cost) : SolveJob(SolveCallback(), context, cost)
993 SolveJobT<T>::~SolveJobT()
998 void SolveJobT<T>::implementation()
1001 static_cast<T*
>(m_task)->dispatch(m_context);
1005 AGX_FORCE_INLINE const SolveKernel::SolveDispatch& SolveKernel::getDispatch()
const {
return m_dispatch; }
1011 # pragma warning(pop)
agx::ref_ptr< Task > TaskRef
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
Data storage for a collection of entity instances of a specified EntityModel.
A model is an abstract representation of the class of an agx::Object.
#define AGX_TYPE_BINDING(_Type, _Name)
#define AGXPHYSICS_EXPORT
AgXString< std::string > String
#define AGX_DECLARE_POINTER_TYPES(type)
Pointer to a entity instance of type Physics.SolveIsland.
VectorPOD< class Job * > JobPtrVector
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
An abstract attribute description, part of an Entity.
Abstract representation of a data buffer.
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
#define AGX_DECLARE_VECTOR_TYPES(type)
void init(const Callback &callback=Callback(), agx::UInt32 costEstimate=100)
Initialize the job.
An agx::Device is an abstract representation of a device on which data can be stored and processed...
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()