dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #14469
MeshFunction write and read problems
I've realized that if MeshFunction is not properly read if mesh contains
also MeshData with MeshFunctions. I'm afraid that there is a small bug
in the XML parser. Attached code demonstrates this problem.
Another MeshFunction issue is that current XML IO can't save bool types.
Is it intentional, or do you plan to extend interface?
Few months ago MeshFuction<bool> could be saved, so that's why I'm asking.
The last question regards MeshFunction (const Mesh &mesh, const
std::string filename) costructor. Currently MeshFunction is saved with
Mesh, so why the constructor needs mesh object? I think it should be
read from the same file where the MeshFunction is.
regrds.
#include <dolfin.h>
#include "Poisson.h"
using namespace dolfin;
int main()
{
UnitSquare mesh(32, 32);
MeshFunction<dolfin::uint> *data_mf;
data_mf = mesh.data().create_mesh_function("MeshData function",2);
(*data_mf) = 1.0;
MeshFunction<dolfin::uint> mf(mesh,2);
mf = 2.0;
cout << "Before read/write: " << mf.get(0) << endl;
File file_mf("x.xml");
file_mf << mf;
MeshFunction<dolfin::uint> mf1(mesh, "x.xml");
cout << "After read/write: " << mf1.get(0) << endl;
return 0;
}
Follow ups