Open
Conversation
Introduce a new Rotation subsystem: adds a C++ Rotation class (include/.../rotation_class.hpp and src/Simulation/Maths/rotation_class.cpp) implementing quaternion-based 3D rotations, Voigt operations, Euler conventions, SLERP, and apply methods for vectors/tensors. Add Python bindings (pybind11) and headers in simcoon-python-builder, update its CMake to build the rotation_class wrapper, and extend the python module registration. Add comprehensive documentation pages (continuum mechanics and C++ API) and index updates. Include a unit test (test/Libraries/Maths/TRotationClass.cpp) and adjust top-level CMakeLists where needed. This patch adds rotation functionality, docs, bindings, and tests to enable quaternion-based rotation operations from C++ and Python.
Add input validation helpers in the Python wrapper (validate_vector_size, validate_matrix_size) and apply them to rotation bindings to ensure correct array shapes. Add SciPy interoperability: Rotation.from_scipy and to_scipy methods with docs and conversions via quaternions. Replace uses of legacy sim_pi/sim_iota with simcoon::pi and simcoon::iota across Rotation implementation and update tests accordingly to use the centralized constants. This improves robustness of the Python API and unifies constant usage in the core code and tests.
Expand rotation Python docs with Scipy interoperability, active vs passive rotation conventions, input validation guidance, and notes on quaternion equivalence. Fix cross‑references in C++ API docs to point to the correct continuum_mechanics doc pages. Rename test file to Trotation_class.cpp, update CMakeLists, and add comprehensive Rotation unit tests (tensor/stiffness/compliance behavior, factory methods, Euler conventions, round‑trip and gimbal‑lock cases) to improve coverage and verify correctness.
kmarchais
reviewed
Feb 5, 2026
kmarchais
approved these changes
Feb 5, 2026
Rename ambiguous as_QS/as_QE to explicit as_voigt_stress_rotation/as_voigt_strain_rotation and add apply_localization_strain/apply_localization_stress to Rotation API. Update implementation, header, Python bindings, documentation and tests to use the new names and to expose rotation of localization tensors (QE·A·QS^T and QS·B·QE^T). Refactor callers (ellipsoid_multi, state_variables*, etc.) to use Rotation::from_euler and the new apply_* methods instead of ad-hoc rotate_* helpers; add necessary includes and input validation for 6×6 tensors. Add unit tests verifying consistency with existing fillQS/fillQE/rotateA/rotateB functions and update docs to reflect the new API and examples.
Remove default values for Euler convention and active/passive flags across rotation APIs and pybind bindings to force callers to specify convention and mode. Updated C++ headers (rotation.hpp, rotation_class.hpp) and Python wrappers to make conv and active mandatory, adjusted pybind registrations in python_module.cpp and rotation_class.cpp, and updated tests (Trotation.cpp) to pass explicit arguments. Also add simcoon_docs rotation docstrings (doc_rotation.hpp) and hook them into module definitions for improved Python documentation.
Docs updated to remove references to a "default" Euler convention and require the convention to be specified in examples. In rotation.cpp, the previous behavior of printing an error and falling back to default axes has been replaced with throwing std::invalid_argument when an invalid Euler convention is supplied (message lists supported conventions). This enforces explicit, valid conventions and prevents silent fallback. Affected files: docs/continuum_mechanics/functions/doc_rotation.rst, docs/cpp_api/simulation/rotation.rst, src/Simulation/Maths/rotation.cpp.
Rename and reorganize rotation-related documentation to match updated API names and types. Key changes: - Replace old function names with clearer ones: rotateL/rotateM -> rotate_stiffness/rotate_compliance; apply_localization_* -> apply_*_concentration; rotate_l2g_*/g2l_* functions replaced by *_R and *_angle variants. - Update free-function autodoc/doxygen entries and Python autofunction names accordingly. - Change C++ include references from rotation_class.hpp to rotation.hpp and document new Rotation construction functions (Rotation::from_euler, Rotation::from_axis_angle). - Update examples to use Rotation::from_euler or pass a Rotation matrix to free functions. These edits align the docs with the refactored rotation API and clarify naming (strain/stress concentration vs localization).
Rename and reorganize rotation-related Python wrappers and docs for clarity and vectorized usage. Replaced legacy fillR/fillQS/fillQE and rotateL/M/A/B/l2g/g2l APIs with clearer functions (rotate_stiffness_*, rotate_compliance_*, rotate_strain_concentration_*, rotate_stress_concentration_*, rotate_strain_*, rotate_stress_*), updated wrapper implementations to use descriptive variable names and support batched (ndim==2) inputs, and adjusted Rotation class method names (apply_localization_* -> apply_*_concentration). Also updated example docs to use simcoon.Rotation.from_axis_angle(...). Modified files: include/docs/Libraries/Maths/doc_rotation.hpp, include/simcoon/python_wrappers/Libraries/Maths/rotation.hpp, src/python_wrappers/Libraries/Maths/rotation.cpp, src/python_wrappers/Libraries/Maths/rotation_class.cpp, src/python_wrappers/python_module.cpp.
Introduce a unified Rotation class into rotation.hpp (merged from the removed rotation_class.hpp) providing quaternion-based factories, conversions, and apply methods for vectors, tensors and Voigt-notation quantities. Rename and refactor many legacy free functions (fillR / fillQS / fillQE / rotateL / rotateM / rotateA / rotateB / etc.) to clearer APIs (rotate_vec/rotate_mat, rotate_stress, rotate_strain, rotate_stiffness, rotate_compliance, rotate_strain_concentration, rotate_stress_concentration, etc.). Update the Python example to use sim.Rotation.from_axis_angle / from_euler and the new rotate_* function names. Remove the standalone rotation_class header and corresponding legacy sources to consolidate rotation functionality; this is a breaking API change that modernizes rotation handling and exposes richer functionality (quaternions, Euler, rotvec, Voigt helpers, slerp, composition, etc.).
Replace legacy rotation helpers with the new Rotation class methods across the codebase and tests. Updates include: using Rotation::from_euler / from_matrix and its apply_* helpers (apply_stiffness, apply_compliance, apply_strain/apply_stress, apply_strain_concentration/apply_stress_concentration) instead of free functions like rotateL, rotateM, rotateA, rotate_g2l_L, rotate_g2l_stress, rotate_l2g_A, fillR, fillQE/QS, etc. Remove includes of rotation_class.hpp where no longer needed. Adjusted unit tests to construct expected rotations via the Rotation API and to validate transformations by applying rotations to vectors/matrices rather than calling the old utility functions. Changes touch continuum mechanics, homogenization, micromechanics schemes, phase state variables, and math tests to unify on the new rotation interface and improve consistency.
kmarchais
reviewed
Feb 6, 2026
Comment on lines
160
to
165
kmarchais
reviewed
Feb 6, 2026
Comment on lines
194
to
195
kmarchais
reviewed
Feb 6, 2026
Comment on lines
5
to
125
Member
Author
There was a problem hiding this comment.
It is not!, will be removed in a next commit
kmarchais
reviewed
Feb 6, 2026
Comment on lines
19
to
33
Member
Author
There was a problem hiding this comment.
All file will be removed in a forthcoming commit
kmarchais
reviewed
Feb 6, 2026
Comment on lines
36
to
41
Member
Author
There was a problem hiding this comment.
same, all these functions should disappear, not more _R or _angle
kmarchais
reviewed
Feb 6, 2026
Comment on lines
17
to
193
Member
Author
There was a problem hiding this comment.
The file will disappear
kmarchais
reviewed
Feb 6, 2026
Comment on lines
214
to
229
Member
Author
There was a problem hiding this comment.
Same, all these functions are to be removed
kmarchais
reviewed
Feb 6, 2026
kmarchais
reviewed
Feb 6, 2026
Comment on lines
98
to
126
| @@ -75,16 +116,16 @@ mat fillR(const double &alpha, const int &axis, const bool &active) { | |||
| break; | |||
| } | |||
| default: { | |||
| cout << "Please choose the axis 1,2 or 3\n"; | |||
| throw invalid_argument("Please choose the axis 1, 2 or 3"); | |||
| } | |||
| } | |||
| return R; | |||
| } | |||
|
|
|||
| mat fillR(const double &psi, const double &theta, const double &phi, const bool &active, const std::string &conv) { | |||
| // Internal: Generate a 3x3 rotation matrix using Euler angles | |||
| mat fillR_euler_internal(const double &psi, const double &theta, const double &phi, const bool &active, const std::string &conv) { | |||
Member
Author
There was a problem hiding this comment.
the file will disappear
kmarchais
requested changes
Feb 6, 2026
Member
kmarchais
left a comment
There was a problem hiding this comment.
Probably there are still a few notations left to modify unless this is intentional
Remove the legacy Python bindings and documentation for the standalone rotation free-functions and migrate examples/docs to use the Rotation class API. Changes: - Docs: updated docs/continuum_mechanics/functions/doc_rotation.rst and docs/cpp_api/simulation/rotation.rst to remove free-function sections and emphasize the Rotation class. - Examples: examples/continuum_mechanics/rotation.py rewritten to use simcoon.Rotation (from_axis_angle/from_euler and apply/apply_tensor/apply_stress/etc.) instead of the rotate_* free functions. - Python bindings: deleted simcoon-python-builder/include/simcoon/docs/Libraries/Maths/doc_rotation.hpp, include/simcoon/python_wrappers/Libraries/Maths/rotation.hpp and src/python_wrappers/Libraries/Maths/rotation.cpp; removed their registration from python_module.cpp. - Build: simcoon-python-builder/CMakeLists.txt no longer compiles src/python_wrappers/Libraries/Maths/rotation.cpp. Rationale: consolidate the public Python API around the object-oriented Rotation class and remove duplicated/free-function Python wrappers while keeping the Rotation class binding and C++ API intact.
Rename the Rotation pybind11 wrapper files and update references: rotation_class.hpp -> rotation.hpp and rotation_class.cpp -> rotation.cpp. Rename the registration function register_rotation_class -> register_rotation and update its declaration, definition, includes, and the call in python_module.cpp. Update CMakeLists.txt to build src/python_wrappers/Libraries/Maths/rotation.cpp. This unifies the wrapper naming and keeps module registration consistent.
kmarchais
approved these changes
Feb 7, 2026
Make simcoon.Rotation a subclass of scipy.spatial.transform.Rotation and add full scipy interoperability. Adds a pure-Python simcoon.rotation.Rotation wrapper that inherits scipy Rotation and delegates mechanics operations (apply_stress/strain/stiffness/etc.) to the C++ backend via a new _CppRotation interface. The C++ pybind wrapper was adjusted to expose simcoon::Rotation as _CppRotation and to accept plain scipy-like Rotation objects (duck-typed via as_quat) for composition, slerp and equality. Updated package metadata to require scipy, refreshed docs and examples to use scipy Euler conventions and show interoperability, and added comprehensive tests for type identity, mechanics methods, scipy upgrades, and C++ handling of scipy objects. Also import Rotation in __init__ to override the star-imported C++ class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a major enhancement to Simcoon 2.0 by adding a comprehensive new 3D rotation library centered around a
Rotationclass, with full Python bindings and extensive documentation. The changes improve both the C++ and Python APIs, update the documentation to reflect the new capabilities, and ensure the new class is tested and integrated throughout the build system.Rotation Library Addition and Integration:
Rotationclass for 3D rotations, using unit quaternions internally for stability and efficiency, with support for various representations (Euler angles, rotation matrices, quaternions, rotation vectors, axis-angle), composition, interpolation (SLERP), and Voigt notation transformations. The class is available in both C++ and Python APIs. [1] [2]Rotationclass in the Python bindings via pybind11, including the new wrapper source and header files in the build system for both C++ and Python modules. [1] [2] [3] [4]Rotationclass to the test suite.Documentation Updates:
doc_rotation.rst) detailing theRotationclass, its API, usage examples, and practical applications in continuum mechanics.