Fixed curvedelems+mesh loaded from file via python. Fixed MPI+curvedelems

This commit is contained in:
Lukas Kogler 2017-06-09 20:21:55 +02:00
parent 7e21f0cd9c
commit 3c1596b8a0
3 changed files with 41 additions and 15 deletions

View File

@ -577,8 +577,8 @@ namespace netgen
PrintMessage (1, "Curve elements, order = ", aorder); PrintMessage (1, "Curve elements, order = ", aorder);
if (rational) PrintMessage (1, "curved elements with rational splines"); if (rational) PrintMessage (1, "curved elements with rational splines");
if (working) // if (working)
const_cast<Mesh&> (mesh).UpdateTopology(); const_cast<Mesh&> (mesh).UpdateTopology();
const MeshTopology & top = mesh.GetTopology(); const MeshTopology & top = mesh.GetTopology();
rational = arational; rational = arational;

View File

@ -783,7 +783,7 @@ namespace netgen
SetMaterial(k+1, string(&compiled_mats[cnt], matsz[k])); SetMaterial(k+1, string(&compiled_mats[cnt], matsz[k]));
cnt += matsz[k]; cnt += matsz[k];
} }
MPI_Barrier(MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD);
int timerloc = NgProfiler::CreateTimer ("Update local mesh"); int timerloc = NgProfiler::CreateTimer ("Update local mesh");

View File

@ -423,26 +423,48 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
.def("Load", FunctionPointer .def("Load", FunctionPointer
([](Mesh & self, const string & filename) ([](Mesh & self, const string & filename)
{ {
istream * infile; istream * infile;
#ifdef PARALLEL
MPI_Comm_rank(MPI_COMM_WORLD, &id);
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
char* buf = nullptr;
int strs = 0;
if(id==0) {
#endif
if (filename.find(".vol.gz") != string::npos) if (filename.find(".vol.gz") != string::npos)
infile = new igzstream (filename.c_str()); infile = new igzstream (filename.c_str());
else else
infile = new ifstream (filename.c_str()); infile = new ifstream (filename.c_str());
// ifstream input(filename); // ifstream input(filename);
#ifdef PARALLEL #ifdef PARALLEL
// int id; //still inside id==0-bracket...
MPI_Comm_rank(MPI_COMM_WORLD, &id); self.Load(*infile);
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
if (id == 0)
{
self.Load(*infile);
self.Distribute(); self.Distribute();
/** Copy the rest of the file into a string (for geometry) **/
stringstream geom_part;
geom_part << infile->rdbuf();
string geom_part_string = geom_part.str();
strs = geom_part_string.size();
buf = new char[strs];
memcpy(buf, geom_part_string.c_str(), strs*sizeof(char));
} }
else else {
{ self.SendRecvMesh();
self.SendRecvMesh(); }
}
/** Scatter the geometry-string **/
MPI_Bcast(&strs, 1, MPI_INT, 0, MPI_COMM_WORLD);
if(id!=0)
buf = new char[strs];
MPI_Bcast(buf, strs, MPI_CHAR, 0, MPI_COMM_WORLD);
if(id==0)
delete infile;
infile = new istringstream(string((const char*)buf, (size_t)strs));
delete buf;
#else #else
self.Load(*infile); self.Load(*infile);
#endif #endif
@ -455,6 +477,10 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
break; break;
} }
} }
if (!ng_geometry)
ng_geometry = make_shared<NetgenGeometry>();
self.SetGeometry(ng_geometry);
delete infile;
})) }))
// static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load)) // static_cast<void(Mesh::*)(const string & name)>(&Mesh::Load))
.def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save)) .def("Save", static_cast<void(Mesh::*)(const string & name)const>(&Mesh::Save))