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

Add nonlinear shell elements and solver #193

Merged
merged 190 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 189 commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
b712453
Define some additional nonlinear element types
A-CGray Jan 25, 2023
091c256
Add cantilever example/benchmark
A-CGray Jan 26, 2023
5ce0d82
Add cantilever example mesh
A-CGray Jan 26, 2023
ff4756a
Add more nonlinear example cases
A-CGray Jan 26, 2023
429185d
Add option to specify that problem is nonlinear
A-CGray Feb 7, 2023
d9a1415
add a `getForces` method
A-CGray Feb 7, 2023
b1c718d
fix capitalisation of `isNonlinear`
A-CGray Feb 10, 2023
61e75b1
black format
A-CGray Feb 10, 2023
03676ce
more black formatting
A-CGray Feb 10, 2023
0df1ed4
Revert "more black formatting"
A-CGray Feb 10, 2023
426de50
More black formatting
A-CGray Feb 10, 2023
55b3e36
Nonlinear solver functioning with basic incrementation
A-CGray Feb 10, 2023
e58d80a
Merge remote-tracking branch 'origin/master' into NLSolverDev
A-CGray Feb 10, 2023
97f8c93
Remove skin_buckle benchmark
A-CGray Feb 10, 2023
337f73b
Fix bug `addDirectorJacobian` in `TACSQuadraticRotation`
A-CGray Feb 10, 2023
7f7aec3
Add moderate rotation elements to shell tests
A-CGray Feb 10, 2023
c079ff2
Merge remote-tracking branch 'origin/master' into NLSolverDev
A-CGray Feb 16, 2023
3624093
Improve clarity of printout for element mat derivative tests
A-CGray Feb 16, 2023
0f09532
Add SolverHistory to utils
A-CGray Feb 16, 2023
3db81d6
Add methods for retreiving number of iterations and residual norm fro…
A-CGray Feb 17, 2023
b24daeb
black formatting
A-CGray Feb 17, 2023
c08e61f
Nonlinear solver working with solver history
A-CGray Feb 18, 2023
8d9d5c3
Example tweaks
A-CGray Feb 18, 2023
917a816
Add methods for retreiving number of iterations and residual norm fro…
A-CGray Feb 17, 2023
2f5726a
PCG fix
A-CGray Feb 18, 2023
254099d
clang-format
A-CGray Feb 18, 2023
7e3355b
Test `getResidualNorm` and `getIterCount` in `StaticTestCase`
A-CGray Feb 18, 2023
745a984
Merge branch 'addKSMOutputs' into NLSolverDev
A-CGray Feb 20, 2023
92cab8f
PCG fix
A-CGray Feb 18, 2023
3ab3c75
Fix SuiteSparse installation commands
A-CGray Feb 21, 2023
af372be
Fix solution file writing
A-CGray Feb 21, 2023
47e515b
Fix compiler warning
A-CGray Feb 21, 2023
c162ec1
Implemented adaptive linear solver convergence using Eisenstat-Walker…
A-CGray Feb 21, 2023
c12974e
Add __init__ method to BaseUI
A-CGray Feb 22, 2023
8037df3
Examples options tweaks
A-CGray Feb 22, 2023
6ad31d0
More example options tweaks
A-CGray Feb 22, 2023
8887345
Add __init__ method to BaseUI
A-CGray Feb 22, 2023
fed66be
Modify problem classes to use __init__ from BaseUI
A-CGray Feb 22, 2023
cc6414e
Modify problem classes to use __init__ from BaseUI
A-CGray Feb 22, 2023
ed15c75
add back isNonlinear to transient problem
A-CGray Feb 22, 2023
5ca2064
Merge remote-tracking branch 'origin/master' into NLSolverDev
A-CGray Feb 22, 2023
4c890d4
black formatting
A-CGray Mar 2, 2023
a9508c6
Fixing some imports
A-CGray Mar 2, 2023
3d632dd
Adding new standalone solver classes
A-CGray Mar 2, 2023
ea06c70
Add solvers docs pages
A-CGray Mar 2, 2023
dcf5630
Solvers __init__
A-CGray Mar 2, 2023
4eb7152
Starting to incorporate NewtonSolver insto Static problem, not workin…
A-CGray Mar 2, 2023
520c8d7
Address Graeme's comments
A-CGray Mar 2, 2023
9c0a3a4
Treat resNorm consistently in all solvers
A-CGray Mar 2, 2023
70e5903
typo
A-CGray Mar 2, 2023
31475ea
Remove unnecessary abs
A-CGray Mar 2, 2023
baec601
Make resNorm and iterCount getters virtual
A-CGray Mar 2, 2023
a5f1305
Merge remote-tracking branch 'origin/addKSMOutputs' into NLSolverDev
A-CGray Mar 3, 2023
83e9513
Fix bug in nonlinear solver option passing
A-CGray Mar 3, 2023
e724377
Fix bugs in `NewtonSolver`, now produces same result as StaticProblem…
A-CGray Mar 3, 2023
cbaf61c
Static problem working with continuatiuon and newton solver classes
A-CGray Mar 19, 2023
184d32a
Fix dumb issue in `_nonlinearCallback`
A-CGray Mar 20, 2023
084b8fd
Add nonlinear shell regression test
A-CGray Mar 21, 2023
ae23b22
Fix bug in problem __init__
A-CGray Mar 21, 2023
77bd90c
Only create solver history if static problem is nonlinear
A-CGray Mar 21, 2023
5af3658
Add test for solution history file writing
A-CGray Mar 21, 2023
befff13
Unignore bdf files used for regression tests
A-CGray Mar 21, 2023
f0bc030
Add nonlinear annular shell example
A-CGray Mar 21, 2023
3184c49
Fix bug in hemisphere mesh generation
A-CGray Mar 21, 2023
d68ac5b
Add .pkl files to gitignore
A-CGray Mar 21, 2023
0d284a5
Tune annular shell example solver settings
A-CGray Mar 21, 2023
b8c3a86
Update nonlinear hemisphere benchmark reference values
A-CGray Mar 21, 2023
0617061
Fix history file test
A-CGray Mar 21, 2023
56ef978
Cleanup static problem code, ensure Jacobian is refactored before adj…
A-CGray Mar 21, 2023
a9abb71
Ensure `optLoadScale` is real
A-CGray Mar 21, 2023
98ee72c
Make shell element test failure messages more helpful
A-CGray Mar 21, 2023
15c0775
Turn off excessive printout
A-CGray Mar 21, 2023
7899036
Update some example meshes
A-CGray Mar 21, 2023
4483b55
Tuning example solver settings
A-CGray Mar 21, 2023
be154c2
Merge branch 'master' of https://github.com/smdogroup/tacs
A-CGray Mar 21, 2023
5c7b0a6
Merge branch 'master' into NLSolverDev
A-CGray Mar 21, 2023
ac11594
Fix some bugs related to restarting the continuation solver from a pr…
A-CGray Mar 22, 2023
ce88ceb
Add guard against failed linear solves to NewtonSolver
A-CGray Mar 22, 2023
2893cff
Fix some NewtonSolverTypos
A-CGray Mar 22, 2023
45c9dd6
Remove solver options from static problem
A-CGray Mar 23, 2023
a34311f
Fix bug in basesolver __init__
A-CGray Mar 23, 2023
6041857
Add predictor step to continuation solver
A-CGray Mar 23, 2023
c6006c7
Remove some relative imports
A-CGray Mar 23, 2023
f79d3cc
Move solverHistory reset to `_initializeSolve`
A-CGray Mar 23, 2023
09f6c46
Add inner solver default options to continuation solver default options
A-CGray Mar 23, 2023
76be2e6
Add continuation solver docs page
A-CGray Mar 23, 2023
4deeadc
Change `_stiffnessUpdateRequired` to `_jacobianUpdateRequired`
A-CGray Mar 23, 2023
13c8290
Chane `_factorOnNext` to `_preconditionerUpdateRequired`
A-CGray Mar 23, 2023
63e113f
print fix
A-CGray Mar 23, 2023
4c31e15
clang-format
A-CGray Mar 24, 2023
8d9e0b9
Revert "clang-format"
A-CGray Mar 24, 2023
3892d5c
clang-format the right way
A-CGray Mar 24, 2023
a2e319d
Add option to force at least 1 Newton iteration (fixes complex test f…
A-CGray Mar 25, 2023
fec8824
Rename `newtonSolverMonitorVars` option to `nonlinearSolverMonitorVar…
A-CGray Mar 28, 2023
d060157
Make continuation solver exit if minimum step size fails
A-CGray Mar 28, 2023
0ad14c1
Fix some bugs in static problem option setting
A-CGray Mar 28, 2023
7daae9c
Make sure nonlinear solver vecs and mats are updated after `_createVa…
A-CGray Mar 28, 2023
8777b45
`black .`
A-CGray Mar 28, 2023
1f59361
Rename `solveJacLinear`, add some docstrings
A-CGray Mar 29, 2023
d8dd95a
Fix so that continuation solver correctly passes options to inner solver
A-CGray Apr 3, 2023
fa666bf
Make static problem solve method return a success flag
A-CGray Apr 3, 2023
48b266a
Add solve failure checking to mphys
A-CGray Apr 3, 2023
b19ec44
Starting to add a blade-stiffened shell constitutive model
A-CGray Apr 8, 2023
51d1e16
Add ContinuationSolver logic for recovering from failed inner solves
A-CGray Apr 8, 2023
bdcad8e
Renaming solver files
A-CGray Apr 8, 2023
b44cb74
Playing around with solver options in nonlinear examples again
A-CGray Apr 8, 2023
ade6379
Give nonlinear shell classes in cython wrapper con and transform attr…
A-CGray Apr 27, 2023
ba27187
Revert "Starting to add a blade-stiffened shell constitutive model"
A-CGray May 19, 2023
c3799d9
minor changes
A-CGray May 15, 2023
4abac6e
Reset predictor states if inner solve fails
A-CGray May 19, 2023
7096791
Merge branch 'master' into NLSolverDev
A-CGray Jul 13, 2023
8f8334c
Fix problem initialization bug
A-CGray Jul 13, 2023
5747f1d
Update nonlinear integration test tolerances
A-CGray Jul 13, 2023
48e6588
Fix bug introduced by merge commit
A-CGray Jul 13, 2023
916a14f
Change how nonlinear solver options are handled so they don't appear …
A-CGray Jul 14, 2023
51f9fc3
Alter `TacsTestElementMatXptSens` to test derivative components indiv…
A-CGray Jul 14, 2023
a12a49b
Trying to debug `TacsTestElementMatXptSens` test failure
A-CGray Jul 14, 2023
56adb88
Change default complex step size to 1e-200
A-CGray Jul 17, 2023
3249ea6
fix in `TacsTestElementMatXptSens`
A-CGray Jul 17, 2023
3d71bce
option name change in NL cantilever example
A-CGray Jul 17, 2023
cc3d2a9
Merge branch 'master' into NLSolverDev
A-CGray Jul 28, 2023
bcb24ce
Make `solveLinear` a private method
A-CGray Jul 28, 2023
7253d35
Remove unused TACS vector
A-CGray Jul 28, 2023
1d5d760
`black .`
A-CGray Jul 28, 2023
db16aa5
Implement cheap method for determining if problem is nonlinear
A-CGray Jul 28, 2023
8b1ec42
Move nonlinearity check to pyTACS so it is easily passed to all probl…
A-CGray Jul 28, 2023
8a802dc
Merge branch 'master' into NLSolverDev
A-CGray Jul 28, 2023
640c235
Normalise nonlinearity check by the residual norm
A-CGray Jul 28, 2023
2e5b1f8
Fix nonlinear option handling when `options` is `None`
A-CGray Jul 28, 2023
7cfc76e
Fix nonlinearity check for case where r(0) != 0
A-CGray Jul 28, 2023
260cbe8
Include velocity and accelerations in nonlinearity check
A-CGray Jul 28, 2023
0e7098e
Fixes in continuation solver to avoid divide by zeros
A-CGray Jul 31, 2023
38686f8
Remove unnecessary call to `applyBCs` in staticProblem
A-CGray Jul 31, 2023
c862838
Add `setBCsInVec` method to pyTACS
A-CGray Jul 31, 2023
f98eea2
add `setBCs` to `setVariables` so that MPhys wrapper works
A-CGray Jul 31, 2023
3a4e598
Fix mphys masked_converter imports
A-CGray Jul 31, 2023
382c8bc
Fix complex type issue in `_checkNonlinearity`
A-CGray Jul 31, 2023
ee6d4c4
Revert "Change default complex step size to 1e-200"
A-CGray Aug 3, 2023
bdb61cc
Fix mat indexing in matrix product sens tests
A-CGray Aug 4, 2023
29dc387
Make element test CS step size consistent with size used in element f…
A-CGray Aug 4, 2023
0959597
add method to set multiple options at once
A-CGray Aug 9, 2023
b0d43eb
Add helper function for printing out any modified options
A-CGray Aug 9, 2023
215861d
`black .`
A-CGray Aug 9, 2023
8d76cd7
Remove all logic for automatically passing options from static proble…
A-CGray Aug 9, 2023
a48821f
Update cantilever example to use new options system
A-CGray Aug 9, 2023
88d8bb0
Don't create solver history until user has chance to set solver options
A-CGray Aug 10, 2023
2152668
Fix nonlinear integration test
A-CGray Aug 10, 2023
2608860
Documentation improvements
A-CGray Aug 10, 2023
44471e7
Rename solver in static problem
A-CGray Aug 10, 2023
4405bdb
Add section on nonlinear solvers to static problem docs
A-CGray Aug 10, 2023
d344ace
Add validation data to nonlinear cantilever example
A-CGray Aug 16, 2023
d066c09
Fix local node ID conversion in `getLocalNodeIDsForComps`
A-CGray Sep 1, 2023
d55b031
Merge branch 'master' into NLSolverDev
A-CGray Sep 5, 2023
3b6d135
Add `linearityTol` option to pyTACS
A-CGray Sep 8, 2023
4dcc2ec
Rename benchmarks
A-CGray Sep 8, 2023
692fe88
`black .`
A-CGray Sep 8, 2023
7bb543d
Merge branch 'master' into NLSolverDev
A-CGray Oct 2, 2023
1d54bd3
Merge branch 'NLSolverDev' of https://github.com/smdogroup/tacs into …
A-CGray Oct 2, 2023
e6382e6
Make final section of `solve` consistent for linear and nonlinear sta…
A-CGray Oct 4, 2023
2b6a396
Rename `solveNonlinear` to `_solveNonlinearProblem`
A-CGray Oct 4, 2023
6ff93f0
Add `_solveLinearProblem` method
A-CGray Oct 4, 2023
0abab31
Rename `res` to `rhs` in `_solveLinear`
A-CGray Oct 5, 2023
53eb0a4
Fixing typo in yield strain
timryanb Oct 5, 2023
0a6d3ee
update nonlinear solver name in examples and test
A-CGray Oct 5, 2023
f6fe0b2
Merge branch 'NLSolverDev' of https://github.com/smdogroup/tacs into …
A-CGray Oct 5, 2023
5255c5c
Fix reference failure function value
A-CGray Oct 5, 2023
a79a0b1
Rename nonlinear solver in static problem
A-CGray Oct 5, 2023
d3c8340
Rename self.KSM to self.linearSolver, remove self.newtonSolver
A-CGray Oct 20, 2023
b4b1a03
Move solver history from static problem to solvers
A-CGray Oct 20, 2023
b3a8d5e
Don't write history file if don't have a nonlinear Solver
A-CGray Oct 20, 2023
db41ba6
Update uses of old solver names
A-CGray Oct 20, 2023
ed9f194
Merge branch 'master' into NLSolverDev
A-CGray Oct 20, 2023
7211165
Fix some linter complaints
A-CGray Oct 20, 2023
6632839
Merge branch 'NLSolverDev' of github.com:smdogroup/tacs into NLSolverDev
A-CGray Oct 20, 2023
bec98c9
Add `printLevel` option to `StaticProblem`
A-CGray Oct 20, 2023
c5c2974
rename `_solveLinearProblem` and `_solveNonlinearProblem`
A-CGray Oct 20, 2023
92a9f5d
Give nonlinear solvers their own vectors and linear solvers
A-CGray Oct 20, 2023
31e5340
Update options used in nonlinear examples
A-CGray Oct 20, 2023
7ce785e
black formatting
A-CGray Oct 20, 2023
5627c85
Fix linear solve call in adjoint solve
A-CGray Oct 20, 2023
92aeba9
Add numNodes in new element type docstrings
A-CGray Oct 20, 2023
1fac5b6
Revert "Give nonlinear solvers their own vectors and linear solvers"
A-CGray Oct 20, 2023
25666cf
Make nonlinear solvers apply boundary conditions to initial state
A-CGray Oct 21, 2023
ed23ae0
Give nonlinear solvers their own vectors and linear solvers
A-CGray Oct 21, 2023
31f22d9
Minor formatting fix
timryanb Oct 23, 2023
58ab5ec
Removing `isNonlinear` option from examples
timryanb Oct 23, 2023
9e964a7
add `nonlinerSolver` option to staticproblem
timryanb Oct 23, 2023
cae5448
Reducing tol on locally failing test
timryanb Oct 23, 2023
4b22e3f
Remove BaseSolver from UI documentation
timryanb Oct 23, 2023
1534480
Fix some mistakes in solver options documentation
A-CGray Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.in.info
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ METIS_LIB = ${TACS_DIR}/extern/metis/lib/libmetis.a

# AMD is a set of routines for ordering matrices, included in the SuiteSparse package. It is not required by default.

# SUITESPARSE_DIR = ${TACS_DIR}/extern/SuiteSparse-5.13.0
# SUITESPARSE_DIR = ${TACS_DIR}/extern/SuiteSparse-7.0.1
# The variables below should not need to be altered if you are installing SuiteSparse from the standard release tarball

# SUITESPARSE_CONFIG_DIR = ${SUITESPARSE_DIR}/SuiteSparse_config
# AMD_DIR = ${SUITESPARSE_DIR}/AMD
# AMD_INCLUDE = -I${AMD_DIR}/Include -I${SUITESPARSE_CONFIG_DIR}
# AMD_LIBS = ${AMD_DIR}/Lib/libamd.a ${SUITESPARSE_CONFIG_DIR}/libsuitesparseconfig.a
# AMD_LIBS = ${AMD_DIR}/build/libamd.a ${SUITESPARSE_CONFIG_DIR}/build/libsuitesparseconfig.a
# TACS_DEF += -DTACS_HAS_AMD_LIBRARY

# TECIO is a library for reading and writing tecplot data files, only required for building f5totec, can use either teciosrc or teciompisrc
Expand Down
9 changes: 9 additions & 0 deletions docs/source/pytacs/base_solver.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BaseSolver
------------------
.. automodule:: tacs.solvers.base

API Reference
^^^^^^^^^^^^^
.. autoclass:: tacs.solvers.BaseSolver
:members:
:inherited-members:
19 changes: 19 additions & 0 deletions docs/source/pytacs/continuation_solver.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ContinuationSolver
------------------
.. automodule:: tacs.solvers.continuation

Options
^^^^^^^
Options can be set for :class:`~tacs.solvers.ContinuationSolver` at time of creation for the class in the
:meth:`pyTACS.createStaticProblem <tacs.solvers.ContinuationSolver.__init__>` method or using the
:meth:`ContinuationSolver.setOption <tacs.solvers.ContinuationSolver.setOption>` method. Current option values for a class
instance can be printed out using the :meth:`ContinuationSolver.printOption <tacs.solvers.ContinuationSolver.printOptions>` method.
The following options, their default values and descriptions are listed below:

.. program-output:: python -c "from tacs.solvers import ContinuationSolver; ContinuationSolver.printDefaultOptions()"

API Reference
^^^^^^^^^^^^^
.. autoclass:: tacs.solvers.ContinuationSolver
:members:
:inherited-members:
19 changes: 19 additions & 0 deletions docs/source/pytacs/newton_solver.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
NewtonSolver
-------------
.. automodule:: tacs.solvers.newton

Options
^^^^^^^
Options can be set for :class:`~tacs.solvers.NewtonSolver` at time of creation for the class in the
:meth:`pyTACS.createStaticProblem <tacs.solvers.NewtonSolver.__init__>` method or using the
:meth:`NewtonSolver.setOption <tacs.solvers.NewtonSolver.setOption>` method. Current option values for a class
instance can be printed out using the :meth:`NewtonSolver.printOption <tacs.solvers.NewtonSolver.printOptions>` method.
The following options, their default values and descriptions are listed below:

.. program-output:: python -c "from tacs.solvers import NewtonSolver; NewtonSolver.printDefaultOptions()"

API Reference
^^^^^^^^^^^^^
.. autoclass:: tacs.solvers.NewtonSolver
:members:
:inherited-members:
3 changes: 2 additions & 1 deletion docs/source/pytacs/pytacs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ repeated until the optimization criteria are satisfied.

pytacs_module
problems
constraints
solvers
constraints
8 changes: 8 additions & 0 deletions docs/source/pytacs/solvers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Solver classes
===============

.. toctree::
:maxdepth: 1

continuation_solver
newton_solver
9 changes: 8 additions & 1 deletion docs/source/pytacs/static.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ The following options, their default values and descriptions are listed below:

.. program-output:: python -c "from tacs.problems import StaticProblem; StaticProblem.printDefaultOptions()"

Nonlinear solvers
^^^^^^^^^^^^^^^^^
When you create an assembler using a nonlinear element type or constitutive model, any static problems you create will automatically setup a nonlinear solver.
A continuation solver is used to control an adaptive load incrementation process, and a Newton solver is used to solve the nonlinear system of equations at each load increment.
The options for these solvers should be set directly to ``problem.nonlinearSolver`` and ``problem.nonlinearSolver.innerSolver``.
See :class:`~tacs.solvers.ContinuationSolver` and :class:`~tacs.solvers.NewtonSolver` for more information.

API Reference
^^^^^^^^^^^^^
.. autoclass:: tacs.problems.StaticProblem
:members:
:inherited-members:
:inherited-members:
178 changes: 178 additions & 0 deletions examples/nonlinear_annulus/analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
"""
==============================================================================
Large deformation annular shell
==============================================================================
@File : analysis.py
@Date : 2023/01/25
@Author : Alasdair Christison Gray
@Description : This code runs a geometrically nonlinear analysis of a
annular shell subject to vertical forces at one end. The problem
is taken from section 3.3 of "Popular benchmark problems for geometric
nonlinear analysis of shells" by Sze et al
(https://doi.org/10.1016/j.finel.2003.11.001).
"""

# ==============================================================================
# Standard Python modules
# ==============================================================================
import os

# ==============================================================================
# External Python modules
# ==============================================================================
import numpy as np
from mpi4py import MPI
from pprint import pprint

# ==============================================================================
# Extension modules
# ==============================================================================
from tacs import pyTACS, constitutive, elements, functions


# ==============================================================================
# Constants
# ==============================================================================
COMM = MPI.COMM_WORLD
BDF_FILE = os.path.join(os.path.dirname(__file__), "annulus.bdf")
E = 21e6 # Young's modulus
NU = 0.0 # Poisson's ratio
RHO = 1.0 # density
YIELD_STRESS = 1.0 # yield stress
THICKNESS = 0.03 # Shell thickness

STRAIN_TYPE = "nonlinear"
ROTATION_TYPE = "quadratic"

elementType = None
if STRAIN_TYPE == "linear":
if ROTATION_TYPE == "linear":
elementType = elements.Quad4Shell
elif ROTATION_TYPE == "quadratic":
elementType = elements.Quad4ShellModRot
elif ROTATION_TYPE == "quaternion":
elementType = elements.Quad4ShellQuaternion
elif STRAIN_TYPE == "nonlinear":
if ROTATION_TYPE == "linear":
elementType = elements.Quad4NonlinearShell
elif ROTATION_TYPE == "quadratic":
elementType = elements.Quad4NonlinearShellModRot
elif ROTATION_TYPE == "quaternion":
elementType = elements.Quad4NonlinearShellQuaternion

if elementType is None:
raise RuntimeError("Invalid element type, check STRAIN_TYPE and ROTATION_TYPE.")

# ==============================================================================
# Create pyTACS Assembler and problems
# ==============================================================================
structOptions = {
"printtiming": True,
}
FEAAssembler = pyTACS(BDF_FILE, options=structOptions, comm=COMM)


def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwargs):
matProps = constitutive.MaterialProperties(rho=RHO, E=E, nu=NU, ys=YIELD_STRESS)
con = constitutive.IsoShellConstitutive(
matProps, t=THICKNESS, tNum=dvNum, tlb=1e-2 * THICKNESS, tub=1e2 * THICKNESS
)
transform = None
element = elementType(transform, con)
tScale = [50.0]
return element, tScale


FEAAssembler.initialize(elemCallBack)

probOptions = {
"nRestarts": 3,
"subSpaceSize": 20,
"printLevel": 1,
}
newtonOptions = {
"MaxIter": 50,
"MaxLinIters": 5,
"UseEW": True,
}
continuationOptions = {
"InitialStep": 0.01,
"TargetIter": 6,
"RelTol": 1e-7,
"UsePredictor": True,
"NumPredictorStates": 8,
}
problem = FEAAssembler.createStaticProblem("Annulus", options=probOptions)
problem.nonlinearSolver.setOptions(continuationOptions)
problem.nonlinearSolver.innerSolver.setOptions(newtonOptions)

# ==============================================================================
# Find tip force points
# ==============================================================================
bdfInfo = FEAAssembler.getBDFInfo()
# cross-reference bdf object to use some of pynastran's advanced features
bdfInfo.cross_reference()
nodeCoords = bdfInfo.get_xyz_in_coord()
nastranNodeNums = list(bdfInfo.node_ids)
SPCNodeIDs = bdfInfo.get_SPCx_node_ids(1)

# The load points lie along the theta = 0 axis, however just searching for points along this axis will return
# both ends of the annulus as it covers a full 360 degrees. So we need to exclude any nodes that are subject to SPC's
nodeTheta = np.arctan2(nodeCoords[:, 1], nodeCoords[:, 0])
loadPointNodeIDs = np.argwhere(nodeTheta == 0.0).flatten() + 1
loadPointNodeIDs = [ii for ii in loadPointNodeIDs if ii not in SPCNodeIDs]

# ==============================================================================
# Add tip loads
# ==============================================================================
PMax = 0.8 # force per length
# Now we need to compute the nodal forces due to the line load, the nodes at the inner and outer radius will be subject to half the load of the other nodes
nodeRadius = np.linalg.norm(nodeCoords, axis=1)
innerRadius = np.min(nodeRadius)
outerRadius = np.max(nodeRadius)
totalForce = PMax * (outerRadius - innerRadius)
loadPointFactors = [
1.0
if nodeRadius[ii - 1] <= (innerRadius + 1e-4)
or nodeRadius[ii - 1] >= (outerRadius - 1e-4)
else 2.0
for ii in loadPointNodeIDs
]
factorSum = np.sum(loadPointFactors)

nodalForces = np.zeros((len(loadPointNodeIDs), 6))
nodalForces[:, 2] = totalForce * np.array(loadPointFactors) / factorSum
problem.addLoadToNodes(loadPointNodeIDs, nodalForces, nastranOrdering=True)

# ==============================================================================
# Add functions
# ==============================================================================

# KS approximation of the maximum failure value
problem.addFunction("KSFailure", functions.KSFailure, ksWeight=80.0, ftype="discrete")

# Maximum displacement in the z-direction (KS with a very large weight to get a true max)
problem.addFunction(
"MaxZDisp",
functions.KSDisplacement,
direction=np.array([0.0, 0.0, 1.0]),
ksWeight=1e20,
ftype="discrete",
)

# Compliance
problem.addFunction("Compliance", functions.Compliance)

# ==============================================================================
# Solve all problems and evaluate functions
# ==============================================================================
funcs = {}
funcsSens = {}
problem.solve()
problem.evalFunctions(funcs)
problem.evalFunctionsSens(funcsSens)
problem.writeSolution(outputDir=os.path.dirname(__file__))
problem.writeSolutionHistory(outputDir=os.path.dirname(__file__))

if COMM.rank == 0:
pprint(funcs)
Loading
Loading