pyNastran
0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
|
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 #import sys 00029 00030 from pyNastran.bdf.cards.baseCard import Element 00031 00032 #------------------------------------------------------------------------------ 00033 class CFAST(Element): 00034 type = 'CFAST' 00035 def __init__(self, card=None, data=None): 00036 Element.__init__(self, card, data) 00037 self.eid = card.field(1) 00038 self.pid = card.field(2) 00039 self.Type = card.field(3) 00040 self.ida = card.field(4) 00041 self.idb = card.field(5) 00042 self.gs = card.field(6) 00043 self.ga = card.field(7) 00044 self.gb = card.field(8) 00045 self.xs = card.field(9) 00046 self.ys = card.field(10) 00047 self.zs = card.field(11) 00048 00049 #if self.Type=='PROP': # PSHELL/PCOMP ida & idb 00050 00051 def crossReference(self, model): ## @todo xref 00052 self.pid = model.Property(self.pid) 00053 #self.gs = model.Node(self.gs) 00054 #self.ga = model.Node(self.ga) 00055 #self.gb = model.Node(self.gb) 00056 00057 def rawFields(self): 00058 fields = ['CFAST', self.eid, self.Pid(), self.Type, self.ida, self.idb, self.gs, self.ga, self.gb, 00059 self.xs, self.ys, self.zs] 00060 return fields 00061 00062 def reprFields(self): 00063 return self.rawFields() 00064 00065 #------------------------------------------------------------------------------ 00066 class CGAP(Element): 00067 type = 'CGAP' 00068 def __init__(self, card=None, data=None): 00069 Element.__init__(self, card, data) 00070 if card: 00071 self.eid = card.field(1) 00072 self.pid = card.field(2) 00073 self.ga = card.field(3) 00074 self.gb = card.field(4) 00075 x1G0 = card.field(5) 00076 if isinstance(x1G0, int): 00077 self.g0 = x1G0 00078 self.x = None 00079 self.cid = None 00080 elif isinstance(x1G0, float): 00081 self.g0 = None 00082 x1 = x1G0 00083 x2 = card.field(6) 00084 x3 = card.field(7) 00085 self.x = [x1, x2, x3] 00086 self.cid = card.field(8, 0) 00087 else: 00088 #raise RuntimeError('invalid CGAP...x1/g0 = |%s|' %(x1G0)) 00089 self.g0 = None 00090 self.x = [None, None, None] 00091 self.cid = None 00092 ### 00093 else: 00094 self.eid = data[0] 00095 self.pid = data[1] 00096 self.ga = data[2] 00097 self.gb = data[3] 00098 self.g0 = data[4] 00099 x1 = data[5] 00100 x2 = data[6] 00101 x3 = data[7] 00102 self.x = [x1, x2, x3] 00103 self.cid = data[8] 00104 ### 00105 00106 def crossReference(self, model): 00107 self.ga = model.Node(self.ga) 00108 self.gb = model.Node(self.gb) 00109 if self.g0: 00110 self.g0 = model.Node(self.g0) 00111 self.x = self.g0.Position() 00112 self.pid = model.Property(self.pid) 00113 if self.cid: 00114 self.cid = model.Coord(self.cid) 00115 ### 00116 00117 def Cid(self): 00118 if isinstance(self.cid, int) or self.cid is None: 00119 return self.cid 00120 return self.cid.cid 00121 00122 def rawFields(self): 00123 if self.g0 is not None: 00124 x = [self.g0, None, None] 00125 else: 00126 x = self.x 00127 fields = ['CGAP', self.eid, self.Pid(), self.ga, self.gb]+x+[self.Cid()] 00128 return fields 00129 00130 #------------------------------------------------------------------------------ 00131 class CrackElement(Element): 00132 def __init__(self, card, data): 00133 pass 00134 00135 def crossReference(self, model): 00136 self.nodes = model.Nodes(self.nodes) 00137 self.pid = model.Property(self.pid) 00138 00139 def rawFields(self): 00140 fields = [self.type, self.eid, self.Pid()]+self.nodeIDs() 00141 return fields 00142 00143 class CRAC2D(CrackElement): 00144 type = 'CRAC2D' 00145 def __init__(self, card=None, data=None): 00146 CrackElement.__init__(self, card, data) 00147 if card: 00148 self.eid = card.field(1) 00149 self.pid = card.field(2) 00150 nids = card.fields(3, 21) # caps at 18 00151 else: 00152 self.eid = data[0] 00153 self.pid = data[1] 00154 nids = data[2:] 00155 ### 00156 self.prepareNodeIDs(nids, allowEmptyNodes=True) 00157 assert len(self.nodes)==18 00158 00159 class CRAC3D(CrackElement): 00160 type = 'CRAC3D' 00161 def __init__(self, card=None, data=None): 00162 CrackElement.__init__(self, card, data) 00163 if card: 00164 self.eid = card.field(1) 00165 self.pid = card.field(2) 00166 nids = card.fields(3, 67) # cap at +3 = 67 00167 else: 00168 self.eid = data[0] 00169 self.pid = data[1] 00170 nids = data[2:] 00171 ### 00172 self.prepareNodeIDs(nids, allowEmptyNodes=True) 00173 assert len(self.nodes)==64