Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kratos lspg hrom #11569

Merged
merged 26 commits into from
Oct 19, 2023
Merged

Kratos lspg hrom #11569

merged 26 commits into from
Oct 19, 2023

Conversation

SADPR
Copy link
Contributor

@SADPR SADPR commented Sep 15, 2023

Description

​The main developments for enabling the LSPG HROM involved the inclusion of a set of complementary elements and conditions corresponding to the HROM selected subset of elements and conditions.

In essence, the HROM LSPG is first assembled by iterating over the subset of HROM selected elements and multiplying them by positive weights. This results in the system:
$$J_h \Phi q = - R_h $$
For LSPG projection, we multiply by a left Reduced Order Basis (ROB), defined as:
$$\Psi = J_{c} \Phi $$
Here, $J_c$​ is assembled with the subset of HROM selected elements plus the complementary mesh, i.e., the neighboring nodes of this subset. After constructing $J_c$ , it's essential to zero out the degrees of freedom that are not part of the subset of HROM element's DOFs. This ensures that only the relevant DOFs contribute to the projection.

This gives:
$$\Psi^T J_h \Phi q = -\Psi^T R_h$$

or equivalently,
$$(J_{c} \Phi)^T J_h \Phi q = -(J_{c} \Phi)^T R_h$$

Changes in LSPG Builder and Solver:

SetUpDofSet

  • Added and overrode SetUpDofSet to introduce the complementary mesh elements.
  • Implemented FindNeighbouringElementsAndConditions(rModelPart).

BuildWithComplementaryMeshAndApplyDirichletConditions

  • Introduced a method to build the system with the complementary mesh and apply Dirichlet conditions.

InitializeSelectedDofs

  • Added a function to populate the mSelectedDofs set with the DOFs that are part of the selected elements and conditions. This set is then used to determine which rows of the system matrix should be zeroed out in subsequent time steps.

ZeroOutUnselectedComplementaryMeshRows

  • Introduced a function to zero out the rows of the system matrix 'rA' that correspond to the DOFs of the complementary mesh. This function uses the mSelectedDofs set to determine which rows should remain non-zero.

BuildWithComplementaryMesh

  • Introduced a function to perform the build of the LHS and RHS on the selected elements and the corresponding complementary mesh. This function takes into account the integration scheme and the model part of the problem to solve, resulting in the LHS matrix and RHS vector.

Summary of other Changes:

  • applications/RomApplication/custom_python/add_custom_utilities_to_python.cpp

    • Exported new functions to Python.
  • applications/RomApplication/custom_utilities/rom_auxiliary_utilities.cpp & applications/RomApplication/custom_utilities/rom_auxiliary_utilities.h

    • Introduced a method SetHRomComputingModelPartWithNeighbours to set the HROM model part, including neighboring entities based on nodal weights.
    • Added the GetJPhiElemental function to obtain the JPhi elemental matrix for a particular element.
  • applications/RomApplication/custom_utilities/rom_residuals_utility.h

    • Introduced the method GetProjectedResidualsOntoJPhi for obtaining projected residuals.
  • applications/RomApplication/python_scripts/hrom_training_utility.py

    • Implemented functionalities for retrieving HROM matrices and projecting residuals onto JPhi.
    • Added routines for preparing and writing the HROM model part, augmented with neighboring elements for LSPG.
  • applications/RomApplication/python_scripts/petrov_galerkin_training_utility.py

    • Corrected a minor error: Changed GetRightRomBasis to GetRightROMBasis.
  • applications/RomApplication/python_scripts/rom_manager.py

    • Introduced trainHROMLSPG and runHROMLSPG options within the self._ChangeRomFlags method to accommodate HROM LSPG simulations.

Test-related changes:

  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/ExpectedOutputLSPGHROM.npy
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/ProjectParametersHROM.json
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/couette_flow_testHROM.mdpa
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/rom_data/HROM_ConditionIds.npy
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/rom_data/HROM_ConditionWeights.npy
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/rom_data/HROM_ElementIds.npy
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/rom_data/HROM_ElementWeights.npy
  • applications/RomApplication/tests/fluid_dynamics_test_files/LSPGHROM/rom_data/RomParameters.json
  • applications/RomApplication/tests/test_fluid_lspg_rom.py

@SADPR SADPR marked this pull request as ready for review September 19, 2023 17:55
@SADPR SADPR requested a review from a team as a code owner September 19, 2023 17:55
@SADPR SADPR added the ROM label Sep 19, 2023
Copy link
Member

@Rbravo555 Rbravo555 left a comment

Choose a reason for hiding this comment

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

Preliminary review looking good. Just two comments that could well be added as TODOs for future PRs

@RiccardoRossi
Copy link
Member

what is missing here?

@Rbravo555
Copy link
Member

Let us just catch whether "elemental" or "global" is requested for LSPG, and raise a warning when "elemental" is selected. Only "global" LSPG is implemented

@SADPR SADPR merged commit 483f522 into master Oct 19, 2023
@SADPR SADPR deleted the Kratos_LSPG_HROM branch October 19, 2023 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

8 participants