I use dolfin 1.2.0 (Python-Version) and Ubuntu 12.04. I'm confused with the plot(Expression,mesh). I want to plot a Expression to see if my function or values is right or not, but got always the wrong values graphic. I paste my short code here. If someone can help, I'll be very appreciated!!!
from dolfin import *
import numpy
#Create mesh
mesh = Mesh("model.xml")
subdomains = MeshFunction("size_t", mesh, "model_physical_region.xml")
#Define function space with Nedelec (edge) elements
V = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 2)
#Define test and trial functions
v = TestFunction(X_h)
u = TrialFunction(X_h)
# Define the current values in the coils
class Current_Coils_SubDomain(Expression):
def eval_cell(self, values, x, ufc_cell):
j = 1.0
i = 0
region_index = subdomains[ufc_cell.index]
x,y,z = [x[0], x[1], x[2]]
if region_index == 1 or region_index == 2:
r = pow(x**2 + y**2, 0.5)
values[0] = -y/r*j
values[1] = x/r*j
values[2] = 0.0
else:
values[0] = 0.0
values[1] = 0.0
values[2] = 0.0
def value_shape(self):
return(3,)
#Instantiate the current
J = Current_Coils_SubDomain()
# Test the current
#print J, J.str(), J.ufl_element(), J.value_shape()
plot(J, mesh, interactive=True)
And what I got is the picture like this one:
And I don't know how to correct it, my xml data was drawed and meshed with Gmsh(2.5.1) and converted with "dolfin-convert". The values I want to set are in the round coils and they should be around over the x-y achse.