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,CustominpRW 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._inpRhas the functions for parsing data from the .inp._inpWhas functions for writing the data in theinpKeywordobject to an input file._inpModhas functions for modifying the data in the inp object structure._inpFindhas functions for finding information inkeywords._inpFindRefshas functions to search for particular named items and all their references in the input file (i.e. node 1)._inpCustomis empty; whatever functions the end user adds to this module will extend the class._importedModulescontains 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 wheninpRWis 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(orinpDecimalif preserveSpacing = True) will be used instead offloatfor all floating point numbers. Will be True ifpreserveSpacingis True. Defaults to True._parentInp (inpRW) – An
inpRWinstance to serve as the parent for the new instance. Meant to be used wheninpRWinstances itself recursively to handle child input files (i.e. *INCLUDE)._parentblock (inpKeyword) – An inpKeyword block which will serve as the parent to the new
inpRWinstance. 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
_kwafter parsing the input file. Defaults to False.- Returns:
inpRWinstance
- 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:
gkw (bool) – If True, calls
_groupKeywordBlocks(). Defaults to True.b (list) – Passed to
_groupKeywordBlocks(). See that function for details. Defaults to None.startIndex (int) – Passed to
updateObjectsPath(). See that function for details. Defaults to 0.parentBlock (inpKeyword) – Passed to
updateObjectsPath(). See that function for details. Defaults to ‘’.updatePaths (bool) – Updates
pathin all keyword blocks after startIndex if True. Defaults to True.
- __repr__()¶
Produces a representation of the
inpRWinstance.This representation can be called to produce another
inpRWinstance. This will only include the arguments toinpRWwhich contain non-default values. This string does not guarantee producing an identicalinpRWinstance upon callingparse(), as the applicable attributes might have changed afterparse()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 iftheir value differs from the default value.
- Return type:
- __str__()¶
Produces a string of the
inpRWinstance.This string is meant to help identify the
inpRWinstance. It will always includeinpNameandjobSuffix, and will includeinputFolder,outputFolder,_parentINP, and_parentblockonly 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. Seendfor 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
inpRWthat should be passed to theinpKeywordconstructor.
- inputFolder: str¶
Name of the folder containing the input file, populated automatically if inpName passed to
inpRWincludes 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
setcontaining the Keywords To Remove If Data Deleted from them. Meant to be used withdeleteItemReferences(). Can be updated withupdateKTRIDD().
- namedRefs: csid¶
A
csidto 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. Thiscsidwill be populated duringparse().
- nd: TotalNodeMesh¶
Node dictionary. A dictionary type object which contains every node in the input file.
ndis populated fromMesh, which make up thedataattribute of *NODE keyword blocks. When operating on nodes, the user should access them throughnd. When adding new nodes, they should be added to an existingMesh, or create a new *NODE keyword block with a newdata, and then updatendwith thedataof 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
inpRWincludes a path.
- 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
csidcontaining the Parent Keywords To Remove If Child Deleted. Meant to be used withdeleteItemReferences(). Can be set withupdatePKTRICD().
- 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.
- step_paths: list¶
Stores the
pathto every *STEP keyword block, in order of appearance in the input file.
- steps: csid¶
Provides quick access to the steps in
keywordsif 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
Decimalfor all floating point numbers if True. Will be True ifpreserveSpacingis True.Private Attributes
- _ParamInInp: bool = False¶
If True, indicates that *PARAMETER is a keyword block in the input file. Will be set in
parse().
- _curBaseStep: inpKeyword = None¶
Tracks the current base step in the model.
- _delayedPlaceBlocks: dict = {0: [], 1: [], 2: []}¶
Tracks blocks that should be parsed on later passes. Any blocks placed into
_delayedPlaceBlockswill have the data in their_inpItemsToUpdateinserted at the end of theparse()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
_kwis generated unless_debug= True
- _joinPS: str¶
The string which is used to join items together when writing strings from the parsed data. If
ssis 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,_kwwill 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.
- _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,
_nlwill 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.
- _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.
- _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.