dg minimun on boundary cells


54
views
0
5 weeks ago by
Hi!
i am working with dg elements and I need a new  alfatil such as every cell:
$h\left(x\right)=min\left(h_T,h_{T'}\right)$h(x)=min(hT,hT') if x is in boundary T and boundary T' ,  T and T' triangles of the mesh.
h(x) =  $h_T$hT  if x in boundary T and exterior boundary domain.
How can I do build the new alfatil?

Thanks in advance!
Jesus
mesh = UnitSquareMesh(5, 5)
V = FunctionSpace(mesh, 'DG', 1)
h = CellSize(mesh)
alfatil = 1/mesh.hmin()
​
Community: FEniCS Project

1 Answer


0
23 days ago by
Hi!
i share a possible solution where I note  $alfatil\left(x\right)=min\left(h_T,h_{T'}\right)$alƒ atil(x)=min(hT,hT')

    Z = FunctionSpace(mesh, 'DG', 0)

    dic = {}
    for elem in cells (mesh):
        for arista in edges (elem):
            xm = arista.midpoint ().x()
            ym = arista.midpoint ().y()
            dic [xm, ym] = alfini

    for elem in cells (mesh):
        for arista in edges (elem):
	    xm = arista.midpoint ().x()
	    ym = arista.midpoint ().y()
	    dic [xm, ym] = min (dic[xm,ym], elem.diameter ())

    # ---------------------------------------------------------------------------------

    def alfatilf (x,y):
        zmin = min (dic.values())
        if (x,y) in dic.keys():
            z = dic [x,y]
        else:
            z = zmin
        return  1. / z

    
    class alfatilf2 (Expression):
	def eval (self, values, x):
		values[0] = alfatilf (x[0],x[1])     

    # at the end i need interpolate with degree 0
    alfatil = avg (interpolate (alfatilf2(), Z))​


Perhaps there is another way more simple.
Regards
Jesus

Please login to add an answer/comment or follow this question.

Similar posts:
Search »