From 4b4f5248a4613527c494225033f55765aac32f63 Mon Sep 17 00:00:00 2001 From: Hailin Wang Date: Mon, 27 Jan 2025 14:57:35 +0800 Subject: [PATCH] [bugfix] Move methods for creating models to `Mdb` class (#5955) (cherry picked from commit 9f8352bedb536d202eeb3c80c63df31201682f24) --- src/abaqus/Mdb/Mdb.py | 154 +++++++++++++++++++++++++++++++++- src/abaqus/Model/ModelBase.py | 143 ------------------------------- 2 files changed, 153 insertions(+), 144 deletions(-) diff --git a/src/abaqus/Mdb/Mdb.py b/src/abaqus/Mdb/Mdb.py index 2a5859921c..e05b75ec13 100644 --- a/src/abaqus/Mdb/Mdb.py +++ b/src/abaqus/Mdb/Mdb.py @@ -9,7 +9,18 @@ from ..Job.JobMdb import JobMdb from ..Model.Model import Model from ..Part.AcisMdb import AcisMdb -from ..UtilityAndView.abaqusConstants import NOT_SET, ON, STANDARD_EXPLICIT, Boolean +from ..UtilityAndView.abaqusConstants import ( + B31, + C3D8I, + C3D10, + NOT_SET, + OFF, + ON, + PRESERVE_SECTION, + S4, + STANDARD_EXPLICIT, + Boolean, +) from ..UtilityAndView.abaqusConstants import abaqusConstants as C @@ -123,3 +134,144 @@ def Model(self, name: str, *args, **kwargs) -> Model: else: self.models[name] = model = Model(name, *args, **kwargs) return model + + @abaqus_method_doc + def ModelFromInputFile(self, name: str, inputFileName: str): + """This method creates a Model object by reading the keywords in an input file and creating the + corresponding Abaqus/CAE objects. + + .. note:: + This function can be accessed by:: + + mdb.ModelFromInputFile + + Parameters + ---------- + name + A String specifying the repository key. + inputFileName + A String specifying the name of the input file (including the .inp extension) to be + parsed into the new model. This String can also be the full path to the input file if it + is located in another directory. + + Returns + ------- + Model + A Model object. + """ + self.models[name] = model = Model(name) + return model + + @abaqus_method_doc + def ModelFromOdbFile(self, name: str, odbFileName: str): + """This method creates a Model object by reading an output database and creating any corresponding + Abaqus/CAE objects. + + .. note:: + This function can be accessed by:: + + mdb.ModelFromOdbFile + + Parameters + ---------- + name + A String specifying the repository key. + odbFileName + A String specifying the name of the output database file (including the .odb extension) + to be read into the new model. This String can also be the full path to the output + database file if it is located in another directory. + + Returns + ------- + Model + A Model object. + """ + self.models[name] = model = Model(name) + return model + + @abaqus_method_doc + def ModelFromNastranFile( + self, + modelName: str, + inputFileName: str, + sectionConsolidation: Literal[C.PRESERVE_SECTION, C.GROUP_BY_MATERIAL, C.NONE] = PRESERVE_SECTION, + preIntegratedShell: Boolean = OFF, + weightMassScaling: Boolean = ON, + loadCases: Boolean = ON, + coupleBeamOffsets: Boolean = ON, + cbar: str = B31, + cquad4: str = S4, + chexa: str = C3D8I, + ctetra: str = C3D10, + keepTranslatedFiles: Boolean = ON, + ): + """This method creates a Model object by reading the keywords in a Nastran bulk data file or Nastran + input file and creating any corresponding Abaqus/CAE objects. The default values is discussed in + following and can be defined alternatively in the Abaqus environment file as the one used for the + translator from Nastran to Abaqus. For more information, see Translating Nastran data to Abaqus files. + + .. note:: + This function can be accessed by:: + + mdb.ModelFromNastranFile + + Parameters + ---------- + modelName + A String specifying the repository key. + inputFileName + A String specifying the name of the Nastran input file (including the .bdf, .dat, .nas, + .nastran, .blk, .bulk extension) to be read into the new model. This String can also be + the full path to the Nastran input file if it is located in another directory. + sectionConsolidation + A SymbolicConstant specifying the method used to create shell section. Possible values + are PRESERVE_SECTION, GROUP_BY_MATERIAL, and NONE. If PRESERVE_SECTION is used, an + Abaqus section is created corresponding to each shell property ID. If GROUP_BY_MATERIAL + is used, a single Abaqus section is created for all homogeneous elements referencing the + same material. In both cases, material orientations and offsets are created using + discrete fields. If NONE is used, a separate shell section is created for each + combination of orientation, material offset, and/or thickness. The default is + PRESERVE_SECTION. + preIntegratedShell + A Boolean specifying whether the pre-integrated shell section is created in default for + shell element. The default value is OFF. + weightMassScaling + A Boolean specifying whether the value on the Nastran data line PARAM, WTMASS is used as + a multiplier for all density, mass, and rotary inertia values created in the Abaqus + input file. The default value is ON. + loadCases + A Boolean specifying whether each SUBCASE for linear static analyses is translated to a + LOAD CASE option, and all such LOAD CASE options are grouped in a single STEP option. + The default value is ON. + coupleBeamOffsets + A Boolean specifying whether to translate the beam element connectivity to newly created + nodes at the offset location and rigidly coupling the new and original nodes. If not, + beam element offsets are translated to the CENTROID and SHEAR CENTER options, which are + suboptions of the BEAM GENERAL SECTION option. The default value is ON. When the beam + element references a PBARL or PBEAML property or if the beam offset has a significant + component in the direction of the beam axis, the setting for this argument is always ON. + cbar + A String specifying the 2-node beam that is created from CBAR and CBEAM elements. + Possible values are B31 and B33. The default is B31. + cquad4 + A String specifying the 4-node shell that is created from CQUAD4 elements. Possible + values are S4 and S4R. The default is S4. If a reduced-integration element is chosen, + the enhanced hourglass formulation is applied automatically. + chexa + A String specifying the 8-node brick that is created from CHEXA elements. Possible + values are C3D8I, C3D8 and C3D8R. The default is C3D8I. If a reduced-integration element + is chosen, the enhanced hourglass formulation is applied automatically. + ctetra + A String specifying the 10-node tetrahedron that is created from CTETRA elements. + Possible values are C3D10 and C3D10M. The default is C3D10. + keepTranslatedFiles + A Boolean specifying whether to keep the generated Abaqus input file after the model is + created from the Nastran input file. The default value is ON. + + Returns + ------- + Model + A Model object. + """ + self.models[modelName] = model = Model(modelName) + return model diff --git a/src/abaqus/Model/ModelBase.py b/src/abaqus/Model/ModelBase.py index b41799d0ed..ecc912336f 100644 --- a/src/abaqus/Model/ModelBase.py +++ b/src/abaqus/Model/ModelBase.py @@ -40,14 +40,9 @@ from ..TableCollection.EventSeriesType import EventSeriesType from ..TableCollection.TableCollection import TableCollection from ..UtilityAndView.abaqusConstants import ( - B31, - C3D8I, - C3D10, NOT_SET, OFF, ON, - PRESERVE_SECTION, - S4, STANDARD_EXPLICIT, Boolean, SymbolicConstant, @@ -313,144 +308,6 @@ def __init__( self.steps["Initial"] = InitialStep() self.rootAssembly = Assembly() - @abaqus_method_doc - def ModelFromInputFile(self, name: str, inputFileName: str): - """This method creates a Model object by reading the keywords in an input file and creating the - corresponding Abaqus/CAE objects. - - .. note:: - This function can be accessed by:: - - mdb.Model - - Parameters - ---------- - name - A String specifying the repository key. - inputFileName - A String specifying the name of the input file (including the .inp extension) to be - parsed into the new model. This String can also be the full path to the input file if it - is located in another directory. - - Returns - ------- - Model - A Model object. - """ - ... - - @abaqus_method_doc - def ModelFromOdbFile(self, name: str, odbFileName: str): - """This method creates a Model object by reading an output database and creating any corresponding - Abaqus/CAE objects. - - .. note:: - This function can be accessed by:: - - mdb.Model - - Parameters - ---------- - name - A String specifying the repository key. - odbFileName - A String specifying the name of the output database file (including the .odb extension) - to be read into the new model. This String can also be the full path to the output - database file if it is located in another directory. - - Returns - ------- - Model - A Model object. - """ - ... - - @abaqus_method_doc - def ModelFromNastranFile( - self, - modelName: str, - inputFileName: str, - sectionConsolidation: Literal[C.PRESERVE_SECTION, C.GROUP_BY_MATERIAL, C.NONE] = PRESERVE_SECTION, - preIntegratedShell: Boolean = OFF, - weightMassScaling: Boolean = ON, - loadCases: Boolean = ON, - coupleBeamOffsets: Boolean = ON, - cbar: str = B31, - cquad4: str = S4, - chexa: str = C3D8I, - ctetra: str = C3D10, - keepTranslatedFiles: Boolean = ON, - ): - """This method creates a Model object by reading the keywords in a Nastran bulk data file or Nastran - input file and creating any corresponding Abaqus/CAE objects. The default values is discussed in - following and can be defined alternatively in the Abaqus environment file as the one used for the - translator from Nastran to Abaqus. For more information, see Translating Nastran data to Abaqus files. - - .. note:: - This function can be accessed by:: - - mdb.Model - - Parameters - ---------- - modelName - A String specifying the repository key. - inputFileName - A String specifying the name of the Nastran input file (including the .bdf, .dat, .nas, - .nastran, .blk, .bulk extension) to be read into the new model. This String can also be - the full path to the Nastran input file if it is located in another directory. - sectionConsolidation - A SymbolicConstant specifying the method used to create shell section. Possible values - are PRESERVE_SECTION, GROUP_BY_MATERIAL, and NONE. If PRESERVE_SECTION is used, an - Abaqus section is created corresponding to each shell property ID. If GROUP_BY_MATERIAL - is used, a single Abaqus section is created for all homogeneous elements referencing the - same material. In both cases, material orientations and offsets are created using - discrete fields. If NONE is used, a separate shell section is created for each - combination of orientation, material offset, and/or thickness. The default is - PRESERVE_SECTION. - preIntegratedShell - A Boolean specifying whether the pre-integrated shell section is created in default for - shell element. The default value is OFF. - weightMassScaling - A Boolean specifying whether the value on the Nastran data line PARAM, WTMASS is used as - a multiplier for all density, mass, and rotary inertia values created in the Abaqus - input file. The default value is ON. - loadCases - A Boolean specifying whether each SUBCASE for linear static analyses is translated to a - LOAD CASE option, and all such LOAD CASE options are grouped in a single STEP option. - The default value is ON. - coupleBeamOffsets - A Boolean specifying whether to translate the beam element connectivity to newly created - nodes at the offset location and rigidly coupling the new and original nodes. If not, - beam element offsets are translated to the CENTROID and SHEAR CENTER options, which are - suboptions of the BEAM GENERAL SECTION option. The default value is ON. When the beam - element references a PBARL or PBEAML property or if the beam offset has a significant - component in the direction of the beam axis, the setting for this argument is always ON. - cbar - A String specifying the 2-node beam that is created from CBAR and CBEAM elements. - Possible values are B31 and B33. The default is B31. - cquad4 - A String specifying the 4-node shell that is created from CQUAD4 elements. Possible - values are S4 and S4R. The default is S4. If a reduced-integration element is chosen, - the enhanced hourglass formulation is applied automatically. - chexa - A String specifying the 8-node brick that is created from CHEXA elements. Possible - values are C3D8I, C3D8 and C3D8R. The default is C3D8I. If a reduced-integration element - is chosen, the enhanced hourglass formulation is applied automatically. - ctetra - A String specifying the 10-node tetrahedron that is created from CTETRA elements. - Possible values are C3D10 and C3D10M. The default is C3D10. - keepTranslatedFiles - A Boolean specifying whether to keep the generated Abaqus input file after the model is - created from the Nastran input file. The default value is ON. - - Returns - ------- - Model - A Model object. - """ - ... - @abaqus_method_doc def setValues( self,