Skip to content

[GeoMechanicsApplication] Accept computing_model_part_name in process model parts - #14854

Open
WPK4FEM wants to merge 4 commits into
masterfrom
geo/accept_computing_model_part_name
Open

WPK4FEM wants to merge 4 commits into
masterfrom
geo/accept_computing_model_part_name

Conversation

@WPK4FEM

@WPK4FEM WPK4FEM commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

📝 Description

  • Split off the computing_model_part_name acceptance from the biaxial test introduction.

  • This contains the addition to Join functionality in string_utilities.cpp too.

  • Unit tests for process_utilities and string_utilities have been adapted and extended.

…est introduction.

This contains the addition to Join functionality in string_utilities.cpp too.

Unit tests for process_utilities and string_utilities have been adapted and extended.
@WPK4FEM WPK4FEM self-assigned this Oct 9, 2026
@WPK4FEM
WPK4FEM requested a review from a team as a code owner October 9, 2026 09:58
@WPK4FEM
WPK4FEM requested review from avdg81 and markelov208 October 9, 2026 09:58

@avdg81 avdg81 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.

Dear Wijtze Pieter,
Thank you very much for moving these changes to a separate PR, and for addressing my previous suggestions. I have three more very minor suggestions (which I had either forgotten to mention before or which were raised by SonarQube). I think this PR is almost ready to go. 👍

Comment thread applications/GeoMechanicsApplication/custom_utilities/process_utilities.cpp Outdated
Comment thread applications/GeoMechanicsApplication/custom_utilities/process_utilities.h Outdated
Comment thread applications/GeoMechanicsApplication/custom_utilities/process_utilities.cpp Outdated
- use of std::ranges
- transparent std::less<> for string comparison
- string literals used in header file.
avdg81
avdg81 previously approved these changes Oct 9, 2026

@avdg81 avdg81 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.

Hi Wijtze Pieter,
Thanks for addressing the final suggestions that I had. From my side, this PR looks good to go. Let's wait for @markelov208's review of this PR. Thanks.

@markelov208 markelov208 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.

Hi Wijtze Pieter, many thanks for this extention for processes that were never used before. I have a few coments. If you have any question, please let me know.

std::string_view Prefix)
{
const std::set<std::string, std::less<>> processes_having_computing_model_part_name = {
"AssignAverageMasterSlaveConstraintsProcess"s, "ApplyPeriodicConditionProcess"s, "SkinDetectionProcess"s};

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 AI: Optional computing-part names can break valid process settings. In process_utilities.cpp:55-61, the three recognized processes are required to provide computing_model_part_name in the raw project settings. But apply_periodic_condition_process.py:30-40 and skin_detection_process.py:14-28 supply defaults for that setting, and the GeoMechanics solver scans settings before constructing processes (geomechanics_solvers_wrapper.py:36-40). Omitting the key therefore throws before those defaults apply. For periodic conditions, explicitly using the valid empty default also adds "" to the generated list; preparation then attempts to resolve it as a submodelpart.

Shall only AssignAverageMasterSlaveConstraintsProcess be added now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Generally I think that a process parameters file should contain the process_name records.
The copilot remark about GeoMechanics solver scans settings before constructing processes generally holds, otherwise we could not create process_sub_model_part_list the way we do now.
I would like to keep all 3 process names in the given list, otherwise the knowledge that they need computing_model_part_name is lost, whilst any user can still add them to a computation with GeoMechanicsApplication.

if (!r_process.Has("Parameters")) continue;
const auto model_part_names = GetProcessModelPartNames(r_process["Parameters"], {});
const auto model_part_name_keys =
r_process.Has("process_name") &&

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.

As far as I understand r_process.Has("process_name") is to prevent a problem with the next line. By now none of our integration tests use process with missing process_name. Only a few unit tests do not use it. Shall process_name be mandatory for all processes?
Secondly, it seems these new lines are not tested with unit test, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The r_process.Has("process_name") is to let all behavior that we not have discovered yet use the current and previous default of looking at model_part_name and model_part_name list.

Indeed coverage analysis on these lines did not show use yet, so I added a test using only of the master slave processes that needs computing_model_part_name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tried to find out if always a process should have process_name.
That does not seem to be the case. Part of the AI answer:

When process_name Is Optional or Omitted
• Custom / Python-defined processes: If a process is instantiated directly in your Python script (MainKratos.py) or uses a custom wrapper rather than Kratos's automatic process factory, the C++ or Python constructor may only look for python_module, kratos_module, and the inner Parameters dictionary.

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.

Here is what AI found:
python_module tells Kratos which Python module to import. For the usual module-based process path, the core factory calls that module’s Factory(item, Model); it does not require process_name itself (core process factory, process_factory.py:68).
A few processes use process_name. Core process_factory: ApplyConstantScalarValueProcess, ApplyConstantVectorValueProcess, TimeAveragingProcess. Its Factory reads process_name to choose the C++ process.
AssignAverageMasterSlaveConstraintsProcess, ApplyPeriodicConditionProcess, SkinDetectionProcess do not require process_name.
What is your opinion: is it better to use python_module instead of process_name?

Comment thread applications/GeoMechanicsApplication/custom_utilities/string_utilities.h Outdated
rClampCharacter -> rNameWrapper
tested extra condition in process_utilities

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.

4 participants