Esempio n. 1
0
 def drawElementValues(self, figElementValues):
     """Draw element values in provided figure"""
     cfv.figure(figElementValues.nr)
     cfv.clf()
     cfv.drawElementValues(self.results.elForces, self.mesh.coords, self.mesh.edof, self.rect.dofsPerNode, self.rect.elementType, self.results.a, 
                           doDrawMesh=True, doDrawUndisplacedMesh=False, 
                           title="Effective Stress", magnfac=1)
Esempio n. 2
0
 def drawDisplacements(self, figDisplacements):
     """Draw displacements in provided figure"""
     cfv.figure(figDisplacements.nr)
     cfv.clf()
     cfv.drawDisplacements(self.results.a, self.mesh.coords, self.mesh.edof, self.rect.dofsPerNode, self.rect.elementType, 
                           doDrawUndisplacedMesh=False, title="Displacements", 
                           magnfac=1)
Esempio n. 3
0
 def drawMesh(self, figMesh):
     """Draw mesh in provided figure"""
     cfv.figure(figMesh.nr)
     cfv.clf()
     cfv.draw_mesh(self.mesh.coords,
                   self.mesh.edof,
                   self.rect.dofsPerNode,
                   self.rect.elementType,
                   filled=True,
                   title="Mesh")  #Draws the mesh.
Esempio n. 4
0
 def drawElementValues(self, figElementValues):
     """Draws element values in specified figure"""
     cfv.figure(figElementValues.nr)
     cfv.clf()
     cfv.draw_element_values(self.vonMises,
                             self.coords,
                             self.edof,
                             self.mesh.dofs_per_node,
                             self.mesh.el_type,
                             self.a,
                             draw_elements=True,
                             draw_undisplaced_mesh=False,
                             title="Example 06 effective stress")
Esempio n. 5
0
 def drawElementValues(self, figElementValues):
     """Draws element values in specified figure"""
     cfv.figure(figElementValues.nr)
     cfv.clf()
     cfv.drawElementValues(self.vonMises,
                           self.coords,
                           self.edof,
                           self.mesh.dofsPerNode,
                           self.mesh.elType,
                           self.a,
                           doDrawMesh=True,
                           doDrawUndisplacedMesh=False,
                           title="Example 06 effective stress")
Esempio n. 6
0
    def drawMesh(self):
        cfv.figure(self.fig2.nr)
        cfv.clf()
        cfv.drawMesh(coords=self.coords,
                     edof=self.edof,
                     dofsPerNode=self.meshGen.dofsPerNode,
                     elType=self.meshGen.elType,
                     filled=True,
                     title="Example 01")

        cfv.addText("This is a Text", pos=(1, -0.3),
                    angle=45)  #Adds a text in world space

        ourLabel = cfv.label("This is a Label", pos=(100, 200),
                             angle=-45)  #Adds a label in the screen space
        ourLabel.text = "Label, changed."  #We can change the attributes of labels and texts, such as color, text, and position.
        ourLabel.textColor = 'r'  #Make it red. (1,0,0) would also have worked.
        ourLabel.position = (20, 30)
Esempio n. 7
0
 def showMesh(self):
     if self.calcDone == True:
         self.meshFig = cfv.figure(self.meshFig)
         cfv.drawMesh(self.outputData.coords,
                      self.outputData.edof,
                      self.outputData.dofsPerNode,
                      self.outputData.elType,
                      filled=True,
                      title="Mesh")  #Draws the mesh.
Esempio n. 8
0
    def showGeometry(self):

        if self.calcDone == True:
            """Visa geometri visualisering"""

            geometry = self.outputData.geometry

            self.geomFig = cfv.figure(self.geomFig)
            cfv.clf()
            cfv.drawGeometry(geometry, title="Geometry")
Esempio n. 9
0
 def showNodalValues(self):
     if self.calcDone == True:
         self.nodeValueFig = cfv.figure(self.nodeValueFig)
         cfv.drawDisplacements(self.outputData.asolve,
                               self.outputData.coords,
                               self.outputData.edof,
                               self.outputData.dofsPerNode,
                               self.outputData.elType,
                               doDrawUndisplacedMesh=False,
                               title="Displacements",
                               magnfac=25.0)
Esempio n. 10
0
    def drawDisplacements(self, figDisplacements):
        """Draws displacements in specified figure"""
        cfv.figure(figDisplacements.nr)
        cfv.clf()
        cfv.drawDisplacements(self.a,
                              self.coords,
                              self.edof,
                              self.mesh.dofsPerNode,
                              self.mesh.elType,
                              doDrawUndisplacedMesh=True,
                              title="Example 06")

        # Make use of attribute 'nodesOnCurve' in GmshMesher to draw some arrows on
        # the right hand side of the mesh:

        rightSideNodes = set()

        # 4 and 5 are the IDs of the curves where we applied the forces.

        for curveID in [4, 5]:

            # Get the nodes, without duplicates.

            rightSideNodes = rightSideNodes.union(
                set(self.mesh.nodesOnCurve[curveID]))

        for i in rightSideNodes:

            # Position of the node with displacements.

            x = self.coords[i, 0] + self.a[i * 2, 0]
            y = self.coords[i, 1] + self.a[i * 2 + 1, 0]

            # A poor man's force indicator. Could also use vv.plot()

            cfv.addText("\rightarrow", (x, y), fontSize=20, color='g')
Esempio n. 11
0
    def on_updateButton_clicked(self):
        """Update preview geo, mesh, stress"""

        self.updateModel()
        warnings = self.inputData.warnings

        #Om det saknas varningar/felmeddelanden:
        if not warnings:
            self.clearfig()

            self.g = fm.InputData.geometry(self.inputData)
            fm.Solver.executeMesh(self)

            #Hämta värden som används vid plot
            q = self.inputData.q
            B = self.inputData.B
            b = self.inputData.b
            hvec = self.inputData.hvec
            coords = self.outputData.coords
            edof = self.outputData.edof
            dofsPerNode = self.outputData.dofsPerNode
            elType = self.outputData.elType
            ndof = edof.max()

            # Bestäm initialspänningarna
            a0 = tg.strdist(coords, ndof, q, B, b, hvec)

            # Figur geometri
            cfv.figure(self.figGeometry.nr)
            cfv.drawGeometry(self.g, title="Geometry")

            # Figur mesh
            cfv.figure(self.figMesh.nr)
            cfv.drawMesh(coords,
                         edof,
                         dofsPerNode,
                         elType,
                         filled=True,
                         title="Mesh")

            # Figur initialspänningar
            cfv.figure(self.figInitial.nr)
            cfv.drawNodalValues(a0,
                                coords,
                                edof,
                                dofsPerNode,
                                elType,
                                clim=(0, self.inputData.q),
                                doDrawMesh=False,
                                title="Initial stress distr.")

            self.tabWidget.setEnabled(True)

        #Om det finns felmeddelanden: visa ej preview utan aktivera felmeddelanden
        else:
            self.wmsg()
Esempio n. 12
0
    def showElementValues(self):
        if self.calcDone == True:
            self.elValueFig = cfv.figure(self.elValueFig)
            cfv.drawElementValues(self.outputData.vonMises,
                                  self.outputData.coords,
                                  self.outputData.edof,
                                  self.outputData.dofsPerNode,
                                  self.outputData.elType,
                                  self.outputData.asolve,
                                  doDrawMesh=True,
                                  doDrawUndisplacedMesh=False,
                                  title="Effective Stress",
                                  magnfac=25.0)

            cfv.colorBar().SetLabel("Effective stress")

            cfu.info("Done drawing...")
Esempio n. 13
0
 def drawGeometry(self, figGeometry):
     """Draws geometry in specified figure"""
     cfv.figure(figGeometry.nr)
     cfv.clf()
     cfv.drawGeometry(self.g, drawPoints=False, labelCurves=True)
Esempio n. 14
0
ed = cfc.extractEldisp(edof, a)
vonMises = []

for i in range(edof.shape[0]):
    es, et = cfc.planqs(ex[i, :], ey[i, :], ep, D, ed[i, :])
    vonMises.append(
        sqrt(pow(es[0], 2) - es[0] * es[1] + pow(es[1], 2) + 3 * es[2]))

# ----- Draw geometry

cfv.drawGeometry(g)

# ----- Draw the mesh.

cfv.figure()
cfv.drawMesh(coords=coords,
             edof=edof,
             dofsPerNode=mesh.dofsPerNode,
             elType=mesh.elType,
             filled=True,
             title="Example 01")

# ----- Draw results

cfv.figure()
cfv.drawElementValues(vonMises,
                      coords,
                      edof,
                      mesh.dofsPerNode,
                      mesh.elType,
Esempio n. 15
0
    def show(self):

        coords = self.outputData.coords
        edof = self.outputData.edof
        dofsPerNode = self.outputData.dofsPerNode
        elType = self.outputData.elType
        avec = self.outputData.avec   
        plotnr = self.inputData.Tv
        
        
        #Plot excess pore water pressure 2D
        cfv.figure(self.figPress.nr) 
        cfv.clf()
        cfv.drawNodalValues(avec[:,plotnr], coords, edof, dofsPerNode, elType, clim=(0,self.inputData.q), doDrawMesh = False, title = "Excess porewater pressure")



        xudict = self.outputData.xudict
        yudict = self.outputData.yudict  
        comboindex = self.inputData.comboindex
  
        PP = np.shape(avec)[1]
        
        
        #If vertical 1 D plot
        if comboindex == 0:
            Xv = self.inputData.Xv
            
            coordvec = xudict[Xv][0]
            uvec = xudict[Xv][1]
            
            cfv.figure(self.figuvec.nr) 
            cfv.clf()
            for i in range(PP):
                vv.plot(uvec[:, i], coordvec, ls = ":", lc = "c") 
            vv.plot(uvec[:,plotnr], coordvec, ls = "-", lc = "b")
            vv.title("u_e - Excess porewater pressure 1D")
            
            
            
            cfv.figure(self.figsigvec.nr) 
            cfv.clf()
            for i in range(PP):
                vv.plot(uvec[:,0]-uvec[:, i], coordvec, ls = ":", lc = "c") 
            vv.plot(uvec[:,0]-uvec[:,plotnr], coordvec, ls = "-", lc = "b")
            vv.title("\Delta\sigma' - Effective stress 1D")
            
            
        else:
            Yv = self.inputData.Yv  
            coordvec = yudict[Yv][0]
            uvec = yudict[Yv][1]
            
            cfv.figure(self.figuvec.nr) 
            cfv.clf()
            for i in range(PP):
               vv.plot(coordvec, uvec[:, i], ls=":", lc = "c") 
            vv.plot(coordvec, uvec[:, plotnr], ls="-", lc = "b")
            vv.title("u_e - Excess porewater pressure 1D")
            
            cfv.figure(self.figsigvec.nr) 
            cfv.clf()
            for i in range(PP):
                vv.plot(coordvec, uvec[:, 0]-uvec[:, i], ls = ":", lc = "c") 
            vv.plot(coordvec, uvec[:, 0]-uvec[:, plotnr], ls = "-", lc = "b")
            vv.title("\Delta\sigma' - Effective stress 1D")
Esempio n. 16
0
 def drawGeometry(self, figGeometry):
     """Draw geometry in provided figure"""
     cfv.figure(figGeometry.nr) 
     cfv.clf()
     cfv.drawGeometry(self.rect.geometry(), title="Geometry")
Esempio n. 17
0
 def drawGeometry(self):
     cfv.figure(self.fig1.nr)
     cfv.clf()
     cfv.drawGeometry(self.g)
Esempio n. 18
0
    def show(self):
        # ------ Shows the geometry
        geometry = self.outputData.geometry
        a = self.outputData.a
        vonMises = self.outputData.stress
        coords = self.outputData.coords
        edof = self.outputData.edof
        dofsPerNode = self.outputData.mp[1]
        elType = self.outputData.mp[0]
        meshGen = self.outputData.meshGen
        stats = self.outputData.statistics
        fp = self.inputData.fp
        bp = self.inputData.bp
        w = stats[4][0]
        h = stats[4][1]
        units = self.inputData.units

        # Create the figure
        print("Visualizing...")
        cfv.close_all()
        if (self.geomFig):
            cfv.figure()
            cfv.drawGeometry(geometry,
                             title="Geometry",
                             drawPoints=False,
                             labelCurves=True)

        if (self.elValueFig):
            cfv.figure()
            cfv.drawElementValues(vonMises,
                                  coords,
                                  edof,
                                  dofsPerNode,
                                  elType,
                                  a,
                                  doDrawMesh=self.meshFig,
                                  doDrawUndisplacedMesh=False,
                                  title="Effective (Von Mises) Stress (Pa)")

            # ------ Add extra text
            node_x = [
                coords[int((edof[stats[0][0]][0] - 1) / 2), 0] +
                a[edof[stats[0][0]][0] - 1, 0], coords[int(
                    (edof[stats[0][0]][2] - 1) / 2), 0] +
                a[edof[stats[0][0]][2] - 1, 0], coords[int(
                    (edof[stats[0][0]][4] - 1) / 2), 0] +
                a[edof[stats[0][0]][4] - 1, 0]
            ]
            node_y = [
                coords[int((edof[stats[0][0]][0] - 1) / 2), 1] +
                a[edof[stats[0][0]][1] - 1, 0], coords[int(
                    (edof[stats[0][0]][2] - 1) / 2), 1] +
                a[edof[stats[0][0]][3] - 1, 0], coords[int(
                    (edof[stats[0][0]][4] - 1) / 2), 1] +
                a[edof[stats[0][0]][5] - 1, 0]
            ]
            node_centroid = [sum(node_x) / 3, sum(node_y) / 3]
            cfv.addText("Max Stress: {0:.2f} MPa".format(stats[0][1] / 1e6),
                        (stats[3][0] + 0.725 * w, stats[3][1] + 0.925 * h),
                        fontSize=15,
                        color='w')
            cfv.vv.plot([stats[3][0] + 0.715 * w, node_centroid[0]],
                        [stats[3][1] + 0.925 * h, node_centroid[1]],
                        lc='w')

        if (self.nodeValueFig):
            cfv.figure()
            cfv.drawDisplacements(a,
                                  coords,
                                  edof,
                                  dofsPerNode,
                                  elType,
                                  doDrawUndisplacedMesh=True,
                                  title="Displacements (m)")

            # Add markers
            symbols = {
                "rightarrow": "\u2192",
                "leftarrow": "\u2190",
                "uparrow": "\u2191",
                "downarrow": "\u2193",
                "nearrow": "\u2197",
                "nwarrow": "\u2196",
                "swarrow": "\u2199",
                "searrow": "\u2198",
                "fixed": "\u2215"
            }

            forceNodes = set()
            bcNodes = set()
            for j in range(len(fp[0])):
                for curveID in stats[2][fp[0][j]]:
                    forceNodes = forceNodes.union(
                        set(meshGen.nodesOnCurve[curveID]))
                for i in forceNodes:
                    x = coords[i,
                               0] + a[i * 2,
                                      0]  # Position of node with displacements
                    y = coords[i, 1] + a[i * 2 + 1, 0]
                    cfv.addText(symbols["rightarrow"], (x, y),
                                angle=fp[2][j],
                                fontSize=20,
                                color='g')
                for curveID in stats[2][bp[0][j]]:
                    bcNodes = bcNodes.union(set(meshGen.nodesOnCurve[curveID]))
                for i in bcNodes:
                    x = coords[i,
                               0] + a[i * 2,
                                      0]  # Position of node with displacements
                    y = coords[i, 1] + a[i * 2 + 1, 0]
                    cfv.addText(symbols["fixed"], (x, y),
                                fontSize=15,
                                color='r')

            # --- Add additional text
            cfv.addText("Forces Applied: {0:6.2f} kN/m".format(
                self.inputData.fp[1][0] * U2SI[units][1] / 1e3),
                        (stats[3][0] + 0.725 * w, stats[3][1] + 0.925 * h),
                        fontSize=15,
                        color='g')
            cfv.addText("Boundary Condition: {0:6.2f}m displacement".format(
                self.inputData.bp[1][0] * U2SI[units][0]),
                        (stats[3][0] + 0.625 * w, stats[3][1] + 0.95 * h),
                        fontSize=15,
                        color='r')
            node_x = coords[int((edof[stats[1][0][0]][stats[1][0][1]] - 1) / 2), 0] +\
                     + a[edof[stats[1][0][0]][stats[1][0][1]] - 1, 0]
            node_y = coords[int((edof[stats[1][0][0]][stats[1][0][1]] - 1) / 2), 1] +\
                     + a[edof[stats[1][0][0]][stats[1][0][1]+1] - 1, 0]
            cfv.addText("Max Displacement: {0:6.2f} mm".format(stats[1][1] *
                                                               1e3),
                        (stats[3][0] + 0.725 * w, stats[3][1] + 0.9 * h),
                        fontSize=15,
                        color='w')
            cfv.vv.plot([stats[3][0] + 0.715 * w, node_x],
                        [stats[3][1] + 0.9 * h, node_y],
                        lc='w')
Esempio n. 19
0
    def clearfig(self):

        cfv.figure(self.figPress.nr)
        cfv.clf()
        cfv.figure(self.figuvec.nr)
        cfv.clf()
        cfv.figure(self.figsigvec.nr)
        cfv.clf()

        cfv.figure(self.figGeometry.nr)
        cfv.clf()
        cfv.figure(self.figMesh.nr)
        cfv.clf()
        cfv.figure(self.figInitial.nr)
        cfv.clf()
Esempio n. 20
0
    else:
        
        # Handle quad elements
        
        es, et = cfc.planqs(ex[i,:], ey[i,:], 
                        elprop[elementmarkers[i]][0], 
                        elprop[elementmarkers[i]][1], 
                        ed[i,:])
        
        vonMises.append( np.math.sqrt( pow(es[0],2) - es[0]*es[1] + pow(es[1],2) + 3*pow(es[2],2) ) )
        
# ---- Visualise results ----------------------------------------------------

print("Drawing results...")

cfv.figure() 
cfv.drawGeometry(g, title="Geometry")

cfv.figure() 
cfv.drawMesh(coords=coords, edof=edof, dofsPerNode=dofsPerNode, elType=elType, 
             filled=True, title="Mesh") #Draws the mesh.

cfv.figure()
cfv.drawDisplacements(a, coords, edof, dofsPerNode, elType, 
                      doDrawUndisplacedMesh=False, title="Displacements", 
                      magnfac=25.0)

cfv.figure()
cfv.drawElementValues(vonMises, coords, edof, dofsPerNode, elType, a, 
                      doDrawMesh=True, doDrawUndisplacedMesh=False, 
                      title="Effective Stress", magnfac=25.0)