mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
curved elements support MPI and multithreading
This commit is contained in:
parent
1312e1d1da
commit
577ecd6f47
@ -24,6 +24,8 @@ namespace netgen
|
||||
enum { MPI_TAG_MESH = 210 };
|
||||
enum { MPI_TAG_VIS = 310 };
|
||||
|
||||
extern MPI_Comm mesh_comm;
|
||||
|
||||
template <class T>
|
||||
MPI_Datatype MyGetMPIType ( ) { cerr << "ERROR in GetMPIType() -- no type found" << endl;return 0;}
|
||||
|
||||
|
@ -454,15 +454,15 @@ namespace netgen
|
||||
Array<int> master_facecoeffsindex;
|
||||
Array<Vec<3> > master_facecoeffs;
|
||||
|
||||
MyMPI_Bcast (master_edgeorder, 0);
|
||||
MyMPI_Bcast (master_edgecoeffsindex, 0);
|
||||
MyMPI_Bcast (master_edgecoeffs, 0);
|
||||
MyMPI_Bcast (master_edgeorder, 0, mesh_comm);
|
||||
MyMPI_Bcast (master_edgecoeffsindex, 0, mesh_comm);
|
||||
MyMPI_Bcast (master_edgecoeffs, 0, mesh_comm);
|
||||
|
||||
if (mesh.GetDimension() == 3)
|
||||
{
|
||||
MyMPI_Bcast (master_faceorder, 0);
|
||||
MyMPI_Bcast (master_facecoeffsindex, 0);
|
||||
MyMPI_Bcast (master_facecoeffs, 0);
|
||||
MyMPI_Bcast (master_faceorder, 0, mesh_comm);
|
||||
MyMPI_Bcast (master_facecoeffsindex, 0, mesh_comm);
|
||||
MyMPI_Bcast (master_facecoeffs, 0, mesh_comm);
|
||||
}
|
||||
|
||||
|
||||
@ -1041,15 +1041,15 @@ namespace netgen
|
||||
#ifdef PARALLEL
|
||||
if (ntasks > 1)
|
||||
{
|
||||
MyMPI_Bcast (edgeorder, 0);
|
||||
MyMPI_Bcast (edgecoeffsindex, 0);
|
||||
MyMPI_Bcast (edgecoeffs, 0);
|
||||
MyMPI_Bcast (edgeorder, 0, mesh_comm);
|
||||
MyMPI_Bcast (edgecoeffsindex, 0, mesh_comm);
|
||||
MyMPI_Bcast (edgecoeffs, 0, mesh_comm);
|
||||
|
||||
if (mesh.GetDimension() == 3)
|
||||
{
|
||||
MyMPI_Bcast (faceorder, 0);
|
||||
MyMPI_Bcast (facecoeffsindex, 0);
|
||||
MyMPI_Bcast (facecoeffs, 0);
|
||||
MyMPI_Bcast (faceorder, 0, mesh_comm);
|
||||
MyMPI_Bcast (facecoeffsindex, 0, mesh_comm);
|
||||
MyMPI_Bcast (facecoeffs, 0, mesh_comm);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -13,12 +13,8 @@ namespace netgen
|
||||
// extern double teterrpow;
|
||||
MESHING3_RESULT MeshVolume (MeshingParameters & mp, Mesh& mesh3d)
|
||||
{
|
||||
int i, oldne;
|
||||
PointIndex pi;
|
||||
|
||||
int oldne;
|
||||
int meshed;
|
||||
int cntsteps;
|
||||
|
||||
|
||||
Array<INDEX_2> connectednodes;
|
||||
|
||||
@ -101,66 +97,67 @@ namespace netgen
|
||||
|
||||
for (int qstep = 1; qstep <= 3; qstep++)
|
||||
{
|
||||
// cout << "openquads = " << mesh3d.HasOpenQuads() << endl;
|
||||
if (mesh3d.HasOpenQuads())
|
||||
{
|
||||
string rulefile = ngdir;
|
||||
|
||||
const char ** rulep = NULL;
|
||||
switch (qstep)
|
||||
{
|
||||
case 1:
|
||||
rulefile += "/rules/prisms2.rls";
|
||||
rulep = prismrules2;
|
||||
break;
|
||||
case 2: // connect pyramid to triangle
|
||||
rulefile += "/rules/pyramids2.rls";
|
||||
rulep = pyramidrules2;
|
||||
break;
|
||||
case 3: // connect to vis-a-vis point
|
||||
rulefile += "/rules/pyramids.rls";
|
||||
rulep = pyramidrules;
|
||||
break;
|
||||
}
|
||||
|
||||
// Meshing3 meshing(rulefile);
|
||||
Meshing3 meshing(rulep);
|
||||
|
||||
MeshingParameters mpquad = mp;
|
||||
|
||||
mpquad.giveuptol = 15;
|
||||
mpquad.baseelnp = 4;
|
||||
mpquad.starshapeclass = 1000;
|
||||
mpquad.check_impossible = qstep == 1; // for prisms only (air domain in trafo)
|
||||
|
||||
|
||||
for (pi = PointIndex::BASE;
|
||||
pi < mesh3d.GetNP()+PointIndex::BASE; pi++)
|
||||
meshing.AddPoint (mesh3d[pi], pi);
|
||||
|
||||
mesh3d.GetIdentifications().GetPairs (0, connectednodes);
|
||||
for (i = 1; i <= connectednodes.Size(); i++)
|
||||
meshing.AddConnectedPair (connectednodes.Get(i));
|
||||
|
||||
for (i = 1; i <= mesh3d.GetNOpenElements(); i++)
|
||||
{
|
||||
Element2d hel = mesh3d.OpenElement(i);
|
||||
meshing.AddBoundaryElement (hel);
|
||||
}
|
||||
|
||||
oldne = mesh3d.GetNE();
|
||||
|
||||
meshing.GenerateMesh (mesh3d, mpquad);
|
||||
|
||||
for (i = oldne + 1; i <= mesh3d.GetNE(); i++)
|
||||
mesh3d.VolumeElement(i).SetIndex (k);
|
||||
|
||||
(*testout)
|
||||
<< "mesh has " << mesh3d.GetNE() << " prism/pyramid elements" << endl;
|
||||
|
||||
mesh3d.FindOpenElements(k);
|
||||
}
|
||||
}
|
||||
|
||||
const char ** rulep = NULL;
|
||||
switch (qstep)
|
||||
{
|
||||
case 1:
|
||||
rulefile += "/rules/prisms2.rls";
|
||||
rulep = prismrules2;
|
||||
break;
|
||||
case 2: // connect pyramid to triangle
|
||||
rulefile += "/rules/pyramids2.rls";
|
||||
rulep = pyramidrules2;
|
||||
break;
|
||||
case 3: // connect to vis-a-vis point
|
||||
rulefile += "/rules/pyramids.rls";
|
||||
rulep = pyramidrules;
|
||||
break;
|
||||
}
|
||||
|
||||
// Meshing3 meshing(rulefile);
|
||||
Meshing3 meshing(rulep);
|
||||
|
||||
MeshingParameters mpquad = mp;
|
||||
|
||||
mpquad.giveuptol = 15;
|
||||
mpquad.baseelnp = 4;
|
||||
mpquad.starshapeclass = 1000;
|
||||
mpquad.check_impossible = qstep == 1; // for prisms only (air domain in trafo)
|
||||
|
||||
|
||||
for (PointIndex pi = PointIndex::BASE;
|
||||
pi < mesh3d.GetNP()+PointIndex::BASE; pi++)
|
||||
meshing.AddPoint (mesh3d[pi], pi);
|
||||
|
||||
mesh3d.GetIdentifications().GetPairs (0, connectednodes);
|
||||
for (int i = 1; i <= connectednodes.Size(); i++)
|
||||
meshing.AddConnectedPair (connectednodes.Get(i));
|
||||
|
||||
for (int i = 1; i <= mesh3d.GetNOpenElements(); i++)
|
||||
{
|
||||
Element2d hel = mesh3d.OpenElement(i);
|
||||
meshing.AddBoundaryElement (hel);
|
||||
}
|
||||
|
||||
oldne = mesh3d.GetNE();
|
||||
|
||||
meshing.GenerateMesh (mesh3d, mpquad);
|
||||
|
||||
for (int i = oldne + 1; i <= mesh3d.GetNE(); i++)
|
||||
mesh3d.VolumeElement(i).SetIndex (k);
|
||||
|
||||
(*testout)
|
||||
<< "mesh has " << mesh3d.GetNE() << " prism/pyramid elements" << endl;
|
||||
|
||||
mesh3d.FindOpenElements(k);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mesh3d.HasOpenQuads())
|
||||
{
|
||||
@ -177,19 +174,19 @@ namespace netgen
|
||||
mesh3d.FindOpenElements(k);
|
||||
|
||||
|
||||
for (pi = PointIndex::BASE;
|
||||
for (PointIndex pi = PointIndex::BASE;
|
||||
pi < mesh3d.GetNP()+PointIndex::BASE; 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));
|
||||
|
||||
oldne = mesh3d.GetNE();
|
||||
|
||||
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);
|
||||
|
||||
PrintMessage (3, mesh3d.GetNP(), " points, ",
|
||||
@ -197,7 +194,7 @@ namespace netgen
|
||||
}
|
||||
|
||||
|
||||
cntsteps = 0;
|
||||
int cntsteps = 0;
|
||||
if (mesh3d.GetNOpenElements())
|
||||
do
|
||||
{
|
||||
@ -220,14 +217,14 @@ namespace netgen
|
||||
Array<int, PointIndex::BASE> glob2loc(mesh3d.GetNP());
|
||||
glob2loc = -1;
|
||||
|
||||
for (pi = PointIndex::BASE;
|
||||
for (PointIndex pi = PointIndex::BASE;
|
||||
pi < mesh3d.GetNP()+PointIndex::BASE; pi++)
|
||||
|
||||
if (domain_bbox.IsIn (mesh3d[pi]))
|
||||
glob2loc[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);
|
||||
for (int j = 0; j < hel.GetNP(); j++)
|
||||
@ -255,14 +252,10 @@ namespace netgen
|
||||
meshed = 0;
|
||||
PrintMessage (5, mesh3d.GetNOpenElements(), " open faces found");
|
||||
|
||||
// mesh3d.Save ("tmp.vol");
|
||||
|
||||
|
||||
MeshOptimize3d optmesh(mp);
|
||||
|
||||
const char * optstr = "mcmstmcmstmcmstmcm";
|
||||
size_t j;
|
||||
for (j = 1; j <= strlen(optstr); j++)
|
||||
for (size_t j = 1; j <= strlen(optstr); j++)
|
||||
{
|
||||
mesh3d.CalcSurfacesOfNode();
|
||||
mesh3d.FreeOpenElementsEnvironment(2);
|
||||
|
@ -16,7 +16,12 @@ namespace netgen
|
||||
|
||||
#ifdef PARALLEL
|
||||
#include <mpi.h>
|
||||
|
||||
extern void ParallelRun();
|
||||
namespace netgen
|
||||
{
|
||||
MPI_Comm mesh_comm;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -74,6 +79,8 @@ int main(int argc, char ** argv)
|
||||
|
||||
if (netgen::id == 0 && provided == MPI_THREAD_MULTIPLE)
|
||||
cout << "multithreaded mpi is supported" << endl;
|
||||
|
||||
MPI_Comm_dup ( MPI_COMM_WORLD, &netgen::mesh_comm);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -42,8 +42,9 @@ namespace netgen
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
MPI_Group MPI_HIGHORDER_WORLD;
|
||||
MPI_Comm MPI_HIGHORDER_COMM;
|
||||
// MPI_Group MPI_HIGHORDER_WORLD;
|
||||
// MPI_Comm MPI_HIGHORDER_COMM;
|
||||
MPI_Comm mesh_comm;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user