### how can I change the function space of sigma from normal space to finite element space?

122

views

0

Hi,

I use the following codes to print the sigma which is corresponded to the coordinates. In the following,m_coords and m_value are all floats loaded from m_file. In the mode,The sigma is related to m_coords and m_value.and I don't kown how to project them to the finite element space.

I use the following codes to print the sigma which is corresponded to the coordinates. In the following,m_coords and m_value are all floats loaded from m_file. In the mode,The sigma is related to m_coords and m_value.and I don't kown how to project them to the finite element space.

```
m_value=np.zeros((linenumber,3))
m_coords=np.zeros((linenumber,3))
for i in range(1,linenumber):
data=m_file.readline()
m_value[i-1,:]=np.array(m(i),dtype=np.float32)
m_coords[i-1,:]=np.array(coords(i),dtype=np.float32)
class MySigma(Expression):
def set_sigma(self,x):
self.x = mesh.coordinates()
def eval(self,value,x):
tol =1E-2
for i in range(0,linenumber):
if (sqrt(np.inner(x-m_coords[i,0:3],x-m_coords[i,0:3]))<=tol):
value=m_value[i,0]
else:
value=1
sigma=MySigma(degree=1)
sigma.set_sigma(x)
sigma_int=interpolate(sigma,V)
```

and it returns:

Couldn't map 'v_1' to a float, returning ufl object without evaluation.

how can I change the function space of sigma from normal space to finite element space?

Community: FEniCS Project

Please login to add an answer/comment or follow this question.