Example #1
0
    def on_create_Ke(self, elx, ely, element_type):
        Ke = None
        if self.mesh.shape.element_type == 2:
            Ke = cfc.plante(elx, ely, self.mesh.shape.ep, self.mesh.shape.D)
        else:
            Ke = cfc.planqe(elx, ely, self.mesh.shape.ep, self.mesh.shape.D)

        return Ke
Example #2
0
    def solve(self):
        """Solve problem"""

        self.updateGeometry()
        self.updateMesh()

        self.ep = [self.ptype, self.t]
        self.D = cfc.hooke(self.ptype, self.E, self.v)

        cfu.info("Assembling system matrix...")

        nDofs = np.size(self.dofs)
        ex, ey = cfc.coordxtr(self.edof, self.coords, self.dofs)
        K = np.zeros([nDofs, nDofs])

        for eltopo, elx, ely in zip(self.edof, ex, ey):
            Ke = cfc.planqe(elx, ely, self.ep, self.D)
            cfc.assem(eltopo, K, Ke)

        cfu.info("Solving equation system...")

        f = np.zeros([nDofs, 1])

        bc = np.array([], 'i')
        bcVal = np.array([], 'i')

        bc, bcVal = cfu.applybc(self.bdofs, bc, bcVal, 5, 0.0, 0)

        cfu.applyforce(self.bdofs, f, 7, 10e5, 1)

        self.a, self.r = cfc.solveq(K, f, bc, bcVal)

        cfu.info("Computing element forces...")

        ed = cfc.extractEldisp(self.edof, self.a)
        self.vonMises = []

        # For each element:

        for i in range(self.edof.shape[0]):

            # Determine element stresses and strains in the element.

            es, et = cfc.planqs(ex[i, :], ey[i, :], self.ep, self.D, ed[i, :])

            # Calc and append effective stress to list.

            self.vonMises.append(
                sqrt(
                    pow(es[0], 2) - es[0] * es[1] + pow(es[1], 2) + 3 * es[2]))
Example #3
0
mesh.elType = 3  # Degrees of freedom per node.
mesh.dofsPerNode = 2  # Factor that changes element sizes.
mesh.elSizeFactor = 0.10

coords, edof, dofs, bdofs, elementmarkers = mesh.create()

# ----- Solve problem

nDofs = np.size(dofs)
ex, ey = cfc.coordxtr(edof, coords, dofs)

K = np.zeros([nDofs, nDofs])

for eltopo, elx, ely in zip(edof, ex, ey):
    Ke = cfc.planqe(elx, ely, ep, D)
    cfc.assem(eltopo, K, Ke)

bc = np.array([], 'i')
bcVal = np.array([], 'f')

bc, bcVal = cfu.applybc(bdofs, bc, bcVal, left_support, 0.0, 0)
bc, bcVal = cfu.applybc(bdofs, bc, bcVal, right_support, 0.0, 2)

f = np.zeros([nDofs, 1])

cfu.applyforcetotal(bdofs, f, top_line, -10e5, 2)

a, r = cfc.solveq(K, f, bc, bcVal)

ed = cfc.extractEldisp(edof, a)
Example #4
0
coords, edof, dofs, bdofs, elementmarkers = meshGen.create()

# ---- Solve problem --------------------------------------------------------

nDofs = np.size(dofs)
K = lil_matrix((nDofs,nDofs))
ex, ey = cfc.coordxtr(edof, coords, dofs)

print("Assembling K... ("+str(nDofs)+")")

for eltopo, elx, ely, elMarker in zip(edof, ex, ey, elementmarkers):

    if elType == 2:
        Ke = cfc.plante(elx, ely, elprop[elMarker][0], elprop[elMarker][1])
    else:
        Ke = cfc.planqe(elx, ely, elprop[elMarker][0], elprop[elMarker][1])
        
    cfc.assem(eltopo, K, Ke)
    
print("Applying bc and loads...")

bc = np.array([],'i')
bcVal = np.array([],'i')

bc, bcVal = cfu.applybc(bdofs, bc, bcVal, markFixed, 0.0)

f = np.zeros([nDofs,1])

cfu.applyforcetotal(bdofs, f, markLoad, value = -10e5, dimension=2)

print("Solving system...")
Example #5
0
coords, edof, dofs, bdofs, elementmarkers = mesh.create()

# ---- Solve problem --------------------------------------------------------

nDofs = np.size(dofs)
K = lil_matrix((nDofs,nDofs))
ex, ey = cfc.coordxtr(edof, coords, dofs)

cfu.info("Assembling K... ("+str(nDofs)+")")

for eltopo, elx, ely, elMarker in zip(edof, ex, ey, elementmarkers):

    if el_type == 2:
        Ke = cfc.plante(elx, ely, elprop[elMarker][0], elprop[elMarker][1])
    else:
        Ke = cfc.planqe(elx, ely, elprop[elMarker][0], elprop[elMarker][1])
        
    cfc.assem(eltopo, K, Ke)
    
cfu.info("Applying bc and loads...")

bc = np.array([],'i')
bcVal = np.array([],'i')

bc, bcVal = cfu.applybc(bdofs, bc, bcVal, mark_fixed, 0.0)

f = np.zeros([nDofs,1])

cfu.applyforcetotal(bdofs, f, mark_load, value = -10e5, dimension=2)

cfu.info("Solving system...")
Example #6
0
    def execute(self):

        # --- Överför modell variabler till lokala referenser

        ep = self.inputData.ep
        E = self.inputData.E
        v = self.inputData.v
        Elementsize = self.inputData.Elementsize

        # --- Anropa InputData för en geomtetribeskrivning

        geometry = self.inputData.geometry()

        # --- Nätgenerering

        elType = 3  # <-- Fyrnodselement flw2i4e
        dofsPerNode = 2

        meshGen = cfm.GmshMeshGenerator(geometry)

        meshGen.elSizeFactor = Elementsize  # <-- Anger max area för element
        meshGen.elType = elType
        meshGen.dofsPerNode = dofsPerNode
        meshGen.returnBoundaryElements = True

        coords, edof, dof, bdofs, elementmarkers, boundaryElements = meshGen.create(
        )
        self.outputData.topo = meshGen.topo

        #Solver
        bc = np.array([], 'i')
        bcVal = np.array([], 'i')

        D = cfc.hooke(1, E, v)
        nDofs = np.size(dof)
        ex, ey = cfc.coordxtr(edof, coords, dof)  #Coordinates
        K = np.zeros([nDofs, nDofs])

        #Append Boundary Conds
        f = np.zeros([nDofs, 1])
        bc, bcVal = cfu.applybc(bdofs, bc, bcVal, 30, 0.0, 0)
        cfu.applyforce(bdofs, f, 20, 100e3, 1)

        qs_array = []
        qt_array = []

        for x, y, z in zip(ex, ey, edof):

            Ke = cfc.planqe(x, y, ep, D)

            cfc.assem(z, K, Ke)

        asolve, r = cfc.solveq(K, f, bc, bcVal)

        ed = cfc.extractEldisp(edof, asolve)
        for x, y, z in zip(ex, ey, ed):
            qs, qt = cfc.planqs(x, y, ep, D, z)

            qs_array.append(qs)
            qt_array.append(qt)

        vonMises = []
        stresses1 = []
        stresses2 = []
        # For each element:

        for i in range(edof.shape[0]):

            # Determine element stresses and strains in the element.

            es, et = cfc.planqs(ex[i, :], ey[i, :], ep, D, ed[i, :])

            # Calc and append effective stress to list.

            vonMises.append(
                np.sqrt(
                    pow(es[0], 2) - es[0] * es[1] + pow(es[1], 2) + 3 * es[2]))

            ## es: [sigx sigy tauxy]
            # sigmaij = np.array([[es(i,1),es(i,3),0],[es(i,3),es(i,2),0],[0,0,0]])
            sigmaij = np.array([[es[0], es[2], 0], [es[2], es[1], 0],
                                [0, 0, 0]])
            [v, w] = np.linalg.eig(sigmaij)
            stresses1.append(v[0] * w[0])
            stresses2.append(v[1] * w[1])

        # --- Överför modell variabler till lokala referenser

        self.outputData.vonMises = vonMises
        self.outputData.edof = edof
        self.outputData.coords = coords
        self.outputData.stresses1 = stresses1
        self.outputData.stresses2 = stresses2
        self.outputData.geometry = geometry
        self.outputData.asolve = asolve
        self.outputData.r = r
        self.outputData.ed = ed
        self.outputData.qs = qs_array
        self.outputData.qt = qt_array
        self.outputData.dofsPerNode = dofsPerNode
        self.outputData.elType = elType
        self.outputData.calcDone = True