I'd very much appreciate if you could help me out with this as I think I'm missing something simple out or should be using alternate syntax:
I am running the following Python code in FEniCS, where I solve for a variable - the solution looking as I expect it to, so no problems there, now I wish to solve a next equation and I need to define the subdomains according to the obtained solution, but the resultant plot of subdomains for the new problem (in the same code) is erroneous. It looks as if it cannot take the solution variable as a legitimate parameter appearing in the subdomain definitions; perhaps I need to change/avoid the inside method?
solve(a == L, phi1)
plot(phi1, title="phi1_t01")
# S at t1
# define mesh
htopv = 0.5
mesh = Rectangle(0, 0, 1, htopv, 250, 250)
# define a meshfunction for numbering subdomains
subdomains = MeshFunction("uint", mesh, 2)
# define the subdomains
class Biomass(SubDomain):
def inside(self, x):
return True if phi1 <= 0 else False
class Interface(SubDomain):
def inside(self, x):
return True if phi1 >= 0 and phi1 <= 0.1 else False
class Bulk(SubDomain):
def inside(self, x):
return True if phi1 >= 0.1 else False
# note: it is essential to use <= and >= in the comparisons
# mark the subdomains with numbers
subdomain0 = Biomass()
subdomain0.mark(subdomains, 0)
subdomain1 = Interface()
subdomain1.mark(subdomains, 1)
subdomain2 = Bulk()
subdomain2.mark(subdomains, 2)
# plot the subdomains
plot(subdomains, title="S_t1 subdomains")