How to Visualize Mesh Function of SubDomains


343
views
0
10 months ago by
Hello

I've got a mesh function full of subdomains.

Is there a quick way I can visualize this inside of jupyter?
Community: FEniCS Project

1 Answer


1
9 months ago by
I think using gmsh would be the quickest way. But try meddling with something like this. (No warranty though, couldn't try it)
Obviously alter the subdomains line to fit your mesh.

from fenics import *
import numpy as np

subdomains = MeshFunction('size_t', mesh, "mesh_physical_region.xml')
subdIDs = np.asarray(subdomains.array(),dtype=np.int32)

IDvalues = np.zeros(max(subdIDs)+1)
IDvalues[np.unique(subdIDs)]=np.unique(subdIDs)

Element = FiniteElement("DP", mesh.ufl_cell(), 0)
Space = FunctionSpace(mesh, Element)
markerFun = Function(Space)
markerFun.vector()[:] = np.choose(subdIDs, IDvalues)

plot(markerFun)​
Please login to add an answer/comment or follow this question.

Similar posts:
Search »