dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #17148
Re: [Question #95908]: Error: Invalid value rank for coefficient 1
Question #95908 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/95908
Status: Open => Answered
Anders Logg proposed the following answer:
On Wed, Jan 06, 2010 at 07:46:28AM -0000, Phil Marinier wrote:
> Question #95908 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/95908
>
> Status: Answered => Open
>
> Phil Marinier is still having a problem:
> I tried this:
>
> element = FiniteElement("Lagrange", triangle, 1)
> VE = VectorElement("Lagrange", triangle, 1)
>
> v = TestFunction(element)
> u = TrialFunction(element)
> f = Function(element)
> g = Function(VE)
>
> a = inner(grad(v), grad(u))*dx
> L = v*f*dx + v*g*ds(3)
>
>
> This was the error message:
>
>
> phil@wolf:~/Desktop/Domain Decomposition$ ffc -l dolfin -O Laplace.ufl
> This is FFC, the FEniCS Form Compiler, version 0.7.1.
> For further information, visit http://www.fenics.org/ffc/.
>
> Trying to integrate expression of rank 1 with free indices ().
> An exception occured during evaluation of form file.
> To help you find the location of the error, a temporary script
> 'Laplace_debug.py'
> has been created and will now be executed with debug output enabled:
> Trying to integrate expression of rank 1 with free indices ().
> Traceback (most recent call last):
> File "/home/claude/FEniCS/build/bin/ffc", line 153, in <module>
> sys.exit(main(sys.argv[1:]))
> File "/home/claude/FEniCS/build/bin/ffc", line 130, in main
> ufd = load_ufl_file(filename)
> File "/home/claude/FEniCS/build/lib/python2.6/site-packages/ufl/algorithms/formfiles.py", line 91, in load_ufl_file
> m = __import__(basename)
> File "/home/phil/Desktop/Domain Decomposition/Laplace_debug.py", line 13, in <module>
> L = v*f*dx + v*g*ds(3)
> File "/home/claude/FEniCS/build/lib/python2.6/site-packages/ufl/integral.py", line 94, in __rmul__
> % (integrand.rank(), integrand.free_indices()))
> File "/home/claude/FEniCS/build/lib/python2.6/site-packages/ufl/assertions.py", line 20, in ufl_assert
> if not condition: error(*message)
> File "/home/claude/FEniCS/build/lib/python2.6/site-packages/ufl/log.py", line 106, in error
> raise UFLException(self._format_raw(*message))
> ufl.log.UFLException: Trying to integrate expression of rank 1 with free indices ().
>
>
> I assumed because of the "rank 1" in the error message that the problem was that I was using a vector valued element for g and that wasn't allowed. I know that I can't use VectorElements for my test and trial functions because it messes up the dot product.
>
> I guess my real question is how would I go about re writing the form
> file to get a neumann boundary condition on one boundary that has both X
> and Y components?
This is not surprising at all. Your function g is now vector-valued so
then it doesn't make sense to write
v*g*ds
since that will be a vector-valued integral.
g must be a scalar in the above example, and it should be equal to the
normal derivative of u on the boundary.
What you can do is instead of writing v*g*ds let g denote the
vector-valued gradient of u on the boundary. Then you must also
include the facet normal:
n = triangle.n
L = v*f*dx + v*dot(g, n)*ds
with g the vector-valued gradient of u on the neighboring domain.
That might be what you are looking for.
You could also do
n = triangle.n
L = v*f*dx + v*dot(grad(g), n)*ds
and let g be the scalar-valued u on the neighboring domain.
--
Anders
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.