Different norms of a functional

Asked by Murtazo Nazarov

Hi,

I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute

1. ||\div(Pu)||_{L_\infty} ?
2. ||\div(Pu)||_{L_1} ?

where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.

I use C++ interface

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Anders Logg
Solved:
Last query:
Last reply:
Revision history for this message
Best Anders Logg (logg) said :
#1

On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
> New question #103034 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Hi,
>
> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>
> 1. ||\div(Pu)||_{L_\infty} ?

Try projecting div(Pu) onto piecewise constants and then pick the
largest absolute value in the vector.

> 2. ||\div(Pu)||_{L_1} ?

Try

M = abs(div(Pu))*dx

--
Anders

> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>
> I use C++ interface
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#2

Anders Logg wrote:
> Question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Status: Open => Answered
>
> Anders Logg proposed the following answer:
> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
>
>> New question #103034 on DOLFIN:
>> https://answers.launchpad.net/dolfin/+question/103034
>>
>> Hi,
>>
>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>>
>> 1. ||\div(Pu)||_{L_\infty} ?
>>
>
> Try projecting div(Pu) onto piecewise constants and then pick the
> largest absolute value in the vector.
>
>

I need L_inf norm on the cell. With this way, doesn't give the L_inf for
the entire domain?

murtazo

>> 2. ||\div(Pu)||_{L_1} ?
>>
>
> Try
>
> M = abs(div(Pu))*dx
>
> --
> Anders
>
>
>
>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>>
>> I use C++ interface
>>
>>
>
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#3

Thanks Anders Logg, that solved my question.

Revision history for this message
Murtazo Nazarov (murtazo) said :
#4

Murtazo Nazarov wrote:
> Your question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Status: Answered => Open
>
> You are still having a problem:
> Anders Logg wrote:
>
>> Question #103034 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/103034
>>
>> Status: Open => Answered
>>
>> Anders Logg proposed the following answer:
>> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
>>
>>
>>> New question #103034 on DOLFIN:
>>> https://answers.launchpad.net/dolfin/+question/103034
>>>
>>> Hi,
>>>
>>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>>>
>>> 1. ||\div(Pu)||_{L_\infty} ?
>>>
>>>
>> Try projecting div(Pu) onto piecewise constants and then pick the
>> largest absolute value in the vector.
>>
>>
>>
>
> I need L_inf norm on the cell. With this way, doesn't give the L_inf for
> the entire domain?
>
> murtazo
>
>

Instead of projecting div(Pu) onto piecewise constants, I projected it
into dG(1), with this way I get three values on each cell, which I can
then pick up the largest of them. That gives me then L_inf_K, where K is
a cell. Now, I cannot figured out how is the numbering done for the
dG(1) elements.

If N is a total number of cells, then my projected vector Pdg has 3*N
elements. How can I pick up elements of Pdg in the cell K?

Thanks,
murtazo

>>> 2. ||\div(Pu)||_{L_1} ?
>>>
>>>
>> Try
>>
>> M = abs(div(Pu))*dx
>>
>> --
>> Anders
>>
>>
>>
>>
>>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>>>
>>> I use C++ interface
>>>
>>>
>>>
>>
>
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#5

Murtazo Nazarov wrote:
> Question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Murtazo Nazarov posted a new comment:
> Murtazo Nazarov wrote:
>
>> Your question #103034 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/103034
>>
>> Status: Answered => Open
>>
>> You are still having a problem:
>> Anders Logg wrote:
>>
>>
>>> Question #103034 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/103034
>>>
>>> Status: Open => Answered
>>>
>>> Anders Logg proposed the following answer:
>>> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
>>>
>>>
>>>
>>>> New question #103034 on DOLFIN:
>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>
>>>> Hi,
>>>>
>>>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>>>>
>>>> 1. ||\div(Pu)||_{L_\infty} ?
>>>>
>>>>
>>>>
>>> Try projecting div(Pu) onto piecewise constants and then pick the
>>> largest absolute value in the vector.
>>>
>>>
>>>
>>>
>> I need L_inf norm on the cell. With this way, doesn't give the L_inf for
>> the entire domain?
>>
>> murtazo
>>
>>
>>
>
> Instead of projecting div(Pu) onto piecewise constants, I projected it
> into dG(1), with this way I get three values on each cell, which I can
> then pick up the largest of them. That gives me then L_inf_K, where K is
> a cell. Now, I cannot figured out how is the numbering done for the
> dG(1) elements.
>
> If N is a total number of cells, then my projected vector Pdg has 3*N
> elements. How can I pick up elements of Pdg in the cell K?
>
> Thanks,
> murtazo
>
>

It seems the numbering is as the following:

      int nsdim = mesh.topology().dim();
      int num_en = 1 + nsdim; // number of vertices's on the cell
      real L_inf_K = 0.;
      for (int i = 0; i < num_en ; i++){
        L_inf_K = max(L_inf_K, fabs(my_arr[num_en*cid + i]));
      }

probably there is a better way, but this works for now in one cpu (maybe
not in parallel).

murtazo

>>>> 2. ||\div(Pu)||_{L_1} ?
>>>>
>>>>
>>>>
>>> Try
>>>
>>> M = abs(div(Pu))*dx
>>>
>>> --
>>> Anders
>>>
>>>
>>>
>>>
>>>
>>>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>>>>
>>>> I use C++ interface
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
>

Revision history for this message
Anders Logg (logg) said :
#6

On Sun, Mar 14, 2010 at 11:48:21PM -0000, Murtazo Nazarov wrote:
> Question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Murtazo Nazarov posted a new comment:
> Murtazo Nazarov wrote:
> > Your question #103034 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/103034
> >
> > Status: Answered => Open
> >
> > You are still having a problem:
> > Anders Logg wrote:
> >
> >> Question #103034 on DOLFIN changed:
> >> https://answers.launchpad.net/dolfin/+question/103034
> >>
> >> Status: Open => Answered
> >>
> >> Anders Logg proposed the following answer:
> >> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
> >>
> >>
> >>> New question #103034 on DOLFIN:
> >>> https://answers.launchpad.net/dolfin/+question/103034
> >>>
> >>> Hi,
> >>>
> >>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
> >>>
> >>> 1. ||\div(Pu)||_{L_\infty} ?
> >>>
> >>>
> >> Try projecting div(Pu) onto piecewise constants and then pick the
> >> largest absolute value in the vector.
> >>
> >>
> >>
> >
> > I need L_inf norm on the cell. With this way, doesn't give the L_inf for
> > the entire domain?
> >
> > murtazo
> >
> >
>
> Instead of projecting div(Pu) onto piecewise constants, I projected it
> into dG(1), with this way I get three values on each cell, which I can
> then pick up the largest of them. That gives me then L_inf_K, where K is
> a cell. Now, I cannot figured out how is the numbering done for the
> dG(1) elements.
>
> If N is a total number of cells, then my projected vector Pdg has 3*N
> elements. How can I pick up elements of Pdg in the cell K?
>
> Thanks,
> murtazo

Why do you use DG(1) instead of DG(0)? If you use DG(0), the numbering
is easier.

--
Anders

> >>> 2. ||\div(Pu)||_{L_1} ?
> >>>
> >>>
> >> Try
> >>
> >> M = abs(div(Pu))*dx
> >>
> >>
> >>
> >>
> >>
> >>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
> >>>
> >>> I use C++ interface
> >>>
> >>>
> >>>
> >>
> >
> >
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#7

Anders Logg wrote:
> Your question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Anders Logg posted a new comment:
> On Sun, Mar 14, 2010 at 11:48:21PM -0000, Murtazo Nazarov wrote:
>
>> Question #103034 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/103034
>>
>> Murtazo Nazarov posted a new comment:
>> Murtazo Nazarov wrote:
>>
>>> Your question #103034 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/103034
>>>
>>> Status: Answered => Open
>>>
>>> You are still having a problem:
>>> Anders Logg wrote:
>>>
>>>
>>>> Question #103034 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>
>>>> Status: Open => Answered
>>>>
>>>> Anders Logg proposed the following answer:
>>>> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
>>>>
>>>>
>>>>
>>>>> New question #103034 on DOLFIN:
>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>
>>>>> Hi,
>>>>>
>>>>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>>>>>
>>>>> 1. ||\div(Pu)||_{L_\infty} ?
>>>>>
>>>>>
>>>>>
>>>> Try projecting div(Pu) onto piecewise constants and then pick the
>>>> largest absolute value in the vector.
>>>>
>>>>
>>>>
>>>>
>>> I need L_inf norm on the cell. With this way, doesn't give the L_inf for
>>> the entire domain?
>>>
>>> murtazo
>>>
>>>
>>>
>> Instead of projecting div(Pu) onto piecewise constants, I projected it
>> into dG(1), with this way I get three values on each cell, which I can
>> then pick up the largest of them. That gives me then L_inf_K, where K is
>> a cell. Now, I cannot figured out how is the numbering done for the
>> dG(1) elements.
>>
>> If N is a total number of cells, then my projected vector Pdg has 3*N
>> elements. How can I pick up elements of Pdg in the cell K?
>>
>> Thanks,
>> murtazo
>>
>
> Why do you use DG(1) instead of DG(0)? If you use DG(0), the numbering
> is easier.
>
>

DG(0) gives me an average of the function I have on the cell, however
the values can be large on the vertices especially in the places where
shocks exist.

murtazo

> --
> Anders
>
>
>
>>>>> 2. ||\div(Pu)||_{L_1} ?
>>>>>
>>>>>
>>>>>
>>>> Try
>>>>
>>>> M = abs(div(Pu))*dx
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>>>>>
>>>>> I use C++ interface
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>
>

Revision history for this message
Anders Logg (logg) said :
#8

On Mon, Mar 15, 2010 at 03:45:30PM -0000, Murtazo Nazarov wrote:
> Question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Murtazo Nazarov posted a new comment:
> Anders Logg wrote:
> > Your question #103034 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/103034
> >
> > Anders Logg posted a new comment:
> > On Sun, Mar 14, 2010 at 11:48:21PM -0000, Murtazo Nazarov wrote:
> >
> >> Question #103034 on DOLFIN changed:
> >> https://answers.launchpad.net/dolfin/+question/103034
> >>
> >> Murtazo Nazarov posted a new comment:
> >> Murtazo Nazarov wrote:
> >>
> >>> Your question #103034 on DOLFIN changed:
> >>> https://answers.launchpad.net/dolfin/+question/103034
> >>>
> >>> Status: Answered => Open
> >>>
> >>> You are still having a problem:
> >>> Anders Logg wrote:
> >>>
> >>>
> >>>> Question #103034 on DOLFIN changed:
> >>>> https://answers.launchpad.net/dolfin/+question/103034
> >>>>
> >>>> Status: Open => Answered
> >>>>
> >>>> Anders Logg proposed the following answer:
> >>>> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
> >>>>
> >>>>
> >>>>
> >>>>> New question #103034 on DOLFIN:
> >>>>> https://answers.launchpad.net/dolfin/+question/103034
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
> >>>>>
> >>>>> 1. ||\div(Pu)||_{L_\infty} ?
> >>>>>
> >>>>>
> >>>>>
> >>>> Try projecting div(Pu) onto piecewise constants and then pick the
> >>>> largest absolute value in the vector.
> >>>>
> >>>>
> >>>>
> >>>>
> >>> I need L_inf norm on the cell. With this way, doesn't give the L_inf for
> >>> the entire domain?
> >>>
> >>> murtazo
> >>>
> >>>
> >>>
> >> Instead of projecting div(Pu) onto piecewise constants, I projected it
> >> into dG(1), with this way I get three values on each cell, which I can
> >> then pick up the largest of them. That gives me then L_inf_K, where K is
> >> a cell. Now, I cannot figured out how is the numbering done for the
> >> dG(1) elements.
> >>
> >> If N is a total number of cells, then my projected vector Pdg has 3*N
> >> elements. How can I pick up elements of Pdg in the cell K?
> >>
> >> Thanks,
> >> murtazo
> >>
> >
> > Why do you use DG(1) instead of DG(0)? If you use DG(0), the numbering
> > is easier.
> >
> >
>
> DG(0) gives me an average of the function I have on the cell, however
> the values can be large on the vertices especially in the places where
> shocks exist.
>
> murtazo

ok, then I suggest working through tabulate_dofs in the DofMap class
to get the degrees of freedom for any given cell. Then you can just
access those from the vector.

--
Anders

> >
> >
> >
> >>>>> 2. ||\div(Pu)||_{L_1} ?
> >>>>>
> >>>>>
> >>>>>
> >>>> Try
> >>>>
> >>>> M = abs(div(Pu))*dx
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
> >>>>>
> >>>>> I use C++ interface
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>
> >
> >
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#9

Anders Logg wrote:
> Your question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Anders Logg posted a new comment:
> On Mon, Mar 15, 2010 at 03:45:30PM -0000, Murtazo Nazarov wrote:
>
>> Question #103034 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/103034
>>
>> Murtazo Nazarov posted a new comment:
>> Anders Logg wrote:
>>
>>> Your question #103034 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/103034
>>>
>>> Anders Logg posted a new comment:
>>> On Sun, Mar 14, 2010 at 11:48:21PM -0000, Murtazo Nazarov wrote:
>>>
>>>
>>>> Question #103034 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>
>>>> Murtazo Nazarov posted a new comment:
>>>> Murtazo Nazarov wrote:
>>>>
>>>>
>>>>> Your question #103034 on DOLFIN changed:
>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>
>>>>> Status: Answered => Open
>>>>>
>>>>> You are still having a problem:
>>>>> Anders Logg wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Question #103034 on DOLFIN changed:
>>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>>
>>>>>> Status: Open => Answered
>>>>>>
>>>>>> Anders Logg proposed the following answer:
>>>>>> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> New question #103034 on DOLFIN:
>>>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>>>>>>>
>>>>>>> 1. ||\div(Pu)||_{L_\infty} ?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Try projecting div(Pu) onto piecewise constants and then pick the
>>>>>> largest absolute value in the vector.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> I need L_inf norm on the cell. With this way, doesn't give the L_inf for
>>>>> the entire domain?
>>>>>
>>>>> murtazo
>>>>>
>>>>>
>>>>>
>>>>>
>>>> Instead of projecting div(Pu) onto piecewise constants, I projected it
>>>> into dG(1), with this way I get three values on each cell, which I can
>>>> then pick up the largest of them. That gives me then L_inf_K, where K is
>>>> a cell. Now, I cannot figured out how is the numbering done for the
>>>> dG(1) elements.
>>>>
>>>> If N is a total number of cells, then my projected vector Pdg has 3*N
>>>> elements. How can I pick up elements of Pdg in the cell K?
>>>>
>>>> Thanks,
>>>> murtazo
>>>>
>>>>
>>> Why do you use DG(1) instead of DG(0)? If you use DG(0), the numbering
>>> is easier.
>>>
>>>
>>>
>> DG(0) gives me an average of the function I have on the cell, however
>> the values can be large on the vertices especially in the places where
>> shocks exist.
>>
>> murtazo
>>
>
> ok, then I suggest working through tabulate_dofs in the DofMap class
> to get the degrees of freedom for any given cell. Then you can just
> access those from the vector.
>
> --
> Anders
>
>

I have some problem with dofmap for dG(1) elements. Here the piece of
the code I am using:

      const DofMap& dofmap = U.function_space().dofmap();
      real Umax = 0.;
      UFCCell ufc_cell(*cell);
      uint dofsize = dofmap.max_local_dimension();
      uint* cell_dofs = new uint[dofsize];
      dofmap.tabulate_dofs(cell_dofs, ufc_cell, cid);
      for (int i = 0; i < dofsize; i++){
        Umax = max(Umax, fabs(Uarr[cell_dofs[i]]));
      }

It works fine for dG(0), however it gives strange results for dG(1).

Can anyone help?

Thanks,
Murtazo

>
>>>
>>>
>>>>>>> 2. ||\div(Pu)||_{L_1} ?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Try
>>>>>>
>>>>>> M = abs(div(Pu))*dx
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>>>>>>>
>>>>>>> I use C++ interface
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>
>
>

Revision history for this message
Murtazo Nazarov (murtazo) said :
#10

Murtazo Nazarov wrote:
> Question #103034 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/103034
>
> Murtazo Nazarov posted a new comment:
> Anders Logg wrote:
>
>> Your question #103034 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/103034
>>
>> Anders Logg posted a new comment:
>> On Mon, Mar 15, 2010 at 03:45:30PM -0000, Murtazo Nazarov wrote:
>>
>>
>>> Question #103034 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/103034
>>>
>>> Murtazo Nazarov posted a new comment:
>>> Anders Logg wrote:
>>>
>>>
>>>> Your question #103034 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>
>>>> Anders Logg posted a new comment:
>>>> On Sun, Mar 14, 2010 at 11:48:21PM -0000, Murtazo Nazarov wrote:
>>>>
>>>>
>>>>
>>>>> Question #103034 on DOLFIN changed:
>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>
>>>>> Murtazo Nazarov posted a new comment:
>>>>> Murtazo Nazarov wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Your question #103034 on DOLFIN changed:
>>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>>
>>>>>> Status: Answered => Open
>>>>>>
>>>>>> You are still having a problem:
>>>>>> Anders Logg wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Question #103034 on DOLFIN changed:
>>>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>>>
>>>>>>> Status: Open => Answered
>>>>>>>
>>>>>>> Anders Logg proposed the following answer:
>>>>>>> On Wed, Mar 03, 2010 at 02:36:59AM -0000, Murtazo Nazarov wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> New question #103034 on DOLFIN:
>>>>>>>> https://answers.launchpad.net/dolfin/+question/103034
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am wondering how to compute an L1-norm, and L_inf norm of a functional on the cell. For instance how to compute
>>>>>>>>
>>>>>>>> 1. ||\div(Pu)||_{L_\infty} ?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Try projecting div(Pu) onto piecewise constants and then pick the
>>>>>>> largest absolute value in the vector.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> I need L_inf norm on the cell. With this way, doesn't give the L_inf for
>>>>>> the entire domain?
>>>>>>
>>>>>> murtazo
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> Instead of projecting div(Pu) onto piecewise constants, I projected it
>>>>> into dG(1), with this way I get three values on each cell, which I can
>>>>> then pick up the largest of them. That gives me then L_inf_K, where K is
>>>>> a cell. Now, I cannot figured out how is the numbering done for the
>>>>> dG(1) elements.
>>>>>
>>>>> If N is a total number of cells, then my projected vector Pdg has 3*N
>>>>> elements. How can I pick up elements of Pdg in the cell K?
>>>>>
>>>>> Thanks,
>>>>> murtazo
>>>>>
>>>>>
>>>>>
>>>> Why do you use DG(1) instead of DG(0)? If you use DG(0), the numbering
>>>> is easier.
>>>>
>>>>
>>>>
>>>>
>>> DG(0) gives me an average of the function I have on the cell, however
>>> the values can be large on the vertices especially in the places where
>>> shocks exist.
>>>
>>> murtazo
>>>
>>>
>> ok, then I suggest working through tabulate_dofs in the DofMap class
>> to get the degrees of freedom for any given cell. Then you can just
>> access those from the vector.
>>
>> --
>> Anders
>>
>>
>>
>
> I have some problem with dofmap for dG(1) elements. Here the piece of
> the code I am using:
>
> const DofMap& dofmap = U.function_space().dofmap();
> real Umax = 0.;
> UFCCell ufc_cell(*cell);
> uint dofsize = dofmap.max_local_dimension();
> uint* cell_dofs = new uint[dofsize];
> dofmap.tabulate_dofs(cell_dofs, ufc_cell, cid);
> for (int i = 0; i < dofsize; i++){
> Umax = max(Umax, fabs(Uarr[cell_dofs[i]]));
> }
>
> It works fine for dG(0), however it gives strange results for dG(1).
>
> Can anyone help?
>
> Thanks,
> Murtazo
>
>

it seems it works now.

murtazo

>
>>
>>
>>>>
>>>>
>>>>>>>> 2. ||\div(Pu)||_{L_1} ?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> Try
>>>>>>>
>>>>>>> M = abs(div(Pu))*dx
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> where u is velocity (vector) and P is pressure (scalar). L2 norm is obvious to do.
>>>>>>>>
>>>>>>>> I use C++ interface
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>
>>>>
>>
>
>