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

Create a subdomain from vertices list with fenics

+1 vote

I have sucessfully created a dolfin mesh within python.[1] But I cannot find any information how to create a subdomain from indices of vertices. Is this allready possible from python?

[1]https://github.com/looooo/FreeCAD/blob/genericSolver1/src/Mod/Fem/genericSolver/FenicsSolver.py#L14L27

asked Feb 11, 2017 by looooo FEniCS Novice (130 points)

1 Answer

0 votes

Hi!

Would something like this do what you are looking for?


subdomain= CellFunction("size_t", mesh, 0)
for c in cells(mesh):
    for v in vertices(c):
        x = v.point().x()
        y = v.point().y()
        z = v.point().z()

    ## check if all vertex locations of a cell are included in your list

    if vertices_in_list:
        subdomain[c] = 1

answered Feb 14, 2017 by meron FEniCS User (2,340 points)

thanks for the answer.
the suggested solution is quite a heavy task, isn't it? For my usecase the mesh is already set up in another format but available from python. Looking for vertices in a list and checkig if the position matches, is like doing the hard task, which has done by the mesher, again.

Maybe going via a xml-file is the better idea.

...