Exemplo n.º 1
0
    def toMesh(self, meshID=None):
        if meshID == None:
            meshID = self.filename
            if meshID[-4:].lower() == '.inp': meshID = meshID[:-4]
        for count, dict_elm in enumerate(self.__Element):
            if len(self.__Element) < 2: importedMeshName = meshID
            else: importedMeshName = meshID + str(count)

            elm = self.__ConvertNode(dict_elm['ElementTable'])
            Mesh(self.__NodeCoordinate,
                 elm,
                 dict_elm['ElementType'],
                 ID=importedMeshName)
            #add set of nodes
            for SetOfId, NodeIndexes in enumerate(self.__NodeSet):
                Mesh.GetAll()[importedMeshName].AddSetOfNodes(
                    self.__ConvertNode(NodeIndexes), SetOfId)

            ElementNumber = dict_elm['ElementNumber']
            ConvertElementDict = dict(
                zip(ElementNumber, list(range(0, len(ElementNumber)))))
            ConvertElement = np.vectorize(ConvertElementDict.get)  #function
            for SetOfId, ElementIndexes in enumerate(self.__ElementSet):
                Temp = ConvertElement(ElementIndexes)
                Mesh.GetAll()[importedMeshName].AddSetOfElements(
                    Temp[Temp != None].astype(int), SetOfId)
Exemplo n.º 2
0
    def SetElementType(self, listElementType, listSubMesh=None):
        """
        Define the Type of Element used for the finite element assembly of each subMesh
        Example of available element type: 'lin2', 'beam', 'tri6', ...
        
        PGD.Assembly.SetElementType([ElementType_1,...,ElementType_n ])
            * ElementType_i is a list of ElementType cooresponding to the ith subMesh 
              (as defined in the constructor of the PGD.Mesh object related to the Assembly)            
            
        PGD.Assembly.SetElementType([ElementType_1,...,ElementType_n ], [subMesh_1,...,subMesh_n] )
            * ElementType_i is a list of ElementType cooresponding to the mesh indicated in subMesh_i
            * subMesh_i can be either a mesh ID (str object) or a Mesh object
            * If a subMesh is not included in listSubMesh, the ElementType for assembly is not modified (based on the geometrical element shape by default)
        """

        if listSubMesh is None:
            if len(listElementType) != len(self.__Mesh.GetListMesh()):
                assert 0, "The lenght of the Element Type List must be equal to the number of submeshes"
            self.__listElementType = [
                ElementType for ElementType in listElementType
            ]
            self.__listNumberOfGaussPoints = [
                GetDefaultNbPG(self.__listElementType[dd],
                               self.__Mesh.GetListMesh()[dd])
                for dd in range(len(self.__listElementType))
            ]  #Nb_pg for every subMesh defined in self.__Mesh (default value)
        else:
            for i, m in enumerate(listSubMesh):
                if isinstance(m, str): m = MeshFEM.GetAll()[m]
                dd = self.__Mesh.GetListMesh().index(m)
                self.__listElementType[dd] = listElementType[i]
                self.__listNumberOfGaussPoints[dd] = GetDefaultNbPG(
                    listElementType[i], m)
Exemplo n.º 3
0
    def __init__(self, weakForm, mesh="", ID=""):
        #mesh should be of type PGD.Mesh

        if isinstance(weakForm, str):
            weakForm = WeakForm.GetAll()[weakForm]

        if isinstance(mesh, str):
            mesh = MeshFEM.GetAll()[mesh]

        AssemblyBase.__init__(self, ID)

        self.__weakForm = weakForm
        self.__Mesh = mesh  #should be a MeshPGD object
        self.__listElementType = [
            m.GetElementShape() for m in mesh.GetListMesh()
        ]  #ElementType for every subMesh defined in self.__Mesh
        self.__listNumberOfGaussPoints = [
            GetDefaultNbPG(eltype) for eltype in self.__listElementType
        ]  #Nb_pg for every subMesh defined in self.__Mesh (default value)
Exemplo n.º 4
0
    def __init__(self, weakForm, mesh="", elementType="", ID="", **kargs):
        #        t0 = time.time()

        if isinstance(weakForm, str):
            weakForm = WeakForm.GetAll()[weakForm]

        if isinstance(mesh, str):
            mesh = Mesh.GetAll()[mesh]

        AssemblyBase.__init__(self, ID)

        self.__MeshChange = kargs.pop('MeshChange', False)
        self.__Mesh = mesh
        self.__weakForm = weakForm
        self.__elmType = elementType  #.lower()
        self.__nb_pg = kargs.pop('nb_pg', None)
        if self.__nb_pg is None:
            self.__nb_pg = GetDefaultNbPG(elementType, mesh)

        #print('Finite element operator for Assembly "' + ID + '" built in ' + str(time.time()-t0) + ' seconds')

        self.computeMatrixMethod = 'new'