Different meshes for different functions in functionspace

Howdy,

So I’m extremely interested in editing the code I got here a little bit

from dolfin import *


class Left(SubDomain):
def inside(self, x, on_boundary):
    return near(x[0], -1.0)

class Right(SubDomain):
def inside(self, x, on_boundary):
    return near(x[0], 1.0)

class Bottom(SubDomain):
def inside(self, x, on_boundary):
    return near(x[1], -1.0)

class Top(SubDomain):
def inside(self, x, on_boundary):
    return near(x[1], 1.0)

class Obstacle(SubDomain):
def inside(self, x, on_boundary):
    return (between(x[1], (-(5.0/8.0), (5.0/8.0))) and between(x[0], (-(5.0/8.0), (5.0/8.0))))




def test():


	left = Left()
	top = Top()
	right = Right()
	bottom = Bottom()
	obstacle = Obstacle()
	p1 = Point(-1.0,-1.0)
	p2 = Point(1.0,1.0)
	size=128
	mesh = RectangleMesh(p1,p2,size,size)
	domains = MeshFunction("size_t", mesh,mesh.topology().dim())
	domains.set_all(0)
	obstacle.mark(domains, 1)
	CG = FiniteElement("CG", mesh.ufl_cell(), 1)
	DG  = FiniteElement("DG", mesh.ufl_cell(), 0)
	W = FunctionSpace(mesh, CG * DG)
	u = Function(W)


test()

I was interested if it was possible the CG function space have the traditional triangle elements everywhere (which is default now) and for the DG I have triangle elements outside obstacle domain, while inside the subdomain I have a quadrilateral mesh of size nxn (i.e 20x20 squares in the subdomain)

Thank you so much!

There is no built-in support for this sort of thing. If the boundaries of the squares in the subdomain always line up with the triangle mesh (i.e., each square is tessellated into triangles), then I can think of a work-around, but it would take some effort to implement.

Hi Kamensky,

At the moment my work around is exactly this, I have 8 triangle elements per square. I figure out what elements are in each specific square and assign them all a constant value due to the DG function space to define a square entirely.

I was thinking of something a little more involved, to be able to use the DG space as part of a mixed formulation (by using the fact that each of the square-mesh basis functions can be expressed as a linear combination of triangle-mesh basis functions to construct a similarity transform for the global linear system, which I built up some infrastructure for earlier, in a different context), but, if you just need constant values on the DG space, then I can’t think of anything simpler/easier than your current work-around.

1 Like

Yea I agree, I’m doing super specialized stuff so its understandable the software can’t solve any posed problem in existence.