curved elements support MPI and multithreading

This commit is contained in:
Joachim Schoeberl 2011-08-11 22:28:22 +00:00
parent 1312e1d1da
commit 577ecd6f47
5 changed files with 89 additions and 86 deletions

View File

@ -24,6 +24,8 @@ namespace netgen
enum { MPI_TAG_MESH = 210 }; enum { MPI_TAG_MESH = 210 };
enum { MPI_TAG_VIS = 310 }; enum { MPI_TAG_VIS = 310 };
extern MPI_Comm mesh_comm;
template <class T> template <class T>
MPI_Datatype MyGetMPIType ( ) { cerr << "ERROR in GetMPIType() -- no type found" << endl;return 0;} MPI_Datatype MyGetMPIType ( ) { cerr << "ERROR in GetMPIType() -- no type found" << endl;return 0;}

View File

@ -454,15 +454,15 @@ namespace netgen
Array<int> master_facecoeffsindex; Array<int> master_facecoeffsindex;
Array<Vec<3> > master_facecoeffs; Array<Vec<3> > master_facecoeffs;
MyMPI_Bcast (master_edgeorder, 0); MyMPI_Bcast (master_edgeorder, 0, mesh_comm);
MyMPI_Bcast (master_edgecoeffsindex, 0); MyMPI_Bcast (master_edgecoeffsindex, 0, mesh_comm);
MyMPI_Bcast (master_edgecoeffs, 0); MyMPI_Bcast (master_edgecoeffs, 0, mesh_comm);
if (mesh.GetDimension() == 3) if (mesh.GetDimension() == 3)
{ {
MyMPI_Bcast (master_faceorder, 0); MyMPI_Bcast (master_faceorder, 0, mesh_comm);
MyMPI_Bcast (master_facecoeffsindex, 0); MyMPI_Bcast (master_facecoeffsindex, 0, mesh_comm);
MyMPI_Bcast (master_facecoeffs, 0); MyMPI_Bcast (master_facecoeffs, 0, mesh_comm);
} }
@ -1041,15 +1041,15 @@ namespace netgen
#ifdef PARALLEL #ifdef PARALLEL
if (ntasks > 1) if (ntasks > 1)
{ {
MyMPI_Bcast (edgeorder, 0); MyMPI_Bcast (edgeorder, 0, mesh_comm);
MyMPI_Bcast (edgecoeffsindex, 0); MyMPI_Bcast (edgecoeffsindex, 0, mesh_comm);
MyMPI_Bcast (edgecoeffs, 0); MyMPI_Bcast (edgecoeffs, 0, mesh_comm);
if (mesh.GetDimension() == 3) if (mesh.GetDimension() == 3)
{ {
MyMPI_Bcast (faceorder, 0); MyMPI_Bcast (faceorder, 0, mesh_comm);
MyMPI_Bcast (facecoeffsindex, 0); MyMPI_Bcast (facecoeffsindex, 0, mesh_comm);
MyMPI_Bcast (facecoeffs, 0); MyMPI_Bcast (facecoeffs, 0, mesh_comm);
} }
} }
#endif #endif

View File

@ -13,12 +13,8 @@ namespace netgen
// extern double teterrpow; // extern double teterrpow;
MESHING3_RESULT MeshVolume (MeshingParameters & mp, Mesh& mesh3d) MESHING3_RESULT MeshVolume (MeshingParameters & mp, Mesh& mesh3d)
{ {
int i, oldne; int oldne;
PointIndex pi;
int meshed; int meshed;
int cntsteps;
Array<INDEX_2> connectednodes; Array<INDEX_2> connectednodes;
@ -101,66 +97,67 @@ namespace netgen
for (int qstep = 1; qstep <= 3; qstep++) for (int qstep = 1; qstep <= 3; qstep++)
{ {
// cout << "openquads = " << mesh3d.HasOpenQuads() << endl;
if (mesh3d.HasOpenQuads()) if (mesh3d.HasOpenQuads())
{ {
string rulefile = ngdir; string rulefile = ngdir;
const char ** rulep = NULL; const char ** rulep = NULL;
switch (qstep) switch (qstep)
{ {
case 1: case 1:
rulefile += "/rules/prisms2.rls"; rulefile += "/rules/prisms2.rls";
rulep = prismrules2; rulep = prismrules2;
break; break;
case 2: // connect pyramid to triangle case 2: // connect pyramid to triangle
rulefile += "/rules/pyramids2.rls"; rulefile += "/rules/pyramids2.rls";
rulep = pyramidrules2; rulep = pyramidrules2;
break; break;
case 3: // connect to vis-a-vis point case 3: // connect to vis-a-vis point
rulefile += "/rules/pyramids.rls"; rulefile += "/rules/pyramids.rls";
rulep = pyramidrules; rulep = pyramidrules;
break; break;
} }
// Meshing3 meshing(rulefile); // Meshing3 meshing(rulefile);
Meshing3 meshing(rulep); Meshing3 meshing(rulep);
MeshingParameters mpquad = mp; MeshingParameters mpquad = mp;
mpquad.giveuptol = 15; mpquad.giveuptol = 15;
mpquad.baseelnp = 4; mpquad.baseelnp = 4;
mpquad.starshapeclass = 1000; mpquad.starshapeclass = 1000;
mpquad.check_impossible = qstep == 1; // for prisms only (air domain in trafo) mpquad.check_impossible = qstep == 1; // for prisms only (air domain in trafo)
for (pi = PointIndex::BASE; for (PointIndex pi = PointIndex::BASE;
pi < mesh3d.GetNP()+PointIndex::BASE; pi++) pi < mesh3d.GetNP()+PointIndex::BASE; pi++)
meshing.AddPoint (mesh3d[pi], pi); meshing.AddPoint (mesh3d[pi], pi);
mesh3d.GetIdentifications().GetPairs (0, connectednodes); mesh3d.GetIdentifications().GetPairs (0, connectednodes);
for (i = 1; i <= connectednodes.Size(); i++) for (int i = 1; i <= connectednodes.Size(); i++)
meshing.AddConnectedPair (connectednodes.Get(i)); meshing.AddConnectedPair (connectednodes.Get(i));
for (i = 1; i <= mesh3d.GetNOpenElements(); i++) for (int i = 1; i <= mesh3d.GetNOpenElements(); i++)
{ {
Element2d hel = mesh3d.OpenElement(i); Element2d hel = mesh3d.OpenElement(i);
meshing.AddBoundaryElement (hel); meshing.AddBoundaryElement (hel);
} }
oldne = mesh3d.GetNE(); oldne = mesh3d.GetNE();
meshing.GenerateMesh (mesh3d, mpquad); meshing.GenerateMesh (mesh3d, mpquad);
for (i = oldne + 1; i <= mesh3d.GetNE(); i++) for (int i = oldne + 1; i <= mesh3d.GetNE(); i++)
mesh3d.VolumeElement(i).SetIndex (k); mesh3d.VolumeElement(i).SetIndex (k);
(*testout) (*testout)
<< "mesh has " << mesh3d.GetNE() << " prism/pyramid elements" << endl; << "mesh has " << mesh3d.GetNE() << " prism/pyramid elements" << endl;
mesh3d.FindOpenElements(k); mesh3d.FindOpenElements(k);
} }
} }
if (mesh3d.HasOpenQuads()) if (mesh3d.HasOpenQuads())
{ {
@ -177,19 +174,19 @@ namespace netgen
mesh3d.FindOpenElements(k); mesh3d.FindOpenElements(k);
for (pi = PointIndex::BASE; for (PointIndex pi = PointIndex::BASE;
pi < mesh3d.GetNP()+PointIndex::BASE; pi++) pi < mesh3d.GetNP()+PointIndex::BASE; pi++)
meshing.AddPoint (mesh3d[pi], pi); meshing.AddPoint (mesh3d[pi], pi);
for (i = 1; i <= mesh3d.GetNOpenElements(); i++) for (int i = 1; i <= mesh3d.GetNOpenElements(); i++)
meshing.AddBoundaryElement (mesh3d.OpenElement(i)); meshing.AddBoundaryElement (mesh3d.OpenElement(i));
oldne = mesh3d.GetNE(); oldne = mesh3d.GetNE();
meshing.Delaunay (mesh3d, k, mp); meshing.Delaunay (mesh3d, k, mp);
for (i = oldne + 1; i <= mesh3d.GetNE(); i++) for (int i = oldne + 1; i <= mesh3d.GetNE(); i++)
mesh3d.VolumeElement(i).SetIndex (k); mesh3d.VolumeElement(i).SetIndex (k);
PrintMessage (3, mesh3d.GetNP(), " points, ", PrintMessage (3, mesh3d.GetNP(), " points, ",
@ -197,7 +194,7 @@ namespace netgen
} }
cntsteps = 0; int cntsteps = 0;
if (mesh3d.GetNOpenElements()) if (mesh3d.GetNOpenElements())
do do
{ {
@ -220,14 +217,14 @@ namespace netgen
Array<int, PointIndex::BASE> glob2loc(mesh3d.GetNP()); Array<int, PointIndex::BASE> glob2loc(mesh3d.GetNP());
glob2loc = -1; glob2loc = -1;
for (pi = PointIndex::BASE; for (PointIndex pi = PointIndex::BASE;
pi < mesh3d.GetNP()+PointIndex::BASE; pi++) pi < mesh3d.GetNP()+PointIndex::BASE; pi++)
if (domain_bbox.IsIn (mesh3d[pi])) if (domain_bbox.IsIn (mesh3d[pi]))
glob2loc[pi] = glob2loc[pi] =
meshing.AddPoint (mesh3d[pi], pi); meshing.AddPoint (mesh3d[pi], pi);
for (i = 1; i <= mesh3d.GetNOpenElements(); i++) for (int i = 1; i <= mesh3d.GetNOpenElements(); i++)
{ {
Element2d hel = mesh3d.OpenElement(i); Element2d hel = mesh3d.OpenElement(i);
for (int j = 0; j < hel.GetNP(); j++) for (int j = 0; j < hel.GetNP(); j++)
@ -255,14 +252,10 @@ namespace netgen
meshed = 0; meshed = 0;
PrintMessage (5, mesh3d.GetNOpenElements(), " open faces found"); PrintMessage (5, mesh3d.GetNOpenElements(), " open faces found");
// mesh3d.Save ("tmp.vol");
MeshOptimize3d optmesh(mp); MeshOptimize3d optmesh(mp);
const char * optstr = "mcmstmcmstmcmstmcm"; const char * optstr = "mcmstmcmstmcmstmcm";
size_t j; for (size_t j = 1; j <= strlen(optstr); j++)
for (j = 1; j <= strlen(optstr); j++)
{ {
mesh3d.CalcSurfacesOfNode(); mesh3d.CalcSurfacesOfNode();
mesh3d.FreeOpenElementsEnvironment(2); mesh3d.FreeOpenElementsEnvironment(2);

View File

@ -16,7 +16,12 @@ namespace netgen
#ifdef PARALLEL #ifdef PARALLEL
#include <mpi.h> #include <mpi.h>
extern void ParallelRun(); extern void ParallelRun();
namespace netgen
{
MPI_Comm mesh_comm;
}
#endif #endif
@ -74,6 +79,8 @@ int main(int argc, char ** argv)
if (netgen::id == 0 && provided == MPI_THREAD_MULTIPLE) if (netgen::id == 0 && provided == MPI_THREAD_MULTIPLE)
cout << "multithreaded mpi is supported" << endl; cout << "multithreaded mpi is supported" << endl;
MPI_Comm_dup ( MPI_COMM_WORLD, &netgen::mesh_comm);
#endif #endif

View File

@ -42,8 +42,9 @@ namespace netgen
namespace netgen namespace netgen
{ {
MPI_Group MPI_HIGHORDER_WORLD; // MPI_Group MPI_HIGHORDER_WORLD;
MPI_Comm MPI_HIGHORDER_COMM; // MPI_Comm MPI_HIGHORDER_COMM;
MPI_Comm mesh_comm;
} }
#endif #endif