Skip to content

Add reaction outputs to f5 files#415

Draft
A-CGray wants to merge 37 commits intomasterfrom
ReactionForces
Draft

Add reaction outputs to f5 files#415
A-CGray wants to merge 37 commits intomasterfrom
ReactionForces

Conversation

@A-CGray
Copy link
Contributor

@A-CGray A-CGray commented Feb 12, 2026

This PR relies on the changes in #336 .

Add reactions (e.g reaction forces and moments, or heat fluxes) as a separate output in f5 files.

PlateForces

Summary of changes

  • Add computeReactions method to TACSAssembler: Computes the reactions at constrained DOFs by computing residual with no external forcing terms then zeroing all but the constrained DOF entries.
  • Adds reaction output in .f5 files: relies on a new TACS_OUTPUT_REACTIONS flag (enabled by default in pyTACS via a writeReactions option)
  • Calculation of external force outputs (TACS_OUTPUT_LOADS) now zeros BC terms to avoid including non-zero Dirichlet contributions.
  • Equilibrium test in the base test class — all static problem integration tests now verify that the sum of applied forces and reaction forces (including moments) is zero, a few tests where this doesn't hold (geometrically nonlinear hemisphere and spring) are skipped.
  • Adds globalToLocalArray and localToGlobalArray helper functions in pyTACS that convert global arrays of nodal values (e.g coordinates or states) to local arrays or vice versa, accounting for TACS' parallel decomposition and node reordering. I use them in the the equilibrium tests but I think it's a useful utility for users.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for computing and outputting reaction forces at constrained degrees of freedom to F5 files. It builds on changes from PR #336 which improved boundary condition handling in TACS. The implementation includes a new computeReactions method in TACSAssembler, support for a TACS_OUTPUT_REACTIONS flag in F5 output, and comprehensive equilibrium tests to validate the correctness of the reaction force calculations.

Changes:

  • Added computeReactions method to TACSAssembler that computes reactions at constrained DOFs by computing residual differences with and without BC application
  • Extended assembly methods (assembleRes, assembleJacobian, etc.) with optional applyBCs parameter to control boundary condition application, enabling more flexible use of these methods
  • Added lambda scaling parameter to BC methods (setBCs, applyBCs) to support load/displacement control
  • Implemented reaction force output in F5 files through new TACS_OUTPUT_REACTIONS flag and associated component naming
  • Added equilibrium tests for all static problems that verify sum of applied and reaction forces/moments equals zero
  • Added globalToLocalArray and localToGlobalArray utility methods in pyTACS for converting between global and local node orderings
  • Updated test tolerances from PR #336 (complex-step: 1e-7 → 1e-10, finite-difference: 1e-2 → 1e-4)
  • Fixed adjoint BC application in time integrators and improved related documentation

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/TACSAssembler.h/.cpp Added computeReactions method and applyBCs/lambda parameters to assembly and BC methods
src/bpmat/TACSBVec.h/.cpp Added lambda parameter to setBCs and applyBCs methods
src/bpmat/KSM.h Updated virtual method signatures for applyBCs and setBCs
src/TACSIntegrator.cpp Added explicit applyBCs calls after addSVSens in BDF and DIRK integrators
src/elements/TACSElementTypes.h/.cpp Added TACS_OUTPUT_REACTIONS flag and component names for reactions
src/io/TACSToFH5.cpp Implemented reaction force computation and output in F5 files
tacs/cpp_headers/TACS.pxd Updated Cython declarations for new parameters
tacs/TACS.pyx Added Python wrappers for new parameters and computeReactions method
tacs/pytacs.py Added globalToLocalArray/localToGlobalArray utility methods and writeReactions option
tacs/problems/static.py Added applyBCs parameter to updateJacobian, removed redundant BC calls
tests/integration_tests/pytacs_analysis_base_test.py Added equilibrium test for static problems
tests/integration_tests/static_analysis_base_test.py Added explicit applyBCs call before adjoint solve, improved documentation
tests/integration_tests/openmdao_analysis_base_test.py Updated test tolerances and removed unnecessary exclusions
tests/integration_tests/test_matrix_operations.py Refactored to use new pyTACS array conversion methods
tests/integration_tests/test_simple_spring.py Added equilibrium check skip flag and main block
tests/integration_tests/test_shell_hemisphere_nonlinear.py Added equilibrium check skip flag for nonlinear problems
tests/integration_tests/test_pcm_element_2d.py Fixed hardcoded tNum parameter bug
tests/integration_tests/test_mphys_struct_plate.py Updated test tolerances
Comments suppressed due to low confidence (1)

tacs/problems/static.py:1040

  • The docstring for the updateJacobian method is missing documentation for the new applyBCs parameter. Please add a description of this parameter in the Parameters section of the docstring.
    def updateJacobian(self, res=None, applyBCs=True):
        """Update the Jacobian (a.k.a stiffness) matrix

        The Jacobian will only actually be updated if the
        ``_jacobianUpdateRequired`` flag is set to True.

        Parameters
        ----------
        res : tacs.TACS.Vec, optional
            If provided, the residual is also computed and stored in this vector
        """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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