[Dune] Fwd: Re: [Dune-Commit] dune-localfunctions r1002 - trunk/dune/localfunctions/lagrange/q2

Oliver Sander sander at mi.fu-berlin.de
Mon Sep 19 12:22:02 CEST 2011


Committed, thanks.


Am 19.09.2011 12:16, schrieb Matthias Wohlmuth:
>
> -------- Original-Nachricht --------
> Betreff: 	Re: [Dune-Commit] dune-localfunctions r1002 -
> trunk/dune/localfunctions/lagrange/q2
> Datum: 	Mon, 19 Sep 2011 12:01:50 +0200
> Von: 	Matthias Wohlmuth <Matthias.Wohlmuth at ma.tum.de>
> An: 	dune-commit at dune-project.org
>
>
>
> Am 16.09.2011 15:24, schriebsander at dune-project.org:Author:  sander
>>  Date: 2011-09-16 15:24:53 +0200 (Fri, 16 Sep 2011)
>>  New Revision: 1002
>>
>>  Modified:
>>      trunk/dune/localfunctions/lagrange/q2/q2localbasis.hh
>>  Log:
>>  Implement a dimension-agnostic local Q2 basis, and use it for all but 3d
>>
> Hi,
>
> in addition to the dimension-agnostic implementation, I would appreciate
> a field_type-agnostic implementation as well ;-).
> It would be great, if the attached patch could be applied which would help me to stay consistent with the trunk.
> The current implementation of q2 elements relies on the fact
> that, for example, in 2*x, 2 is automatically converted to the
> RangeFieldType R. (Same for weightedsum operator :-( and other parts of the code).  Unfortunately,
> this does not work for complex<double>. So, basically, the patch replaces 2*x by
> R(2)*x.
>
> Best,
> Matthias
>
>
>>  Modified: trunk/dune/localfunctions/lagrange/q2/q2localbasis.hh
>>  ===================================================================
>>  --- trunk/dune/localfunctions/lagrange/q2/q2localbasis.hh	2011-09-12 15:00:52 UTC (rev 1001)
>>  +++ trunk/dune/localfunctions/lagrange/q2/q2localbasis.hh	2011-09-16 13:24:53 UTC (rev 1002)
>>  @@ -42,38 +42,18 @@
>>      {
>>        out.resize(size());
>>
>>  -    switch (dim) {
>>  +    // Evaluate the Lagrange functions
>>  +    array<array<R,3>, dim>   X;
>>  +
>>  +    for (size_t i=0; i<dim; i++) {
>>  +            X[i][0] =  2*in[i]*in[i] - 3*in[i]+1;
>>  +            X[i][1] = -4*in[i]*in[i] + 4*in[i];
>>  +            X[i][2] =  2*in[i]*in[i] -   in[i];
>>  +    }
>>
>>  -        case 1: {
>>  -            out[0] =  2 * (in[0]-0.5) * (in[0] - 1);
>>  -            out[1] = -4 *  in[0]      * (in[0] - 1);
>>  -            out[2] =  2 *  in[0]      * (in[0] - 0.5);
>>  -            break;
>>  -        }
>>  +    // legacy special case
>>  +    if (dim==3) {
>>
>>  -        case 2: {
>>  -
>>  -            R x=in[0], y=in[1];
>>  -            R X0=2*x*x-3*x+1, X1=-4*x*x+4*x, X2=2*x*x-x;
>>  -            R Y0=2*y*y-3*y+1, Y1=-4*y*y+4*y, Y2=2*y*y-y;
>>  -
>>  -            out[0] = X0*Y0;
>>  -            out[1] = X1*Y0;
>>  -            out[2] = X2*Y0;
>>  -
>>  -            out[3] = X0*Y1;
>>  -            out[4] = X1*Y1;
>>  -            out[5] = X2*Y1;
>>  -
>>  -            out[6] = X0*Y2;
>>  -            out[7] = X1*Y2;
>>  -            out[8] = X2*Y2;
>>  -
>>  -            break;
>>  -        }
>>  -
>>  -        case 3: {
>>  -
>>            R x=in[0], y=in[1], z=in[2];
>>            R X0=2*x*x-3*x+1, X1=-4*x*x+4*x, X2=2*x*x-x;
>>            R Y0=2*y*y-3*y+1, Y1=-4*y*y+4*y, Y2=2*y*y-y;
>>  @@ -111,11 +91,27 @@
>>            out[19] = X1*Y2*Z2;
>>            out[7]  = X2*Y2*Z2;
>>
>>  -        break;
>>  +        return;
>>        }
>>  -        default:
>>  -            DUNE_THROW(NotImplemented, "Q2LocalBasis for dim=="<<   dim);
>>  +
>>  +    for (size_t i=0; i<out.size(); i++) {
>>  +
>>  +        out[i] = 1;
>>  +
>>  +        // Construct the i-th Lagrange point
>>  +        size_t ternary = i;
>>  +        for (int j=0; j<dim; j++) {
>>  +
>>  +            int digit = ternary%3;
>>  +            ternary /= 3;
>>  +
>>  +            // Multiply the 1d Lagrange shape functions together
>>  +            out[i] *= X[j][digit];
>>  +
>>  +        }
>>  +
>>        }
>>  +
>>      }
>>
>>      //! \brief Evaluate Jacobian of all shape functions
>>
>>
>>  _______________________________________________
>>  Dune-Commit mailing list
>>  Dune-Commit at dune-project.org
>>  http://lists.dune-project.org/mailman/listinfo/dune-commit
>>
>
>
> --
> *****************************************************************
> ***************  Dipl.-Math. Matthias Wohlmuth
> ************
> **********  Department of Mathematics (M2)
> ********  Technische Universität München (TU Munich)
> ******  Boltzmannstr. 3, 85748 Garching, Germany
> ****
> **http://www-m2.ma.tum.de/bin/view/Allgemeines/MatthiasWohlmuth
> ****matthias.wohlmuth at ma.tum.de
> ******  Phone: +49 89 / 289 18441
> ********  Fax: +49 89 / 289 18435
> **********  Office: 03.10.036
> *****************************************************************
>
>
>




More information about the Dune mailing list