pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
crossReference.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=E1101,C0103,R0902,R0904,R0914,W0611
00026 
00027 from __future__ import print_function
00028 import sys
00029 #from pyNastran.bdf.cards.constraints import constraintObject2
00030 
00031 class XrefMesh(object):
00032     """
00033     Links up the various cards in the BDF.
00034     """
00035     def __init__(self):
00036         """
00037         The main BDF class defines all the parameters that are used.
00038         """
00039         pass
00040 
00041     def crossReference(self, xref=True):
00042         """
00043         Links up all the cards to the cards they reference
00044         """
00045         if xref:
00046             self.log.debug("Cross Referencing...")
00047             #for key,e in self.elements.iteritems():
00048                 #print(e)
00049 
00050             self._cross_reference_nodes()
00051             self._cross_reference_coordinates()
00052 
00053             self._cross_reference_elements()
00054             self._cross_reference_properties()
00055             self._cross_reference_materials()
00056 
00057             self._cross_reference_aero()
00058             self._cross_reference_constraints()
00059             self._cross_reference_loads()
00060             #self.caseControlDeck.crossReference(self)
00061         ###
00062     
00063     def _cross_reference_constraints(self):
00064         """
00065         Links the SPCADD, SPC, SPCAX, SPCD, MPCADD, MPC cards.
00066         """
00067         #self.spcObject.crossReference(self)  # enable to output SPCs
00068         #self.mpcObject.crossReference(self)  # enable to output MPCs
00069         
00070         #self.spcObject2 = constraintObject2()
00071         for spcadd in self.spcadds.itervalues():
00072             self.spcObject2.Add(spcadd)
00073 
00074         for spcs in self.spcs.itervalues():
00075             for spc in spcs:
00076                 self.spcObject2.append(spc)
00077 
00078         for mpcadd in self.mpcadds.itervalues():
00079             self.mpcObject2.Add(mpcadd)
00080 
00081         for mpcs in self.mpcs.itervalues():
00082             for mpc in mpcs:
00083                 self.mpcObject2.append(mpc)
00084         #self.mpcObject2 = constraintObject2()
00085         #self.spcObject.crossReference(self)
00086 
00087 
00088     def _cross_reference_coordinates(self):
00089         """
00090         Links up all the coordinate cards to other coordinate cards and nodes
00091         """
00092         # CORD2x: links the rid to coordinate systems
00093         # CORD1x: links g1,g2,g3 to grid points
00094         for coord in self.coords.itervalues():
00095             coord.crossReference(self)
00096 
00097         # CORD1x: Since the grid points were already referenced,
00098         # we can now resolve the coordinate systems.
00099         # We couldnt do it in the previous step b/c
00100         # the grid's coordinate system might have been
00101         # unresolved
00102         for coord in self.coords.itervalues(): 
00103             coord.resolveCid()
00104 
00105     def _cross_reference_aero(self):
00106         """
00107         Links up all the aero cards
00108         """
00109         for caero in self.caeros.itervalues():
00110             caero.crossReference(self)
00111 
00112         for spline in self.splines.itervalues():
00113             spline.crossReference(self)
00114 
00115     def _cross_reference_nodes(self):
00116         """
00117         Links the nodes to coordinate systems
00118         """
00119         gridSet = self.gridSet
00120         for n in self.nodes.itervalues():
00121             try:
00122                 n.crossReference(self, gridSet)
00123             except:
00124                 self.log.error("Couldn't cross reference GRID.\n%s" % (str(n)))
00125                 raise
00126 
00127         if self.spoints:
00128             self.spointi = self.spoints.createSPOINTi()
00129 
00130     def _cross_reference_elements(self):
00131         """
00132         Links the elements to nodes, properties (and materials depending on
00133         the card).
00134         """
00135         for elem in self.elements.itervalues():
00136             try:
00137                 elem.crossReference(self)
00138             except:
00139                 msg = "Couldn't cross reference Element.\n%s" % (str(elem))
00140                 self.log.error(msg)
00141                 raise
00142 
00143     def _cross_reference_properties(self):
00144         """
00145         Links the properties to materials
00146         """
00147         for prop in self.properties.itervalues():
00148             try:
00149                 prop.crossReference(self)
00150             except:
00151                 msg = "Couldn't cross reference Property.\n%s" % (str(prop))
00152                 self.log.error(msg)
00153                 raise
00154 
00155     def _cross_reference_materials(self):
00156         """
00157         Links the materials to materials (e.g. MAT1, CREEP)
00158         often this is a pass statement
00159         """
00160         for mat in self.materials.itervalues(): # MAT1
00161             try:
00162                 mat.crossReference(self)
00163             except:
00164                 msg = "Couldn't cross reference Material\n%s" % (str(mat))
00165                 self.log.error(msg)
00166                 raise
00167 
00168         for mat in self.materialDeps.itervalues(): # CREEP - depends on MAT1
00169             try:
00170                 mat.crossReference(self)
00171             except:
00172                 msg = "Couldn't cross reference Material\n%s" % (str(mat))
00173                 self.log.error(msg)
00174                 raise
00175 
00176     def _cross_reference_loads(self):
00177         """
00178         Links the loads to nodes, coordinate systems, and other loads.
00179         """
00180         for (lid, sid) in self.loads.iteritems():
00181             #self.log.debug("lid=%s sid=%s" %(lid,sid))
00182             for load in sid:
00183                 try:
00184                     load.crossReference(self)
00185                 except:
00186                     self.log.error("lid=%s sid=%s" % (lid, sid))
00187                     msg = "Couldn't cross reference Load\n%s" % (str(load))
00188                     self.log.error(msg)
00189                     raise
00190 
 All Classes Namespaces Files Functions Variables