DIRICHLET = 101 # # Lambda = 1.25E10 # Lame coefficient # Mu = 1.875E10 # Lame coefficient # ##################################### # Mesh definition: m = gf.Mesh('regular_simplices', -0.5 + np.arange(nx + 1) / float(nx), -0.5 + np.arange(nx + 1) / float(nx)) #m = gf.Mesh('import','gmsh','quad.msh') # Boundary set: m.set_region(DIRICHLET, m.outer_faces()) # Global functions for asymptotic enrichment: ck0 = gf.GlobalFunction('crack', 0) ck1 = gf.GlobalFunction('crack', 1) ck2 = gf.GlobalFunction('crack', 2) ck3 = gf.GlobalFunction('crack', 3) if variant == 1: # Cutoff enrichement coff = gf.GlobalFunction('cutoff', 2, 0.4, 0.01, 0.4) ckoff0 = ck0 * coff # gf.GlobalFunction('product',ck0,coff) ckoff1 = ck1 * coff ckoff2 = ck2 * coff ckoff3 = ck3 * coff # Levelset definition: ls = gf.LevelSet(m, 1, 'y', 'x') mls = gf.MeshLevelSet(m) mls.add(ls)
else: mf_pre.set_fem(gf.Fem("FEM_PK(2,2)")) # Definition of the enriched finite element method (MeshFemLevelSet): mfls = gf.MeshFem("levelset", mls, mf_pre) # Global functions for asymptotic enrichment: mf_part_unity = gf.MeshFem(m) mf_part_unity.set_classical_fem(1) DOFpts = mf_part_unity.basic_dof_nodes() ctip_dofs = [ np.nonzero(np.linalg.norm(DOFpts - x, axis=0) < 0.5)[0] for x in [[[xtip], [-ytip]], [[-xtip], [ytip]], [[xtip], [ytip]], [[-xtip], [-ytip]]] ] ck = [gf.GlobalFunction("crack", i) for i in range(4)] mf_sing = [ gf.MeshFem("product", mf_part_unity, gf.MeshFem("global function", m, ls, ck, 1)) for ls in [ls1, ls2] ] mf_sing[0].set_enriched_dofs(np.union1d(ctip_dofs[0], ctip_dofs[1])) mf_sing[1].set_enriched_dofs(np.union1d(ctip_dofs[2], ctip_dofs[3])) mf_u = gf.MeshFem("sum", mf_sing[0], mf_sing[1], mfls) mf_u.set_qdim(2) mf_theta = gf.MeshFem("sum", mf_sing[0], mf_sing[1], mfls) # MeshIm definition (MeshImLevelSet): if (quad): mim = gf.MeshIm(
$Id$ """ import numpy as np import getfem as gf import os # mesh fem to export m = gf.Mesh('triangles grid', [-1, -0.5, 0, 0.5, 1], [-1, -0.5, 0, 0.5, 1]) # m = gf.Mesh('import','gmsh','quad.msh') mf = gf.MeshFem(m) mf.set_fem(gf.Fem('FEM_PK(2,1)')) PTs = mf.basic_dof_nodes() # crack: ck0 = gf.GlobalFunction('crack', 0) ck1 = gf.GlobalFunction('crack', 1) ck2 = gf.GlobalFunction('crack', 2) ck3 = gf.GlobalFunction('crack', 3) ck4 = gf.GlobalFunction('crack', 4) ck5 = gf.GlobalFunction('crack', 5) ck6 = gf.GlobalFunction('crack', 6) ck7 = gf.GlobalFunction('crack', 7) ck8 = gf.GlobalFunction('crack', 8) ck9 = gf.GlobalFunction('crack', 9) ck10 = gf.GlobalFunction('crack', 10) ck11 = gf.GlobalFunction('crack', 11) mf.export_to_pos('check_global_functions0.pos', ck0(PTs), 'ck0') mf.export_to_pos('check_global_functions1.pos', ck1(PTs), 'ck1') mf.export_to_pos('check_global_functions2.pos', ck2(PTs), 'ck2') mf.export_to_pos('check_global_functions3.pos', ck3(PTs), 'ck3')