|
Tempus Version of the Day
Time Integration
|
The primary goal of Example 1: Utilize Thyra is to replace the raw arrays used in Example 0: Basic Problem with Thyra vectors, while preserving the same van der Pol problem, the same hand-written Forward Euler stepping logic, the same simple tabular solution output, and the same regression-testing workflow.
New concepts introduced from Teuchos and Thyra are:
std::shared_ptrThyra::DetachedVectorView and Thyra::ConstDetachedVectorViewThyra::V_VpStV, Thyra::V_V, Thyra::norm, and Thyra::norm_2This transition is the first step toward expressing the application in terms of abstract numerical interfaces rather than concrete array storage. That abstraction is what later allows Tempus steppers, model evaluators, and solver infrastructure to work with the application state.


The code excerpts below highlight the main changes needed to move from raw arrays to Thyra vectors.
Setup Thyra vectors. The raw double arrays are replaced by Thyra vectors, which are created from a Thyra::VectorSpaceBase. This step also introduces Teuchos::RCP for memory management.
Before
After
The state is now represented through abstract vector interfaces rather than fixed-size arrays.
Initialize Thyra vectors. Initial values are assigned through Thyra::DetachedVectorView. The local scope ensures the detached views are destroyed immediately after use.
Before
After
Evaluate the right-hand side. The van der Pol right-hand side is still evaluated directly in the application code, but element access now goes through detached vector views.
Before
After
Element-wise access is still possible, but it now uses Thyra utilities.
Use Thyra vector algebra. The Forward Euler update is expressed with Thyra::V_VpStV, which performs the vector operation 
Before
After
Use Thyra vector assignment. The accepted solution is copied into the current state using Thyra::V_V.
Before
After
A more detailed comparison can be viewed by diffing:
From 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 (e.g., #include statements and Doxygen comments) and trailing regression-testing lines.