Please refer to linelast01.py on my github repository SME:
https://github.com/ernestyalumni/SME/blob/master/linelast01.py
Nevertheless, in this script, to solve a Dirichlet boundary condition problem in solid mechanics, I have a BoxMesh
mesh = BoxMesh(0.0,0.0,0.0,0.6,0.0254,0.0254,16,10,10)
I try to define a FacetNormal on the mesh:
n = FacetNormal(mesh)
However, I obtain the following errors when I try to plot n:
>>> n
FacetNormal(Domain(Cell('tetrahedron', 3), label='dolfin_mesh_with_id_0', data='<data with id 0>'))
>>> plot(n,interactive=True)
Object cannot be plotted directly, projecting to piecewise linears.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/common/plotting.py", line 126, in plot
object = project(object, mesh=mesh)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/projection.py", line 90, in project
V = _extract_function_space(v, mesh)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/projection.py", line 135, in _extract_function_space
raise RuntimeError("Unable to project expression, can't find a suitable mesh.")
RuntimeError: Unable to project expression, can't find a suitable mesh.
I want to know if it's possible or not to plot the normal. Also, could someone help me understand what's going on with "can't find a suitable mesh" as I want to understand what is FEniCS is doing here, in dealing with the FacetNormal.
Further, now I successfully calculated with LinearVariationalSolver, for the displacement $u$. I can define a stress tensor and obtain a stress tensor that's solved for, for this displacement:
sigma_f = 2*mu*sym(grad(u)) + lmbda*tr(grad(u))*Identity(3)
I would like to multiply this with the normal so to obtain vector values over the mesh. However when I try to plot the multiplication of sigma_f with FacetNormal n, I obtain the following errors:
>>> plot(sigma_f*n, interactive=True)
Object cannot be plotted directly, projecting to piecewise linears.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Integral of type cell cannot contain a FacetNormal.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/common/plotting.py", line 126, in plot
object = project(object, mesh=mesh)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/projection.py", line 111, in project
form_compiler_parameters=form_compiler_parameters)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/assembling.py", line 281, in assemble_system
cell_domains, exterior_facet_domains, interior_facet_domains)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/assembling.py", line 75, in _create_dolfin_form
form_compiler_parameters=form_compiler_parameters)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/fem/form.py", line 70, in __init__
mpi_comm=mesh.mpi_comm())
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 64, in mpi_jit
return local_jit(*args, **kwargs)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/dolfin/compilemodules/jit.py", line 128, in jit
return form_compiler.jit(form, parameters=p)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ffc/jitcompiler.py", line 74, in jit
return jit_form(ufl_object, parameters)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ffc/jitcompiler.py", line 130, in jit_form
parameters=parameters)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ffc/compiler.py", line 151, in compile_form
analysis = analyze_forms(forms, parameters)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ffc/analysis.py", line 59, in analyze_forms
parameters) for form in forms)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ffc/analysis.py", line 59, in <genexpr>
parameters) for form in forms)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ffc/analysis.py", line 132, in _analyze_form
form_data = compute_form_data(form)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ufl/algorithms/compute_form_data.py", line 299, in compute_form_data
_check_facet_geometry(self.integral_data)
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ufl/algorithms/compute_form_data.py", line 141, in _check_facet_geometry
error("Integral of type %s cannot contain a %s." % (it, cls.__name__))
File "/Applications/FEniCS.app/Contents/Resources/lib/python2.7/site-packages/ufl/log.py", line 151, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Integral of type cell cannot contain a FacetNormal.
Could you help me understand what FEniCS is trying to do, with this UFLException? In the context of a problem in solid mechanics, beyond the displacement, if I want to "plot" the stress tensor over the mesh, what can I multiply with it to get something sensible to try to understand and make sense of the stress tensor? Thanks, -EY