← Back to team overview

ufl team mailing list archive

Re: [noreply@xxxxxxxxxxxxx: [Branch ~ufl-core/ufl/main] Rev 1051: erge]

 

On 13 May 2011 09:53, Anders Logg <logg@xxxxxxxxx> wrote:
> Thanks! I'll see if it works.
>
> Have you thought about what should happen if say degree is given for a
> mixed element but only one of the subelements has an undefined degree?

No. If you specify the degree, reconstruct will set it for all subelements.
There is no other unique way. If you want to treat certain subelements
in a hierarchy specially you'll just have to traverse the mixed elements
yourself. I just added a reconstruct_from_elements(*elements) to
MixedElement which you can use to get some checking when piecing
together the mixed elements.

Note that it is important that reconstructed elements have the same
value shape. If used to reconstruct functions to reconstruct an expression,
the result of a changing value shape would be completely undefined
behaviour and there is no way to do that correctly. I've added some
asserts for this, just so you know they are really there for a very good reason.

> It might also be the case that we will completely miss such cases. I
> think degree() for a mixed element returns the maximum degree of the
> subelements and if one of them is None but not all, we will miss it
> since max(None, q) = q.

Seems so. But that's a problem for FFC/PyDOLFIN :)
I don't know why you would want to put yourself in that situation...

Martin

\> --
> Anders
>
>
> On Fri, May 13, 2011 at 09:03:27AM +0200, Martin Sandve Alnæs wrote:
>> Done, did a manual test and checking in now:
>>
>> In [5]: print FiniteElement("CG", triangle,
>> 2).reconstruct(family="DG", cell=quadrilateral, degree=3)
>> <DG3 on a <quadrilateral cell in R2>>
>>
>> In [8]: print VectorElement("CG", triangle,
>> 2).reconstruct(family="DG", cell=quadrilateral, degree=3)
>> <Discontinuous Lagrange vector element of degree 3 on a <quadrilateral
>> cell in R2>: 2 x <DG3 on a <quadrilateral cell in R2>>>
>>
>> In [9]: print TensorElement("CG", triangle,
>> 2).reconstruct(family="DG", cell=quadrilateral, degree=3)
>> <Discontinuous Lagrange tensor element of degree 3 and shape (2, 2) on
>> a <quadrilateral cell in R2>>
>>
>> In [10]: print MixedElement(VectorElement("CG", triangle, 2),
>> FiniteElement("CG", triangle, 2)).reconstruct(family="DG",
>> cell=quadrilateral, degree=3)
>> <Mixed element: (<Discontinuous Lagrange vector element of degree 3 on
>> a <quadrilateral cell in R2>: 2 x <DG3 on a <quadrilateral cell in
>> R2>>>, <DG3 on a <quadrilateral cell in R2>>)>
>>
>> I'll move this into the unit tests, but don't have more time for this today.
>>
>> Martin
>>
>> On 13 May 2011 00:33, Anders Logg <logg@xxxxxxxxx> wrote:
>> > It seems to work fine, but some unit tests are failing since
>> > reconstruct is only implemented for FiniteElement (not for mixed
>> > elements etc).
>> >
>> > Could you add a suitable reconstruct for mixed elements? I'm not sure
>> > how it should be done, in particular how the input should be
>> > propagated to the subelements.
>> >
>> >
>> >
>> >
>> > On Thu, May 12, 2011 at 10:37:08PM +0200, Martin Sandve Alnæs wrote:
>> >> Be aware that form_data.elements and friends are _after_ mapping, so
>> >> if you get to the dolfin.FunctionSpaces through them something must be
>> >> changed. If you get them from the original functions everything should
>> >> be fine though.
>> >>
>> >> Martin
>> >>
>> >> On 12 May 2011 22:30, Anders Logg <logg@xxxxxxxxx> wrote:
>> >> > On Thu, May 12, 2011 at 10:22:51PM +0200, Martin Sandve Alnæs wrote:
>> >> >> On 12 May 2011 22:21, Anders Logg <logg@xxxxxxxxx> wrote:
>> >> >> > On Thu, May 12, 2011 at 08:39:55PM +0200, Anders Logg wrote:
>> >> >> >> On Thu, May 12, 2011 at 07:39:39PM +0200, Martin Sandve Alnæs wrote:
>> >> >> >> > I've pushed some changes to lp:~martinal/ufl/reconstruction mostly
>> >> >> >> > implementing the ufl side of taking an (optional) element_mapping
>> >> >> >> > as input to preprocess, but I want to test it a bit more before pushing
>> >> >> >> > to trunk.
>> >> >> >>
>> >> >> >> ok. I'm currently working on sorting out some remaining cache problems
>> >> >> >> in the FFC JIT compiler. That should hopefully take care of the
>> >> >> >> remaining tests that fail in DOLFIN. When that works, I can try out
>> >> >> >> the reconstruction.
>> >> >> >
>> >> >> > Is it safe to try out the new element replacement now?
>> >> >>
>> >> >> Yes, I even checked it in. element_mapping is None by default, just
>> >> >> try adding it.
>> >> >
>> >> > ok, will try.
>> >> >
>> >> >
>> >
>



Follow ups

References