change the sub-domains by "MeshFunction"
4 months ago by
So My question is how to change the sub-domains by "MeshFunction"??
I am struggling with it about a month, tried to read from other questions and fenics tutorial and book as well, but I could not find a solution.
I really appreciate any help or hint.
Here is my function to find sub-domains
def Material(mesh,powder_height): # define a meshfunction for numbering subdomains subdomains = MeshFunction("size_t",mesh,3) # define the subdomains class Air(SubDomain): def inside(self, x,on_boundary): return (x >= powder_height) class Powder(SubDomain): def inside(self, x,on_boundary): return (x <= powder_height) # mark the subdomains with numbers subdomain_air = Air() subdomain_powder= Powder() subdomains.set_all(1) subdomain_air.mark(subdomains,0) V0 = FunctionSpace(mesh, "DG", 0) kappa = Function(V0) density = Function(V0) help = numpy.asarray(subdomains.array(), dtype=numpy.int64) kappa.vector()[:] = numpy.choose(help, kappa_values) density.vector()[:] = numpy.choose(help, density_values) return(kappa,density)
Community: FEniCS Project
Please login to add an answer/comment or follow this question.