This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Extract coordinates of vertices over a subdomain

0 votes

Hi,

I defined a subdomain over a mesh in 3D :

TOL = DOLFIN_EPS

class MidPoint(SubDomain):
    def inside(self, x, on_boundary):
    return near(x[0], b/2., TOL) and near(x[1], h, TOL) and near(x[2], L/2., TOL)

midpoint = MidPoint()

I then transformed my mesh using the mesh.move function and I need to access to the new coordinates of midpoint. Is there a way to access coordinates of a subdomains, I tried to iterate over vertices :

for v in vertices(midpoint):
     x = v.point().x()
     y = v.point().y()
     z = v.point().z()
    print(x, y, z)

But it does not work...
Many thanks in advance !!

asked Mar 17, 2016 by Claire L FEniCS User (2,120 points)
edited Mar 17, 2016 by Claire L

1 Answer

+1 vote
 
Best answer

Hi,
maybe try:

for v in vertices(mesh):
    if midpoint.inside(v.point(), True):    
        x = v.point().x()
        y = v.point().y()
        z = v.point().z()
        print (x, y, z)
answered Mar 18, 2016 by hernan_mella FEniCS Expert (19,460 points)
selected Mar 18, 2016 by Claire L
...