Conversation
Igarizza
requested review from
sunethwarna and
talhah-ansari
and
a lite review from Copilot
and removed request for
Copilot
September 28, 2026 07:37
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Three moderate issues remain unresolved, including API compatibility and empty/deformed-domain lookup behavior.
Review effort: Lite
Findings: 3
Open (3)
What changed in this PR
This PR accelerates sensor creation by reusing spatial element bins instead of performing brute-force lookups.
Changes:
- Adds shared
GeometricalObjectsBinssearches. - Updates generated sensor and bounding-surface lookup.
- Extends sensor APIs and Python bindings with bin support and tolerance handling.
| File | Summary |
|---|---|
applications/SystemIdentificationApplication/python_scripts/utilities/sensor_utils.py |
Builds and shares element bins. Moderate issue (3 votes): lookup semantics may differ after deformation. |
applications/SystemIdentificationApplication/python_scripts/sensor_generator_analysis.py |
Uses spatial bins for generated sensor locations. Moderate issue (4 votes): empty meshes can cause invalid bin access. |
applications/SystemIdentificationApplication/custom_sensors/strain_sensor.h |
Extends strain sensor creation declarations. |
applications/SystemIdentificationApplication/custom_sensors/strain_sensor.cpp |
Uses bin-based lookup and updated tolerance handling. |
applications/SystemIdentificationApplication/custom_sensors/displacement_sensor.h |
Extends displacement sensor creation declarations. |
applications/SystemIdentificationApplication/custom_sensors/displacement_sensor.cpp |
Uses bin-based lookup and tolerance handling. |
applications/SystemIdentificationApplication/custom_python/add_custom_sensors_to_python.cpp |
Exposes the updated creation signatures. Moderate issue (4 votes): the new required domain_bins argument breaks existing callers. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| py::arg("error_threshold") = Sensor::DefaultErrorThreshold) | ||
| .def_static("GetDefaultParameters", &DisplacementSensor::GetDefaultParameters) | ||
| .def_static("Create", &DisplacementSensor::Create, py::arg("domain_model_part"), py::arg("sensor_model_part"), py::arg("sensor_id"), py::arg("sensor_parameters")) | ||
| .def_static("Create", &DisplacementSensor::Create, py::arg("domain_model_part"), py::arg("sensor_model_part"), py::arg("sensor_id"), py::arg("sensor_parameters"), py::arg("domain_bins")) |
|
|
||
| point_locator = Kratos.BruteForcePointLocator(self.model_part) | ||
| # spatial search built once for all generated points (mesh is in its initial configuration here) | ||
| bins = Kratos.GeometricalObjectsBins(self.model_part.Elements, 1e-8) |
| if domain_model_part.NumberOfElements() == 0: | ||
| raise RuntimeError(f"The domain model part \"{domain_model_part.FullName()}\" has no elements to locate the sensors in.") | ||
| # same local coordinate tolerance as the former brute force point locator | ||
| domain_bins = Kratos.GeometricalObjectsBins(domain_model_part.Elements, 1e-6) |
This branch has not been deployed
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.

name: ✨ Fixing Sensor Utility to be faster
about: Improve the process
📝 Description
Sensor Creation is very slow when we work with DIC, where we have 1000 + sensor points because it runs in one thread. This PR speeds up this utility.