dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #26389
Re: Fwd: [Branch ~dolfin-core/dolfin/trunk] Rev 7462: Changed unsigned long int to std::size_t in File interface fixing
On 21 February 2013 20:39, Johan Hake <hake.dev@xxxxxxxxx> wrote:
> Why do we need the unsigned int version btw?
>
Perhaps we can just get rid of it.
Garth
> Johan
>
> On 02/21/2013 09:10 PM, Johan Hake wrote:
>> Ok, then I am not sure we have a solution for the problem without having
>> some conditional compilation for 32 bit machines.
>>
>> Johan
>>
>> On 02/21/2013 08:41 PM, Garth N. Wells wrote:
>>> This will cause a problem on 32-bit systems where std::size_t is a
>>> typedef for unsigned int. The use of long unsigned int was deliberate.
>>>
>>> Garth
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: <noreply@xxxxxxxxxxxxx>
>>> Date: 21 February 2013 19:38
>>> Subject: [Branch ~dolfin-core/dolfin/trunk] Rev 7462: Changed unsigned
>>> long int to std::size_t in File interface fixing
>>> To: Garth Wells <gnw20@xxxxxxxxx>
>>>
>>>
>>> ------------------------------------------------------------
>>> revno: 7462
>>> committer: Johan Hake <hake.dev@xxxxxxxxx>
>>> branch nick: work-trunk
>>> timestamp: Thu 2013-02-21 20:35:38 +0100
>>> message:
>>> Changed unsigned long int to std::size_t in File interface fixing
>>> problem with outputting MeshFunction<std::size_t> to file
>>> modified:
>>> dolfin/io/GenericFile.cpp
>>> dolfin/io/GenericFile.h
>>> dolfin/io/HDF5Interface.h
>>> dolfin/io/VTKFile.cpp
>>> dolfin/io/VTKFile.h
>>> dolfin/io/XDMFFile.cpp
>>> dolfin/io/XDMFFile.h
>>> dolfin/io/XMLFile.h
>>> dolfin/swig/io/pre.i
>>> test/unit/io/python/XDMF.py
>>>
>>>
>>> --
>>> lp:dolfin
>>> https://code.launchpad.net/~dolfin-core/dolfin/trunk
>>>
>>> Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
>>> To unsubscribe from this branch go to
>>> https://code.launchpad.net/~dolfin-core/dolfin/trunk/+edit-subscription
>>>
>>> === modified file 'dolfin/io/GenericFile.cpp'
>>> --- dolfin/io/GenericFile.cpp 2012-12-04 20:34:24 +0000
>>> +++ dolfin/io/GenericFile.cpp 2013-02-21 19:35:38 +0000
>>> @@ -73,9 +73,9 @@
>>> read_not_impl("MeshFunction<int>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> -void GenericFile::operator>> (MeshFunction<unsigned long int>& mesh_function)
>>> +void GenericFile::operator>> (MeshFunction<std::size_t>& mesh_function)
>>> {
>>> - read_not_impl("MeshFunction<unsigned long int>");
>>> + read_not_impl("MeshFunction<std::size_t>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> void GenericFile::operator>> (MeshFunction<unsigned int>& mesh_function)
>>> @@ -98,9 +98,9 @@
>>> read_not_impl("MeshValueCollection<int>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> -void GenericFile::operator>> (MeshValueCollection<unsigned long int>&
>>> mesh_markers)
>>> +void GenericFile::operator>> (MeshValueCollection<std::size_t>& mesh_markers)
>>> {
>>> - read_not_impl("MeshValueCollection<unsigned long int>");
>>> + read_not_impl("MeshValueCollection<std::size_t>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> void GenericFile::operator>> (MeshValueCollection<unsigned int>& mesh_markers)
>>> @@ -202,10 +202,9 @@
>>> {
>>> write_not_impl("MeshFunction<int>");
>>> }
>>> -//-----------------------------------------------------------------------------
>>> -void GenericFile::operator<< (const MeshFunction<unsigned long int>&
>>> mesh_function)
>>> +void GenericFile::operator<< (const MeshFunction<std::size_t>& mesh_function)
>>> {
>>> - write_not_impl("MeshFunction<unsigned long int>");
>>> + write_not_impl("MeshFunction<std::size_t>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> void GenericFile::operator<< (const MeshFunction<unsigned int>& mesh_function)
>>> @@ -228,9 +227,9 @@
>>> write_not_impl("MeshValueCollection<int>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> -void GenericFile::operator<< (const MeshValueCollection<unsigned long
>>> int>& mesh_markers)
>>> +void GenericFile::operator<< (const MeshValueCollection<std::size_t>&
>>> mesh_markers)
>>> {
>>> - write_not_impl("MeshValueCollection<unsigned long int>");
>>> + write_not_impl("MeshValueCollection<std::size_t>");
>>> }
>>> //-----------------------------------------------------------------------------
>>> void GenericFile::operator<< (const MeshValueCollection<unsigned
>>> int>& mesh_markers)
>>>
>>> === modified file 'dolfin/io/GenericFile.h'
>>> --- dolfin/io/GenericFile.h 2012-12-19 17:29:40 +0000
>>> +++ dolfin/io/GenericFile.h 2013-02-21 19:35:38 +0000
>>> @@ -59,12 +59,12 @@
>>> virtual void operator>> (GenericDofMap& dofmap);
>>> virtual void operator>> (LocalMeshData& data);
>>> virtual void operator>> (MeshFunction<int>& mesh_function);
>>> - virtual void operator>> (MeshFunction<unsigned long int>& mesh_function);
>>> + virtual void operator>> (MeshFunction<std::size_t>& mesh_function);
>>> virtual void operator>> (MeshFunction<unsigned int>& mesh_function);
>>> virtual void operator>> (MeshFunction<double>& mesh_function);
>>> virtual void operator>> (MeshFunction<bool>& mesh_function);
>>> virtual void operator>> (MeshValueCollection<int>& mesh_markers);
>>> - virtual void operator>> (MeshValueCollection<unsigned long int>&
>>> mesh_markers);
>>> + virtual void operator>> (MeshValueCollection<std::size_t>& mesh_markers);
>>> virtual void operator>> (MeshValueCollection<unsigned int>& mesh_markers);
>>> virtual void operator>> (MeshValueCollection<double>& mesh_markers);
>>> virtual void operator>> (MeshValueCollection<bool>& mesh_markers);
>>> @@ -87,12 +87,12 @@
>>> virtual void operator<< (const GenericDofMap& dofmap);
>>> virtual void operator<< (const LocalMeshData& data);
>>> virtual void operator<< (const MeshFunction<int>& mesh_function);
>>> - virtual void operator<< (const MeshFunction<unsigned long int>&
>>> mesh_function);
>>> + virtual void operator<< (const MeshFunction<std::size_t>& mesh_function);
>>> virtual void operator<< (const MeshFunction<unsigned int>& mesh_function);
>>> virtual void operator<< (const MeshFunction<double>& mesh_function);
>>> virtual void operator<< (const MeshFunction<bool>& mesh_function);
>>> virtual void operator<< (const MeshValueCollection<int>& mesh_markers);
>>> - virtual void operator<< (const MeshValueCollection<unsigned long
>>> int>& mesh_markers);
>>> + virtual void operator<< (const MeshValueCollection<std::size_t>&
>>> mesh_markers);
>>> virtual void operator<< (const MeshValueCollection<unsigned int>&
>>> mesh_markers);
>>> virtual void operator<< (const MeshValueCollection<double>& mesh_markers);
>>> virtual void operator<< (const MeshValueCollection<bool>& mesh_markers);
>>>
>>> === modified file 'dolfin/io/HDF5Interface.h'
>>> --- dolfin/io/HDF5Interface.h 2012-12-19 17:29:40 +0000
>>> +++ dolfin/io/HDF5Interface.h 2013-02-21 19:35:38 +0000
>>> @@ -458,7 +458,7 @@
>>> template<>
>>> inline void HDF5Interface::add_attribute_value(const hid_t dset_id,
>>> const std::string attribute_name,
>>> - const std::vector<unsigned
>>> long int>& attribute_value)
>>> + const
>>> std::vector<std::size_t>& attribute_value)
>>> {
>>>
>>> // Create a vector dataspace
>>> @@ -526,7 +526,7 @@
>>> template<>
>>> inline void HDF5Interface::get_attribute_value(const hid_t attr_type,
>>> const hid_t attr_id,
>>> - unsigned long int&
>>> attribute_value)
>>> + std::size_t& attribute_value)
>>> {
>>> // FIXME: more complete check of type
>>> dolfin_assert(H5Tget_class(attr_type) == H5T_INTEGER);
>>> @@ -588,7 +588,7 @@
>>> template<>
>>> inline void HDF5Interface::get_attribute_value(const hid_t attr_type,
>>> const hid_t attr_id,
>>> - std::vector<unsigned long
>>> int>& attribute_value)
>>> + std::vector<std::size_t>&
>>> attribute_value)
>>> {
>>> // FIXME: more complete check of type
>>> dolfin_assert(H5Tget_class(attr_type) == H5T_INTEGER);
>>> @@ -622,7 +622,7 @@
>>> { return H5T_NATIVE_UINT; }
>>> //-----------------------------------------------------------------------------
>>> template <>
>>> - inline hid_t HDF5Interface::hdf5_type<unsigned long int>()
>>> + inline hid_t HDF5Interface::hdf5_type<std::size_t>()
>>> { return H5T_NATIVE_ULONG; }
>>> //-----------------------------------------------------------------------------
>>>
>>>
>>> === modified file 'dolfin/io/VTKFile.cpp'
>>> --- dolfin/io/VTKFile.cpp 2013-02-05 19:34:25 +0000
>>> +++ dolfin/io/VTKFile.cpp 2013-02-21 19:35:38 +0000
>>> @@ -128,7 +128,7 @@
>>> mesh_function_write(meshfunction);
>>> }
>>> //----------------------------------------------------------------------------
>>> -void VTKFile::operator<<(const MeshFunction<unsigned long int>& meshfunction)
>>> +void VTKFile::operator<<(const MeshFunction<std::size_t>& meshfunction)
>>> {
>>> mesh_function_write(meshfunction);
>>> }
>>>
>>> === modified file 'dolfin/io/VTKFile.h'
>>> --- dolfin/io/VTKFile.h 2012-12-04 11:29:59 +0000
>>> +++ dolfin/io/VTKFile.h 2013-02-21 19:35:38 +0000
>>> @@ -52,7 +52,7 @@
>>> void operator<< (const Mesh& mesh);
>>> void operator<< (const MeshFunction<bool>& meshfunction);
>>> void operator<< (const MeshFunction<unsigned int>& meshfunction);
>>> - void operator<< (const MeshFunction<unsigned long int>& meshfunction);
>>> + void operator<< (const MeshFunction<std::size_t>& meshfunction);
>>> void operator<< (const MeshFunction<int>& meshfunction);
>>> void operator<< (const MeshFunction<double>& meshfunction);
>>> void operator<< (const Function& u);
>>>
>>> === modified file 'dolfin/io/XDMFFile.cpp'
>>> --- dolfin/io/XDMFFile.cpp 2013-02-11 15:13:49 +0000
>>> +++ dolfin/io/XDMFFile.cpp 2013-02-21 19:35:38 +0000
>>> @@ -453,7 +453,7 @@
>>> write_mesh_function(meshfunction);
>>> }
>>> //----------------------------------------------------------------------------
>>> -void XDMFFile::operator<< (const MeshFunction<unsigned long int>& meshfunction)
>>> +void XDMFFile::operator<< (const MeshFunction<std::size_t>& meshfunction)
>>> {
>>> write_mesh_function(meshfunction);
>>> }
>>>
>>> === modified file 'dolfin/io/XDMFFile.h'
>>> --- dolfin/io/XDMFFile.h 2012-12-04 11:29:59 +0000
>>> +++ dolfin/io/XDMFFile.h 2013-02-21 19:35:38 +0000
>>> @@ -77,7 +77,7 @@
>>> void operator<< (const MeshFunction<bool>& meshfunction);
>>> void operator<< (const MeshFunction<int>& meshfunction);
>>> void operator<< (const MeshFunction<unsigned int>& meshfunction);
>>> - void operator<< (const MeshFunction<unsigned long int>& meshfunction);
>>> + void operator<< (const MeshFunction<std::size_t>& meshfunction);
>>> void operator<< (const MeshFunction<double>& meshfunction);
>>>
>>> private:
>>>
>>> === modified file 'dolfin/io/XMLFile.h'
>>> --- dolfin/io/XMLFile.h 2012-12-19 19:10:49 +0000
>>> +++ dolfin/io/XMLFile.h 2013-02-21 19:35:38 +0000
>>> @@ -89,9 +89,9 @@
>>> { write_mesh_function(output, "uint"); }
>>>
>>> // MeshFunction (uint)
>>> - void operator>> (MeshFunction<unsigned long int>& input)
>>> + void operator>> (MeshFunction<std::size_t>& input)
>>> { read_mesh_function(input, "uint"); }
>>> - void operator<< (const MeshFunction<unsigned long int>& output)
>>> + void operator<< (const MeshFunction<std::size_t>& output)
>>> { write_mesh_function(output, "uint"); }
>>>
>>> // MeshFunction (int)
>>> @@ -118,10 +118,10 @@
>>> void operator<< (const MeshValueCollection<unsigned int>& output)
>>> { write_mesh_value_collection(output, "uint"); }
>>>
>>> - // MeshValueCollection (unsigned long int)
>>> - void operator>> (MeshValueCollection<unsigned long int>& input)
>>> + // MeshValueCollection (std::size_t)
>>> + void operator>> (MeshValueCollection<std::size_t>& input)
>>> { read_mesh_value_collection(input, "uint"); }
>>> - void operator<< (const MeshValueCollection<unsigned long int>& output)
>>> + void operator<< (const MeshValueCollection<std::size_t>& output)
>>> { write_mesh_value_collection(output, "uint"); }
>>>
>>> // MeshValueCollection (int)
>>>
>>> === modified file 'dolfin/swig/io/pre.i'
>>> --- dolfin/swig/io/pre.i 2012-12-04 20:34:24 +0000
>>> +++ dolfin/swig/io/pre.i 2013-02-21 19:35:38 +0000
>>> @@ -17,7 +17,7 @@
>>> // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
>>> //
>>> // First added: 2012-11-01
>>> -// Last changed: 2012-11-01
>>> +// Last changed: 2013-02-21
>>>
>>> %ignore dolfin::GenericFile::operator>> (std::vector<int>& x);
>>> %ignore dolfin::GenericFile::operator>> (std::vector<std::size_t>& x);
>>>
>>> === modified file 'test/unit/io/python/XDMF.py'
>>> --- test/unit/io/python/XDMF.py 2013-02-05 16:34:21 +0000
>>> +++ test/unit/io/python/XDMF.py 2013-02-21 19:35:38 +0000
>>> @@ -30,14 +30,17 @@
>>> def test_save_1d_mesh(self):
>>> mesh = UnitIntervalMesh(32)
>>> File("output/mesh.xdmf") << mesh
>>> + XDMFFile("output/mesh.xdmf") << mesh
>>>
>>> def test_save_2d_mesh(self):
>>> mesh = UnitSquareMesh(32, 32)
>>> File("output/mesh_2D.xdmf") << mesh
>>> + XDMFFile("output/mesh_2D.xdmf") << mesh
>>>
>>> def test_save_3d_mesh(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> File("output/mesh_3D.xdmf") << mesh
>>> + XDMFFile("output/mesh_3D.xdmf") << mesh
>>>
>>> class XDMF_Vertex_Function_Output(unittest.TestCase):
>>> """Test output of vertex-based Functions to XDMF files"""
>>> @@ -47,18 +50,21 @@
>>> u = Function(FunctionSpace(mesh, "Lagrange", 2))
>>> u.vector()[:] = 1.0
>>> File("output/u.xdmf") << u
>>> + XDMFFile("output/u.xdmf") << u
>>>
>>> def test_save_2d_scalar(self):
>>> mesh = UnitSquareMesh(16, 16)
>>> u = Function(FunctionSpace(mesh, "Lagrange", 2))
>>> u.vector()[:] = 1.0
>>> File("output/u.xdmf") << u
>>> + XDMFFile("output/u.xdmf") << u
>>>
>>> def test_save_3d_scalar(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> u = Function(FunctionSpace(mesh, "Lagrange", 2))
>>> u.vector()[:] = 1.0
>>> File("output/u.xdmf") << u
>>> + XDMFFile("output/u.xdmf") << u
>>>
>>> def test_save_2d_vector(self):
>>> mesh = UnitSquareMesh(16, 16)
>>> @@ -66,6 +72,7 @@
>>> c = Constant((1.0, 2.0))
>>> u.interpolate(c)
>>> File("output/u_2dv.xdmf") << u
>>> + XDMFFile("output/u.xdmf") << u
>>>
>>> def test_save_3d_vector(self):
>>> mesh = UnitCubeMesh(1, 1, 1)
>>> @@ -73,6 +80,7 @@
>>> c = Constant((1.0, 2.0, 3.0))
>>> u.interpolate(c)
>>> File("output/u_3Dv.xdmf") << u
>>> + XDMFFile("output/u.xdmf") << u
>>>
>>> def test_save_3d_vector_series(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> @@ -87,18 +95,32 @@
>>>
>>> u.vector()[:] = 3.0
>>> file << (u, 0.3)
>>> + del file
>>> +
>>> + file = XDMFFile("output/u_3D.xdmf")
>>> +
>>> + u.vector()[:] = 1.0
>>> + file << (u, 0.1)
>>> +
>>> + u.vector()[:] = 2.0
>>> + file << (u, 0.2)
>>> +
>>> + u.vector()[:] = 3.0
>>> + file << (u, 0.3)
>>>
>>> def test_save_2d_tensor(self):
>>> mesh = UnitSquareMesh(16, 16)
>>> u = Function(TensorFunctionSpace(mesh, "Lagrange", 2))
>>> u.vector()[:] = 1.0
>>> File("output/tensor.xdmf") << u
>>> + XDMFFile("output/tensor.xdmf") << u
>>>
>>> def test_save_3d_tensor(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> u = Function(TensorFunctionSpace(mesh, "Lagrange", 2))
>>> u.vector()[:] = 1.0
>>> File("output/u.xdmf") << u
>>> + XDMFFile("output/u.xdmf") << u
>>>
>>> class XDMF_MeshFunction_Output(unittest.TestCase):
>>> """Test output of Meshes to XDMF files"""
>>> @@ -110,6 +132,7 @@
>>> for cell in cells(mesh):
>>> mf[cell] = cell.index()
>>> File("output/mf_1D.xdmf") << mf
>>> + XDMFFile("output/mf_1D.xdmf") << mf
>>>
>>> def test_save_2D_cell_function(self):
>>> mesh = UnitSquareMesh(32, 32)
>>> @@ -117,6 +140,7 @@
>>> for cell in cells(mesh):
>>> mf[cell] = cell.index()
>>> File("output/mf_2D.xdmf") << mf
>>> + XDMFFile("output/mf_2D.xdmf") << mf
>>>
>>> def test_save_3D_cell_function(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> @@ -124,6 +148,7 @@
>>> for cell in cells(mesh):
>>> mf[cell] = cell.index()
>>> File("output/mf_3D.xdmf") << mf
>>> + XDMFFile("output/mf_3D.xdmf") << mf
>>>
>>> def test_save_2D_facet_function(self):
>>> mesh = UnitSquareMesh(32, 32)
>>> @@ -131,6 +156,7 @@
>>> for facet in facets(mesh):
>>> mf[facet] = facet.index()
>>> File("output/mf_facet_2D.xdmf") << mf
>>> + XDMFFile("output/mf_facet_2D.xdmf") << mf
>>>
>>> def test_save_3D_facet_function(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> @@ -138,6 +164,7 @@
>>> for facet in facets(mesh):
>>> mf[facet] = facet.index()
>>> File("output/mf_facet_3D.xdmf") << mf
>>> + XDMFFile("output/mf_facet_3D.xdmf") << mf
>>>
>>> def test_save_3D_edge_function(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> @@ -145,6 +172,7 @@
>>> for edge in edges(mesh):
>>> mf[edge] = edge.index()
>>> File("output/mf_edge_3D.xdmf") << mf
>>> + XDMFFile("output/mf_edge_3D.xdmf") << mf
>>>
>>> def test_save_2D_vertex_function(self):
>>> mesh = UnitSquareMesh(32, 32)
>>> @@ -152,6 +180,7 @@
>>> for vertex in vertices(mesh):
>>> mf[vertex] = vertex.index()
>>> File("output/mf_vertex_2D.xdmf") << mf
>>> + XDMFFile("output/mf_vertex_2D.xdmf") << mf
>>>
>>> def test_save_3D_vertex_function(self):
>>> mesh = UnitCubeMesh(8, 8, 8)
>>> @@ -159,6 +188,7 @@
>>> for vertex in vertices(mesh):
>>> mf[vertex] = vertex.index()
>>> File("output/mf_vertex_3D.xdmf") << mf
>>> + XDMFFile("output/mf_vertex_3D.xdmf") << mf
>>>
>>> if __name__ == "__main__":
>>> unittest.main()
>>>
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dolfin
>>> Post to : dolfin@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dolfin
>>> More help : https://help.launchpad.net/ListHelp
>>>
>>
>
Follow ups
References