Save DG solution to file without any projection

Asked by Praveen C

Hello

Is it possible to save a DG solution to file (for visualization or some other post-processing) without any projection to a CG space. I guess this should be possible with some extra coding, but I need some help on this.

Saving in xml format has the full DG solution, but which softwares are able to visualize xml files ? At present I just need 1-D xy plots.

praveen

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Johan Hake
Solved:
Last query:
Last reply:
Revision history for this message
Garth Wells (garth-wells) said :
#1

DG0 can be sent to a VTK without projection. Higher orders require projection or some form of interpolation.

XML files cannot be visualised.

Revision history for this message
Praveen C (cpraveen) said :
#2

I am saving the numpy array to a file. But how can I get the spatial location of the dof ? I am using "DG" basis functions of degree >= 1. In one dimension, are the dof locations of DG lagrange basis function equally spaced in each cell ? Then I can generate the spatial locations of dof values myself.

In deal.II I am able to save the discontinuous solution, and these can be seen in vtk or tecplot format. The visualization tools like paraview/tecplot are capable of displaying discontinuous solutions.

Revision history for this message
Kristian B. Ølgaard (k.b.oelgaard) said :
#3

On 25 October 2011 07:25, Praveen C
<email address hidden> wrote:
> Question #175835 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/175835
>
>    Status: Answered => Open
>
> Praveen C is still having a problem:
> I am saving the numpy array to a file. But how can I get the spatial
> location of the dof ?

Use DofMap::tabulate_coordinates()

http://fenicsproject.org/doc/dolfin/dev/python/programmers-reference/cpp/GenericDofMap.html#dolfin.cpp.GenericDofMap

Kristian

 I am using "DG" basis functions of degree >= 1. In
> one dimension, are the dof locations of DG lagrange basis function
> equally spaced in each cell ? Then I can generate the spatial locations
> of dof values myself.
>
> In deal.II I am able to save the discontinuous solution, and these can
> be seen in vtk or tecplot format. The visualization tools like
> paraview/tecplot are capable of displaying discontinuous solutions.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Revision history for this message
Praveen C (cpraveen) said :
#4

Do I need to use c++ for this ?

Revision history for this message
Johan Hake (johan-hake) said :
#5

On Tuesday October 25 2011 08:00:57 Praveen C wrote:
> Question #175835 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/175835
>
> Status: Answered => Open
>
> Praveen C is still having a problem:
> Do I need to use c++ for this ?

No. Try something like:

  mesh = UnitCube(2,2,2)
  V = FunctionSpace(mesh, "DG", 1)
  for cell in cells(mesh):
      print V.dofmap().tabulate_coordinates(cell)

To speedup it up a bit you can also pass a 2D numpy array as a second argument
to tabulate_coordinates, then that one will be filled with the tabulated
coordinates.

Johan

Revision history for this message
Praveen C (cpraveen) said :
#6

Thanks Johan. I am able to use tabulate_coordinates. Where can I find information about the other functions in GenericDofMap like cell_dofs and tabulate_dofs ? I want to know the arguments for those functions.

Revision history for this message
Best Johan Hake (johan-hake) said :
#7

On Tuesday October 25 2011 10:20:55 Praveen C wrote:
> Question #175835 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/175835
>
> Status: Answered => Open
>
> Praveen C is still having a problem:
> Thanks Johan. I am able to use tabulate_coordinates. Where can I find
> information about the other functions in GenericDofMap like cell_dofs
> and tabulate_dofs ? I want to know the arguments for those functions.

Well there aren't too much of documentation available for these functions, and
I guess that need to be added in the C++ header files. But they have been
considered low level functions with low priority for documentation.

That said whenever the C++ interface wants a {double,int, uint}* or
std::vector of these types, think numpy arrays in python. We have also wrapped
most some_map<uint, {uint, int, double}> out arguments to Python. You will
then receive a python dict.

Also have alook in the DofMap unit test for more info of the use of tabulating
dofs and coordinates.

  test/unit/fem/python/DofMap.py

Johan

Revision history for this message
Praveen C (cpraveen) said :
#8

Thanks Johan Hake, that solved my question.