Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
ISolver Class Referenceabstract

Abstract base class for all numerical solvers. More...

#include <ISolver.h>

Inheritance diagram for ISolver:
[legend]

Public Member Functions

virtual ~ISolver ()=default
 Virtual destructor for proper cleanup of derived classes.
 
virtual bool stepFrame ()=0
 Advances the solver by one step.
 

Detailed Description

Abstract base class for all numerical solvers.

ISolver provides a minimal interface for solvers that operate on physics simulations or other iterative processes. The solver is called repeatedly by the physics system until it signals completion.

Design Philosophy

Solvers are intentionally decoupled from physics-specific code. They operate on generic callables (std::function) rather than physics objects directly. This allows the same solver infrastructure to be reused for different problem domains.

Usage Pattern

  1. Construct solver with problem-specific functions
  2. Physics system calls stepFrame() each simulation step
  3. Solver returns false until convergence/completion
  4. Solver returns true when done (success or failure)

Implementations

See also
InterceptSolver, VectorRootSolver
ProblemRouter for automatic solver selection

Example usage:

// Create a solver
auto solver = std::make_unique<InterceptSolver>(
[]() { return currentHeight - targetHeight; }, // monitor function
[]() { return simTime > 60.0f; } // timeout
);
// In physics loop
while (!solver->stepFrame()) {
// Continue simulation
physicsSystem->step(dt);
}
// Solver has finished

Definition at line 59 of file ISolver.h.

Constructor & Destructor Documentation

◆ ~ISolver()

virtual ISolver::~ISolver ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ stepFrame()

virtual bool ISolver::stepFrame ( )
pure virtual

Advances the solver by one step.

This method is called by the physics system after each simulation step. The solver examines the current state and decides whether to continue or declare completion.

Typical Implementation Pattern

Forward solvers (InterceptSolver):

  • Check if stop condition is met
  • Return true if condition satisfied or timeout

Inverse solvers (VectorRootSolver):

  • Extract current output from simulation
  • Compute error vs target
  • Adjust input guess
  • Reset simulation with new guess
  • Return true if converged
Returns
true if solver has finished (converged, intercepted, or failed)
false if solver needs to continue
Note
This method should NOT advance the physics simulation itself. The physics system handles that externally.
Called from physics thread; must be thread-safe if solver accesses shared state

Implemented in InterceptSolver, and VectorRootSolver< InputT, OutputT >.


The documentation for this class was generated from the following file: