pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
sets.py
Go to the documentation of this file.
00001 ## GNU Lesser General Public License
00002 ## 
00003 ## Program pyNastran - a python interface to NASTRAN files
00004 ## Copyright (C) 2011-2012  Steven Doyle, Al Danial
00005 ## 
00006 ## Authors and copyright holders of pyNastran
00007 ## Steven Doyle <mesheb82@gmail.com>
00008 ## Al Danial    <al.danial@gmail.com>
00009 ## 
00010 ## This file is part of pyNastran.
00011 ## 
00012 ## pyNastran is free software: you can redistribute it and/or modify
00013 ## it under the terms of the GNU Lesser General Public License as published by
00014 ## the Free Software Foundation, either version 3 of the License, or
00015 ## (at your option) any later version.
00016 ## 
00017 ## pyNastran is distributed in the hope that it will be useful,
00018 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 ## GNU General Public License for more details.
00021 ## 
00022 ## You should have received a copy of the GNU Lesser General Public License
00023 ## along with pyNastran.  If not, see <http://www.gnu.org/licenses/>.
00024 ## 
00025 # pylint: disable=C0103,R0902,R0904,R0914
00026 
00027 from __future__ import division, print_function
00028 from itertools import izip
00029 
00030 from pyNastran.bdf.cards.baseCard import BaseCard, expandThru
00031 from pyNastran.bdf.fieldWriter import print_int_card
00032 
00033 class Set(BaseCard):
00034     """Generic Class all SETx cards inherit from"""
00035     type = 'Set'
00036     def __init__(self, card, data):
00037         ## Unique identification number. (Integer > 0)
00038         self.sid = None
00039         ## list of IDs in the SETx
00040         self.IDs = None
00041 
00042     def cleanIDs(self):
00043         """eliminates duplicate IDs from self.IDs and sorts self.IDs"""
00044         self.IDs = list(set(self.IDs))
00045         self.IDs.sort()
00046 
00047     def SetIDs(self):
00048         """gets the IDs of the SETx"""
00049         return self.IDs
00050 
00051     def reprFields(self):
00052         fields = self.rawFields()
00053         return fields
00054 
00055     def __repr__(self):
00056         return print_int_card(self.reprFields())
00057 
00058 class SetSuper(Set):
00059     """Generic Class all Superelement SETx cards inherit from."""
00060     def __init__(self, card, data):
00061         ## Superelement identification number. Must be a primary superelement.
00062         ## (Integer >= 0)
00063         self.seid = None
00064         ## list of IDs in the SESETx
00065         self.IDs = None
00066 
00067 class ABCQSet(Set):
00068     """
00069     Generic Class ASET, BSET, CSET, QSET cards inherit from.
00070 
00071     Defines degrees-of-freedom in the analysis set (a-set)
00072     ASET ID1 C1 ID2 C2   ID3 C3 ID4 C4
00073     ASET 16  2  23  3516 1   4
00074     """
00075     def __init__(self, card=None, data=None): ## @todo doesnt support data
00076         Set.__init__(self, card, data)
00077 
00078         ## Identifiers of grids points. (Integer > 0)
00079         self.IDs = []
00080         self.components = []
00081 
00082         fields = card.fields(1)
00083         for i in xrange(0, fields, 2):
00084             self.IDs.append(fields[i])
00085             self.components.append(str(fields[i+1]))
00086 
00087     def rawFields(self):
00088         """gets the "raw" card without any processing as a list for printing"""
00089         fields = [self.type] # ASET, BSET
00090         for (ID, comp) in izip(self.IDs, self.components):
00091             fields += [ID, comp]
00092         return fields
00093 
00094     def __repr__(self):
00095         fields = self.rawFields()
00096         return self.printCard(fields)
00097 
00098 class ASET(ABCQSet):
00099     """
00100     Defines degrees-of-freedom in the analysis set (a-set).
00101     ASET ID1 C1 ID2 C2   ID3 C3 ID4 C4
00102     ASET 16  2  23  3516 1   4
00103     """
00104     type = 'ASET'
00105     def __init__(self, card=None, data=None): ## @todo doesnt support data
00106         ABCQSet.__init__(self, card, data)
00107 
00108 class BSET(ABCQSet):
00109     """
00110     Defines analysis set (a-set) degrees-of-freedom to be fixed (b-set) during
00111     generalized dynamic reduction or component mode synthesis calculations.
00112     ASET ID1 C1 ID2 C2   ID3 C3 ID4 C4
00113     ASET 16  2  23  3516 1   4
00114     """
00115     type = 'BSET'
00116     def __init__(self, card=None, data=None): ## @todo doesnt support data
00117         ABCQSet.__init__(self, card, data)
00118 
00119 class CSET(ABCQSet):
00120     """
00121     Defines analysis set (a-set) degrees-of-freedom to be fixed (b-set) during
00122     generalized dynamic reduction or component mode synthesis calculations.
00123     ASET ID1 C1 ID2 C2   ID3 C3 ID4 C4
00124     ASET 16  2  23  3516 1   4
00125     """
00126     type = 'CSET'
00127     def __init__(self, card=None, data=None): ## @todo doesnt support data
00128         ABCQSet.__init__(self, card, data)
00129 
00130 class QSET(ABCQSet):
00131     """
00132     Defines generalized degrees-of-freedom (q-set) to be used for dynamic
00133     reduction or component mode synthesis.
00134     QSET ID1 C1 ID2 C2   ID3 C3 ID4 C4
00135     QSET 16  2  23  3516 1   4
00136     """
00137     type = 'QSET'
00138     def __init__(self, card=None, data=None): ## @todo doesnt support data
00139         ABCQSet.__init__(self, card, data)
00140 
00141 class ABQSet1(Set):
00142     """
00143     Generic Class ASET1, BSET1, QSET1 cards inherit from.
00144 
00145     Defines degrees-of-freedom in the analysis set (a-set).
00146     ASET1 C ID1 ID2 ID3 ID4 ID5 ID6 ID7
00147     ID8 ID9
00148     ASET1 C ID1 'THRU' ID2
00149     """
00150     def __init__(self, card=None, data=None): ## @todo doesnt support data
00151         Set.__init__(self, card, data)
00152         ## Component number. (Integer zero or blank for scalar points or any
00153         ## unique combination of the Integers 1 through 6 for grid points with
00154         ## no embedded blanks.)
00155         self.components = str(card.field(1, 0))
00156 
00157         ## Identifiers of grids points. (Integer > 0)
00158         self.IDs = expandThru(card.fields(2))
00159 
00160     def rawFields(self):
00161         """gets the "raw" card without any processing as a list for printing"""
00162         fields = [self.type, self.components]+self.IDs
00163         return fields
00164 
00165     def __repr__(self):
00166         fields = self.rawFields()
00167         return self.printCard(fields)
00168 
00169 class ASET1(ABQSet1):
00170     """
00171     Defines degrees-of-freedom in the analysis set (a-set)
00172     ASET1 C ID1 ID2 ID3 ID4 ID5 ID6 ID7
00173     ID8 ID9
00174     ASET1 C ID1 'THRU' ID2
00175     """
00176     type = 'ASET1'
00177     def __init__(self, card=None, data=None):
00178         ABQSet1.__init__(self, card, data)
00179 
00180 class BSET1(ABQSet1):
00181     type = 'BSET1'
00182     def __init__(self, card=None, data=None):
00183         ABQSet1.__init__(self, card, data)
00184 
00185 class CSET1(Set):
00186     """
00187     Defines analysis set (a-set) degrees-of-freedom to be fixed (b-set) during
00188     generalized dynamic reduction or component mode synthesis calculations.
00189     CSET1 C ID1 ID2 ID3 ID4 ID5 ID6 ID7
00190     ID8 ID9
00191     CSET1 C ID1 'THRU' ID2
00192     CSET1,,'ALL'
00193     """
00194     def __init__(self, card=None, data=None): ## @todo doesnt support data
00195         Set.__init__(self, card, data)
00196 
00197         ## Identifiers of grids points. (Integer > 0)
00198         self.IDs = []
00199         if card.field(2)=='ALL':
00200             self.components = '123456'
00201         else:
00202             self.components = str(card.field(1))
00203             self.IDs = expandThru(card.fields(2))
00204         ###
00205 
00206     def rawFields(self):
00207         """gets the "raw" card without any processing as a list for printing"""
00208         fields = [self.type, self.components]+self.IDs
00209         return fields
00210 
00211     def __repr__(self):
00212         fields = self.rawFields()
00213         return self.printCard(fields)
00214 
00215 class QSET1(ABQSet1):
00216     """
00217     Defines generalized degrees-of-freedom (q-set) to be used for dynamic
00218     reduction or component mode synthesis.
00219     """
00220     type = 'QSET1'
00221     def __init__(self, card=None, data=None):
00222         ABQSet1.__init__(self, card, data)
00223 
00224 class SET1(Set):
00225     """
00226     Defines a list of structural grid points or element identification numbers.
00227     SET1 SID ID1 ID2 ID3 ID4 ID5 ID6 ID7
00228     ID8 -etc.-
00229     SET1 3 31 62 93 124 16 17 18
00230     19
00231     SET1 6 29 32 THRU 50 61 THRU 70
00232     17 57
00233     """
00234     type = 'SET1'
00235     def __init__(self, card=None, data=None): ## @todo doesnt support data
00236         Set.__init__(self, card, data)
00237         ## Unique identification number. (Integer > 0)
00238         self.sid = card.field(1)
00239 
00240         ## List of structural grid point or element identification numbers.
00241         ## (Integer > 0 or 'THRU'; for the 'THRU' option, ID1 < ID2 or 'SKIN';
00242         ## in field 3)
00243         self.IDs = []
00244 
00245         fields = card.fields(2)
00246         self.isSkin = False
00247         i = 0
00248         if isinstance(fields[0], str) and fields[0].upper() == 'SKIN':
00249             self.isSkin = True
00250             i+=1
00251         self.IDs = expandThru(fields[i:])
00252         self.cleanIDs()
00253 
00254     def IsSkin(self):
00255         return self.isSkin
00256 
00257     def rawFields(self):
00258         """gets the "raw" card without any processing as a list for printing"""
00259         fields = ['SET1', self.sid]
00260         if self.isSkin:
00261             fields.append('SKIN')
00262         fields += self.SetIDs()
00263         return fields
00264 
00265 class SET3(Set):
00266     """
00267     Defines a list of grids, elements or points.
00268     SET3 SID DES ID1 ID2 ID3 ID4 ID5 ID6
00269     ID7 ID8 -etc-
00270     SET3 1 POINT 11 12
00271     """
00272     type = 'SET1'
00273     def __init__(self, card=None, data=None): ## @todo doesnt support data
00274         Set.__init__(self, card, data)
00275         ## Unique identification number. (Integer > 0)
00276         self.sid = card.field(1)
00277         
00278         ## Set description (Character). Valid options are 'GRID', 'ELEM',
00279         ## 'POINT' and 'PROP'.
00280         self.desc = card.field(2).upper()
00281         assert self.desc in ['GRID', 'POINT', 'ELEM', 'PROP']
00282 
00283         ## Identifiers of grids points, elements, points or properties.
00284         ## (Integer > 0)
00285         self.IDs = []
00286 
00287         fields = card.fields(2)
00288         self.IDs = expandThru(fields)
00289         self.cleanIDs()
00290 
00291     def IsGrid(self):
00292         if self.desc=='GRID':
00293             return True
00294         return False
00295 
00296     def IsPoint(self):
00297         if self.desc=='POINT':
00298             return True
00299         return False
00300 
00301     def IsProperty(self):
00302         if self.desc=='PROP':
00303             return True
00304         return False
00305 
00306     def IsElement(self):
00307         if self.desc=='ELEM':
00308             return True
00309         return False
00310     
00311     def rawFields(self):
00312         """gets the "raw" card without any processing as a list for printing"""
00313         fields = ['SET3', self.sid, self.desc]+self.SetIDs()
00314         return fields
00315 
00316     def __repr__(self):
00317         fields = ['SET3', self.sid, self.desc]+self.SetIDs()
00318         return self.printCard(fields)
00319 
00320 class SESET(SetSuper):
00321     """
00322     Defines interior grid points for a superelement.
00323     """
00324     type = 'SESET'
00325     def __init__(self, card=None, data=None):
00326         SetSuper.__init__(self, card, data)
00327         self.seid = card.field(1, 0)
00328         ## Grid or scalar point identification number.
00329         ## (0 < Integer < 1000000; G1 < G2)
00330         self.IDs = []
00331 
00332         fields = card.fields(2)
00333         self.IDs = expandThru(fields)
00334         self.cleanIDs()
00335 
00336     def rawFields(self):
00337         fields = ['SESET', self.seid]+self.SetIDs()
00338         return fields
00339 
00340 class SEQSEP(SetSuper): # not integrated...is this an SESET ???
00341     """
00342     Used with the CSUPER entry to define the correspondence of the
00343     exterior grid points between an identical or mirror-image superelement
00344     and its primary superelement.
00345     """
00346     type = 'SEQSEP'
00347     def __init__(self, card=None, data=None):
00348         SetSuper.__init__(self, card, data)
00349         ## Identification number for secondary superelement. (Integer >= 0).
00350         self.ssid = card.field(1)
00351         ## Identification number for the primary superelement. (Integer >= 0).
00352         self.psid = card.field(2)
00353         ## Exterior grid point identification numbers for the primary
00354         ## superelement. (Integer > 0)
00355         self.IDs = []
00356 
00357         fields = card.fields(3)
00358         self.IDs = expandThru(fields)
00359         self.cleanIDs()
00360 
00361     def rawFields(self):
00362         """gets the "raw" card without any processing as a list for printing"""
00363         fields = ['SEQSEP',self.ssid,self.psid]+self.SetIDs()
00364         return fields
00365 
00366 class RADSET(Set): # not integrated
00367     """
00368     Specifies which radiation cavities are to be included for
00369     radiation enclosure analysis.
00370     RADSET ICAVITY1 ICAVITY2 ICAVITY3 ICAVITY4 ICAVITY5 ICAVITY6 ICAVITY7 ICAVITY8
00371            ICAVITY9 -etc.-
00372     """
00373     type = 'RADSET'
00374     def __init__(self, card=None, data=None):
00375         Set.__init__(self, card, data)
00376         self.seid = card.field(1)
00377         ## Grid or scalar point identification number.
00378         ## (0 < Integer < 1000000; G1 < G2)
00379         self.IDs = []
00380 
00381         fields = card.fields(2)
00382         self.IDs = expandThru(fields)
00383         self.cleanIDs()
00384 
00385     def addRadsetObject(self, radset):
00386         self.IDs += radset.IDs
00387         self.cleanIDs()
00388         
00389     def rawFields(self):
00390         """gets the "raw" card without any processing as a list for printing"""
00391         fields = ['RADSET',self.seid]+self.SetIDs()
00392         return fields
00393 
 All Classes Namespaces Files Functions Variables