nx, ny, nz = 20, 20, 20 # Initial composition field class StepFunction(UserExpression): def eval_cell(self, values, x, cell): c = Cell(mesh, cell.index) if c.midpoint()[1] > db + 0.02*np.cos(np.pi*x[0]/float(lmbdax))*np.cos(np.pi*x[2]/float(lmbdaz)): values[0] = 1.0 else: values[0] = 0.0 mesh = BoxMesh.create( comm, [Point(0.0, 0.0, 0.0), Point(float(lmbdax), 1.0, float(lmbdaz))], [nx, ny, nz], CellType.Type.tetrahedron) # Shift the mesh to line up with the initial step function condition scale = db * (1.0 - db) shift = Expression(("0.0", "x[1]*(H - x[1])/S*A*cos(pi/Lx*x[0])*cos(pi/Lz*x[2])", "0.0"), A=0.02, Lx=lmbdax, Lz=lmbdaz, H=1.0, S=scale, degree=4) V = VectorFunctionSpace(mesh, "CG", 1) displacement = interpolate(shift, V) ALE.move(mesh, displacement) # Entrainment functional measures de = 1 cf = MeshFunction("size_t", mesh, mesh.topology().dim(), 0) CompiledSubDomain("x[1] > db - DOLFIN_EPS", db=db).mark(cf, de)
def box(): return BoxMesh.create( MPI.comm_world, [Point(0, 0, 0)._cpp_object, Point(2, 2, 2)._cpp_object], [2, 2, 5], CellType.Type.tetrahedron, cpp.mesh.GhostMode.none)
basis = VectorSpaceBasis(nullspace_basis) basis.orthonormalize() _x = [basis[i] for i in range(6)] nsp = PETSc.NullSpace() nsp.create(_x) return nsp # Load mesh from file # mesh = Mesh(MPI.comm_world) # XDMFFile(MPI.comm_world, "../pulley.xdmf").read(mesh) # mesh = UnitCubeMesh(2, 2, 2) mesh = BoxMesh.create( MPI.comm_world, [Point(0, 0, 0)._cpp_object, Point(2, 1, 1)._cpp_object], [12, 12, 12], CellType.Type.tetrahedron, dolfin.cpp.mesh.GhostMode.none) cmap = dolfin.fem.create_coordinate_map(mesh.ufl_domain()) mesh.geometry.coord_mapping = cmap # Function to mark inner surface of pulley # def inner_surface(x, on_boundary): # r = 3.75 - x[2]*0.17 # return (x[0]*x[0] + x[1]*x[1]) < r*r and on_boundary def boundary(x, on_boundary): return np.logical_or(x[:, 0] < np.finfo(float).eps, x[:, 0] > 1.0 - np.finfo(float).eps)