Skip to content

Commit

Permalink
pyTACS docstring cleanup (#210)
Browse files Browse the repository at this point in the history
* Cleaning up pytacs docstrings

* Adding scipy cross reference to docs

* Minor batter doc edit
  • Loading branch information
timryanb authored May 17, 2023
1 parent d536ca5 commit a74d677
Show file tree
Hide file tree
Showing 12 changed files with 518 additions and 90 deletions.
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
intersphinx_mapping = {
"https://docs.python.org/": None,
"numpy [stable]": ("https://numpy.org/doc/stable/", None),
"scipy [stable]": ("https://docs.scipy.org/doc/scipy/", None),
"pynastran [latest]": ("https://pynastran-git.readthedocs.io/en/latest/", None),
"mpi4py [stable]": ("https://mpi4py.readthedocs.io/en/stable/", None),
"paropt": ("https://smdogroup.github.io/paropt/", None),
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/Example-Transient_Battery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ index indicates the time-step of the analysis (000 through 050). These files can

.. code-block:: console
$ f5tovtk Transient_000_0xx.f5
$ f5tovtk Transient_000_*.f5
or

.. code-block:: console
$ f5totec Transient_000_0xx.f5
$ f5totec Transient_000_*.f5
The animation below shows what the transient heat transfer temperature solution looks like when visualized in Paraview.

Expand Down
23 changes: 23 additions & 0 deletions tacs/constraints/adjacency.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,29 @@ def addConstraint(self, conName, compIDs=None, lower=-1e20, upper=1e20, dvIndex=
return success

def _createConstraint(self, dvIndex, compIDs, lbound, ubound):
"""
Create a new constraint object for TACS.
Parameters
----------
dvIndex : int
Index number of element DV to be used in constraint.
compIDs: list[int]
List of compIDs to select.
lbound: float or complex
lower bound for constraint. Defaults to 0.0.
ubound: float or complex
upper bound for constraint. Defaults to 1e20.
Returns
-------
constraint : tacs.constraints.base.SparseLinearConstraint or None
Constraint object if successful, None otherwise.
"""
size = self.comm.size
rank = self.comm.rank
# Gather the dv mapping from each proc
Expand Down
36 changes: 36 additions & 0 deletions tacs/constraints/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ class TACSConstraint(TACSSystem):
def __init__(
self, assembler, comm=None, options=None, outputViewer=None, meshLoader=None
):
"""
Parameters
----------
assembler : tacs.TACS.Assembler
Cython object responsible for creating and setting tacs objects used to solve problem
comm : mpi4py.MPI.Intracomm
The comm object on which to create the pyTACS object.
options : dict
Dictionary holding problem-specific option parameters (case-insensitive).
outputViewer : tacs.TACS.TACSToFH5
Cython object used to write out f5 files that can be converted and used for postprocessing.
meshLoader : tacs.pymeshloader.pyMeshLoader
pyMeshLoader object used to create the assembler.
"""
# Set attributes and options
TACSSystem.__init__(self, assembler, comm, options, outputViewer, meshLoader)

Expand Down Expand Up @@ -141,6 +159,11 @@ def getConstraintSizes(self, sizes, evalCons=None):
def getConstraintKeys(self):
"""
Return a list of the current constraint key names
Returns
-------
conNames : list[str]
List containing user-defined names for constraint groups added so far.
"""
return list(self.constraintList.keys())

Expand Down Expand Up @@ -202,6 +225,19 @@ def evalConstraintsSens(self, funcsSens, evalCons=None):
def _processEvalCons(self, evalCons, ignoreMissing=True):
"""
Internal method for processing user-provided evalCons
Parameters
----------
evalCons : iterable object containing strings or None
The constraints the user wants returned
ignoreMissing : bool
Flag to supress checking for a valid constraint.
Defaults to True.
Returns
-------
conList : list[str]
List of constraints the user wants returned
"""
# Check if user specified which constraints to output
# Otherwise, output them all
Expand Down
28 changes: 28 additions & 0 deletions tacs/constraints/dv.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,34 @@ def addConstraint(
return success

def _createConstraint(self, dvIndices, dvWeights, compIDs, lbound, ubound):
"""
Create a new constraint object for TACS.
Parameters
----------
dvIndices : list[int]
Index numbers of element DVs to be used in constraint.
Defaults to 0.
dvWeights : list[float or complex]
Linear scaling factors for each DV used in constraint definition.
If list, should match length of dvIndices. Defaults to 1's.
compIDs: list[int]
List of compIDs to select.
lbound: float or complex
lower bound for constraint. Defaults to 0.0.
ubound: float or complex
upper bound for constraint. Defaults to 1e20.
Returns
-------
constraint : tacs.constraints.base.SparseLinearConstraint or None
Constraint object if successful, None otherwise.
"""
# Assemble constraint info
conCount = 0
rows = []
Expand Down
22 changes: 21 additions & 1 deletion tacs/constraints/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ def addConstraint(self, conName, compIDs=None, lower=0, upper=1e20):
return success

def _createConstraint(self, compIDs, lbound, ubound):
"""
Create a new constraint object for TACS.
Parameters
----------
compIDs: list[int]
List of compIDs to select.
lbound: float or complex
lower bound for constraint. Defaults to 0.0.
ubound: float or complex
upper bound for constraint. Defaults to 1e20.
Returns
-------
constraint : ParallelVolumeConstraint or None
Constraint object if successful, None otherwise.
"""
# Check if elements in supplied compIDs are all shell elements or all solid elements
elemIDs = self.meshLoader.getGlobalElementIDsForComps(
compIDs, nastranOrdering=True
Expand Down Expand Up @@ -651,7 +671,7 @@ def write_unstructured_zone(
self.log.info("is_points = %s" % is_points)
datapacking = "POINT" if is_points else "BLOCK"
# Make sure to include title
msg += f" T={self.title}, n={nnodes:d}, e={nelements:d}, ZONETYPE={zone_type}, DATAPACKING={datapacking}\n"
msg += f' T="{self.title}", n={nnodes:d}, e={nelements:d}, ZONETYPE={zone_type}, DATAPACKING={datapacking}\n'
tecplot_file.write(msg)

self._write_xyz_results(tecplot_file, is_points, ivars)
Expand Down
Loading

0 comments on commit a74d677

Please sign in to comment.