parallel command processing

This commit is contained in:
Joachim Schoeberl 2012-07-05 11:05:33 +00:00
parent a4dcf70c69
commit faad040fb0
8 changed files with 51 additions and 45 deletions

View File

@ -231,6 +231,11 @@ void Ng_LoadMeshFromStream ( istream & input )
void Ng_LoadMesh (const char * filename)
{
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
if (id == 0)
{
if ( (strlen (filename) > 4) &&
strcmp (filename + (strlen (filename)-4), ".vol") != 0 )
@ -245,6 +250,18 @@ void Ng_LoadMesh (const char * filename)
ifstream infile(filename);
Ng_LoadMeshFromStream(infile);
if (ntasks > 1)
{
// MyMPI_SendCmd ("mesh");
mesh -> Distribute();
}
}
else
{
mesh.Reset (new Mesh());
mesh->SendRecvMesh();
}
}
void Ng_LoadMeshFromString (const char * mesh_as_string)

View File

@ -1197,16 +1197,10 @@ namespace netgen
topology -> Update();
clusters -> Update();
#ifdef PARALLEL
if ( ntasks > 1 ) Distribute ();
#endif
// Distribute();
SetNextMajorTimeStamp();
// PrintMemInfo (cout);
}

View File

@ -657,6 +657,9 @@ namespace netgen
// call it only for the master !
void Mesh :: Distribute ()
{
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
if (id != 0 || ntasks == 1 ) return;
#ifdef METIS
@ -666,17 +669,15 @@ namespace netgen
(*this)[ei].SetPartition(ntasks * ei/GetNE() + 1);
#endif
/*
for (ElementIndex ei = 0; ei < GetNE(); ei++)
*testout << "el(" << ei << ") is in part " << (*this)[ei].GetPartition() << endl;
for (SurfaceElementIndex ei = 0; ei < GetNSE(); ei++)
*testout << "sel(" << int(ei) << ") is in part " << (*this)[ei].GetPartition() << endl;
*/
// send partition
MyMPI_SendCmd ("mesh");
// MyMPI_SendCmd ("mesh");
SendRecvMesh ();
// paralleltop -> UpdateCoarseGrid();
// paralleltop -> Print();
}

View File

@ -221,6 +221,11 @@ namespace netgen
ifstream infile(filename.c_str());
mesh -> Load(infile);
#ifdef PARALLEL
MyMPI_SendCmd ("mesh");
mesh -> Distribute();
#endif
for (int i = 0; i < geometryregister.Size(); i++)
{
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (infile);

View File

@ -2,9 +2,6 @@
#include "dlfcn.h"
#ifdef OCCGEOMETRY
#include <occgeom.hpp>
#endif
// #include <mystdlib.h>
@ -30,23 +27,16 @@
#endif
/*
#include <geometry2d.hpp>
#include <stlgeom.hpp>
// #include <incvis.hpp>
// #include <visual.hpp>
// #include <mystdlib.h>
// #include <myadt.hpp>
// #include <linalg.hpp>
// #include <csg.hpp>
*/
#include <meshing.hpp>
// #include "parallel.hpp"
#include "parallelfunc.hpp"
// #include "parallelfunc.hpp"
// extern "C" void NGS_ParallelRun (const string & message);
@ -72,6 +62,7 @@ namespace netgen {
extern AutoPtr<Mesh> mesh;
extern VisualSceneMesh vsmesh;
extern Flags parameters;
extern DLL_HEADER MeshingParameters mparam;
}
using namespace netgen;

View File

@ -1,3 +1,7 @@
das braucht keiner mehr
#ifndef FILE_PARALLELFUNC
#define FILE_PARALLELFUNC

View File

@ -5,7 +5,7 @@ dist_pkgdata_DATA = cube.surf
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(MPI_INCLUDES) $(OCCFLAGS)
lib_LTLIBRARIES = libnglib.la
libnglib_la_SOURCES = nglib.cpp
libnglib_la_SOURCES = nglib.cpp parallelfunc.cpp
libnglib_la_LIBADD = \
$(top_builddir)/libsrc/interface/libinterface.la \

View File

@ -31,20 +31,14 @@ namespace netgen {
MeshingParameters & mp);
}
namespace netgen
{
int id, ntasks;
}
#ifdef PARALLEL
#ifdef PARALLELxxx
#include <mpi.h>
namespace netgen
{
// MPI_Group MPI_HIGHORDER_WORLD;
// MPI_Comm MPI_HIGHORDER_COMM;
MPI_Comm mesh_comm;
// MPI_Comm mesh_comm;
}
#endif