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

how to mark edges from list of nodes...

0 votes

Hi every one,

I have a list of nodes from my mesh. I d like to mark the edges from a this list.
I m not sure if it is the best away, but if i have one segment and this segment has theirs two nodes from this list. It will be marked.

list=[1,5,6,7] =DATA

How to do it? Is it the best away to do it? Because there will lots of loops to do.

Thanks.

asked Feb 4, 2016 by LeoCosta FEniCS User (1,190 points)

1 Answer

+1 vote

Hi,

so i did not programm the full answer but most of it. What you want should be something like this:

    from dolfin import*
    import numpy as np

    p1 = Point(0.0,0.0)
    p2 = Point(40e-3,40e-3)

    mesh_density = 5

    mesh = RectangleMesh(p1,p2, mesh_density, mesh_density)

    edge = EdgeFunction("size_t", mesh)
    edge.set_all(0)

    for e in edges(mesh):
           owned_vertices = np.sort(e.entities(0))
           edge_number = e.index()
           if (here you need to add something now, if owned_vertices (both) are on your list):
                    edge[edge_number]=42

     plot(edge)    

Kind regards

Johann

answered Feb 4, 2016 by jh600 FEniCS Novice (900 points)

I forgot to mention, i assumed you want it in 2D, i did not test it for 3D.

Thanks. I am looking for it now.

I did one simple exemplo with 2D mesh to see (mesh_density =2). I d like to mark 2 edges. Then I have a list of this nodes.

List of nodes from mesh:

In this exemplo:

from dolfin import*
import numpy as np
Lc=1E-3
p1 = Point(0.0,0.0)
p2 = Point(Lc,Lc)

mesh=RectangleMesh(p1, p2, 2, 2, "left")
nodes=MeshFunction("size_t", mesh, 0)
boundaries = FacetFunctionSizet(mesh, 1)

#the list of nodes:
list=[3,4,7]

There are 2 segments that contain this nodes [3 and 4] the first one and the second one node 4 and node 7

How can i mark my "FacetFunctionSizet"?

I will try using what you did...

thanks!!!

I did:

   B = Function(V)
   a = np.zeros(np.shape(nodes))
   DATA=[3,4,7]
   for i in DATA:
      a[i]=1.

   dofmap = dof_to_vertex_map(V)
   amod = a[dofmap]
   B.vector()[:] = amod

   C=Function(V)
   C.vector()[:]=a
   plot(B)
   plot(C)

B is totally different than C bc dofmap...

The problem is I have the nodes but not the list of segments... and it is reagroup for dofmap

Thanks for help me .. but i think it the list is regroup for dof map...

...