|
Tempus Version of the Day
Time Integration
|
The primary goal of Example 2: Use ModelEvaluator is to move the van der Pol problem definition into a Thyra::ModelEvaluator while preserving the same Thyra-based state representation and the same Forward Euler stepping logic used in Example 1: Utilize Thyra.
New concepts introduced are:
Thyra::ModelEvaluatorBase::InArgsThyra::ModelEvaluatorBase::OutArgsgetNominalValues()evalModel()This is the first step in separating the problem physics from the time integration algorithm. Rather than evaluating the right-hand side directly in the application, the code now requests that evaluation through a common model interface. This is a key part of how Tempus steppers and integrators interact with application models.
The code excerpts below highlight the main changes needed to move from direct application-level right-hand-side evaluation to the use of a Thyra::ModelEvaluator.
Construct a ModelEvaluator. The application now creates an object that represents the problem model.
Before
After
The application now delegates model-specific information to a dedicated model object.
Obtain nominal initial conditions from the model. The nominal solution and its time derivative are no longer assembled manually.
Before
After
Evaluate the right-hand side through ModelEvaluator. The application fills InArgs and OutArgs and then requests the model evaluation.
Before
After
The right-hand side is now obtained through the model interface rather than being coded directly in the time loop.
A more detailed comparison can be made by diffing:
examples/01_Utilize_Thyra/01_Utilize_Thyra.cppexamples/02_Use_ModelEvaluator/02_Use_ModelEvaluator.cppFrom the packages/tempus directory, a focused comparison of the main time-integration logic between these two examples can be generated locally in bash or zsh with:
This ignores leading header lines (for example, #include statements and Doxygen comments) and trailing regression-testing lines.