### coordinates of nodes where the solutions satisfy a condition

132

views

1

Dear all,

I have solved a Poisson equation. Now, I need to get the coordinates of all nodes of which the solution is larger than, say 0.5. I tried to google this topic but could not find any. My initial attempt is:

indices = np.where(self.u.vector() > 0.5)[0] # self.u = FunctionSpace(self.mesh, "CG", 1)

I guess that I should do something mesh.get_coordinates (indices) to retrieve the corresponding coords, but mesh does not have such a function.

Bests,

Phu

I have solved a Poisson equation. Now, I need to get the coordinates of all nodes of which the solution is larger than, say 0.5. I tried to google this topic but could not find any. My initial attempt is:

indices = np.where(self.u.vector() > 0.5)[0] # self.u = FunctionSpace(self.mesh, "CG", 1)

I guess that I should do something mesh.get_coordinates (indices) to retrieve the corresponding coords, but mesh does not have such a function.

Bests,

Phu

Community: FEniCS Project

### 1 Answer

4

Conisder this:

```
indices = np.where(self.u.vector() > 0.5)[0]
dof_x = FunctionSpace(self.mesh, "CG", 1).tabulate_dof_coordinates().reshape((-1, 2))
print dof_x[indices]
```

Thanks a lot Hernan. That works.

written
3 months ago by
Nguyen Vinh Phu

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