Question #109445 on DOLFIN changed: https://answers.launchpad.net/dolfin/+question/109445
cutejeff posted a new comment: from dolfin import * # Create mesh and function space mesh = Interval(5000,0,1) V = FunctionSpace(mesh, "CG", 8) f = Expression("9.0*pi*pi*sin(3.0*pi*x[0])*sin(3.0*pi*x[0])*cos(3.0*pi*x[0])*cos(3.0*pi*x[0])+9.0*pi*pi*sin(3.0*pi*x[0])") u = Function(V) # Define variational problem v = TestFunction(V) du = TrialFunction(V) L = u*u*u.dx(0)*u.dx(0)*v*dx+u.dx(0)*v.dx(0)*dx - v*f*dx a = derivative(L, u, du) # Sub domain for Dirichlet boundary condition 1 u0 = Constant(0.0) class LeftDirichletBoundary(SubDomain): def inside(self, x, on_boundary): tol=1E-14 return on_boundary and abs(x[0]) < tol bc_1 = DirichletBC(V, u0, LeftDirichletBoundary()) # Sub domain for Dirichlet boundary condition 2 u1 = Constant(0.0) class RightDirichletBoundary(SubDomain): def inside(self, x, on_boundary): tol=1E-14 return on_boundary and abs(x[0]-1) < tol bc_2 = DirichletBC(V, u1, RightDirichletBoundary()) bc=[bc_1,bc_2] # Solve PDE and plot solution problem = VariationalProblem(a, L, bc, nonlinear=True) problem.solve(u) # Save solution to file file = File("power2.pvd") file << u # Plot solution p=plot(u) p.write_png("1.png") -- You received this question notification because you are a member of DOLFIN Team, which is an answer contact for DOLFIN. _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : dolfin@lists.launchpad.net Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp