def p_list(self, p): '''list : '(' itemlist ')' ''' p[0] = self.condenseAllPreFixLists(p[2]) if not self.noVectorOrTensor and (len(p[2]) == 3 or len(p[2]) == 9 or len(p[2]) == 6): isVector = True for i in p[2]: try: float(i) except: isVector = False if isVector: if len(p[2]) == 3: p[0] = Vector(*p[2]) elif len(p[2]) == 9: p[0] = Tensor(*p[2]) else: p[0] = SymmTensor(*p[2])
scale=1., vtkOut=True, hullPatch=None, localPts=None): res = cls(name=join(case, getFilePath("initFlexDict")), read=False) res.header["class"] = "dictionary" fem = DictProxy() fem["mdFile"] = '"../{}"; selected ( '.format( mdFile) + len(modes2use) * '{} '.format(*modes2use) + ')' fem["datFile"] = '"../{}"'.format(datFile) fem["dmigMfile"] = '"../{}"'.format(dmigFile) fem["dmigKfile"] = '"../{}"'.format(dmigFile) fem["pchCoordinate"] = SymmTensor(*[0, 0, -draft, 0, 0, 0]) fem["pchScaleMode"] = scale fem["pchLengthUnit"] = 1 fem["pchMassUnit"] = 1 if not vtkOut: fem["outputToVTK"] = "no" fem["patches"] = "({})".format(hullPatch) fem["ySym"] = "(true)" if localPts is not None: if len(localPts) > 0: fem["pointList"] = "(localMotion)" fem["localMotion"] = [Vector(*pt) for pt in localPts] res["FEM_STRUCTURALMESH_VTU"] = fem return res
def p_symmtensor(self, p): '''symmtensor : '(' number number number number number number ')' ''' if self.noVectorOrTensor: p[0] = p[2:8] else: p[0] = SymmTensor(*p[2:8])
""" class SixDofDomainBody(ReadWriteFile): """SixDofDomainBody dictionnary """ @classmethod def Build(cls , case, mass, inertia, COG, nModes=0, donName=None) : res = cls( name = join(case, getFilePath("sixDofDomainBody") ), read = False ) res.header["class"] = "dictionary" res.header["object"] = "singleBody" res["mass"] = mass res["momentOfInertia"] = SymmTensor( *inertia ) res["cogInitial"] = Vector( *COG ) res["Xrel"] = "(0 0 0)" res["dotXrel"] = "(0 0 0)" res["omega"] = "(0 0 0)" res["EulerZYX"] = { "rollPitchYaw" : "(0 0 0)" } if nModes>0: res["modalData"] = { "readFromFile" : "constant/{}.flex".format(donName) } return res if __name__ == "__main__" : print(SixDofDomainBody.Build("test", 1000., 2000., '1 2 3'))