Skip to content

[SI APP] Fixing sensor creation - #14821

Open
Igarizza wants to merge 3 commits into
masterfrom
siapp/fix_sensor_utilities
Open

Igarizza wants to merge 3 commits into
masterfrom
siapp/fix_sensor_utilities

Conversation

@Igarizza

Copy link
Copy Markdown
Member

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.

image

@Igarizza
Igarizza requested review from sunethwarna and talhah-ansari and a lite review from Copilot and removed request for Copilot September 28, 2026 07:37
@Igarizza Igarizza closed this Sep 28, 2026
@Igarizza Igarizza reopened this Sep 28, 2026
Copilot AI lite review requested due to automatic review settings September 30, 2026 05:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Three moderate issues remain unresolved, including API compatibility and empty/deformed-domain lookup behavior.

Review effort: Lite
Findings: 3 Medium severity

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 GeometricalObjectsBins searches.
  • 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants