pickle mesh-load also via ngsolve.Mesh('filename.vol.bin')

This commit is contained in:
Joachim Schoeberl 2021-06-17 07:58:17 +02:00
parent 4b40a7eb31
commit b51df253fd

View File

@ -146,27 +146,37 @@ void Ng_LoadMesh (const char * filename, ngcore::NgMPI_Comm comm)
if( id == 0) { if( id == 0) {
string fn(filename);
if (fn.substr (fn.length()-3, 3) == ".gz")
infile = new igzstream (filename);
else
infile = new ifstream (filename);
mesh.reset (new Mesh()); mesh.reset (new Mesh());
mesh->SetCommunicator(comm); mesh->SetCommunicator(comm);
mesh -> Load(*infile);
SetGlobalMesh (mesh);
// make string from rest of file (for geometry info!) string fn(filename);
// (this might be empty, in which case we take the global ng_geometry) if (fn.substr (fn.length()-8, 8) == ".vol.bin")
stringstream geom_part; {
geom_part << infile->rdbuf(); mesh -> Load(fn);
string geom_part_string = geom_part.str(); SetGlobalMesh (mesh);
strs = geom_part_string.size(); }
// buf = new char[strs]; else
buf.SetSize(strs); {
memcpy(&buf[0], geom_part_string.c_str(), strs*sizeof(char)); if (fn.substr (fn.length()-3, 3) == ".gz")
infile = new igzstream (filename);
else
infile = new ifstream (filename);
mesh -> Load(*infile);
SetGlobalMesh (mesh);
// make string from rest of file (for geometry info!)
// (this might be empty, in which case we take the global ng_geometry)
stringstream geom_part;
geom_part << infile->rdbuf();
string geom_part_string = geom_part.str();
strs = geom_part_string.size();
// buf = new char[strs];
buf.SetSize(strs);
memcpy(&buf[0], geom_part_string.c_str(), strs*sizeof(char));
delete infile;
}
delete infile;
if (ntasks > 1) if (ntasks > 1)
{ {