Dear Amireh, Some effort to do mesh adaptation has been done in Firedrake, notably in: https://arxiv.org/pdf/1610.09874.pdf and https://arxiv.org/pdf/1612.08077.pdf I know this does not answer your specific questions, however, it might be worth looking at what's already there before trying to do complicated stuff, as neither of your questions has a trivial answer (as far as I'm aware). Best wishes, -- Nicolas On 03/08/2018 10:03, Amireh Mousavi wrote:
Dear all,
I'm trying to use adaptive algorithm in Firedrake. Because it's essential in my thesis. I have problem with /marking cell/ and /locally refining/ step. The following is my test code for one iteration:
REFINE_RATIO = 0.50 # Refine 50 % of the cells in each iteration mesh = UnitSquareMesh(4, 4) BDM = FunctionSpace(mesh, "BDM", 1) DG = FunctionSpace(mesh, "DG", 0) W = BDM * DG sigma, u = TrialFunctions(W) tau, v = TestFunctions(W) x, y = SpatialCoordinate(mesh) f = Function(DG).interpolate( 10*exp(-(pow(x - 0.5, 2) + pow(y - 0.5, 2)) / 0.02)) a = (dot(sigma, tau) + div(tau)*u + div(sigma)*v)*dx L = - f*v*dx bc0 = DirichletBC(W.sub(0), as_vector([0.0, -sin(5*x)]), 1) bc1 = DirichletBC(W.sub(0), as_vector([0.0, sin(5*y)]), 2) w = Function(W) solve(a == L, w, bcs=[bc0, bc1]) sigma, u = w.split() expr = (div(sigma)+f)*(div(sigma)+f) P0 = FunctionSpace(mesh, "DG", 0) Re = project(expr, P0) coeffs = Re.dat.data ss = sorted(coeffs, reverse=True)[int(len(coeffs)*REFINE_RATIO)] #-------------------------The followin are marking and refining which work in Dolfin --------------------------- cell_markers = MeshFunction("bool", mesh, mesh.topology().dim()) for c in cells(mesh): cell_markers[c] = coeffs[c.index()] > ss mesh = refine(mesh, cell_markers)
1) How can I use the loop over the cells in Firedrake? ( *for c in ?*) 2) Is there a way to refine some marked cell in Firedrake?
Your answer will be greatly appreciated.
All the best, Amireh
_______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
-- Nicolas Barral Dept. of Earth Science and Engineering Imperial College London Royal School of Mines - Office 4.88 London SW7 2AZ