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

Adaptive mesh refinement, problem when boundary terms appear in linear form L

–2 votes

Hello,

when running the minimal example attached below the following problem occurs. When I consider

L = inner(f, v)*dx

I can solve a linear elasticity equation with adaptive mesh refinement.

Whenever I include terms with ds in the linear form, like

L = inner(f, v)*dx + inner(g, v)*ds(2)

I receive the following error message:

In instant.recompile: The module did not compile with command 'make VERBOSE=1 ', see '/home/kimmerle/.instant/error/instant_module_f85117a588b102c37e97eb08e8ba64a1195dcf6a/compile.log'
Traceback (most recent call last):
  File "Test_MinimalExample.py", line 57, in <module>
    solve(a == L, u, bc, tol=5.0E-7, M=MF) #Solve adaptively
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 264, in solve
    _solve_varproblem_adaptive(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 339, in _solve_varproblem_adaptive
    solver = AdaptiveLinearVariationalSolver(problem, M)
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/adaptivesolving.py", line 58, in __init__
    ec = generate_error_control(self.problem, goal)
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/adaptivesolving.py", line 150, in generate_error_control
    forms = [Form(form, form_compiler_parameters=p) for form in ufl_forms]
  File "/usr/lib/python2.7/dist-packages/dolfin/fem/form.py", line 56, in __init__
    common_cell)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 154, in jit
    return jit_compile(form, parameters=p, common_cell=common_cell)
  File "/usr/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 77, in jit
    return jit_form(ufl_object, parameters, common_cell)
  File "/usr/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 212, in jit_form
    cache_dir = cache_dir)
  File "/usr/lib/python2.7/dist-packages/ufc_utils/build.py", line 64, in build_ufc_module
    **kwargs)
  File "/usr/lib/python2.7/dist-packages/instant/build.py", line 541, in build_module
    recompile(modulename, module_path, new_compilation_checksum, build_system)
  File "/usr/lib/python2.7/dist-packages/instant/build.py", line 150, in recompile
    instant_error(msg % (cmd, compile_log_filename_dest))
  File "/usr/lib/python2.7/dist-packages/instant/output.py", line 49, in instant_error
    raise RuntimeError(text)
RuntimeError: In instant.recompile: The module did not compile with command 'make VERBOSE=1 ', see '/home/kimmerle/.instant/error/instant_module_f85117a588b102c37e97eb08e8ba64a1195dcf6a/compile.log'

By choosing a fine mesh manually, I can solve the problem by FEniCS accurately. The PDE is well-posed and numerical locking effects have been taken care of.

It seams to me that there is a bug or what might be the issue?

I am working with FEniCS v1.2 in python.

Thanks in advance,

SJ

PS: Here is a minimal example:

from dolfin import *

parameters["linear_algebra_backend"] ="PETSc"
parameters["form_compiler"]["quadrature_degree"] = 4
parameters["allow_extrapolation"] = True

b2 = 0.8
mesh = BoxMesh(0, -0.5*b2, -0.4, 45.0, 0.5*b2, 0.4, 10, 6, 4)
print mesh
V = VectorFunctionSpace(mesh, 'Lagrange', 2)

# Initialize mesh function for boundary domains
boundary_parts = MeshFunction("size_t", mesh, mesh.topology().dim()-1)

# Define boundary conditions
class DirichletBoundaryCondLeft (SubDomain):
   def inside(self, x, on_boundary):
      return on_boundary and (x[0] <= DOLFIN_EPS)
class NeumannBoundaryCondBottom (SubDomain):
   def inside(self, x, on_boundary):
      return on_boundary and (x[1] <= -0.4 + DOLFIN_EPS)
u0_boundary = DirichletBoundaryCondLeft()
u0_boundary.mark(boundary_parts, 1)
g_boundary = NeumannBoundaryCondBottom()
g_boundary.mark(boundary_parts, 2)

u0 = Constant((0.0, 0.0, 0.0))
bc = DirichletBC(V, u0, boundary_parts, 1) 

# Define parameters for Cauchy tensor
E, nu = pow(10,7)/6.0, 0.285
lambdaS=Constant(E*nu/((1.0 + nu)*(1.0 - 2.0*nu)))
muS=Constant(E/(2.0*(1.0 + nu)))

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
# Define Cauchy tensor
def sigma(v):
    return lambdaS*tr(sym(grad(v)))*Identity(v.cell().d) + 2.0*muS*sym(grad(v))

# Define volume/boundary forces
f = Constant((0.0, -0.2, 0.0))
g = Constant((0.0, -10.0, 0.0))

# Define (bi)linear forms
a = (inner(sigma(u), grad(v)))*dx
L = inner(f, v)*dx + inner(g, v)*ds(2)
#L = inner(f, v)*dx

u = Function(V)
# Define goal functional for adaptive mesh refinement
n = FacetNormal(mesh)
MF = -inner(u, n)*ds #(inner(f, u)-inner(sigma(u), grad(u)))*dx #inner(sigma(u)*n, n)*ds(2)+inner(g, n))*ds(2)
solve(a == L, u, bc, tol=5.0E-7, M=MF) #Solve adaptively

plot(u, mode="displacement")
interactive()
asked Jun 13, 2013 by SvenJoachim FEniCS Novice (140 points)
edited Jun 13, 2013 by johannr

The example code works for me with quite recent master.

see '/home/kimmerle/.instant/error/instant_module_f85117a588b102c37e97eb08e8ba64a1195dcf6a/compile.log' to check what's wrong.

Well I tried with 1.2.0 and it seems that FFC generates code with syntax error. I've reported it as an FFC issue.

Thank you Marie and Jan!
For the moment, I have found a "work around" for my issue. But I will try again, when the next FEniCS update is out.

1 Answer

+1 vote
 
Best answer

Since this runs in master, it will probably not be fixed in 1.2.0.

answered Jun 14, 2013 by Marie E. Rognes FEniCS User (5,380 points)
selected Jun 14, 2013 by Jan Blechta
...