inpRW

Package Contents

Classes

class inpRW.inpRW(inpName, organize=True, ss=False, rmtrailing0=False, jobSuffix='_NEW.inp', parseSubFiles=True, preserveSpacing=True, useDecimal=True, _parentINP='', _parentblock='', _debug=False)

Bases: Read, Write, Mod, Find, FindRefs, Custom

inpRW is a collection of Python modules for parsing, modifying, and writing Abaqus input files.

The inpRW class is composed of _inpR, _inpW, _inpMod, _inpFind, _inpFindRefs, _inpCustom, and _importedModules. _inpR has the functions for parsing data from the .inp. _inpW has functions for writing the data in the inpKeyword object to an input file. _inpMod has functions for modifying the data in the inp object structure. _inpFind has functions for finding information in keywords. _inpFindRefs has functions to search for particular named items and all their references in the input file (i.e. node 1). _inpCustom is empty; whatever functions the end user adds to this module will extend the class. _importedModules contains the module imports for all the _inp* modules.

__init__(inpName, organize=True, ss=False, rmtrailing0=False, jobSuffix='_NEW.inp', parseSubFiles=True, preserveSpacing=True, useDecimal=True, _parentINP='', _parentblock='', debug=False)

__init__() is called when inpRW is instanced and it sets many instance variables before the input file is parsed.

Parameters:
  • inpName (str) – The file name and optionally path to the input file.

  • organize (bool) – Will group keywords together as parentblock and suboptions if True. Defaults to True.

  • ss (bool) – Strip spaces from items in input file if True. Defaults to False.

  • rmtrailing0 (bool) – Remove trailing 0s from decimal numbers if True. Defaults to False.

  • jobSuffix (str) – Suffix to be appended to each input file (and reference to input files) that inpRW writes out. Defaults to ‘_NEW.inp’.

  • parseSubFiles (bool) – Parse sub input files (i.e. target of INCLUDE) if True. Defaults to False.

  • preserveSpacing (bool) – Preserve the original spacing for every item in the input file if True. Defaults to True.

  • useDecimal (bool) – If True, Decimal (or inpDecimal if preserveSpacing = True) will be used instead of float for all floating point numbers. Will be True if preserveSpacing is True. Defaults to True.

  • _parentInp (inpRW) – An inpRW instance to serve as the parent for the new instance. Meant to be used when inpRW instances itself recursively to handle child input files (i.e. *INCLUDE).

  • _parentblock (inpKeyword) – An inpKeyword block which will serve as the parent to the new inpRW instance. All keywords in the child inp will be suboptions to _parentblock.

  • _debug (bool) – If True, prints some additional information while inpRW is performing certain tasks and keeps _kw after parsing the input file. Defaults to False.

Returns:

inpRW instance

parse()

This function parses the input file.

printDocs()

This function will print the documentation strings for all functions inside the inpRW class.

updateInp(gkw=True, b=None, startIndex=0, parentBlock='', updatePaths=True)

This function calls updateObjectsPath(), _getLastBlockPath(), findStepLocations(), _groupKeywordBlocks(), _findIncludeFileNames(), and updates __methods__, __members__, _couplingSurfNames, _kinCoupNsetNames, and _distCoupElsetNames.

Parameters:
__repr__()

Produces a representation of the inpRW instance.

This representation can be called to produce another inpRW instance. This will only include the arguments to inpRW which contain non-default values. This string does not guarantee producing an identical inpRW instance upon calling parse(), as the applicable attributes might have changed after parse() was called, and there are additional attributes which affect parsing which are not output by this function.

Returns:

The form will be inpRW(inpName='path/name', arg=value). Additional args will be included only if

their value differs from the default value.

Return type:

str

__str__()

Produces a string of the inpRW instance.

This string is meant to help identify the inpRW instance. It will always include inpName and jobSuffix, and will include inputFolder, outputFolder, _parentINP, and _parentblock only if they are non-empty.

Returns:

str

Attributes

delayParsingDataKws: set

A set for the user to specify the element names which will not have their keywords parsed. The keyword names should be all lower case and include no spaces.

ed: TotalElementMesh

Element dictionary. Identical in concept to nd, but holds element information. See nd for further details.

fastElementParsing: bool = True

Parse element blocks with the fast mode if True and if the number of nodes to define the element type is less than 10.

includeBlockPaths: list = []

Contains the paths to all keyword blocks which reference child input files. This will be populated as the input file is parsed.

includeFileNames: list = []

Contains the names of all input files referenced by this input file. This will be populated as the input file is parsed.

inpKeywordArgs: dict

A dictionary containing the attributes from inpRW that should be passed to the inpKeyword constructor.

inpName: str

Name of the input file without extension.

inputFolder: str

Name of the folder containing the input file, populated automatically if inpName passed to inpRW includes a path.

jobSuffix: str = '_NEW

Suffix to append to each new input file. This should include the file extension.

keywords: inpKeywordSequence

Holds all the parsed keyword blocks. This is the main point of interaction for the user.

ktridd: set = set()

A set containing the Keywords To Remove If Data Deleted from them. Meant to be used with deleteItemReferences(). Can be updated with updateKTRIDD().

kwg: csid

A csid that groups keyword blocks by their keyword name.

namedRefs: csid

A csid to track references to named objects. The keys will be the names of keyword blocks which can create named references. For example, ‘NSET’. Each value will be the block which defines the named reference. This csid will be populated during parse().

nd: TotalNodeMesh

Node dictionary. A dictionary type object which contains every node in the input file. nd is populated from Mesh, which make up the data attribute of *NODE keyword blocks. When operating on nodes, the user should access them through nd. When adding new nodes, they should be added to an existing Mesh, or create a new *NODE keyword block with a new data, and then update nd with the data of the new block.

nodesUpdatedConnectivity: list

Tracks nodes which have had their connectivity updated (i.e. they are connected to fewer elements than they previously were, likely due to the user running deleteItemReferences()).

organize: bool = True

If True, keyword blocks will be grouped together as parent blocks and suboptions.

outputFolder: str

Name of the folder to which new input files will be written, populated automatically if inpName passed to inpRW includes a path.

parseSubFiles: bool = True

Parse sub input files if True.

pd: csid = csid()

Parameter dictionary, uses each variable defined in *PARAMETER block datalines as the key, the value is the evaluated result. If the user needs the value of a group of items which may reference parameters, call _subParam() on the group of objects.

pktricd: csid = csid()

A csid containing the Parent Keywords To Remove If Child Deleted. Meant to be used with deleteItemReferences(). Can be set with updatePKTRICD().

preserveSpacing: bool = True

Preserve the exact spacing in the input file if true. If that is not important, set to False for a performance improvement.

rmtrailing0: bool = False

Remove the trailing 0s (i.e. 1.0 -> 1.) to reduce file-size.

ss: bool = False

Strip spaces from strings.

step_paths: list

Stores the path to every *STEP keyword block, in order of appearance in the input file.

steps: csid

Provides quick access to the steps in keywords if the step names are known. The key is the step name and the value is [index in inp.sortKWs(kwg['step']) , inpKeyword]. If a step does not have a name, the index is used for the key.

useDecimal: bool = True

Use Decimal for all floating point numbers if True. Will be True if preserveSpacing is True.

Private Attributes

_ParamInInp: bool = False

If True, indicates that *PARAMETER is a keyword block in the input file. Will be set in parse().

__members__: list

Holds all the member names of the inpRW instance.

__methods__: list

Holds all the method names of the inpRW instance.

_addSpace: str

Adds a space between items when ss is True.

_bad_kwblock: list = []

For development purposes.

_couplingSurfNames: set

A set to track the surface names which are used by *COUPLING keywords.

_curBaseStep: inpKeyword = None

Tracks the current base step in the model.

_debug: bool

Stores debug mode status.

_delayedPlaceBlocks: dict = {0: [], 1: [], 2: []}

Tracks blocks that should be parsed on later passes. Any blocks placed into _delayedPlaceBlocks will have the data in their _inpItemsToUpdate inserted at the end of the parse() function. For example, *PARAMETER keyword blocks should have their data placed before all other blocks (loop 0), and all *NODE blocks should have their data populated before any *ELEMENT blocks are placed. Unless otherwise specified in _keywordsDelayPlacingData, all blocks will have their data placed in loop 1.

_distCoupElsetNames: set

A set to track the elset names which are used by *DISTRIBUTING COUPLING keywords.

_firstItem: bool = True

Tracks the first item to be written to an output input file; a new line character will not be written prior to the item if True.

_inpText: str

Holds the raw text string of the entire input file. Will be deleted once _kw is generated unless _debug = True

_joinPS: str

The string which is used to join items together when writing strings from the parsed data. If ss is True, this will be ‘, ‘, else it is ‘’ (spaces are assumed to be tracked with each item in this case).

_kinCoupNsetNames: set

A set to track the nset names which are used by *KINEMATIC COUPLING keywords.

_kw: list

A list of strings, with each string corresponding to a keyword block. If _debug = False, _kw will be deleted once all blocks have been parsed.

_kwsumFile

File object to which a summary of the parsed keyword blocks will be written. Reference file object.

_kwsumName: str = inpName

Name of the file to which a summary of the parsed keyword blocks will be written.

_lbp: str

The path to the last block in keywords.

_leadingcomments: str = None

Stores any comments prior to the first keyword block.

_manBaseStep: inpKeyword = None

The last base step for *MANIFEST simulations.

_nl: str

Tracks the new line character used by the file. If new line characters are inconsistent, _nl will be set to ‘\n’.

_numCpus: int = 1

Indicates the number of cpus to use for multi-threaded supported tasks, which is currently parsing keyword blocks. It is not recommended to use more than 1 cpu, as the current speedup does not justify the extra hardware use.

_parentINP: inpRW

References the parent inp instance if this is reading a sub input file (i.e. *INCLUDE, *MANIFEST). This is needed to track some variables from the parent instance.

_parentblock: inpKeyword

References the parent block. All keyword blocks read by a child inpRW instance will be suboptions of _parentblock.

_parentkws: list = []

Tracks the open parent keyword blocks.

_subP: bool = False

When evaluating particular items, check if item is a parameter and substitute the true value. If the input file has *PARAMETER keyword block, this will be set to True automatically.

_subkwin: int = 0

Tracks the active suboptions index.

_tree: scipy.spatial.cKDTree = None

A KDTree of some portion of the nodes in the input file. Created via findCloseNodes().

Submodules

All of the functions in the submodules will be accessible directly through the inpRW instance. For example, createPathFromSequence() can be accessed via inp.createPathFromSequence instead of inp._inpR.Read.createPathFromSequence. The submodules are merely for organizational purposes.