State manipulation function moved into Variables (PR #764)
Hi all,
I have just merged PR #764 [1], which has some implications for the interactive problem description files (especially for time-dependent problems), because the imperative API has been revisited. The PR #764 addresses the long standing issue #378 [2] which caused a number of subtle bugs. The main changed are listed below, for more see the PR page.
I recommend looking at [3], [4], [5] - do not hesitate to ask in case of problems.
[1] https://github.com/sfepy/sfepy/pull/764 [2] https://github.com/sfepy/sfepy/issues/378 [3] https://sfepy.org/doc-devel/examples/diffusion-time_poisson_interactive.html [4] https://sfepy.org/doc-devel/examples/linear_elasticity-its2D_interactive.htm... [5] https://sfepy.org/doc-devel/primer.html#running-sfepy-in-interactive-mode
Description of the changes:
Old (replaced) API:
- State instance holds a global DOF vector that contains as contiguous sub-vectors (slices) the data of the unknown (state) variables from the Variables container.
- Possible to set DOF vector to a variable without changing the DOF vector in the State instance that contains the variable. -> Prone to hard-to-debug bugs (#378)
- Inconsistent naming of functions (historical code evolution).
New API:
- No State, only Variables.
- Once Variables.init_state() is called, the state variables are locked - cannot use variable.set_data() directly.
- Problem.solve() and other functions that worked/returned State instance return now the Variables instance instead.
- Declarative problem description API not affected.
- Imperative problem description API changed in a not backward-compatible way
due to:
- Renamed or removed functions (mostly Variables and related Equations methods and former State methods).
- Locking of the state variables.
- No need to create State instances (no State class).
- Problem.create_state() is now an alias to Problem.get_initial_state(), which sets up initial conditions - those have to be set using Problem.set_ics() before Problem.create_state()/.get_initial_state() are called.
- Stationary examples likely affected only in post-processing of results, after calling Problem.solve().
- Time dependent examples need to be adjusted already when dealing with the initial state: calling Problem.get_initial_state() should do the job (provided the conditions are set, see above).
Best regards, r.
participants (1)
-
Robert Cimrman