This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

update mesh after autoadaptive refinement

0 votes

Hi I have to solve coupled equation, In that i am solving equations individually. First equation i want to solve auto adaptive, How can I update mesh to solve second equation.

I have given minimal working code, Thanks in advance

from dolfin import *
import mshr
domain = mshr.Rectangle(Point(0,0), Point(1,1))-mshr.Circle(Point(0.5,0.5), 0.1)
mesh = mshr.generate_mesh(domain, 10)
V = VectorFunctionSpace(mesh, 'CG',1)
u = TrialFunction(V)
v = TestFunction(V)
lmbda=121.15E3
mu=80.77E3
def epsilon(u):
    return 0.5*(grad(u)  + grad(u).T)

def sigma(u):
    return 2.0*mu*epsilon(u) + lmbda*tr(epsilon(u))*Identity(2)

class top(SubDomain):
    def inside(self,x,on_boundary):
        tol = 1e-5
        return abs(x[1]-1.0) < tol and on_boundary

class bottom(SubDomain):
def inside(self,x,on_boundary):
        tol = 1e-5
        return abs(x[1]) < tol and on_boundary
Bottom = bottom()
Top = top()
u0=Constant(("0.0","0.0"))
bc1=DirichletBC(V,u0,Bottom)
bc2=DirichletBC(V.sub(1),Constant(1.0),Top)
bc = [bc1, bc2]

Eu = inner(nabla_grad(v), sigma(u))*dx
u = Function(V)

M = inner(u*u)dx
tol = 1.e-3

solver_parameters = {"error_control":{"dual_variational_solver":{"linear_solver": "cg"}}}
solve(lhs(Eu) == rhs(Eu), u, bc , tol=tol , M=M,solver_parameters=solver_parameters)

# I want mesh update for the second equation
asked Jun 20, 2017 by hirshikesh FEniCS User (1,890 points)
...