Sorry for my previous inaccurate posts,
Basically I have a 3D box and I want to apply boundary conditions on the specific points that I mention inside the bc1, bc2, bc3, bc4,…bc9
The points are:
(x, y, z)
2, 0, 2
1.5, 0, 2
0.5, 0, 2
0, 0, 2
-0.5, 0, 2
-1, 0, 2
-1.5, 0, 2
-2, 0, 2
import matplotlib.pyplot as plt
from dolfin import *
import numpy as np
mesh = Mesh(“dolfinmesh.xml”)
mesh_file_volume = MeshFunction(‘size_t’, mesh ,“dolfinmesh_volume_meshvalue.xml”)
mesh_file_boundary = MeshFunction(‘size_t’ , mesh , “dolfinmesh_bcfunc.xml”)
V = FunctionSpace(mesh, “Lagrange”, 1)
‘’’’
bc1 = DirichletBC(V, Constant(2.46),“near(x[0] , 2.0) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc2 = DirichletBC(V, Constant(2.43),“near(x[0] , 1.5) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc3 = DirichletBC(V, Constant(2.3),“near(x[0], 1.0) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc4 = DirichletBC(V, Constant(2.6),“near(x[0], 0.5) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc5 = DirichletBC(V, Constant(4.3),“near(x[0], 0.0) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc6 = DirichletBC(V, Constant(2.44),“near(x[0], -0.5) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc7 = DirichletBC(V, Constant(2.43),“near(x[0], -1.0) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc8 = DirichletBC(V, Constant(2.55),“near(x[0], -1.5) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bc9 = DirichletBC(V, Constant(2.69),“near(x[0], -2.0) && x[1] == 0.0 && x[2] == 2.0”,“pointwise”)
bcs = [bc1, bc2, bc3, bc4, bc5, bc6, bc7, bc8, bc9]
‘’’’’
Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
a = inner(Cgrad(u), grad(v))dx
f = Constant(0.0)
L = fvdx
A, b = assemble_system(a, L, bcs)
u_k = Function(V)
solve(A, u_k.vector(), b, ‘lu’)
File(‘saved_u.xml’) << u_k
file = File(“final2.pvd”)
file << u_k
All the above seem not to work.