bagla0
1
I have a mesh with 2 subdomains - dx(0) and dx(1)
. I wanted the know the subdomain data for each node.
I have got the nodal values of function w (determined by solve(a==L,w,bc)
) using w.compute_vertex_values(mesh)
.
#Do we have similar command to compute subdomain data for each node, like list of dx(0)
or dx(1)
for each node.
I tried using a0= np.ndarray[np.float64[0.09333333, 0. ]]
SubDomain.inside(a0, True)
TypeError Traceback (most recent call last)
/tmp/ipykernel_295/1734471881.py in <module>
----> 1 a0= np.ndarray[np.float64[0.09333333, 0. ]]
2
3 SubDomain.inside(a0, True)
TypeError: 'type' object is not subscriptable
but getting the following error.
The work is related to
https://comet-fenics.readthedocs.io/en/latest/demo/periodic_homog_elas/periodic_homog_elas.html
Any help is greatly appreciated!!!
dokken
2
To me it is not clear what you are trying to do in
as you have not presented a code that can repodue this.
Do you mean that you want the coordinates of all vertices within the cells marked with 0 or 1?
bagla0
3
Hi@dokken
Thanks for your reply. I exactly want the coordinates of all vertices marked as 0 or 1 ( based on corresponding subdomain 0 or 1 respectively).
I will share other part of code too.
dokken
4
Consider the following MWE:
from IPython import embed
import dolfin
mesh = dolfin.UnitSquareMesh(10, 10)
class Left(dolfin.SubDomain):
def inside(self, x, on_boundary):
return x[0] < 0.5
cell_marker = dolfin.MeshFunction("size_t", mesh, mesh.topology().dim(), 0)
Left().mark(cell_marker, 1)
left_cells = cell_marker.where_equal(1)
cell_to_vertex = mesh.topology()(mesh.topology().dim(), 0)
x = mesh.coordinates()
for cell in left_cells:
vertices = cell_to_vertex(cell)
print(x[vertices])
1 Like