Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-10-03 Thread Tetsuo Koyama
P.S. Sorry, I pushed devel-tetsuo-xml-binary by mistake. Delete
devel-tetsuo-xml-binary and merge devel-tetsuo-xml-binary-squash with the
commit squashed.

2020年10月4日(日) 10:02 Tetsuo Koyama :

> Dear Yves and Kostas
>
> I hope you are well.  I finally completed adding the VTU binary output
> and its testing.
>
> I added "tests/python/check_export_vtu.py" to test the output of the
> VTK/VTU file in more detail.
> To run this test you need to use pyvisa which can be installed by command.
> $ pip3 install pyvista
>
> Could you please merge devel-tetsuo-xml-binary-squash ?
>
> Best Regards
>
> 2020年5月28日(木) 20:54 Tetsuo Koyama :
>
>> Dear Yves
>>
>> Thank you for your merge.
>>
>> Dear Kostas
>>
>> Thank you for your comment. I will fix it in next branch.
>>
>> Best regards Tetsuo
>>
>> 2020年5月28日(木) 19:14 Yves Renard :
>> >
>> > Dear all,
>> >
>> > I did the merge.
>> >
>> > Best regards,
>> >
>> > Yves
>> >
>> > - Mail original -
>> > De: "logari81" 
>> > À: "Tetsuo Koyama" 
>> > Cc: "yves renard" , "getfem-commits" <
>> getfem-commits@nongnu.org>
>> > Envoyé: Mercredi 27 Mai 2020 16:47:40
>> > Objet: Re: [Getfem-commits] please merge branch devel-tetsuo-xml
>> >
>> > it looks good and clean. Thanks. I will do the merge later if Yves
>> doesn't
>> > do it first.
>> >
>> > Just a minor comment. Now in modern C++ we use to rewrite the old loops
>> > like this
>> >
>> > for (size_type i=0; i < s.size(); ++i) {
>> >   write_val(int(vtk_simplex_code[s[i].dim()]));
>> > }
>> >
>> > to
>> >
>> > for (const auto  : s)
>> >   write_val(int(vtk_simplex_code[val.dim()]));
>> >
>> > if possible. You can also drop the extra brackets {} if they are not
>> > necessary.
>> >
>> > BR
>> > Kostas
>> >
>> > On Wed, May 27, 2020 at 3:03 AM Tetsuo Koyama 
>> wrote:
>> >
>> > > P.S. branch is devel-tetsuo-xml-slices
>> > >
>> > > 2020年5月27日(水) 10:02 Tetsuo Koyama :
>> > > >
>> > > > Dear all
>> > > >
>> > > > I added the following functions and confirmed that the test passed.
>> It
>> > > > is ready for merge.
>> > > > > 2) make exporting slices work for VTU. Based on my refactored
>> version,
>> > > it shouldn't be difficult.
>> > > >
>> > > > I plan to add 1) 3) after this.
>> > > >
>> > > > BR Tetsuo
>> > > >
>> > > > 2020年5月26日(火) 2:01 Yves Renard :
>> > > > >
>> > > > >
>> > > > > Dear all,
>> > > > >
>> > > > > Ok, I merged the branch and I will proceed with 5.4.1 patch
>> version.
>> > > > >
>> > > > > Best regards,
>> > > > >
>> > > > > Yves
>> > > > >
>> > > > > - Mail original -
>> > > > > De: "logari81" 
>> > > > > À: "Tetsuo Koyama" 
>> > > > > Cc: "getfem-commits" , "yves renard" <
>> > > yves.ren...@insa-lyon.fr>
>> > > > > Envoyé: Lundi 25 Mai 2020 15:04:23
>> > > > > Objet: Re: [Getfem-commits] please merge branch devel-tetsuo-xml
>> > > > >
>> > > > > Dear Tetsuo,
>> > > > >
>> > > > > Great, thanks for testing and for the original vtu
>> implementation. It
>> > > is a
>> > > > > very useful feature.
>> > > > >
>> > > > > I will let Yves do the merge. I think he will prepare a 5.4.1
>> version
>> > > soon
>> > > > > to fix the issues with 5.4. on Ubuntu 20.04.
>> > > > >
>> > > > > Best regards
>> > > > > Kostas
>> > > > >
>> > > > >
>> > > > > On Mon, May 25, 2020 at 2:32 PM Tetsuo Koyama <
>> tkoyama...@gmail.com>
>> > > wrote:
>> > > > >
>> > > > > > Dear Kostas
>> > > > > >
>> > > > > > My test of branch devel-logari81-xml was passed.
>> > > > > > Your branch is awesome.
>> > > > > > I think it is a very good idea to add vtk as a option too.
>> > > > > > Could you merge this branch?
>> > > > > > After that I will checkout new branch to add more functionality.
>> > > > > >
>> > > > > > Best regards Tetsuo
>> > > > > >
>> > > > > > 2020年5月24日(日) 20:49 Tetsuo Koyama :
>> > > > > > >
>> > > > > > > Dear Kostas
>> > > > > > >
>> > > > > > > Sorry for my late reply and thank you for your refactoring.
>> > > > > > > I'll check it and will continue you proposal. After I finished
>> > > > > > > development, I'll contact getfem project to merge.
>> > > > > > > Thanks for your advice.
>> > > > > > >
>> > > > > > > Best regards Tetsuo
>> > > > > > >
>> > > > > > > 2020年5月24日(日) 4:13 Konstantinos Poulios <
>> logar...@googlemail.com>:
>> > > > > > > >
>> > > > > > > > Dear Tetsuo,
>> > > > > > > >
>> > > > > > > > I have revised your code and refactored it in my
>> > > logari81-devel-xml
>> > > > > > branch. Can you test that my refactored version works as your
>> > > original
>> > > > > > version? I removed your "only_mesh" option intentionally.
>> > > > > > > >
>> > > > > > > > Moreover, it would be nice if you could:
>> > > > > > > > 1) implement the scripting interface for vtu export.
>> > > > > > > > 2) make exporting slices work for VTU. Based on my
>> refactored
>> > > version,
>> > > > > > it shouldn't be difficult.
>> > > > > > > > 3) implement the binary version of VTU.
>> > > > > > > >
>> > > > > > > > Best regards
>> > > > > > > > Kostas
>> > > > > > > >
>> > > > > > > > On Wed, May 13, 2020 

[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary-squash
commit 732533f63e119c7f96e3d54a3e8e032b1356f933
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 09:37:05 2020 +0900

Add VTU(XML) binary option
---
 .travis.yml|   1 +
 interface/src/gf_mesh_fem_get.cc   |  33 +++
 interface/src/gf_mesh_get.cc   |  25 ++
 interface/src/gf_slice_get.cc  |  72 +++
 interface/tests/python/Makefile.am |   2 +
 interface/tests/python/check_export_vtu.py |  60 +
 requirements.txt   |   1 +
 src/getfem/getfem_export.h |  51 ++-
 src/getfem_export.cc   | 139 ++---
 9 files changed, 331 insertions(+), 53 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index f8a6b9b..7b7d300 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,6 +24,7 @@ before_install:
 - sudo apt-get install -y --no-install-recommends xzdec
 - sudo apt-get install -y --no-install-recommends fig2ps
 - sudo apt-get install -y --no-install-recommends gv
+- sudo apt-get install -y --no-install-recommends python3-vtk7
 - pip install -r requirements.txt
 addons:
   apt:
diff --git a/interface/src/gf_mesh_fem_get.cc b/interface/src/gf_mesh_fem_get.cc
index 03abb0c..8a179b1 100644
--- a/interface/src/gf_mesh_fem_get.cc
+++ b/interface/src/gf_mesh_fem_get.cc
@@ -763,6 +763,39 @@ void gf_mesh_fem_get(getfemint::mexargs_in& m_in,
}
);
 
+/*@GET ('export to vtu',@str filename, ... ['ascii'], U, 'name'...)
+Export a @tmf and some fields to a vtu file.
+
+The FEM and geometric transformations will be mapped to order 1
+or 2 isoparametric Pk (or Qk) FEMs (as VTK(XML) does not handle higher
+order elements). If you need to represent high-order FEMs or
+high-order geometric transformations, you should consider
+SLICE:GET('export to vtu').@*/
+sub_command
+  ("export to vtu", 0, -1, 0, 0,
+   std::string fname = in.pop().to_string();
+   bool ascii = false;
+   while (in.remaining() && in.front().is_string()) {
+std::string cmd2 = in.pop().to_string();
+if (cmd_strmatch(cmd2, "ascii"))
+  ascii = true;
+else THROW_BADARG("expecting 'ascii', got " << cmd2);
+   }
+   getfem::vtu_export exp(fname, ascii);
+   exp.exporting(*mf);
+   exp.write_mesh();
+   int count = 1;
+   while (in.remaining()) {
+const getfem::mesh_fem *mf2 = mf;
+if (in.remaining() >= 2 && is_meshfem_object(in.front()))
+  mf2 = to_meshfem_object(in.pop());
+darray U = in.pop().to_darray();
+in.last_popped().check_trailing_dimension(int(mf2->nb_dof()));
+exp.write_point_data(*mf2, U, get_vtk_dataset_name(in, count));
+count+=1;
+   }
+   );
+
 
 /*@GET ('export to dx',@str filename, ...['as', @str 
mesh_name][,'edges']['serie',@str serie_name][,'ascii'][,'append'], U, 
'name'...)
 Export a @tmf and some fields to an OpenDX file.
diff --git a/interface/src/gf_mesh_get.cc b/interface/src/gf_mesh_get.cc
index 6c9687f..9fcf011 100644
--- a/interface/src/gf_mesh_get.cc
+++ b/interface/src/gf_mesh_get.cc
@@ -1247,6 +1247,31 @@ void gf_mesh_get(getfemint::mexargs_in& m_in,
);
 
 
+/*@GET ('export to vtu', @str filename, ... [,'ascii'][,'quality'])
+Exports a mesh to a VTK(XML) file .
+
+If 'quality' is specified, an estimation of the quality of each
+convex will be written to the file.
+
+See also MESH_FEM:GET('export to vtu'), SLICE:GET('export to vtu').@*/
+sub_command
+  ("export to vtu", 1, 3, 0, 1,
+   bool write_q = false; bool ascii = false;
+   std::string fname = in.pop().to_string();
+   while (in.remaining() && in.front().is_string()) {
+ std::string cmd2 = in.pop().to_string();
+ if (cmd_strmatch(cmd2, "ascii"))
+   ascii = true;
+ else if (cmd_strmatch(cmd2, "quality"))
+   write_q = true;
+ else THROW_BADARG("expecting 'ascii' or 'quality', got " << cmd2);
+   }
+   getfem::vtu_export exp(fname, ascii);
+   exp.exporting(*pmesh);
+   exp.write_mesh(); if (write_q) exp.write_mesh_quality(*pmesh);
+   );
+
+
 /*@GET ('export to dx', @str filename, ... 
[,'ascii'][,'append'][,'as',@str name,[,'serie',@str serie_name]][,'edges'])
 Exports a mesh to an OpenDX file.
 
diff --git a/interface/src/gf_slice_get.cc b/interface/src/gf_slice_get.cc
index 985072c..9a47f09 100644
--- a/interface/src/gf_slice_get.cc
+++ b/interface/src/gf_slice_get.cc
@@ -438,6 +438,78 @@ void gf_slice_get(getfemint::mexargs_in& m_in,
);
 
 
+/*@GET ('export to vtu', @str filename, ...)
+Export a slice to VTK(XML).
+
+Following the `filename`, you may use any of the following options:
+
+- if 'ascii' is not used, the file will contain binary data
+  (non portable, but fast).
+- if 'edges' is used, the edges of the 

[Getfem-commits] [getfem-commits] branch devel-tetsuo-xml-binary-squash created (now 732533f)

2020-10-03 Thread Tetsuo Koyama
tkoyama010 pushed a change to branch devel-tetsuo-xml-binary-squash.

  at 732533f  Add VTU(XML) binary option

This branch includes the following new commits:

 new 732533f  Add VTU(XML) binary option




Re: [Getfem-commits] please merge branch devel-tetsuo-xml

2020-10-03 Thread Tetsuo Koyama
Dear Yves and Kostas

I hope you are well.  I finally completed adding the VTU binary output and
its testing.

I added "tests/python/check_export_vtu.py" to test the output of the
VTK/VTU file in more detail.
To run this test you need to use pyvisa which can be installed by command.
$ pip3 install pyvista

Could you please merge devel-tetsuo-xml-binary-squash ?

Best Regards

2020年5月28日(木) 20:54 Tetsuo Koyama :

> Dear Yves
>
> Thank you for your merge.
>
> Dear Kostas
>
> Thank you for your comment. I will fix it in next branch.
>
> Best regards Tetsuo
>
> 2020年5月28日(木) 19:14 Yves Renard :
> >
> > Dear all,
> >
> > I did the merge.
> >
> > Best regards,
> >
> > Yves
> >
> > - Mail original -
> > De: "logari81" 
> > À: "Tetsuo Koyama" 
> > Cc: "yves renard" , "getfem-commits" <
> getfem-commits@nongnu.org>
> > Envoyé: Mercredi 27 Mai 2020 16:47:40
> > Objet: Re: [Getfem-commits] please merge branch devel-tetsuo-xml
> >
> > it looks good and clean. Thanks. I will do the merge later if Yves
> doesn't
> > do it first.
> >
> > Just a minor comment. Now in modern C++ we use to rewrite the old loops
> > like this
> >
> > for (size_type i=0; i < s.size(); ++i) {
> >   write_val(int(vtk_simplex_code[s[i].dim()]));
> > }
> >
> > to
> >
> > for (const auto  : s)
> >   write_val(int(vtk_simplex_code[val.dim()]));
> >
> > if possible. You can also drop the extra brackets {} if they are not
> > necessary.
> >
> > BR
> > Kostas
> >
> > On Wed, May 27, 2020 at 3:03 AM Tetsuo Koyama 
> wrote:
> >
> > > P.S. branch is devel-tetsuo-xml-slices
> > >
> > > 2020年5月27日(水) 10:02 Tetsuo Koyama :
> > > >
> > > > Dear all
> > > >
> > > > I added the following functions and confirmed that the test passed.
> It
> > > > is ready for merge.
> > > > > 2) make exporting slices work for VTU. Based on my refactored
> version,
> > > it shouldn't be difficult.
> > > >
> > > > I plan to add 1) 3) after this.
> > > >
> > > > BR Tetsuo
> > > >
> > > > 2020年5月26日(火) 2:01 Yves Renard :
> > > > >
> > > > >
> > > > > Dear all,
> > > > >
> > > > > Ok, I merged the branch and I will proceed with 5.4.1 patch
> version.
> > > > >
> > > > > Best regards,
> > > > >
> > > > > Yves
> > > > >
> > > > > - Mail original -
> > > > > De: "logari81" 
> > > > > À: "Tetsuo Koyama" 
> > > > > Cc: "getfem-commits" , "yves renard" <
> > > yves.ren...@insa-lyon.fr>
> > > > > Envoyé: Lundi 25 Mai 2020 15:04:23
> > > > > Objet: Re: [Getfem-commits] please merge branch devel-tetsuo-xml
> > > > >
> > > > > Dear Tetsuo,
> > > > >
> > > > > Great, thanks for testing and for the original vtu implementation.
> It
> > > is a
> > > > > very useful feature.
> > > > >
> > > > > I will let Yves do the merge. I think he will prepare a 5.4.1
> version
> > > soon
> > > > > to fix the issues with 5.4. on Ubuntu 20.04.
> > > > >
> > > > > Best regards
> > > > > Kostas
> > > > >
> > > > >
> > > > > On Mon, May 25, 2020 at 2:32 PM Tetsuo Koyama <
> tkoyama...@gmail.com>
> > > wrote:
> > > > >
> > > > > > Dear Kostas
> > > > > >
> > > > > > My test of branch devel-logari81-xml was passed.
> > > > > > Your branch is awesome.
> > > > > > I think it is a very good idea to add vtk as a option too.
> > > > > > Could you merge this branch?
> > > > > > After that I will checkout new branch to add more functionality.
> > > > > >
> > > > > > Best regards Tetsuo
> > > > > >
> > > > > > 2020年5月24日(日) 20:49 Tetsuo Koyama :
> > > > > > >
> > > > > > > Dear Kostas
> > > > > > >
> > > > > > > Sorry for my late reply and thank you for your refactoring.
> > > > > > > I'll check it and will continue you proposal. After I finished
> > > > > > > development, I'll contact getfem project to merge.
> > > > > > > Thanks for your advice.
> > > > > > >
> > > > > > > Best regards Tetsuo
> > > > > > >
> > > > > > > 2020年5月24日(日) 4:13 Konstantinos Poulios <
> logar...@googlemail.com>:
> > > > > > > >
> > > > > > > > Dear Tetsuo,
> > > > > > > >
> > > > > > > > I have revised your code and refactored it in my
> > > logari81-devel-xml
> > > > > > branch. Can you test that my refactored version works as your
> > > original
> > > > > > version? I removed your "only_mesh" option intentionally.
> > > > > > > >
> > > > > > > > Moreover, it would be nice if you could:
> > > > > > > > 1) implement the scripting interface for vtu export.
> > > > > > > > 2) make exporting slices work for VTU. Based on my refactored
> > > version,
> > > > > > it shouldn't be difficult.
> > > > > > > > 3) implement the binary version of VTU.
> > > > > > > >
> > > > > > > > Best regards
> > > > > > > > Kostas
> > > > > > > >
> > > > > > > > On Wed, May 13, 2020 at 3:35 PM Tetsuo Koyama <
> > > tkoyama...@gmail.com>
> > > > > > wrote:
> > > > > > > >>
> > > > > > > >> I forgot to CC: in the last email, so I am re-sending it.
> > > > > > > >> --
> > > > > > > >> Dear Kostas
> > > > > > > >>
> > > > > > > >> Thank you for your reply.
> > > > > > > >> > Thanks for your answer. Your code looks quite nice
> actually.
> > > I 

[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit e7cf0ce4e2c0ce9f861d1386ee62afd05d6d2829
Author: Tetsuo Koyama 
AuthorDate: Fri Sep 4 00:55:59 2020 +0900

convert test from vtk to pyvista
---
 interface/tests/python/check_export_vtu.py | 35 +++---
 requirements.txt   |  2 +-
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index e0ec891..dfdd7cb 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -26,28 +26,29 @@
 
   $Id$
 """
-import vtk
 import getfem as gf
+import numpy as np
+import pyvista as pv
 
-m0 = gf.Mesh("cartesian", [0, 1])
+convex_connectivity = np.array([0, 1])
+mesh = gf.Mesh("cartesian", convex_connectivity * 2)
+pts = mesh.pts()[0]
 
-filenames = ["check_m0_ascii.vtu", "check_m0_binary.vtu"]
 
-m0.export_to_vtu(filenames[0], "ascii")
-filenames.append(filenames[0])
+filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
 
-m0.export_to_vtu(filenames[1])
-filenames.append(filenames[1])
+mesh.export_to_vtu(filenames[0], "ascii")
+
+mesh.export_to_vtu(filenames[1])
 
 for filename in filenames:
 print(filename)
-reader = vtk.vtkXMLUnstructuredGridReader()
-reader.SetFileName(filename)
-reader.Update()
-output = reader.GetOutput()
-cell_data = output.GetCellData()
-nbpts = output.GetNumberOfPoints()
-nbcvs = output.GetNumberOfCells()
-array_name = cell_data.GetArrayName(0)
-assert nbpts == m0.nbpts(), "Number of points is not correct."
-assert nbcvs == m0.nbcvs(), "Number of cells is not correct."
+unstructured_grid = pv.read(filename)
+
+expected = pts
+actual = unstructured_grid.points[:, 0]
+np.testing.assert_equal(expected, actual, "export of mesh pts is not 
correct.")
+
+expected = convex_connectivity
+actual = unstructured_grid.cell_connectivity
+np.testing.assert_equal(expected, actual, "export of mesh convex is not 
correct.")
diff --git a/requirements.txt b/requirements.txt
index 13536d5..5b55979 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
 numpy
 scipy
 Sphinx
-vtk
+pyvista



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 3447cb1e156b853ff77e08dcc24aff9234021a66
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:40:47 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 534a936..40e3e17 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -51,7 +51,7 @@ namespace getfem
   {
 const std::string 
table("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
 std::string dst;
-for (std::size_t i = 0; i < src.size(); ++i) {
+for (size_type i = 0; i < src.size(); ++i) {
   switch (i % 3) {
   case 0:
 dst.push_back(table[(src[i] & 0xFC) >> 2]);



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit aa90662b6ec169000b534a82b1e3f7438434a48d
Author: Tetsuo Koyama 
AuthorDate: Fri Oct 2 19:04:12 2020 +0900

Fix test error by hard coding
---
 src/getfem_export.cc | 43 ---
 1 file changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 1649c17..8e9bdd3 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -568,16 +568,26 @@ namespace getfem
   os << "\n";
   os << "\n" : "format=\"binary\">\n");
-}
-
-for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
-  const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-  if (vtk) write_val(int(dmap.size()));
-  if (!vtk && !ascii) write_val(int(sizeof(int64_t)*dmap.size()));
-  for (size_type i=0; i < dmap.size(); ++i)
-write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
+  // TODO: genelize to multi cell
+  //if (!ascii) write_val(sizeof(int64_t)*4);
+  if (!ascii) write_val(32);
+  write_val(int64_t(0));
+  write_val(int64_t(1));
+  write_separ();
+  write_val(int64_t(1));
+  write_val(int64_t(2));
   write_separ();
 }
+
+// TODO: genelize to multi cell
+//  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+//const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
+//if (vtk) write_val(int(dmap.size()));
+//if (!vtk && !ascii) write_val(int(sizeof(int64_t)*dmap.size()));
+//for (size_type i=0; i < dmap.size(); ++i)
+//  write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
+//write_separ();
+//  }
 write_vals();
 
 if (vtk) {
@@ -588,21 +598,24 @@ namespace getfem
   os << "\n" : "format=\"binary\">\n");
   cnt = 0;
-  size = sizeof(int64_t);
-  write_val(size);
+  // TODO: genelize to multi cell
+  //if (!ascii) write_val(sizeof(int64_t)*2);
+  if (!ascii) write_val(16);
   write_val(int64_t(2));
+  write_val(int64_t(4));
   write_vals();
-  os << (ascii ? "" : "\n") << "\n";
+  os << "\n" << "\n";
   os << "\n" : "format=\"binary\">\n");
 }
 size = sizeof(int64_t);
-write_val(size);
+// TODO: genelize to multi cell
+//if (!ascii) write_val(sizeof(int64_t)*2);
+if (!ascii) write_val(16);
+write_val(int64_t(3));
 write_val(int64_t(3));
 write_vals();
-if (!vtk)
-  os << (ascii ? "" : "\n") << "\n"
- << "\n";
+if (!vtk) os << "\n" << "\n" << "\n";
 
 state = STRUCTURE_WRITTEN;
   }



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 5d71b1572b2d44ddbb7f0b9d7f203703a1cb73dd
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 00:39:00 2020 +0900

Update check_export_vtu.py
---
 interface/tests/python/check_export_vtu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index dfdd7cb..8894968 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -31,7 +31,7 @@ import numpy as np
 import pyvista as pv
 
 convex_connectivity = np.array([0, 1])
-mesh = gf.Mesh("cartesian", convex_connectivity * 2)
+mesh = gf.Mesh("cartesian", convex_connectivity)
 pts = mesh.pts()[0]
 
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 46f6fa69c24f096d0c420528bd5d85c2caef7792
Author: Tetsuo Koyama 
AuthorDate: Sat Oct 3 23:51:13 2020 +0900

Update size print
---
 src/getfem_export.cc | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index c7313e9..00fe7a3 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -570,7 +570,11 @@ namespace getfem
   os << (ascii ? "format=\"ascii\">\n" : "format=\"binary\">\n");
   // TODO: genelize to multi cell
   if (!vtk && !ascii) {
-int size = sizeof(int64_t)*4;
+int size = 0;
+for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+  const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
+  size += sizeof(int64_t)*dmap.size();
+}
 write_val(size);
   }
   write_val(int64_t(0));



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 029dd9274af80938123d74b5bb24145cb5a7222b
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 02:26:52 2020 +0900

Fix type
---
 interface/tests/python/check_mesh_ascii.vtu  |  6 +++---
 interface/tests/python/check_mesh_binary.vtu | 12 ++--
 src/getfem_export.cc | 28 +++-
 3 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/interface/tests/python/check_mesh_ascii.vtu 
b/interface/tests/python/check_mesh_ascii.vtu
index 97edd31..a5a87f1 100644
--- a/interface/tests/python/check_mesh_ascii.vtu
+++ b/interface/tests/python/check_mesh_ascii.vtu
@@ -11,14 +11,14 @@
 
 
 
-
+
  0 1
  1 2
 
-
+
  2 4
 
-
+
  3 3
 
 
diff --git a/interface/tests/python/check_mesh_binary.vtu 
b/interface/tests/python/check_mesh_binary.vtu
index e271a5f..35f4af6 100644
--- a/interface/tests/python/check_mesh_binary.vtu
+++ b/interface/tests/python/check_mesh_binary.vtu
@@ -9,14 +9,14 @@ JAAAgD8AAE==
 
 
 
-
-IQABAAIA
+
+EAABAQI=
 
-
-EAIABAA=
+
+CAIE
 
-
-EAMAAwA=
+
+CAMD
 
 
 
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 49fe774..28e85cc 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -471,7 +471,7 @@ namespace getfem
   write_separ(); os << "CELLS " << splx_cnt << " " << cells_cnt << "\n";
 } else {
   os << "\n";
-  os << "\n" : "format=\"binary\">\n");
 }
 for (size_type ic=0; ic < psl->nb_convex(); ++ic) {
@@ -492,7 +492,7 @@ namespace getfem
   write_separ(); os << "CELL_TYPES " << splx_cnt << "\n";
 } else {
   os << (ascii ? "" : "\n") << "\n";
-  os << "\n" : "format=\"binary\">\n");
 }
 int cnt = 0;
@@ -512,7 +512,7 @@ namespace getfem
 assert(splx_cnt == 0); // sanity check
 if (!vtk) {
   os << (ascii ? "" : "\n") << "\n";
-  os << "\n" : "format=\"binary\">\n");
   for (size_type ic=0; ic < psl->nb_convex(); ++ic) {
 const getfem::mesh_slicer::cs_simplexes_ct& s = psl->simplexes(ic);
@@ -566,13 +566,13 @@ namespace getfem
   os << (ascii ? "" : "\n") << "\n";
   os << "\n";
   os << "\n";
-  os << "\n" : "format=\"binary\">\n");
   if (!vtk && !ascii) {
 int size = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
   const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-  size += sizeof(int64_t)*dmap.size();
+  size += sizeof(int)*dmap.size();
 }
 write_val(size);
   }
@@ -582,7 +582,7 @@ namespace getfem
   const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
   if (vtk) write_val(int(dmap.size()));
   for (size_type i=0; i < dmap.size(); ++i)
-write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
+write_val(int(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
   write_separ();
 }
 write_vals();
@@ -592,30 +592,32 @@ namespace getfem
   os << "CELL_TYPES " << pmf->convex_index().card() << "\n";
 } else {
   os << (ascii ? "" : "\n") << "\n";
-  os << "\n" : "format=\"binary\">\n");
-  int64_t cnt = 0;
+  int cnt = 0;
   if (!vtk && !ascii) {
-int size = sizeof(int64_t)*2;
+int size = sizeof(int)*2;
 write_val(size);
   }
   for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
 const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-cnt += int64_t(dmap.size());
+cnt += int(dmap.size());
 write_val(cnt);
 if (vtk) write_separ();
   }
   write_vals();
   os << "\n" << "\n";
-  os << "\n" : "format=\"binary\">\n");
 }
 if (!vtk && !ascii) {
-  int size = sizeof(int64_t)*2;
+  int size = 0;
+  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
+size += sizeof(int);
   write_val(size);
 }
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
-  write_val(int64_t(select_vtk_type(pmf_mapping_type[cv])));
+  write_val(int(select_vtk_type(pmf_mapping_type[cv])));
   if (vtk) write_separ();
 }
 write_vals();



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 1b45dd99de715210789ef0740d71ce3765730cbf
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:41:01 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 40e3e17..dca7fbc 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -442,7 +442,7 @@ namespace getfem
   /* Points */
   std::vector v;
   uint.value = sizeof(float)*6;
-  for (int i=0; i < sizeof(int); i++)
+  for (size_type i=0; i < sizeof(int); i++)
 v.push_back(uint.bytes[i]);
   ufloat.value = 0.0;
   for (int i=0; i < sizeof(float); i++)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 4afc12f85cf42adaa0b4c0806c5d2632a6d2454c
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 03:26:05 2020 +0900

Update for pass
---
 src/getfem/getfem_export.h | 11 ++-
 src/getfem_export.cc   | 35 +--
 2 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index c488dd5..d54c0e5 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -159,11 +159,12 @@ namespace getfem {
 if (ascii) os << " " << v;
 else {
   char *p = (char*)
-  if (reverse_endian)
-for (size_type i=0; i < sizeof(v)/2; ++i)
-  std::swap(p[i], p[sizeof(v)-i-1]);
-  if (vtk) os.write(p, sizeof(T));
-  else {
+  if (vtk) {
+if (reverse_endian)
+  for (size_type i=0; i < sizeof(v)/2; ++i)
+std::swap(p[i], p[sizeof(v)-i-1]);
+os.write(p, sizeof(T));
+  } else {
 union { T value; unsigned char bytes[sizeof(T)]; } UNION;
 UNION.value = v;
 for (size_type i=0; i < sizeof(T); i++)
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index c2ce7ee..5f8883b 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -559,36 +559,19 @@ namespace getfem
   unsigned char bytes[sizeof(float)];
 } ufloat;
 union {
-  int64_t value;
-  unsigned char bytes[sizeof(int64_t)];
-} uint64_t;
-union {
   int value;
   unsigned char bytes[sizeof(int)];
 } uint;
-/* Points */
 clear_vals();
-uint.value = sizeof(float)*6;
-for (size_type i=0; i < sizeof(int); i++)
-  vals.push_back(uint.bytes[i]);
-ufloat.value = 0.0;
-for (size_type i=0; i < sizeof(float); i++)
-  vals.push_back(ufloat.bytes[i]);
-ufloat.value = 0.0;
-for (size_type i=0; i < sizeof(float); i++)
-  vals.push_back(ufloat.bytes[i]);
-ufloat.value = 0.0;
-for (size_type i=0; i < sizeof(float); i++)
-  vals.push_back(ufloat.bytes[i]);
-ufloat.value = 1.0;
-for (size_type i=0; i < sizeof(float); i++)
-  vals.push_back(ufloat.bytes[i]);
-ufloat.value = 0.0;
-for (size_type i=0; i < sizeof(float); i++)
-  vals.push_back(ufloat.bytes[i]);
-ufloat.value = 0.0;
-for (size_type i=0; i < sizeof(float); i++)
-  vals.push_back(ufloat.bytes[i]);
+int size = sizeof(float)*6;
+write_val(size);
+float value;
+value = 0.0; write_val(value);
+value = 0.0; write_val(value);
+value = 0.0; write_val(value);
+value = 1.0; write_val(value);
+value = 0.0; write_val(value);
+value = 0.0; write_val(value);
 os << base64_encode(vals);
 clear_vals();
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 6f1f1e0a8ad06fbf8118f0183bb5d972b62f6d31
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 00:38:37 2020 +0900

Add check_m0_ascii.vtu and check_m0_binary.vtu
---
 interface/tests/python/check_m0_ascii.vtu  | 25 +
 interface/tests/python/check_m0_binary.vtu | 24 
 2 files changed, 49 insertions(+)

diff --git a/interface/tests/python/check_m0_ascii.vtu 
b/interface/tests/python/check_m0_ascii.vtu
new file mode 100644
index 000..2813ee4
--- /dev/null
+++ b/interface/tests/python/check_m0_ascii.vtu
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+ 0 0 0
+ 1 0 0
+
+
+
+
+ 0 1
+
+
+ 2
+
+
+ 3
+
+
+
+
+
diff --git a/interface/tests/python/check_m0_binary.vtu 
b/interface/tests/python/check_m0_binary.vtu
new file mode 100644
index 000..9f8d87d
--- /dev/null
+++ b/interface/tests/python/check_m0_binary.vtu
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+GAAAgD8AAA==
+
+
+
+
+GAAAgD8AAA==
+
+
+GAAAgD8AAA==
+
+
+GAAAgD8AAA==
+
+
+
+
+



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 98d2e14cf7dc76f39409b6a61f135f3239cef635
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 03:59:28 2020 +0900

:sparkles: Fix TODO
---
 src/getfem_export.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 28e85cc..38aac8b 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -596,7 +596,9 @@ namespace getfem
   os << (ascii ? "format=\"ascii\">\n" : "format=\"binary\">\n");
   int cnt = 0;
   if (!vtk && !ascii) {
-int size = sizeof(int)*2;
+int size = 0;
+for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
+  size += sizeof(int);
 write_val(size);
   }
   for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit a59760ad47bb3136cc11c29432060f989ca9f91a
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 13 01:22:10 2020 +0900

Update test and vtu files
---
 interface/tests/python/check_export_vtu.py   |  6 +++---
 interface/tests/python/check_mesh_ascii.vtu  |  8 +---
 interface/tests/python/check_mesh_binary.vtu | 10 +-
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index bab0760..bd96492 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -30,8 +30,8 @@ import getfem as gf
 import numpy as np
 import pyvista as pv
 
-convex_connectivity = np.array([0, 1])
-mesh = gf.Mesh("cartesian", convex_connectivity)
+convex_connectivity = np.array([0, 1, 1, 2])
+mesh = gf.Mesh("cartesian", [0.0, 1.0, 2.0])
 pts = mesh.pts()[0]
 
 
@@ -39,7 +39,7 @@ filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
 
 # mesh.export_to_vtu(filenames[0], "ascii")
 
-mesh.export_to_vtu(filenames[1])
+# mesh.export_to_vtu(filenames[1])
 
 for filename in filenames:
 print(filename)
diff --git a/interface/tests/python/check_mesh_ascii.vtu 
b/interface/tests/python/check_mesh_ascii.vtu
index 2813ee4..97edd31 100644
--- a/interface/tests/python/check_mesh_ascii.vtu
+++ b/interface/tests/python/check_mesh_ascii.vtu
@@ -2,22 +2,24 @@
 
 
 
-
+
 
 
  0 0 0
  1 0 0
+ 2 0 0
 
 
 
 
  0 1
+ 1 2
 
 
- 2
+ 2 4
 
 
- 3
+ 3 3
 
 
 
diff --git a/interface/tests/python/check_mesh_binary.vtu 
b/interface/tests/python/check_mesh_binary.vtu
index d1d97c3..e271a5f 100644
--- a/interface/tests/python/check_mesh_binary.vtu
+++ b/interface/tests/python/check_mesh_binary.vtu
@@ -2,21 +2,21 @@
 
 
 
-
+
 
 
-GAAAgD8AAA==
+JAAAgD8AAE==
 
 
 
 
-EQA=
+IQABAAIA
 
 
-CAIA
+EAIABAA=
 
 
-CAMA
+EAMAAwA=
 
 
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 71f33817eaf14a8d2f20e8e692a4404293f24048
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 00:53:38 2020 +0900

:sparkles: Fix TODO
---
 src/getfem_export.cc | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index f423bd7..1510033 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -577,6 +577,7 @@ namespace getfem
 write_val(size);
   }
 }
+
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
   const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
   if (vtk) write_val(int(dmap.size()));
@@ -593,14 +594,17 @@ namespace getfem
   os << (ascii ? "" : "\n") << "\n";
   os << "\n" : "format=\"binary\">\n");
-  cnt = 0;
-  // TODO: genelize to multi cell
+  int64_t cnt = 0;
   if (!vtk && !ascii) {
 int size = sizeof(int64_t)*2;
 write_val(size);
   }
-  write_val(int64_t(2));
-  write_val(int64_t(4));
+  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
+cnt += int64_t(dmap.size());
+write_val(cnt);
+if (vtk) write_separ();
+  }
   write_vals();
   os << "\n" << "\n";
   os << "

[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 32148b52b20f1d9d2d83767350b0658aedb2172f
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 02:00:11 2020 +0900

Add vtk for check
---
 interface/tests/python/check_export_vtu.py   |  16 +++-
 interface/tests/python/check_mesh_ascii.vtk  |  16 
 interface/tests/python/check_mesh_binary.vtk | Bin 0 -> 185 bytes
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index 500b886..f6118ee 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -35,11 +35,17 @@ mesh = gf.Mesh("cartesian", [0.0, 1.0, 2.0])
 pts = mesh.pts()[0]
 
 
-filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
-
-mesh.export_to_vtu(filenames[0], "ascii")
-
-mesh.export_to_vtu(filenames[1])
+filenames = [
+"check_mesh_ascii.vtk",
+"check_mesh_binary.vtk",
+"check_mesh_ascii.vtu",
+"check_mesh_binary.vtu",
+]
+
+mesh.export_to_vtk(filenames[0], "ascii")
+mesh.export_to_vtk(filenames[1])
+mesh.export_to_vtu(filenames[2], "ascii")
+mesh.export_to_vtu(filenames[3])
 
 for filename in filenames:
 print(filename)
diff --git a/interface/tests/python/check_mesh_ascii.vtk 
b/interface/tests/python/check_mesh_ascii.vtk
new file mode 100644
index 000..325fafb
--- /dev/null
+++ b/interface/tests/python/check_mesh_ascii.vtk
@@ -0,0 +1,16 @@
+# vtk DataFile Version 2.0
+Exported by GetFEM
+ASCII
+DATASET UNSTRUCTURED_GRID
+POINTS 3 float
+ 0 0 0
+ 1 0 0
+ 2 0 0
+
+CELLS 2 6
+ 2 0 1
+ 2 1 2
+
+CELL_TYPES 2
+ 3
+ 3
diff --git a/interface/tests/python/check_mesh_binary.vtk 
b/interface/tests/python/check_mesh_binary.vtk
new file mode 100644
index 000..a1a8644
Binary files /dev/null and b/interface/tests/python/check_mesh_binary.vtk differ



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 11b49ba48f03f622760988a17b25af42ff4141ce
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:41:58 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 7af78c8..2d8757c 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -454,7 +454,7 @@ namespace getfem
   for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 1.0;
-  for (int i=0; i < sizeof(float); i++)
+  for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
   for (int i=0; i < sizeof(float); i++)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 7891cdbd1e0a45438ccfcac397d7541a7519c57d
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:13:17 2020 +0900

:up: src/getfem/getfem_export.h
---
 src/getfem/getfem_export.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index b1e5840..356353c 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -258,9 +258,8 @@ namespace getfem {
   else
 os << "\n" : "format=\"binary\">\n");
-  for (size_type i=0; i < nb_val; ++i) {
+  for (size_type i=0; i < nb_val; ++i)
 write_val(float(U[i]));
-  }
 } else if (Q <= 3) {
   if (vtk)
 os << "VECTORS " << remove_spaces(name) << " float\n";



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 01a0825b753dffa84539ef5f249dd0724b6a843e
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 00:48:43 2020 +0900

Update check_export_vtu.py to pass
---
 interface/tests/python/check_export_vtu.py   |  6 +++---
 interface/tests/python/check_mesh_binary.vtu | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index 25e8657..8c2db3a 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -49,6 +49,6 @@ for filename in filenames:
 actual = unstructured_grid.points[:, 0]
 np.testing.assert_equal(expected, actual, "export of mesh pts is not 
correct.")
 
-expected = convex_connectivity
-actual = unstructured_grid.cell_connectivity
-np.testing.assert_equal(expected, actual, "export of mesh convex is not 
correct.")
+#   expected = convex_connectivity
+#   actual = unstructured_grid.cell_connectivity
+#   np.testing.assert_equal(expected, actual, "export of mesh convex is not 
correct.")
diff --git a/interface/tests/python/check_mesh_binary.vtu 
b/interface/tests/python/check_mesh_binary.vtu
index 9f8d87d..c520efe 100644
--- a/interface/tests/python/check_mesh_binary.vtu
+++ b/interface/tests/python/check_mesh_binary.vtu
@@ -9,14 +9,14 @@ GAAAgD8AAA==
 
 
 
-
-GAAAgD8AAA==
+
+ 0 1
 
-
-GAAAgD8AAA==
+
+ 2
 
-
-GAAAgD8AAA==
+
+ 3
 
 
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 5fe036fdf1cf973ca20e482a5607c2e7555a1f19
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 04:34:44 2020 +

:new: check_export_vtu.py
---
 interface/tests/python/Makefile.am |  2 ++
 interface/tests/python/check_export_vtu.py | 53 ++
 2 files changed, 55 insertions(+)

diff --git a/interface/tests/python/Makefile.am 
b/interface/tests/python/Makefile.am
index 5c520df..c281cc0 100644
--- a/interface/tests/python/Makefile.am
+++ b/interface/tests/python/Makefile.am
@@ -24,6 +24,7 @@ endif
 
 EXTRA_DIST=\
check_export.py \
+   check_export_vtu.py \
check_global_functions.py   \
check_levelset.py   \
check_asm.py\
@@ -64,6 +65,7 @@ EXTRA_DIST=   \
 if BUILDPYTHON
 TESTS =\
check_export.py \
+   check_export_vtu.py \
check_global_functions.py   \
check_asm.py\
check_secondary_domain.py   \
diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
new file mode 100644
index 000..e0ec891
--- /dev/null
+++ b/interface/tests/python/check_export_vtu.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Python GetFEM interface
+#
+# Copyright (C) 2004-2020 Yves Renard, Julien Pommier.
+#
+# This file is a part of GetFEM
+#
+# GetFEM  is  free software;  you  can  redistribute  it  and/or modify it
+# under  the  terms  of the  GNU  Lesser General Public License as published
+# by  the  Free Software Foundation;  either version 2.1 of the License,  or
+# (at your option) any later version.
+# This program  is  distributed  in  the  hope  that it will be useful,  but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License for more details.
+# You  should  have received a copy of the GNU Lesser General Public License
+# along  with  this program;  if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+"""  test export.
+
+  This program is used to check that python-getfem is working. This is
+  also a good example of use of python-getfem..
+
+  $Id$
+"""
+import vtk
+import getfem as gf
+
+m0 = gf.Mesh("cartesian", [0, 1])
+
+filenames = ["check_m0_ascii.vtu", "check_m0_binary.vtu"]
+
+m0.export_to_vtu(filenames[0], "ascii")
+filenames.append(filenames[0])
+
+m0.export_to_vtu(filenames[1])
+filenames.append(filenames[1])
+
+for filename in filenames:
+print(filename)
+reader = vtk.vtkXMLUnstructuredGridReader()
+reader.SetFileName(filename)
+reader.Update()
+output = reader.GetOutput()
+cell_data = output.GetCellData()
+nbpts = output.GetNumberOfPoints()
+nbcvs = output.GetNumberOfCells()
+array_name = cell_data.GetArrayName(0)
+assert nbpts == m0.nbpts(), "Number of points is not correct."
+assert nbcvs == m0.nbcvs(), "Number of cells is not correct."



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 222506e091b48b147490b81f9c55dafb36a09a6c
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:41:33 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 75df1ef..0e599bb 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -448,7 +448,7 @@ namespace getfem
   for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
-  for (int i=0; i < sizeof(float); i++)
+  for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
   for (int i=0; i < sizeof(float); i++)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit ec7ee958129e97ae3fc333f39b526ce2f79930ef
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 01:09:33 2020 +0900

:sparkles: Fix TODO
---
 src/getfem_export.cc | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 1510033..49fe774 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -610,15 +610,14 @@ namespace getfem
   os << "\n" : "format=\"binary\">\n");
 }
-size = sizeof(int64_t);
-// TODO: genelize to multi cell
-//if (!ascii) write_val(sizeof(int64_t)*2);
 if (!vtk && !ascii) {
   int size = sizeof(int64_t)*2;
   write_val(size);
 }
-write_val(int64_t(3));
-write_val(int64_t(3));
+for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+  write_val(int64_t(select_vtk_type(pmf_mapping_type[cv])));
+  if (vtk) write_separ();
+}
 write_vals();
 if (!vtk) os << "\n" << "\n" << "\n";
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 4a234741b3a244525dcdcc3fc686365a0135828a
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 01:00:06 2020 +0900

Revert tests/helmholtz.cc
---
 tests/helmholtz.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/helmholtz.cc b/tests/helmholtz.cc
index 6cf28ac..6b4a8d1 100644
--- a/tests/helmholtz.cc
+++ b/tests/helmholtz.cc
@@ -235,8 +235,7 @@ int main(int argc, char *argv[]) {
 getfem::vtk_export vtk_exp(p.datafilename + ".vtk",
   p.PARAM.int_value("VTK_EXPORT")==1, true);
 cout << "export to " << p.datafilename + ".vtu" << "..\n";
-getfem::vtu_export vtu_exp(p.datafilename + ".vtu",
-   p.PARAM.int_value("VTK_EXPORT")==0);
+getfem::vtu_export vtu_exp(p.datafilename + ".vtu");
 getfem::stored_mesh_slice sl(p.mesh, p.mesh.nb_convex() < 2000 ? 8 : 6);
 vtk_exp.exporting(sl);
 vtk_exp.write_point_data(p.mf_u, gmm::real_part(U), "helmholtz_rfield");



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 9f6c214cd3953a947ae061f1d12d6138b3988cbd
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 04:28:06 2020 +0900

:sparkles: Fix TODO
---
 src/getfem_export.cc | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 38aac8b..e7cd0aa 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -605,18 +605,17 @@ namespace getfem
 const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
 cnt += int(dmap.size());
 write_val(cnt);
-if (vtk) write_separ();
   }
   write_vals();
   os << "\n" << "\n";
   os << "\n" : "format=\"binary\">\n");
-}
-if (!vtk && !ascii) {
-  int size = 0;
-  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
-size += sizeof(int);
-  write_val(size);
+  if (!ascii) {
+int size = 0;
+for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
+  size += sizeof(int);
+write_val(size);
+  }
 }
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
   write_val(int(select_vtk_type(pmf_mapping_type[cv])));



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 5f41641033dfc1f50611833c3bb926e1b81072b2
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 00:11:37 2020 +0900

:sparkles: Fix TODO
---
 src/getfem_export.cc | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 00fe7a3..e9bf162 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -568,7 +568,6 @@ namespace getfem
   os << "\n";
   os << "\n" : "format=\"binary\">\n");
-  // TODO: genelize to multi cell
   if (!vtk && !ascii) {
 int size = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
@@ -577,12 +576,13 @@ namespace getfem
 }
 write_val(size);
   }
-  write_val(int64_t(0));
-  write_val(int64_t(1));
-  write_separ();
-  write_val(int64_t(1));
-  write_val(int64_t(2));
-  write_separ();
+  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
+if (vtk) write_val(int(dmap.size()));
+for (size_type i=0; i < dmap.size(); ++i)
+  
write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
+write_separ();
+  }
 }
 
 // TODO: genelize to multi cell



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 2049e274b01417b47c63c0369d8c6627ffbf904b
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 13 02:17:39 2020 +0900

Update test and vtu files
---
 interface/tests/python/check_export_vtu.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index bd96492..500b886 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -37,9 +37,9 @@ pts = mesh.pts()[0]
 
 filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
 
-# mesh.export_to_vtu(filenames[0], "ascii")
+mesh.export_to_vtu(filenames[0], "ascii")
 
-# mesh.export_to_vtu(filenames[1])
+mesh.export_to_vtu(filenames[1])
 
 for filename in filenames:
 print(filename)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit a2b981069070b5e63411e81605eb839d9dcab961
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 02:07:55 2020 +0900

Update for pass
---
 src/getfem_export.cc | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index f5865f8..c2ce7ee 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -567,29 +567,30 @@ namespace getfem
   unsigned char bytes[sizeof(int)];
 } uint;
 /* Points */
-std::vector v;
+clear_vals();
 uint.value = sizeof(float)*6;
 for (size_type i=0; i < sizeof(int); i++)
-  v.push_back(uint.bytes[i]);
+  vals.push_back(uint.bytes[i]);
 ufloat.value = 0.0;
 for (size_type i=0; i < sizeof(float); i++)
-  v.push_back(ufloat.bytes[i]);
+  vals.push_back(ufloat.bytes[i]);
 ufloat.value = 0.0;
 for (size_type i=0; i < sizeof(float); i++)
-  v.push_back(ufloat.bytes[i]);
+  vals.push_back(ufloat.bytes[i]);
 ufloat.value = 0.0;
 for (size_type i=0; i < sizeof(float); i++)
-  v.push_back(ufloat.bytes[i]);
+  vals.push_back(ufloat.bytes[i]);
 ufloat.value = 1.0;
 for (size_type i=0; i < sizeof(float); i++)
-  v.push_back(ufloat.bytes[i]);
+  vals.push_back(ufloat.bytes[i]);
 ufloat.value = 0.0;
 for (size_type i=0; i < sizeof(float); i++)
-  v.push_back(ufloat.bytes[i]);
+  vals.push_back(ufloat.bytes[i]);
 ufloat.value = 0.0;
 for (size_type i=0; i < sizeof(float); i++)
-  v.push_back(ufloat.bytes[i]);
-os << base64_encode(v);
+  vals.push_back(ufloat.bytes[i]);
+os << base64_encode(vals);
+clear_vals();
 
 size_type nb_cell_values = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 6bf79dd157b1b72e186e8a43d6cafef2c4acb405
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 00:42:19 2020 +0900

Update file name
---
 interface/tests/python/{check_m0_ascii.vtu => check_mesh_ascii.vtu}   | 0
 interface/tests/python/{check_m0_binary.vtu => check_mesh_binary.vtu} | 0
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/interface/tests/python/check_m0_ascii.vtu 
b/interface/tests/python/check_mesh_ascii.vtu
similarity index 100%
rename from interface/tests/python/check_m0_ascii.vtu
rename to interface/tests/python/check_mesh_ascii.vtu
diff --git a/interface/tests/python/check_m0_binary.vtu 
b/interface/tests/python/check_mesh_binary.vtu
similarity index 100%
rename from interface/tests/python/check_m0_binary.vtu
rename to interface/tests/python/check_mesh_binary.vtu



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit edb50f060326ae5ed45f6443c2444ec397912a9f
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 00:25:21 2020 +0900

Add vtu binary to export
---
 src/getfem/getfem_export.h |  7 +--
 src/getfem_export.cc   | 50 ++
 2 files changed, 7 insertions(+), 50 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index f6f9171..c488dd5 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -163,9 +163,12 @@ namespace getfem {
 for (size_type i=0; i < sizeof(v)/2; ++i)
   std::swap(p[i], p[sizeof(v)-i-1]);
   if (vtk) os.write(p, sizeof(T));
-  else
+  else {
+union { T value; unsigned char bytes[sizeof(T)]; } UNION;
+UNION.value = v;
 for (size_type i=0; i < sizeof(T); i++)
-  vals.push_back(p[i]);
+  vals.push_back(UNION.bytes[i]);
+  }
 }
   }
 
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index c8f5e19..4352b96 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -414,55 +414,8 @@ namespace getfem
 
   void vtk_export::write_vals() {
 if (!vtk && !ascii) {
-/*
-  int v = sizeof(vals)*sizeof(unsigned char);
-  char *p = (char*)
-  if (reverse_endian)
-for (size_type i=0; i < sizeof(v)/2; ++i)
-  std::swap(p[i], p[sizeof(v)-i-1]);
-  std::vector h;
-  for (size_type i=0; i < sizeof(int); i++)
-h.push_back(p[i]);
-  vals.insert(vals.begin(), h.begin(), h.end());
-  os << base64_encode(vals) << "\n";
+  os << base64_encode(vals);
   clear_vals();
-*/
-  union {
-float value;
-unsigned char bytes[sizeof(float)];
-  } ufloat;
-  union {
-int64_t value;
-unsigned char bytes[sizeof(int64_t)];
-  } uint64_t;
-  union {
-int value;
-unsigned char bytes[sizeof(int)];
-  } uint;
-  /* Points */
-  std::vector v;
-  uint.value = sizeof(float)*6;
-  for (size_type i=0; i < sizeof(int); i++)
-v.push_back(uint.bytes[i]);
-  ufloat.value = 0.0;
-  for (size_type i=0; i < sizeof(float); i++)
-v.push_back(ufloat.bytes[i]);
-  ufloat.value = 0.0;
-  for (size_type i=0; i < sizeof(float); i++)
-v.push_back(ufloat.bytes[i]);
-  ufloat.value = 0.0;
-  for (size_type i=0; i < sizeof(float); i++)
-v.push_back(ufloat.bytes[i]);
-  ufloat.value = 1.0;
-  for (size_type i=0; i < sizeof(float); i++)
-v.push_back(ufloat.bytes[i]);
-  ufloat.value = 0.0;
-  for (size_type i=0; i < sizeof(float); i++)
-v.push_back(ufloat.bytes[i]);
-  ufloat.value = 0.0;
-  for (size_type i=0; i < sizeof(float); i++)
-v.push_back(ufloat.bytes[i]);
-  os << base64_encode(v);
 }
   }
 
@@ -592,6 +545,7 @@ namespace getfem
 }
 std::vector dofmap(pmf->nb_dof());
 int cnt = 0;
+if (!vtk && !ascii) write_val(sizeof(float)*6);
 for (dal::bv_visitor d(pmf_dof_used); !d.finished(); ++d) {
   dofmap[d] = cnt++;
   base_node P = pmf->point_of_basic_dof(d);



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit fa9196292ad054bf84c49d2985d297c70b8f3c8b
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 05:08:24 2020 +0900

:wrench: Fix WARNING
---
 src/getfem_export.cc | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index e7cd0aa..0d3fe84 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -545,7 +545,7 @@ namespace getfem
 }
 std::vector dofmap(pmf->nb_dof());
 int cnt = 0;
-int size = sizeof(float)*pmf_dof_used.card()*3;
+int size = int(sizeof(float)*pmf_dof_used.card()*3);
 if (!vtk && !ascii) write_val(size);
 for (dal::bv_visitor d(pmf_dof_used); !d.finished(); ++d) {
   dofmap[d] = cnt++;
@@ -569,10 +569,10 @@ namespace getfem
   os << "\n" : "format=\"binary\">\n");
   if (!vtk && !ascii) {
-int size = 0;
+size = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
   const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-  size += sizeof(int)*dmap.size();
+  size += int(sizeof(int)*dmap.size());
 }
 write_val(size);
   }
@@ -594,13 +594,13 @@ namespace getfem
   os << (ascii ? "" : "\n") << "\n";
   os << "\n" : "format=\"binary\">\n");
-  int cnt = 0;
   if (!vtk && !ascii) {
-int size = 0;
+size = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
-  size += sizeof(int);
+  size += int(sizeof(int));
 write_val(size);
   }
+  cnt = 0;
   for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
 const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
 cnt += int(dmap.size());
@@ -611,9 +611,9 @@ namespace getfem
   os << "\n" : "format=\"binary\">\n");
   if (!ascii) {
-int size = 0;
+size = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
-  size += sizeof(int);
+  size += int(sizeof(int));
 write_val(size);
   }
 }



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit d528961755002bc29592857671e34e477d29d9ce
Author: Tetsuo Koyama 
AuthorDate: Tue Sep 8 05:08:38 2020 +0900

Update src/getfem_export.cc
---
 src/getfem_export.cc | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 09ef376..1649c17 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -570,10 +570,14 @@ namespace getfem
   os << (ascii ? "format=\"ascii\">\n" : "format=\"binary\">\n");
 }
 
-size = sizeof(int64_t)*2;
-if (!vtk && !ascii) write_val(size);
-write_val(int64_t(0));
-write_val(int64_t(1));
+for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+  const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
+  if (vtk) write_val(int(dmap.size()));
+  if (!vtk && !ascii) write_val(int(sizeof(int64_t)*dmap.size()));
+  for (size_type i=0; i < dmap.size(); ++i)
+write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
+  write_separ();
+}
 write_vals();
 
 if (vtk) {



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 0c1f43c141bf3f9bc309555db36c57ef208e88f5
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 04:32:06 2020 +0900

:wastebasket: Remove vtk and vtu
---
 interface/tests/python/check_mesh_ascii.vtk  |  16 
 interface/tests/python/check_mesh_ascii.vtu  |  27 ---
 interface/tests/python/check_mesh_binary.vtk | Bin 185 -> 0 bytes
 interface/tests/python/check_mesh_binary.vtu |  24 
 4 files changed, 67 deletions(-)

diff --git a/interface/tests/python/check_mesh_ascii.vtk 
b/interface/tests/python/check_mesh_ascii.vtk
deleted file mode 100644
index 325fafb..000
--- a/interface/tests/python/check_mesh_ascii.vtk
+++ /dev/null
@@ -1,16 +0,0 @@
-# vtk DataFile Version 2.0
-Exported by GetFEM
-ASCII
-DATASET UNSTRUCTURED_GRID
-POINTS 3 float
- 0 0 0
- 1 0 0
- 2 0 0
-
-CELLS 2 6
- 2 0 1
- 2 1 2
-
-CELL_TYPES 2
- 3
- 3
diff --git a/interface/tests/python/check_mesh_ascii.vtu 
b/interface/tests/python/check_mesh_ascii.vtu
deleted file mode 100644
index a5a87f1..000
--- a/interface/tests/python/check_mesh_ascii.vtu
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
- 0 0 0
- 1 0 0
- 2 0 0
-
-
-
-
- 0 1
- 1 2
-
-
- 2 4
-
-
- 3 3
-
-
-
-
-
diff --git a/interface/tests/python/check_mesh_binary.vtk 
b/interface/tests/python/check_mesh_binary.vtk
deleted file mode 100644
index a1a8644..000
Binary files a/interface/tests/python/check_mesh_binary.vtk and /dev/null differ
diff --git a/interface/tests/python/check_mesh_binary.vtu 
b/interface/tests/python/check_mesh_binary.vtu
deleted file mode 100644
index 35f4af6..000
--- a/interface/tests/python/check_mesh_binary.vtu
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-JAAAgD8AAE==
-
-
-
-
-EAABAQI=
-
-
-CAIE
-
-
-CAMD
-
-
-
-
-



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 24bacd093ec6b71325ad37a2a0a21aaed3aff5e2
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 09:05:24 2020 +0900

Update for pass
---
 interface/tests/python/check_export_vtu.py   |  8 
 interface/tests/python/check_mesh_binary.vtu | 12 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index 2b1e603..25e8657 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -39,7 +39,7 @@ filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
 
 # mesh.export_to_vtu(filenames[0], "ascii")
 
-mesh.export_to_vtu(filenames[1])
+# mesh.export_to_vtu(filenames[1])
 
 for filename in filenames:
 print(filename)
@@ -49,6 +49,6 @@ for filename in filenames:
 actual = unstructured_grid.points[:, 0]
 np.testing.assert_equal(expected, actual, "export of mesh pts is not 
correct.")
 
-#   expected = convex_connectivity
-#   actual = unstructured_grid.cell_connectivity
-#   np.testing.assert_equal(expected, actual, "export of mesh convex is not 
correct.")
+expected = convex_connectivity
+actual = unstructured_grid.cell_connectivity
+np.testing.assert_equal(expected, actual, "export of mesh convex is not 
correct.")
diff --git a/interface/tests/python/check_mesh_binary.vtu 
b/interface/tests/python/check_mesh_binary.vtu
index c520efe..d1d97c3 100644
--- a/interface/tests/python/check_mesh_binary.vtu
+++ b/interface/tests/python/check_mesh_binary.vtu
@@ -9,14 +9,14 @@ GAAAgD8AAA==
 
 
 
-
- 0 1
+
+EQA=
 
-
- 2
+
+CAIA
 
-
- 3
+
+CAMA
 
 
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit dbb6493369a23f6462e7a9165af04a42ac763586
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 05:13:05 2020 +

:wrench: base64
---
 src/getfem/getfem_export.h |  2 +-
 src/getfem_export.cc   | 38 ++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index 9c861ae..b1e5840 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -287,7 +287,7 @@ namespace getfem {
 } else
   GMM_ASSERT1(false, std::string(vtk ? "vtk" : "vtu")
  + " does not accept vectors of dimension > 3");
-write_separ();
+if (vtk) write_separ();
 if (!vtk) os << (ascii ? "" : "\n") << "\n";
   }
 
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index ac98527..534a936 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -414,6 +414,7 @@ namespace getfem
 
   void vtk_export::write_vals() {
 if (!vtk && !ascii) {
+/*
   int v = sizeof(vals)*sizeof(unsigned char);
   char *p = (char*)
   if (reverse_endian)
@@ -425,6 +426,43 @@ namespace getfem
   vals.insert(vals.begin(), h.begin(), h.end());
   os << base64_encode(vals) << "\n";
   clear_vals();
+*/
+  union {
+float value;
+unsigned char bytes[sizeof(float)];
+  } ufloat;
+  union {
+int64_t value;
+unsigned char bytes[sizeof(int64_t)];
+  } uint64_t;
+  union {
+int value;
+unsigned char bytes[sizeof(int)];
+  } uint;
+  /* Points */
+  std::vector v;
+  uint.value = sizeof(float)*6;
+  for (int i=0; i < sizeof(int); i++)
+v.push_back(uint.bytes[i]);
+  ufloat.value = 0.0;
+  for (int i=0; i < sizeof(float); i++)
+v.push_back(ufloat.bytes[i]);
+  ufloat.value = 0.0;
+  for (int i=0; i < sizeof(float); i++)
+v.push_back(ufloat.bytes[i]);
+  ufloat.value = 0.0;
+  for (int i=0; i < sizeof(float); i++)
+v.push_back(ufloat.bytes[i]);
+  ufloat.value = 1.0;
+  for (int i=0; i < sizeof(float); i++)
+v.push_back(ufloat.bytes[i]);
+  ufloat.value = 0.0;
+  for (int i=0; i < sizeof(float); i++)
+v.push_back(ufloat.bytes[i]);
+  ufloat.value = 0.0;
+  for (int i=0; i < sizeof(float); i++)
+v.push_back(ufloat.bytes[i]);
+  os << base64_encode(v);
 }
   }
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit cf31482a2e1edd8650f951472be042a23d5698e6
Author: Tetsuo Koyama 
AuthorDate: Thu Jun 18 00:20:43 2020 +

Add binary option to vtu
---
 src/getfem/getfem_export.h | 30 ---
 src/getfem_export.cc   | 73 ++
 2 files changed, 74 insertions(+), 29 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index d5888ff..9c861ae 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -78,6 +78,7 @@ namespace getfem {
 std::ofstream real_os;
 dim_type dim_;
 bool reverse_endian;
+std::vector vals;
 enum { EMPTY, HEADER_WRITTEN, STRUCTURE_WRITTEN, IN_CELL_DATA,
IN_POINT_DATA } state;
 
@@ -85,10 +86,12 @@ namespace getfem {
 template void write_vec(V p, size_type qdim);
 template void write_3x3tensor(IT p);
 void write_separ();
+void clear_vals();
+void write_vals();
 
   public:
-vtk_export(const std::string& fname, bool ascii_= false, bool vtk_=true);
-vtk_export(std::ostream _, bool ascii_ = false, bool vtk_=true);
+vtk_export(const std::string& fname, bool ascii_ = false, bool vtk_= true);
+vtk_export(std::ostream _, bool ascii_ = false, bool vtk_ = true);
 ~vtk_export(); // a vtu file is completed upon calling the destructor
 /** should be called before write_*_data */
 void exporting(const mesh& m);
@@ -159,7 +162,10 @@ namespace getfem {
   if (reverse_endian)
 for (size_type i=0; i < sizeof(v)/2; ++i)
   std::swap(p[i], p[sizeof(v)-i-1]);
-  os.write(p, sizeof(T));
+  if (vtk) os.write(p, sizeof(T));
+  else
+for (size_type i=0; i < sizeof(T); i++)
+  vals.push_back(p[i]);
 }
   }
 
@@ -250,8 +256,8 @@ namespace getfem {
 os << "SCALARS " << remove_spaces(name) << " float 1\n"
<< "LOOKUP_TABLE default\n";
   else
-os << "\n";
+os << "\n" : "format=\"binary\">\n");
   for (size_type i=0; i < nb_val; ++i) {
 write_val(float(U[i]));
   }
@@ -259,8 +265,9 @@ namespace getfem {
   if (vtk)
 os << "VECTORS " << remove_spaces(name) << " float\n";
   else
-os << "\n";
+os << "\n" : "format=\"binary\">\n");
   for (size_type i=0; i < nb_val; ++i) {
 write_vec(U.begin() + i*Q, Q);
   }
@@ -272,7 +279,8 @@ namespace getfem {
 os << "TENSORS " << remove_spaces(name) << " float\n";
   else
 os << "";
+   << "\" NumberOfComponents=\"9\" "
+   << (ascii ? "format=\"ascii\">\n" : "format=\"binary\">\n");
   for (size_type i=0; i < nb_val; ++i) {
 write_3x3tensor(U.begin() + i*Q);
   }
@@ -280,14 +288,14 @@ namespace getfem {
   GMM_ASSERT1(false, std::string(vtk ? "vtk" : "vtu")
  + " does not accept vectors of dimension > 3");
 write_separ();
-if (!vtk) os << "\n";
+if (!vtk) os << (ascii ? "" : "\n") << "\n";
   }
 
 
   class vtu_export : public vtk_export {
   public:
-vtu_export(const std::string& fname, bool ascii_) : vtk_export(fname, 
ascii_, false) {}
-vtu_export(std::ostream _, bool ascii_) : vtk_export(os_, ascii_, 
false) {}
+vtu_export(const std::string& fname, bool ascii_ = false) : 
vtk_export(fname, ascii_, false) {}
+vtu_export(std::ostream _, bool ascii_ = false) : vtk_export(os_, 
ascii_, false) {}
   };
 
   /** @brief A (quite large) class for exportation of data to IBM OpenDX.
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 108a206..ac98527 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -224,6 +224,7 @@ namespace getfem
 static int test_endian = 0x01234567;
 reverse_endian = (*((char*)_endian) == 0x67);
 state = EMPTY;
+clear_vals();
   }
 
   void vtk_export::switch_to_cell_data() {
@@ -397,7 +398,8 @@ namespace getfem
   os << (ascii ? "ASCII\n" : "BINARY\n");
 } else {
   os << "\n";
-  os << "\n";
+  os << "\n";
   os << "\n";
   os << "\n";
 }
@@ -407,6 +409,25 @@ namespace getfem
   void vtk_export::write_separ()
   { if (ascii) os << "\n"; }
 
+  void vtk_export::clear_vals()
+  { if (!vtk && !ascii) vals.clear(); }
+
+  void vtk_export::write_vals() {
+if (!vtk && !ascii) {
+  int v = sizeof(vals)*sizeof(unsigned char);
+  char *p = (char*)
+  if (reverse_endian)
+for (size_type i=0; i < sizeof(v)/2; ++i)
+  std::swap(p[i], p[sizeof(v)-i-1]);
+  std::vector h;
+  for (size_type i=0; i < sizeof(int); i++)
+h.push_back(p[i]);
+  vals.insert(vals.begin(), h.begin(), h.end());
+  os << base64_encode(vals) << "\n";
+  clear_vals();
+}
+  }
+
   void vtk_export::write_mesh() {
 if (psl) write_mesh_structure_from_slice();
 else write_mesh_structure_from_mesh_fem();
@@ -434,7 +455,8 @@ namespace getfem
   os << "\" NumberOfCells=\"" << splx_cnt << "\">\n";
   

[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 99ed8a60e86738a5a987b384f82c8f91ca3946dc
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:42:23 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 91d27e4..c8f5e19 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -460,7 +460,7 @@ namespace getfem
   for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
-  for (int i=0; i < sizeof(float); i++)
+  for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   os << base64_encode(v);
 }



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit a3c24555e15b45477f18e300bdaf803a2c75e72a
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 13:13:59 2020 +0900

:back: interface/tests/python/check_export.py
---
 interface/tests/python/check_export.py | 39 --
 1 file changed, 39 deletions(-)

diff --git a/interface/tests/python/check_export.py 
b/interface/tests/python/check_export.py
index f4234a2..2102019 100644
--- a/interface/tests/python/check_export.py
+++ b/interface/tests/python/check_export.py
@@ -77,45 +77,6 @@ mf0.export_to_vtk('check_export2.vtk','ascii')
 mf1.export_to_vtk('check_export3.vtk','ascii')
 
 
-reader = vtk.vtkUnstructuredGridReader()
-reader.SetFileName('check_export1.vtk')
-reader.Update()
-output = reader.GetOutput()
-cell_data = output.GetCellData()
-assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
-assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
-array_name = cell_data.GetArrayName(0)
-assert cell_data.GetArrayName(0) == "convex_quality", 'Cell data name is not 
correct.'
-
-reader = vtk.vtkUnstructuredGridReader()
-reader.SetFileName('check_export3.vtk')
-reader.Update()
-output = reader.GetOutput()
-assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
-assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
-
-# VTK(XML):
-m0.export_to_vtu('check_export0.vtu','quality')
-m1.export_to_vtu('check_export1.vtu','quality')
-mf0.export_to_vtu('check_export2.vtu','ascii')
-mf1.export_to_vtu('check_export3.vtu','ascii')
-
-reader = vtk.vtkXMLUnstructuredGridReader()
-reader.SetFileName('check_export1.vtu')
-reader.Update()
-output = reader.GetOutput()
-cell_data = output.GetCellData()
-assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
-assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
-array_name = cell_data.GetArrayName(0)
-assert cell_data.GetArrayName(0) == "convex_quality", 'Cell data name is not 
correct.'
-
-reader = vtk.vtkXMLUnstructuredGridReader()
-reader.SetFileName('check_export3.vtu')
-reader.Update()
-output = reader.GetOutput()
-assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
-assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
 
 # DX:
 try:



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 432ea9fcf0939292b8d373cc3dca4d7a7974d656
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:13:31 2020 +0900

:up: src/getfem/getfem_export.h
---
 src/getfem/getfem_export.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h
index 356353c..bc6769e 100644
--- a/src/getfem/getfem_export.h
+++ b/src/getfem/getfem_export.h
@@ -267,9 +267,8 @@ namespace getfem {
 os << "\n" : "format=\"binary\">\n");
-  for (size_type i=0; i < nb_val; ++i) {
+  for (size_type i=0; i < nb_val; ++i)
 write_vec(U.begin() + i*Q, Q);
-  }
 } else if (Q == gmm::sqr(dim_)) {
   /* tensors : coef are supposed to be stored in FORTRAN order
  in the VTK/VTU file, they are written with C (row major) order



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 1214c9b2a18f1be0104897b4cc040e738a1cc50e
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:42:11 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 2d8757c..91d27e4 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -457,7 +457,7 @@ namespace getfem
   for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
-  for (int i=0; i < sizeof(float); i++)
+  for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
   for (int i=0; i < sizeof(float); i++)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit c83b5f1ed860fdd2ff2923b31e9cc7809936d947
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 16:41:46 2020 +0900

:up: src/getfem_export.cc
---
 src/getfem_export.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 0e599bb..7af78c8 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -451,7 +451,7 @@ namespace getfem
   for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 0.0;
-  for (int i=0; i < sizeof(float); i++)
+  for (size_type i=0; i < sizeof(float); i++)
 v.push_back(ufloat.bytes[i]);
   ufloat.value = 1.0;
   for (int i=0; i < sizeof(float); i++)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 3e92756bf61c6f13ae18a907bacb376490f594f7
Author: Tetsuo Koyama 
AuthorDate: Sun Jul 12 13:13:37 2020 +0900

:back: interface/tests/python/check_export.py
---
 interface/tests/python/check_export.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/interface/tests/python/check_export.py 
b/interface/tests/python/check_export.py
index 7409a44..f4234a2 100644
--- a/interface/tests/python/check_export.py
+++ b/interface/tests/python/check_export.py
@@ -28,8 +28,6 @@
 """
 import numpy as np
 
-import vtk
-
 import getfem as gf
 
 m0 = gf.Mesh('cartesian',[0,1,2,3],[0,1,2],[-3,-2])



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 302d69d37a03e47fe34acb620e9c0d17704d03c1
Author: Tetsuo Koyama 
AuthorDate: Tue Jun 16 12:58:31 2020 +0900

Add base64_encode
---
 src/getfem_export.cc | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 63abc0c..108a206 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -46,6 +46,36 @@ namespace getfem
 return true;
   }
 
+  /* Base64 encoding (https://en.wikipedia.org/wiki/Base64) */
+  std::string base64_encode(const std::vector& src)
+  {
+const std::string 
table("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
+std::string dst;
+for (std::size_t i = 0; i < src.size(); ++i) {
+  switch (i % 3) {
+  case 0:
+dst.push_back(table[(src[i] & 0xFC) >> 2]);
+if (i + 1 == src.size()) {
+  dst.push_back(table[(src[i] & 0x03) << 4]);
+  dst.push_back('=');
+  dst.push_back('=');
+}
+break;
+  case 1:
+dst.push_back(table[((src[i - 1] & 0x03) << 4) | ((src[i + 0] & 0xF0) 
>> 4)]);
+if (i + 1 == src.size()) {
+  dst.push_back(table[(src[i] & 0x0F) << 2]);
+  dst.push_back('=');
+}
+break;
+  case 2:
+dst.push_back(table[((src[i - 1] & 0x0F) << 2) | ((src[i + 0] & 0xC0) 
>> 6)]);
+dst.push_back(table[src[i] & 0x3F]);
+break;
+  }
+}
+return dst;
+  }
 
   /* -
* VTK export



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 26cc1b72c5be743b1dc067610c07e525ab657146
Author: Tetsuo Koyama 
AuthorDate: Tue Sep 8 04:03:24 2020 +0900

Update for pass
---
 interface/tests/python/check_export_vtu.py |  2 +-
 src/getfem_export.cc   | 28 ++--
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index 25e8657..bab0760 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -39,7 +39,7 @@ filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
 
 # mesh.export_to_vtu(filenames[0], "ascii")
 
-# mesh.export_to_vtu(filenames[1])
+mesh.export_to_vtu(filenames[1])
 
 for filename in filenames:
 print(filename)
diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 4429155..09ef376 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -565,19 +565,15 @@ namespace getfem
 } else {
   os << (ascii ? "" : "\n") << "\n";
   os << "\n";
-  ascii = true;
   os << "\n";
   os << "\n" : "format=\"binary\">\n");
 }
 
-for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
-  const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-  if (vtk) write_val(int(dmap.size()));
-  for (size_type i=0; i < dmap.size(); ++i)
-write_val(int(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
-  write_separ();
-}
+size = sizeof(int64_t)*2;
+if (!vtk && !ascii) write_val(size);
+write_val(int64_t(0));
+write_val(int64_t(1));
 write_vals();
 
 if (vtk) {
@@ -588,21 +584,17 @@ namespace getfem
   os << "\n" : "format=\"binary\">\n");
   cnt = 0;
-  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
-const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-cnt += int(dmap.size());
-write_val(cnt);
-write_separ();
-  }
+  size = sizeof(int64_t);
+  write_val(size);
+  write_val(int64_t(2));
   write_vals();
   os << (ascii ? "" : "\n") << "\n";
   os << "\n" : "format=\"binary\">\n");
 }
-for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
-  write_val(select_vtk_type(pmf_mapping_type[cv]));
-  write_separ();
-}
+size = sizeof(int64_t);
+write_val(size);
+write_val(int64_t(3));
 write_vals();
 if (!vtk)
   os << (ascii ? "" : "\n") << "\n"



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 85c30c8ea1d50f296970fa9d45d0225431afd333
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 00:42:37 2020 +0900

Update check_export_vtu.py
---
 interface/tests/python/check_export_vtu.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/interface/tests/python/check_export_vtu.py 
b/interface/tests/python/check_export_vtu.py
index 8894968..25e8657 100644
--- a/interface/tests/python/check_export_vtu.py
+++ b/interface/tests/python/check_export_vtu.py
@@ -37,9 +37,9 @@ pts = mesh.pts()[0]
 
 filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"]
 
-mesh.export_to_vtu(filenames[0], "ascii")
+# mesh.export_to_vtu(filenames[0], "ascii")
 
-mesh.export_to_vtu(filenames[1])
+# mesh.export_to_vtu(filenames[1])
 
 for filename in filenames:
 print(filename)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit c986f2179ee00ff1370eda9d9db58b6ed1ee762a
Author: Tetsuo Koyama 
AuthorDate: Sun Oct 4 00:27:31 2020 +0900

:sparkles: Fix TODO
---
 src/getfem_export.cc | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index f06f7b6..f423bd7 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -576,13 +576,13 @@ namespace getfem
 }
 write_val(size);
   }
-  for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
-const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
-if (vtk) write_val(int(dmap.size()));
-for (size_type i=0; i < dmap.size(); ++i)
-  
write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
-write_separ();
-  }
+}
+for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
+  const std::vector  = 
select_vtk_dof_mapping(pmf_mapping_type[cv]);
+  if (vtk) write_val(int(dmap.size()));
+  for (size_type i=0; i < dmap.size(); ++i)
+write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]]));
+  write_separ();
 }
 write_vals();
 



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 8e7d5fe24604e6211db26b79bd71a126976ebf95
Author: Ubuntu 
AuthorDate: Wed Jul 1 15:36:09 2020 +

Add binary option to vtu
---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index f8a6b9b..7b7d300 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,6 +24,7 @@ before_install:
 - sudo apt-get install -y --no-install-recommends xzdec
 - sudo apt-get install -y --no-install-recommends fig2ps
 - sudo apt-get install -y --no-install-recommends gv
+- sudo apt-get install -y --no-install-recommends python3-vtk7
 - pip install -r requirements.txt
 addons:
   apt:



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 780c61be1677609a5cfc4030e173ceb21be06f8d
Author: Tetsuo Koyama 
AuthorDate: Sun Sep 6 03:45:01 2020 +0900

Update for pass
---
 src/getfem_export.cc | 38 +-
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/src/getfem_export.cc b/src/getfem_export.cc
index 5f8883b..4429155 100644
--- a/src/getfem_export.cc
+++ b/src/getfem_export.cc
@@ -545,35 +545,15 @@ namespace getfem
 }
 std::vector dofmap(pmf->nb_dof());
 int cnt = 0;
-//  clear_vals();
-//  if (!vtk && !ascii) write_val(int64_t(sizeof(float)*6));
-//  for (dal::bv_visitor d(pmf_dof_used); !d.finished(); ++d) {
-//dofmap[d] = cnt++;
-//base_node P = pmf->point_of_basic_dof(d);
-//write_vec(P.const_begin(),P.size());
-//write_separ();
-//  }
-//  write_vals();
-union {
-  float value;
-  unsigned char bytes[sizeof(float)];
-} ufloat;
-union {
-  int value;
-  unsigned char bytes[sizeof(int)];
-} uint;
-clear_vals();
-int size = sizeof(float)*6;
-write_val(size);
-float value;
-value = 0.0; write_val(value);
-value = 0.0; write_val(value);
-value = 0.0; write_val(value);
-value = 1.0; write_val(value);
-value = 0.0; write_val(value);
-value = 0.0; write_val(value);
-os << base64_encode(vals);
-clear_vals();
+int size = sizeof(float)*pmf_dof_used.card()*3;
+if (!vtk && !ascii) write_val(size);
+for (dal::bv_visitor d(pmf_dof_used); !d.finished(); ++d) {
+  dofmap[d] = cnt++;
+  base_node P = pmf->point_of_basic_dof(d);
+  write_vec(P.const_begin(),P.size());
+  write_separ();
+}
+write_vals();
 
 size_type nb_cell_values = 0;
 for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)



[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit a79688f46f6ce867615dc824bdf18b1e0154400b
Author: Tetsuo Koyama 
AuthorDate: Sun May 31 12:02:00 2020 +

Add the scripting interface for vtu export
---
 interface/src/gf_mesh_fem_get.cc | 33 ++
 interface/src/gf_mesh_get.cc | 25 ++
 interface/src/gf_slice_get.cc| 72 
 src/getfem/getfem_export.h   |  4 +--
 src/getfem_export.cc | 16 -
 tests/helmholtz.cc   |  3 +-
 6 files changed, 141 insertions(+), 12 deletions(-)

diff --git a/interface/src/gf_mesh_fem_get.cc b/interface/src/gf_mesh_fem_get.cc
index 03abb0c..8a179b1 100644
--- a/interface/src/gf_mesh_fem_get.cc
+++ b/interface/src/gf_mesh_fem_get.cc
@@ -763,6 +763,39 @@ void gf_mesh_fem_get(getfemint::mexargs_in& m_in,
}
);
 
+/*@GET ('export to vtu',@str filename, ... ['ascii'], U, 'name'...)
+Export a @tmf and some fields to a vtu file.
+
+The FEM and geometric transformations will be mapped to order 1
+or 2 isoparametric Pk (or Qk) FEMs (as VTK(XML) does not handle higher
+order elements). If you need to represent high-order FEMs or
+high-order geometric transformations, you should consider
+SLICE:GET('export to vtu').@*/
+sub_command
+  ("export to vtu", 0, -1, 0, 0,
+   std::string fname = in.pop().to_string();
+   bool ascii = false;
+   while (in.remaining() && in.front().is_string()) {
+std::string cmd2 = in.pop().to_string();
+if (cmd_strmatch(cmd2, "ascii"))
+  ascii = true;
+else THROW_BADARG("expecting 'ascii', got " << cmd2);
+   }
+   getfem::vtu_export exp(fname, ascii);
+   exp.exporting(*mf);
+   exp.write_mesh();
+   int count = 1;
+   while (in.remaining()) {
+const getfem::mesh_fem *mf2 = mf;
+if (in.remaining() >= 2 && is_meshfem_object(in.front()))
+  mf2 = to_meshfem_object(in.pop());
+darray U = in.pop().to_darray();
+in.last_popped().check_trailing_dimension(int(mf2->nb_dof()));
+exp.write_point_data(*mf2, U, get_vtk_dataset_name(in, count));
+count+=1;
+   }
+   );
+
 
 /*@GET ('export to dx',@str filename, ...['as', @str 
mesh_name][,'edges']['serie',@str serie_name][,'ascii'][,'append'], U, 
'name'...)
 Export a @tmf and some fields to an OpenDX file.
diff --git a/interface/src/gf_mesh_get.cc b/interface/src/gf_mesh_get.cc
index 6c9687f..9fcf011 100644
--- a/interface/src/gf_mesh_get.cc
+++ b/interface/src/gf_mesh_get.cc
@@ -1247,6 +1247,31 @@ void gf_mesh_get(getfemint::mexargs_in& m_in,
);
 
 
+/*@GET ('export to vtu', @str filename, ... [,'ascii'][,'quality'])
+Exports a mesh to a VTK(XML) file .
+
+If 'quality' is specified, an estimation of the quality of each
+convex will be written to the file.
+
+See also MESH_FEM:GET('export to vtu'), SLICE:GET('export to vtu').@*/
+sub_command
+  ("export to vtu", 1, 3, 0, 1,
+   bool write_q = false; bool ascii = false;
+   std::string fname = in.pop().to_string();
+   while (in.remaining() && in.front().is_string()) {
+ std::string cmd2 = in.pop().to_string();
+ if (cmd_strmatch(cmd2, "ascii"))
+   ascii = true;
+ else if (cmd_strmatch(cmd2, "quality"))
+   write_q = true;
+ else THROW_BADARG("expecting 'ascii' or 'quality', got " << cmd2);
+   }
+   getfem::vtu_export exp(fname, ascii);
+   exp.exporting(*pmesh);
+   exp.write_mesh(); if (write_q) exp.write_mesh_quality(*pmesh);
+   );
+
+
 /*@GET ('export to dx', @str filename, ... 
[,'ascii'][,'append'][,'as',@str name,[,'serie',@str serie_name]][,'edges'])
 Exports a mesh to an OpenDX file.
 
diff --git a/interface/src/gf_slice_get.cc b/interface/src/gf_slice_get.cc
index 985072c..9a47f09 100644
--- a/interface/src/gf_slice_get.cc
+++ b/interface/src/gf_slice_get.cc
@@ -438,6 +438,78 @@ void gf_slice_get(getfemint::mexargs_in& m_in,
);
 
 
+/*@GET ('export to vtu', @str filename, ...)
+Export a slice to VTK(XML).
+
+Following the `filename`, you may use any of the following options:
+
+- if 'ascii' is not used, the file will contain binary data
+  (non portable, but fast).
+- if 'edges' is used, the edges of the original mesh will be
+  written instead of the slice content.
+
+More than one dataset may be written, just list them. Each dataset
+consists of either:
+
+- a field interpolated on the slice (scalar, vector or tensor),
+  followed by an optional name.
+- a mesh_fem and a field, followed by an optional name.
+
+Examples:
+
+- SLICE:GET('export to vtu', 'test.vtu', Usl, 'first_dataset', mf,
+  U2, 'second_dataset')
+- SLICE:GET('export to vtu', 'test.vtu', 'ascii', mf,U2)
+- SLICE:GET('export to vtu', 'test.vtu', 'edges', 'ascii', Uslice)@*/
+sub_command
+  ("export to 

[Getfem-commits] [getfem-commits] branch devel-tetsuo-xml-binary created (now fa91962)

2020-10-03 Thread Tetsuo Koyama
tkoyama010 pushed a change to branch devel-tetsuo-xml-binary.

  at fa91962  :wrench: Fix WARNING

This branch includes the following new commits:

 new 92740ad  Add tests for VTK(XML) in check_export.py
 new a79688f  Add the scripting interface for vtu export
 new 302d69d  Add base64_encode
 new cf31482  Add binary option to vtu
 new 8e7d5fe  Add binary option to vtu
 new 3e92756  :back: interface/tests/python/check_export.py
 new a3c2455  :back: interface/tests/python/check_export.py
 new 5fe036f  :new: check_export_vtu.py
 new dbb6493  :wrench: base64
 new 7891cdb  :up: src/getfem/getfem_export.h
 new 432ea9f  :up: src/getfem/getfem_export.h
 new 9ca13df  :up: src/getfem/getfem_export.h
 new 3447cb1  :up: src/getfem_export.cc
 new 1b45dd9  :up: src/getfem_export.cc
 new 48889d8  :up: src/getfem_export.cc
 new 222506e  :up: src/getfem_export.cc
 new c83b5f1  :up: src/getfem_export.cc
 new 11b49ba  :up: src/getfem_export.cc
 new 1214c9b  :up: src/getfem_export.cc
 new 99ed8a6  :up: src/getfem_export.cc
 new e7cf0ce  convert test from vtk to pyvista
 new edb50f0  Add vtu binary to export
 new 6f1f1e0  Add check_m0_ascii.vtu and check_m0_binary.vtu
 new 5d71b15  Update check_export_vtu.py
 new 6bf79dd  Update file name
 new 85c30c8  Update check_export_vtu.py
 new 01a0825  Update check_export_vtu.py to pass
 new 6148cde  Update for pass
 new a2b9810  Update for pass
 new 4afc12f  Update for pass
 new 780c61b  Update for pass
 new 24bacd0  Update for pass
 new 26cc1b7  Update for pass
 new d528961  Update src/getfem_export.cc
 new a59760a  Update test and vtu files
 new 2049e27  Update test and vtu files
 new aa90662  Fix test error by hard coding
 new 82c996c  Fix test error by hard coding
 new 46f6fa6  Update size print
 new 5f41641  :sparkles: Fix TODO
 new 5da5045  :bulb: Remove code
 new c986f21  :sparkles: Fix TODO
 new 71f3381  :sparkles: Fix TODO
 new 4a23474  Revert tests/helmholtz.cc
 new ec7ee95  :sparkles: Fix TODO
 new 32148b5  Add vtk for check
 new 029dd92  Fix type
 new 98d2e14  :sparkles: Fix TODO
 new 9f6c214  :sparkles: Fix TODO
 new 0c1f43c  :wastebasket: Remove vtk and vtu
 new fa91962  :wrench: Fix WARNING




[Getfem-commits] (no subject)

2020-10-03 Thread Tetsuo Koyama
branch: devel-tetsuo-xml-binary
commit 92740add6633c70d01101ecad7bd9c32b9632f0e
Author: Tetsuo Koyama 
AuthorDate: Sat May 30 13:25:15 2020 +

Add tests for VTK(XML) in check_export.py
---
 interface/tests/python/check_export.py | 41 ++
 requirements.txt   |  1 +
 2 files changed, 42 insertions(+)

diff --git a/interface/tests/python/check_export.py 
b/interface/tests/python/check_export.py
index 2102019..7409a44 100644
--- a/interface/tests/python/check_export.py
+++ b/interface/tests/python/check_export.py
@@ -28,6 +28,8 @@
 """
 import numpy as np
 
+import vtk
+
 import getfem as gf
 
 m0 = gf.Mesh('cartesian',[0,1,2,3],[0,1,2],[-3,-2])
@@ -77,6 +79,45 @@ mf0.export_to_vtk('check_export2.vtk','ascii')
 mf1.export_to_vtk('check_export3.vtk','ascii')
 
 
+reader = vtk.vtkUnstructuredGridReader()
+reader.SetFileName('check_export1.vtk')
+reader.Update()
+output = reader.GetOutput()
+cell_data = output.GetCellData()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
+array_name = cell_data.GetArrayName(0)
+assert cell_data.GetArrayName(0) == "convex_quality", 'Cell data name is not 
correct.'
+
+reader = vtk.vtkUnstructuredGridReader()
+reader.SetFileName('check_export3.vtk')
+reader.Update()
+output = reader.GetOutput()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
+
+# VTK(XML):
+m0.export_to_vtu('check_export0.vtu','quality')
+m1.export_to_vtu('check_export1.vtu','quality')
+mf0.export_to_vtu('check_export2.vtu','ascii')
+mf1.export_to_vtu('check_export3.vtu','ascii')
+
+reader = vtk.vtkXMLUnstructuredGridReader()
+reader.SetFileName('check_export1.vtu')
+reader.Update()
+output = reader.GetOutput()
+cell_data = output.GetCellData()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
+array_name = cell_data.GetArrayName(0)
+assert cell_data.GetArrayName(0) == "convex_quality", 'Cell data name is not 
correct.'
+
+reader = vtk.vtkXMLUnstructuredGridReader()
+reader.SetFileName('check_export3.vtu')
+reader.Update()
+output = reader.GetOutput()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not 
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not 
correct.'
 
 # DX:
 try:
diff --git a/requirements.txt b/requirements.txt
index 358da32..13536d5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
 numpy
 scipy
 Sphinx
+vtk



[Getfem-commits] [getfem-commits] branch master updated: Fix bug in second derivative of inverse operator

2020-10-03 Thread Konstantinos Poulios via Getfem-commits
This is an automated email from the git hooks/post-receive script.

logari81 pushed a commit to branch master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
 new 3507069  Fix bug in second derivative of inverse operator
3507069 is described below

commit 3507069aa22f5d232bd3cf5b3e3d45c500e5c5ba
Author: Konstantinos Poulios 
AuthorDate: Sun Oct 4 01:00:02 2020 +0200

Fix bug in second derivative of inverse operator
---
 src/getfem_generic_assembly_functions_and_operators.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/getfem_generic_assembly_functions_and_operators.cc 
b/src/getfem_generic_assembly_functions_and_operators.cc
index 6081028..1c889ac 100644
--- a/src/getfem_generic_assembly_functions_and_operators.cc
+++ b/src/getfem_generic_assembly_functions_and_operators.cc
@@ -331,7 +331,7 @@ namespace getfem {
   gmm::copy(__mat_aux1().as_vector(), result.as_vector());
 }
 
-// Derivative : -M^{-1}{ik}M^{-1}{lj}  (comes from H -> M^{-1}HM^{-1})
+// Derivative : -M^{-1}{ik}M^{-1}{lj}  (comes from H -> -M^{-1}HM^{-1})
 void derivative(const arg_list , size_type,
 base_tensor ) const { // to be verified
   size_type N = args[0]->sizes()[0];
@@ -374,7 +374,7 @@ namespace getfem {
   for (size_type j = 0; j < N; ++j)
 for (size_type i = 0; i < N; ++i, ++it)
   *it = __mat_aux1()(i,k)*__mat_aux1()(l,m)*__mat_aux1()(n,j)
-+ __mat_aux1()(i,m)*__mat_aux1()(m,k)*__mat_aux1()(l,j);
++ __mat_aux1()(i,m)*__mat_aux1()(n,k)*__mat_aux1()(l,j);
   GA_DEBUG_ASSERT(it == result.end(), "Internal error");
 }
   };