← Back to team overview

dolfin team mailing list archive

Re: [Question #153352]: project grad f to a VectorFunctionSpace

 

Question #153352 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/153352

    Status: Open => Answered

Anders Logg proposed the following answer:
On Mon, Apr 18, 2011 at 08:10:56PM -0000, Chaffra wrote:
> New question #153352 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/153352
>
> I don't know if it makes sense but I'd like to do:
>
> m = UnitInterval(11)
> Q= FunctionSpace(m,'CG',1)
> W = VectorFunctionSpace(m,'CG',1,dim=3)
>
> f = Function(Q)
> df = grad(f)
>
> g = project(df,W)
>
> but I get the errpr below.  Any help?

Skip the dim=3 argument.

--
Anders


> Thanks,
> Chaffra
>
>
> /usr/local/lib/python2.6/dist-packages/dolfin/fem/project.py in project(v, V, mesh, solver_type, preconditioner_type, form_compiler_parameters)
>      50     Pv = TrialFunction(V)
>      51     a = ufl.inner(w, Pv)*ufl.dx
> ---> 52     L = ufl.inner(w, v)*ufl.dx
>      53
>      54     # Assemble linear system
>
>
> /usr/local/lib/python2.6/dist-packages/ufl/operators.pyc in inner(a, b)
>      56     if a.shape() == () and b.shape() == ():
>      57         return a*b
> ---> 58     return Inner(a, b)
>      59     #return contraction(a, range(a.rank()), b, range(b.rank()))
>
>      60
>
> /usr/local/lib/python2.6/dist-packages/ufl/tensoralgebra.pyc in __new__(cls, a, b)
>     160
>     161     def __new__(cls, a, b):
> --> 162         ufl_assert(a.shape() == b.shape(), "Shape mismatch.")
>     163         if isinstance(a, Zero) or isinstance(b, Zero):
>     164             free_indices, index_dimensions = merge_indices(a, b)
>
> /usr/local/lib/python2.6/dist-packages/ufl/assertions.pyc in ufl_assert(condition, *message)
>      18 def ufl_assert(condition, *message):
>      19     "Assert that condition is true and otherwise issue an error with given message."
> ---> 20     if not condition: error(*message)
>      21
>      22
>
> /usr/local/lib/python2.6/dist-packages/ufl/log.pyc in error(self, *message)
>     122         "Write error message and raise an exception."
>     123         self._log.error(*message)
> --> 124         raise UFLException(self._format_raw(*message))
>     125
>     126     def begin(self, *message):
>
> UFLException: Shape mismatch.
>
>

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.