← Back to team overview

dolfin team mailing list archive

Re: Auto-detection of elements

 

On Thu, Nov 26, 2009 at 08:20:31PM +0100, Marie Rognes wrote:
> Anders Logg wrote:
> >I made some fixes to UFL and FFC to allow auto-detection of degree and
> >shape for all types of elements.
> >
> >I also changed in expression.py in DOLFIN to use Lagrange by default
> >instead of Quadrature. The Poisson demo now works with the new simple
> >Expression interface:
> >
> > f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)")
> > g = Expression("sin(5*x[0])")
> >
>
> Nice :)
>
> >No need for V=V anymore.
> >
>
> Can one still use V=V if one wants to prescribe a function space?

Yes, one can do things like

 f = Expression(("sin(5*x[0])"), ("cos(x[1])"), element=FiniteElement("BDM", triangle, 10))

or just

 f = Expression(("sin(5*x[0])"), ("cos(x[1])"), degree=5)

> >I think it would be ok to use Lagrange by default.
> >
>
> Lagrange yes, but maybe higher order? (Using the same (or lower)
> order for input
> data as the discretization tends to be slightly dangerous.)

Any input on how it should be chosen is appreciated!

All the logic is in the function _adjust_elements in compiler.py in FFC:

def _adjust_elements(form_data):
    "Adjust cell and degree for elements when unspecified"

    # Extract common cell
    common_cell = form_data.cell
    if common_cell.domain() is None:
        error("Missing cell definition in form.")

    # Extract common degree
    degrees = [metadata["quadrature_order"] for metadata in form_data.metadata.itervalues()]
    degrees = [q for q in degrees if not q is None]
    if degrees:
        common_degree = max(degrees)
    else:
        common_degree = default_quadrature_degree

    # Set cell and degree if missing
    for element in form_data.elements:

        # Check if cell and degree need to be adjusted
        cell = element.cell()
        degree = element.degree()
        if degree is None:
            info("Adjusting element degree from %s to %d" % (istr(degree), common_degree))
            element.set_degree(common_degree)
        if cell.domain() is None:
            info("Adjusting element cell from %s to %s." % (istr(cell), str(common_cell)))
            element.set_cell(common_cell)

Please help out to get this right.

--
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References