← Back to team overview

dolfin team mailing list archive

Re: [Question #122406]: assemble VariationalProblem members

 

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

    Status: Open => Answered

Garth Wells proposed the following answer:

On 23/08/10 18:26, Dominique wrote:
> New question #122406 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/122406
>
> Hello,
>
> In Python, I am trying to encapsulate a problem stated in weak form:
> a(v,u) = L(v) for all v in V (nonlinear or not). The first option
> that came to my mind is to use
>
> problem = VariationalProblem(a, L, bc)
>
> Now I can do
>
> A = assemble(a, mesh=mesh) ; b = assemble(L, mesh=mesh) ;
> bc.apply(A,b)
>

You should just do

   A = assemble(a)
   b = assemble(L)

> but I cannot do
>
> A = assemble(problem.a, mesh=mesh) ; b = assemble(problem.L,
> mesh=mesh)
>
> Somehow assemble() doesn't want to work on the members of 'problem'.
> It returns:
>
> Unable to convert object to a UFL form:<dolfin.fem.form.Form; proxy
> of<Swig Object of type 'dolfin::Form *' at 0x99fa350>  > ERROR: An
> unexpected error occurred while tokenizing input The following
> traceback may be corrupted or invalid The error message is: ('EOF in
> multi-line statement', (4, 0)) [...] UFLException: Unable to convert
> object to a UFL form:<dolfin.fem.form.Form; proxy of<Swig Object of
> type 'dolfin::Form *' at 0x99fa350>  >
>
> I don't *have* to use VariationalProblem to encapsulate the data, but
> I need to be able to get A and b somehow. I saw in a previous post
> that one could subclass NonlinearProblem. That would be fine for me,
> but I have 2 questions:
>
> 1) Is there a recommended way to encapsulate a and L so that they can
> be assemble()'d?
>
> 2) Could you please show an example usage of calling problem.F and
> problem.J when problem is a VariationalProblem? That just might
> answer the question.
>

You don't want to put a and L in a VariationalProblem if you're not
going to use the member function of VariationalProblem. Just work with a
and L directly.

Garth

> Thanks in advance! Dominique
>

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