def create_model(self):
        meshfile = open(self.filename, 'r')
        self.mesh = gmsh.gmshInput_mesh(meshfile)
        meshfile.close()

        # nNodes = self.mesh.getNNodes()
        # nEleme = self.mesh.getNElements()
        # print("Read mesh with %d nodes and %d elements" % (nNodes, nEleme))

        self.FE_model = fem.FEModel(self.mesh, self.material)
Beispiel #2
0
    def compute_deformation(self):
        # --- create FE model
        FE_model = fem.FEModel(self.mesh)

        # --- compute deformation gradient and langrangian strain tensor fields
        FE_model.computeStrain(self.U)  # compute gradient and strain
        self.F = []  # list of deformation gradient by element
        self.E = []  # list of lagrangian strain by element
        for n in range(FE_model.nElements()):
            # flatten() transforms a 2D array into a 1D array, cf. numpy documentation
            self.F.append(FE_model.getDeformationGradient(n).flatten())
            # flatten() transforms a 2D array into a 1D array, cf. numpy documentation
            self.E.append(FE_model.getStrainGreenLagrange(n).flatten())
# stop()

#
#--- create material model instance
#
if matmodel == "StVenant":
    material = elasticity.StVenantKirchhoffElasticity(Eyoung, nu)
elif matmodel == "NeoHookean":
    material = elasticity.NeoHookeanElasticity(Eyoung, nu)
else:
    raise (KeyError, "matmodel must be one of 'StVenant', 'NeoHookean'")

#
#--- create FE model instance
#
model = fem.FEModel(mesh, material)

#################################
#       INITIALISE ARRAYS       #
#################################
# displacement array
# flattened vector of the 2-entry array U = [u1 v1 u2 v2 ... uN vN]
U_notflat = np.zeros((nNodes, dim))
U = np.zeros(nDofs)
U1 = np.zeros(len(bcDofs))
U2 = np.zeros(len(freeDofs))
Uref = np.zeros(nDofs)
# residual array
Fint_notflat = np.zeros((nNodes, dim))  # unknown: initialisation (R=Tint),
Fext_notflat = np.zeros((nNodes, dim))  # unknown: initialisation (R=Tint),
Fint = np.zeros(nDofs)  # unknown: initialisation (R=Tint),
Beispiel #4
0
 def create_model(self):
     self.FE_model = fem.FEModel(self.mesh, self.material)