change the sub-domains by "MeshFunction"

4 months ago by
I am trying to simulate a 3D simulation of heat transfer in a cube which has powder in bottom and air on the top. I know that we can define these sub domains by "Expression" or "MeshFunction" marker. Till now everything works perfect. The next step is to add another powder layer on top of the first one. It works with "Expression", but not for "MeshFuction".
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[2] >= powder_height)
	class Powder(SubDomain):
		def inside(self, x,on_boundary):
			return (x[2] <= powder_height)

	# mark the subdomains with numbers
	subdomain_air = Air()
	subdomain_powder= Powder()

	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)

Community: FEniCS Project

In the code you supplied you only have powder below and air on top. How are you trying to add the second powder layer? Do you have the code for that?

I'd define a third subdomain. You could have classes Powder_1, Air and Powder_2. Then you'd need to mark them as 0, 1 and 2 and extend your kappa_values and density_values vectors to include the kappa value and density value of the second powder layer, respectively.


written 4 months ago by Lee Curtin  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »