예제 #1
0
    def __init__(self, name, conf, props, globdat):
        self.name = name
        myConf = conf.makeProps(name)
        myProps = props.getProps(name)

        self.type = myProps.get("type", "Periodic")
        self.strain = myProps.find("strainRate", None)
        self.factor = myProps.get("coarsenFactor", 1.0)
        self.numTNode = myProps.get("numTNode", 10)

        myConf.set("type", self.type)
        myConf.set("strainRate", self.strain)
        myConf.set("coarsenFactor", self.factor)
        myConf.set("numTNode", 10)

        mesh = globdat.get("mesh")
        self.rank = mesh.rank

        #-----------------------------------------------------------------------
        #   initialize
        #-----------------------------------------------------------------------

        # Add displacement doftypes
        types = ['u', 'v', 'w']
        self.udofTypes = [types[x] for x in range(self.rank)]
        mesh.addTypes(self.udofTypes)

        # Add traction doftypes
        types = ['tx', 'ty', 'tz']
        self.tdofTypes = [types[x] for x in range(self.rank)]
        mesh.addTypes(self.tdofTypes)

        # Get specimen dimensions
        self.__boundingBox(mesh)
        self.__setTolerances()

        # Get boundary nodes
        self.__findBndNodes(mesh)
        self.__sortBndNodes(mesh)

        # Find corner nodes
        self.__findCornerNodes()

        # Create boundary element
        self.bshape = Shape.shapeFactory(myConf, myProps)
        self.ipCount = self.bshape.nIP
        self.tnodeCount = self.bshape.nnod
        self.tdofCount = self.tnodeCount * self.rank
        self.localrank = self.bshape.ndim
        if self.localrank != self.rank - 1:
            msg = "Shape ndim = {}. Should be {}".format(
                self.localrank, self.rank - 1)
            raise ValueError(msg)

        # Create traction mesh
        self.tnodes = NodeSet()
        self.__findSmallestElement(mesh)
        self.__createTractionMesh2(mesh)
예제 #2
0
    def __init__(self, name, conf, props, globdat):
        self.name = name
        myConf = conf.makeProps(name)
        myProps = props.getProps(name)

        self.type = myProps.get("type", "Solid")
        self.group = myProps.get("elements", "All")

        myConf.set("type", self.type)
        myConf.set("elements", self.group)

        mesh = globdat.get("mesh")
        self.rank = mesh.rank

        if self.group != "All":
            key = int(re.search(r'\d+', self.group).group())
            group_name = mesh.groupNames[key]
            logging.debug("    Obtaining elements from {}".format(group_name))
            idx = mesh.groupNames.keys().index(key)
            self.ielements = mesh.groups[idx]
            logging.debug("    Elements in mesh.groups[{}]".format(idx))
        else:
            group_name = next(iter(mesh.groupNames.values()))
            self.ielements = mesh.groups[0]
            logging.debug("    Obtaining elements from {}".format(group_name))

    #-----------------------------------------------------------------------
    #   initialize
    #-----------------------------------------------------------------------

    # Add types
        types = ['u', 'v', 'w']
        self.types = [types[x] for x in range(self.rank)]
        mesh.addTypes(self.types)

        # Add dofs
        self.inodes = mesh.getNodeIndices(self.ielements)
        mesh.addDofs(self.inodes, self.types)

        # Add thickness (2D)
        if self.rank == 2:
            self.t = myProps.get("thickness", 1.0)
            myConf.set("thickness", self.t)

        # Create element
        self.shape = Shape.shapeFactory(myConf, myProps)
        localrank = self.shape.ndim
        if localrank != self.rank:
            msg = "Shape ndim = {}. Should be {}".format(localrank, self.rank)
            raise ValueError(msg)

        # Create material
        self.mat = Material.materialFactory(myConf, myProps)