Re: [Paraview] Writing XML VTK Binary files from C++

2017-12-03 Thread Stegmeier, Nicholas
Hello again Mark,

I have been working on implementing the binary "inline" option for my VTK XML 
files. I looked through the OpenFOAM code that you suggested and am having 
trouble interpreting it.

Would you be able to give me a hint as to where I should be looking in 
foamVtkBase64Layer? For example, in my current code I write the array data like 
this:

  int i,j;
  ofstream lfile;

  lfile << "\t\t\t\t\n";
  lfile << "\t\t\t\t\t";
for (j = firsty-1; j <= lasty+1; j++){
for (i = firstx-1; i <= lastx+1; i++){
  lfile << rho[j][i][t] << " ";
}
}
  lfile << "\n";
  lfile << "\t\t\t\t\n";

 I have not used the write function in C++ before. Is there a quick way to 
explain how the above code would be modified (with the contents of "rho" being 
written to the file)? I wonder if I will run into a problem because of how I 
have set up the array with the 't' index last.

Thank you so much for your help so far.

Nicholas Stegmeier
Graduate Student
Mathematics and Statistics
South Dakota State University



From: Mark Olesen <mark.ole...@esi-group.com>
Sent: Friday, December 1, 2017 1:34:58 AM
To: Stegmeier, Nicholas; paraview@paraview.org
Subject: Re: [Paraview] Writing XML VTK Binary files from C++

When you say "writing binary", you need to distinguish between three
possibilities.
1) writing binary "inline" (actually base64 encoded)
2) writing binary "append" (actually base64 encoded)
3) writing raw binary "append" (really raw binary)

Since you already have ASCII writing working and its content is
"inline", it won't take much more to get binary inline working.
By "inline", I mean when the output is placed between the  
markers. Eg,
 
 content
 

For the binary case, the content is written as base64-encoded data,
which means that your output writer for these sections needs to pass the
content through a base64 layer to do the encoding for you.

If it helps as reference, we have the same thing in OpenFOAM, except
that we only write vtu and vtp files (we don't have rectilinear meshes).

In the repo https://develop.openfoam.com/Development/OpenFOAM-plus
we have a foamVtkBase64Formatter and a foamVtkBase64Layer (both under
src/fileFormats/vtk/format/) that add a base64Layer to encode and output
as base64 (src/OpenFOAM/db/IOstreams/hashes/base64Layer.[CH]).

You'll see that the foamVtkBase64Layer and base64Layer are quite low
level means of adding an tiny encoding buffer (3 chars size) to
intercept output prior to sending through to a std::ostream. It take
very little effort to adopt for your output and thus quite easy to drop
in instead of your current ASCII outputter.  For it too work easily,
however, you should make sure that you need to generate your output
content with a write() method instead of using '<<'. This allows
somewhat easy switching between something like a foamVtkAsciiFormatter
and the binary version, but more importantly it makes it easier to track
the output state.

When browsing through the code, you may also notice that we have support
for writing in appended format (raw and base64). However, I would not
advise you to tackle that immediately. There are a few more things to
watch out for here, but more importantly it will change many more things
on the calling side.

I hope this information helps you.
/mark

--
Dr Mark OLESEN
Principal Engineer, ESI-OpenCFD
ESI GmbH | Einsteinring 24 | 85609 Munich | GERMANY
www.openfoam.com<http://www.openfoam.com> | 
www.esi-group.com<http://www.esi-group.com> | mark.ole...@esi-group.com


On 11/30/17 18:00, Stegmeier, Nicholas wrote:
> Hello,
>
> I am new to Paraview and C++ coming from a mostly mathematics
> background. I am emailing to get resources or help on writing binary XML
> VTK files from C++.
>
> I have finally succeeded in using the ASCII XML VTK format for a 2D
> rectilinear CFD application. My ".pvtr" file is shown below.
>
> How can I write this file and my other XML VTK files in binary from C++?
> Do I need a special C++ library?
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] Writing XML VTK Binary files from C++

2017-12-01 Thread Stegmeier, Nicholas
Hello,


Thank you both for your advice. I will be sure to pursue both options and see 
if I can get them working.


Thank you again,

Nicholas Stegmeier


From: David E DeMarle <dave.dema...@kitware.com>
Sent: Friday, December 1, 2017 8:35:45 AM
To: Mark Olesen
Cc: Stegmeier, Nicholas; paraview@paraview.org
Subject: Re: [Paraview] Writing XML VTK Binary files from C++

Another approach is to use VTK itself to write the files.

Since VTK 6 it is straightforward to configure a VTK build consisting
of only the IO/ParallelXML module and its required dependencies. To do
so, in cmake, turn of testing, all groups and turn on
Module_vtkIOParallelXML, and you should be set.

David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Dec 1, 2017 at 2:34 AM, Mark Olesen <mark.ole...@esi-group.com> wrote:
> When you say "writing binary", you need to distinguish between three
> possibilities.
> 1) writing binary "inline" (actually base64 encoded)
> 2) writing binary "append" (actually base64 encoded)
> 3) writing raw binary "append" (really raw binary)
>
> Since you already have ASCII writing working and its content is "inline", it
> won't take much more to get binary inline working.
> By "inline", I mean when the output is placed between the  
> markers. Eg,
> 
> content
> 
>
> For the binary case, the content is written as base64-encoded data, which
> means that your output writer for these sections needs to pass the content
> through a base64 layer to do the encoding for you.
>
> If it helps as reference, we have the same thing in OpenFOAM, except that we
> only write vtu and vtp files (we don't have rectilinear meshes).
>
> In the repo https://develop.openfoam.com/Development/OpenFOAM-plus
> we have a foamVtkBase64Formatter and a foamVtkBase64Layer (both under
> src/fileFormats/vtk/format/) that add a base64Layer to encode and output as
> base64 (src/OpenFOAM/db/IOstreams/hashes/base64Layer.[CH]).
>
> You'll see that the foamVtkBase64Layer and base64Layer are quite low level
> means of adding an tiny encoding buffer (3 chars size) to intercept output
> prior to sending through to a std::ostream. It take very little effort to
> adopt for your output and thus quite easy to drop in instead of your current
> ASCII outputter.  For it too work easily, however, you should make sure that
> you need to generate your output content with a write() method instead of
> using '<<'. This allows somewhat easy switching between something like a
> foamVtkAsciiFormatter and the binary version, but more importantly it makes
> it easier to track the output state.
>
> When browsing through the code, you may also notice that we have support for
> writing in appended format (raw and base64). However, I would not advise you
> to tackle that immediately. There are a few more things to watch out for
> here, but more importantly it will change many more things on the calling
> side.
>
> I hope this information helps you.
> /mark
>
> --
> Dr Mark OLESEN
> Principal Engineer, ESI-OpenCFD
> ESI GmbH | Einsteinring 24 | 85609 Munich | GERMANY
> www.openfoam.com<http://www.openfoam.com> | 
> www.esi-group.com<http://www.esi-group.com> | mark.ole...@esi-group.com
>
>
> On 11/30/17 18:00, Stegmeier, Nicholas wrote:
>>
>> Hello,
>>
>> I am new to Paraview and C++ coming from a mostly mathematics background.
>> I am emailing to get resources or help on writing binary XML VTK files from
>> C++.
>>
>> I have finally succeeded in using the ASCII XML VTK format for a 2D
>> rectilinear CFD application. My ".pvtr" file is shown below.
>>
>> How can I write this file and my other XML VTK files in binary from C++?
>> Do I need a special C++ library?
>
> ___
> Powered by www.kitware.com<http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] Writing XML VTK Binary files from C++

2017-12-01 Thread David E DeMarle
Another approach is to use VTK itself to write the files.

Since VTK 6 it is straightforward to configure a VTK build consisting
of only the IO/ParallelXML module and its required dependencies. To do
so, in cmake, turn of testing, all groups and turn on
Module_vtkIOParallelXML, and you should be set.

David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Dec 1, 2017 at 2:34 AM, Mark Olesen  wrote:
> When you say "writing binary", you need to distinguish between three
> possibilities.
> 1) writing binary "inline" (actually base64 encoded)
> 2) writing binary "append" (actually base64 encoded)
> 3) writing raw binary "append" (really raw binary)
>
> Since you already have ASCII writing working and its content is "inline", it
> won't take much more to get binary inline working.
> By "inline", I mean when the output is placed between the  
> markers. Eg,
> 
> content
> 
>
> For the binary case, the content is written as base64-encoded data, which
> means that your output writer for these sections needs to pass the content
> through a base64 layer to do the encoding for you.
>
> If it helps as reference, we have the same thing in OpenFOAM, except that we
> only write vtu and vtp files (we don't have rectilinear meshes).
>
> In the repo https://develop.openfoam.com/Development/OpenFOAM-plus
> we have a foamVtkBase64Formatter and a foamVtkBase64Layer (both under
> src/fileFormats/vtk/format/) that add a base64Layer to encode and output as
> base64 (src/OpenFOAM/db/IOstreams/hashes/base64Layer.[CH]).
>
> You'll see that the foamVtkBase64Layer and base64Layer are quite low level
> means of adding an tiny encoding buffer (3 chars size) to intercept output
> prior to sending through to a std::ostream. It take very little effort to
> adopt for your output and thus quite easy to drop in instead of your current
> ASCII outputter.  For it too work easily, however, you should make sure that
> you need to generate your output content with a write() method instead of
> using '<<'. This allows somewhat easy switching between something like a
> foamVtkAsciiFormatter and the binary version, but more importantly it makes
> it easier to track the output state.
>
> When browsing through the code, you may also notice that we have support for
> writing in appended format (raw and base64). However, I would not advise you
> to tackle that immediately. There are a few more things to watch out for
> here, but more importantly it will change many more things on the calling
> side.
>
> I hope this information helps you.
> /mark
>
> --
> Dr Mark OLESEN
> Principal Engineer, ESI-OpenCFD
> ESI GmbH | Einsteinring 24 | 85609 Munich | GERMANY
> www.openfoam.com | www.esi-group.com | mark.ole...@esi-group.com
>
>
> On 11/30/17 18:00, Stegmeier, Nicholas wrote:
>>
>> Hello,
>>
>> I am new to Paraview and C++ coming from a mostly mathematics background.
>> I am emailing to get resources or help on writing binary XML VTK files from
>> C++.
>>
>> I have finally succeeded in using the ASCII XML VTK format for a 2D
>> rectilinear CFD application. My ".pvtr" file is shown below.
>>
>> How can I write this file and my other XML VTK files in binary from C++?
>> Do I need a special C++ library?
>
> ___
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview


Re: [Paraview] Writing XML VTK Binary files from C++

2017-11-30 Thread Mark Olesen
When you say "writing binary", you need to distinguish between three 
possibilities.

1) writing binary "inline" (actually base64 encoded)
2) writing binary "append" (actually base64 encoded)
3) writing raw binary "append" (really raw binary)

Since you already have ASCII writing working and its content is 
"inline", it won't take much more to get binary inline working.
By "inline", I mean when the output is placed between the   
markers. Eg,


content


For the binary case, the content is written as base64-encoded data, 
which means that your output writer for these sections needs to pass the 
content through a base64 layer to do the encoding for you.


If it helps as reference, we have the same thing in OpenFOAM, except 
that we only write vtu and vtp files (we don't have rectilinear meshes).


In the repo https://develop.openfoam.com/Development/OpenFOAM-plus
we have a foamVtkBase64Formatter and a foamVtkBase64Layer (both under 
src/fileFormats/vtk/format/) that add a base64Layer to encode and output 
as base64 (src/OpenFOAM/db/IOstreams/hashes/base64Layer.[CH]).


You'll see that the foamVtkBase64Layer and base64Layer are quite low 
level means of adding an tiny encoding buffer (3 chars size) to 
intercept output prior to sending through to a std::ostream. It take 
very little effort to adopt for your output and thus quite easy to drop 
in instead of your current ASCII outputter.  For it too work easily, 
however, you should make sure that you need to generate your output 
content with a write() method instead of using '<<'. This allows 
somewhat easy switching between something like a foamVtkAsciiFormatter 
and the binary version, but more importantly it makes it easier to track 
the output state.


When browsing through the code, you may also notice that we have support 
for writing in appended format (raw and base64). However, I would not 
advise you to tackle that immediately. There are a few more things to 
watch out for here, but more importantly it will change many more things 
on the calling side.


I hope this information helps you.
/mark

--
Dr Mark OLESEN
Principal Engineer, ESI-OpenCFD
ESI GmbH | Einsteinring 24 | 85609 Munich | GERMANY
www.openfoam.com | www.esi-group.com | mark.ole...@esi-group.com


On 11/30/17 18:00, Stegmeier, Nicholas wrote:

Hello,

I am new to Paraview and C++ coming from a mostly mathematics 
background. I am emailing to get resources or help on writing binary XML 
VTK files from C++.


I have finally succeeded in using the ASCII XML VTK format for a 2D 
rectilinear CFD application. My ".pvtr" file is shown below.


How can I write this file and my other XML VTK files in binary from C++? 
Do I need a special C++ library?

___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview