Conversation
Contributor
There was a problem hiding this comment.
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
computeReactionsmethod toTACSAssemblerthat computes reactions at constrained DOFs by computing residual differences with and without BC application - Extended assembly methods (
assembleRes,assembleJacobian, etc.) with optionalapplyBCsparameter to control boundary condition application, enabling more flexible use of these methods - Added
lambdascaling parameter to BC methods (setBCs,applyBCs) to support load/displacement control - Implemented reaction force output in F5 files through new
TACS_OUTPUT_REACTIONSflag and associated component naming - Added equilibrium tests for all static problems that verify sum of applied and reaction forces/moments equals zero
- Added
globalToLocalArrayandlocalToGlobalArrayutility 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
updateJacobianmethod is missing documentation for the newapplyBCsparameter. 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.
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.
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.
Summary of changes
computeReactionsmethod toTACSAssembler: Computes the reactions at constrained DOFs by computing residual with no external forcing terms then zeroing all but the constrained DOF entries.TACS_OUTPUT_REACTIONSflag (enabled by default inpyTACSvia awriteReactionsoption)TACS_OUTPUT_LOADS) now zeros BC terms to avoid including non-zero Dirichlet contributions.globalToLocalArrayandlocalToGlobalArrayhelper functions inpyTACSthat 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.