2009-01-26 00:37:14 +05:00
|
|
|
#ifdef PARALLEL
|
|
|
|
|
|
|
|
|
|
|
|
#include <meshing.hpp>
|
|
|
|
#include "paralleltop.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace netgen
|
|
|
|
{
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
ParallelMeshTopology :: ParallelMeshTopology (const Mesh & amesh)
|
|
|
|
: mesh(amesh)
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
is_updated = false;
|
2011-02-15 21:22:05 +05:00
|
|
|
}
|
2012-06-21 20:19:25 +06:00
|
|
|
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
ParallelMeshTopology :: ~ParallelMeshTopology ()
|
|
|
|
{
|
2011-07-15 03:36:19 +06:00
|
|
|
;
|
2011-02-15 21:22:05 +05:00
|
|
|
}
|
|
|
|
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
void ParallelMeshTopology :: Reset ()
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2016-02-28 10:05:19 +05:00
|
|
|
cout << "ParallelMeshTopology::Reset called" << endl;
|
2012-06-21 20:19:25 +06:00
|
|
|
*testout << "ParallelMeshTopology::Reset" << endl;
|
|
|
|
|
|
|
|
if ( ntasks == 1 ) return;
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
int ned = mesh.GetTopology().GetNEdges();
|
|
|
|
int nfa = mesh.GetTopology().GetNFaces();
|
2012-06-16 18:04:04 +06:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
if (glob_edge.Size() != ned)
|
|
|
|
{
|
|
|
|
glob_edge.SetSize(ned);
|
|
|
|
glob_face.SetSize(nfa);
|
|
|
|
glob_edge = -1;
|
|
|
|
glob_face = -1;
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
loc2distedge.ChangeSize (ned);
|
|
|
|
loc2distface.ChangeSize (nfa);
|
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
if (glob_vert.Size() != mesh.GetNV())
|
2011-02-15 21:22:05 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
SetNV(mesh.GetNV());
|
|
|
|
SetNE(mesh.GetNE());
|
2011-02-15 21:22:05 +05:00
|
|
|
}
|
2016-02-28 10:05:19 +05:00
|
|
|
cout << "ParallelMeshTopology::Reset complete" << endl;
|
2009-01-26 00:37:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
void ParallelMeshTopology :: Print() const
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
;
|
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
void ParallelMeshTopology :: SetDistantFaceNum (int dest, int locnum)
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
for ( int i = 0; i < loc2distface[locnum-1].Size(); i+=1 )
|
2009-01-26 00:37:14 +05:00
|
|
|
if ( loc2distface[locnum-1][i] == dest )
|
2012-06-21 20:19:25 +06:00
|
|
|
return;
|
2009-01-26 00:37:14 +05:00
|
|
|
loc2distface.Add(locnum-1, dest);
|
|
|
|
}
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
void ParallelMeshTopology :: SetDistantPNum (int dest, int locnum)
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
for ( int i = 0; i < loc2distvert[locnum-1].Size(); i+=1 )
|
|
|
|
if ( loc2distvert[locnum-1][i] == dest )
|
2009-01-26 00:37:14 +05:00
|
|
|
return;
|
2012-06-21 20:19:25 +06:00
|
|
|
loc2distvert.Add (locnum-1, dest);
|
2009-01-26 00:37:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
void ParallelMeshTopology :: SetDistantEdgeNum (int dest, int locnum)
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
for ( int i = 0; i < loc2distedge[locnum-1].Size(); i+=1 )
|
2009-01-26 00:37:14 +05:00
|
|
|
if ( loc2distedge[locnum-1][i] == dest )
|
|
|
|
return;
|
2012-06-21 20:19:25 +06:00
|
|
|
loc2distedge.Add (locnum-1, dest);
|
2009-01-26 00:37:14 +05:00
|
|
|
}
|
|
|
|
|
2012-06-16 18:04:04 +06:00
|
|
|
void ParallelMeshTopology :: SetNV (int anv)
|
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
glob_vert.SetSize(anv);
|
|
|
|
glob_vert = -1;
|
2012-06-16 18:04:04 +06:00
|
|
|
loc2distvert.ChangeSize (anv);
|
|
|
|
}
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
void ParallelMeshTopology :: SetNE ( int ane )
|
2012-06-16 18:04:04 +06:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
glob_el.SetSize (ane);
|
|
|
|
glob_el = -1;
|
2012-06-16 18:04:04 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ParallelMeshTopology :: SetNSE ( int anse )
|
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
glob_surfel.SetSize(anse);
|
|
|
|
glob_surfel = -1;
|
2012-06-16 18:04:04 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ParallelMeshTopology :: SetNSegm ( int anseg )
|
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
glob_segm.SetSize (anseg);
|
|
|
|
glob_segm = -1;
|
2012-06-16 18:04:04 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
|
|
|
|
{
|
2016-02-28 10:05:19 +05:00
|
|
|
cout << "updatecoarsegridglobal called" << endl;
|
2011-07-15 03:36:19 +06:00
|
|
|
if (id == 0)
|
2012-08-20 20:10:23 +06:00
|
|
|
PrintMessage ( 3, "UPDATE GLOBAL COARSEGRID STARTS" );
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
int timer = NgProfiler::CreateTimer ("UpdateCoarseGridGlobal");
|
|
|
|
NgProfiler::RegionTimer reg(timer);
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
*testout << "ParallelMeshTopology :: UpdateCoarseGridGlobal" << endl;
|
2011-07-17 05:13:26 +06:00
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
const MeshTopology & topology = mesh.GetTopology();
|
2012-06-16 18:04:04 +06:00
|
|
|
|
2011-07-17 05:13:26 +06:00
|
|
|
if ( id == 0 )
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-16 18:04:04 +06:00
|
|
|
Array<Array<int>*> sendarrays(ntasks);
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
2012-06-21 20:19:25 +06:00
|
|
|
sendarrays[dest] = new Array<int>;
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
Array<int> edges, faces;
|
|
|
|
for (int el = 1; el <= mesh.GetNE(); el++)
|
2011-07-17 05:13:26 +06:00
|
|
|
{
|
|
|
|
topology.GetElementFaces (el, faces);
|
2012-06-16 18:04:04 +06:00
|
|
|
topology.GetElementEdges (el, edges);
|
2011-07-17 05:13:26 +06:00
|
|
|
const Element & volel = mesh.VolumeElement (el);
|
|
|
|
|
2012-06-16 18:04:04 +06:00
|
|
|
Array<int> & sendarray = *sendarrays[volel.GetPartition()];
|
2011-07-17 05:13:26 +06:00
|
|
|
|
|
|
|
for ( int i = 0; i < edges.Size(); i++ )
|
2012-06-21 20:19:25 +06:00
|
|
|
sendarray.Append (edges[i]);
|
|
|
|
for ( int i = 0; i < faces.Size(); i++ )
|
|
|
|
sendarray.Append (faces[i]);
|
2011-07-17 05:13:26 +06:00
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
for (int el = 1; el <= mesh.GetNSE(); el++)
|
2011-07-17 05:13:26 +06:00
|
|
|
{
|
2012-06-16 18:04:04 +06:00
|
|
|
topology.GetSurfaceElementEdges (el, edges);
|
2011-07-17 05:13:26 +06:00
|
|
|
const Element2d & surfel = mesh.SurfaceElement (el);
|
2012-06-16 18:04:04 +06:00
|
|
|
Array<int> & sendarray = *sendarrays[surfel.GetPartition()];
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2011-07-17 05:13:26 +06:00
|
|
|
for ( int i = 0; i < edges.Size(); i++ )
|
2012-06-16 18:04:04 +06:00
|
|
|
sendarray.Append (edges[i]);
|
2012-08-20 20:10:23 +06:00
|
|
|
sendarray.Append (topology.GetSurfaceElementFace (el));
|
2011-07-17 05:13:26 +06:00
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-16 18:04:04 +06:00
|
|
|
Array<MPI_Request> sendrequests;
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
|
|
|
sendrequests.Append (MyMPI_ISend (*sendarrays[dest], dest, MPI_TAG_MESH+10));
|
|
|
|
MPI_Waitall (sendrequests.Size(), &sendrequests[0], MPI_STATUS_IGNORE);
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-16 18:04:04 +06:00
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
|
|
|
delete sendarrays[dest];
|
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
2012-06-16 18:04:04 +06:00
|
|
|
Array<int> recvarray;
|
|
|
|
MyMPI_Recv (recvarray, 0, MPI_TAG_MESH+10);
|
|
|
|
|
2011-07-17 05:13:26 +06:00
|
|
|
int ii = 0;
|
2009-01-26 00:37:14 +05:00
|
|
|
|
|
|
|
Array<int> faces, edges;
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
for (int volel = 1; volel <= mesh.GetNE(); volel++)
|
2009-01-26 00:37:14 +05:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
topology.GetElementEdges ( volel, edges);
|
|
|
|
for ( int i = 0; i < edges.Size(); i++)
|
|
|
|
SetLoc2Glob_Edge ( edges[i], recvarray[ii++]);
|
2012-06-16 18:04:04 +06:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
topology.GetElementFaces( volel, faces);
|
|
|
|
for ( int i = 0; i < faces.Size(); i++)
|
|
|
|
SetLoc2Glob_Face ( faces[i], recvarray[ii++]);
|
2009-01-26 00:37:14 +05:00
|
|
|
}
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
for (int surfel = 1; surfel <= mesh.GetNSE(); surfel++)
|
2011-07-17 05:13:26 +06:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
topology.GetSurfaceElementEdges (surfel, edges);
|
|
|
|
for (int i = 0; i < edges.Size(); i++)
|
|
|
|
SetLoc2Glob_Edge (edges[i], recvarray[ii++]);
|
2012-08-20 20:10:23 +06:00
|
|
|
int face = topology.GetSurfaceElementFace (surfel);
|
|
|
|
SetLoc2Glob_Face ( face, recvarray[ii++]);
|
2011-07-17 05:13:26 +06:00
|
|
|
}
|
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
is_updated = true;
|
2011-02-15 21:22:05 +05:00
|
|
|
}
|
2009-01-26 00:37:14 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParallelMeshTopology :: UpdateCoarseGrid ()
|
|
|
|
{
|
2016-02-28 10:05:19 +05:00
|
|
|
cout << "updatecoarsegrid called, is_updated = " << is_updated << endl;
|
2016-02-28 12:11:34 +05:00
|
|
|
// if (is_updated) return;
|
2012-06-21 20:19:25 +06:00
|
|
|
|
|
|
|
Reset();
|
2011-07-15 03:36:19 +06:00
|
|
|
static int timer = NgProfiler::CreateTimer ("UpdateCoarseGrid");
|
2009-01-26 00:37:14 +05:00
|
|
|
NgProfiler::RegionTimer reg(timer);
|
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
|
2009-01-26 00:37:14 +05:00
|
|
|
(*testout) << "UPDATE COARSE GRID PARALLEL TOPOLOGY " << endl;
|
2011-07-15 03:36:19 +06:00
|
|
|
if (id == 0)
|
2012-09-03 15:49:43 +06:00
|
|
|
PrintMessage (1, "update parallel topology");
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2011-07-17 05:13:26 +06:00
|
|
|
|
2012-08-20 20:10:23 +06:00
|
|
|
// UpdateCoarseGridGlobal();
|
2012-06-21 20:19:25 +06:00
|
|
|
|
|
|
|
|
2011-07-15 03:36:19 +06:00
|
|
|
|
2012-09-28 18:39:41 +06:00
|
|
|
// MPI_Barrier (MPI_COMM_WORLD);
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2012-06-16 18:04:04 +06:00
|
|
|
MPI_Group MPI_GROUP_WORLD;
|
|
|
|
MPI_Group MPI_LocalGroup;
|
|
|
|
MPI_Comm MPI_LocalComm;
|
|
|
|
|
|
|
|
int process_ranks[] = { 0 };
|
|
|
|
MPI_Comm_group (MPI_COMM_WORLD, &MPI_GROUP_WORLD);
|
|
|
|
MPI_Group_excl (MPI_GROUP_WORLD, 1, process_ranks, &MPI_LocalGroup);
|
|
|
|
MPI_Comm_create (MPI_COMM_WORLD, MPI_LocalGroup, &MPI_LocalComm);
|
|
|
|
|
|
|
|
if (id == 0) return;
|
|
|
|
|
2016-02-28 09:50:15 +05:00
|
|
|
const MeshTopology & topology = mesh.GetTopology();
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2016-02-28 09:50:15 +05:00
|
|
|
cout << "update refined vertices" << endl;
|
|
|
|
// update new vertices after mesh-refinement
|
2016-02-28 12:11:34 +05:00
|
|
|
if (mesh.mlbetweennodes.Size() > 0)
|
2016-02-28 09:50:15 +05:00
|
|
|
{
|
2016-02-28 12:11:34 +05:00
|
|
|
// int oldnv = loc2distvert.Size();
|
2016-02-28 09:50:15 +05:00
|
|
|
int newnv = mesh.mlbetweennodes.Size();
|
|
|
|
loc2distvert.ChangeSize(mesh.mlbetweennodes.Size());
|
2016-02-28 12:11:34 +05:00
|
|
|
for (PointIndex pi = PointIndex::BASE; pi < newnv+PointIndex::BASE; pi++)
|
2016-02-28 09:50:15 +05:00
|
|
|
{
|
2016-02-28 10:05:19 +05:00
|
|
|
PointIndex v1 = mesh.mlbetweennodes[pi][0];
|
|
|
|
PointIndex v2 = mesh.mlbetweennodes[pi][1];
|
2016-02-28 12:11:34 +05:00
|
|
|
if (mesh.mlbetweennodes[pi][0] != PointIndex::BASE-1)
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
|
|
|
if (IsExchangeVert (dest, v1) && IsExchangeVert (dest, v2))
|
|
|
|
SetDistantPNum(dest, pi);
|
2016-02-28 09:50:15 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << "update refined vertices done" << endl;
|
|
|
|
|
|
|
|
|
2009-01-26 00:37:14 +05:00
|
|
|
|
2011-02-15 21:22:05 +05:00
|
|
|
Array<int> sendarray, recvarray;
|
2009-01-26 00:37:14 +05:00
|
|
|
|
|
|
|
|
2014-09-15 14:09:39 +06:00
|
|
|
// static int timerv = NgProfiler::CreateTimer ("UpdateCoarseGrid - ex vertices");
|
2011-07-15 03:36:19 +06:00
|
|
|
static int timere = NgProfiler::CreateTimer ("UpdateCoarseGrid - ex edges");
|
|
|
|
static int timerf = NgProfiler::CreateTimer ("UpdateCoarseGrid - ex faces");
|
|
|
|
|
|
|
|
|
|
|
|
Array<int> cnt_send(ntasks-1);
|
|
|
|
|
|
|
|
NgProfiler::StartTimer (timere);
|
|
|
|
|
2012-08-20 20:10:23 +06:00
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
int nfa = topology . GetNFaces();
|
|
|
|
int ned = topology . GetNEdges();
|
2011-07-15 14:04:25 +06:00
|
|
|
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
// exchange edges
|
2011-07-15 14:04:25 +06:00
|
|
|
cnt_send = 0;
|
|
|
|
int v1, v2;
|
|
|
|
for (int edge = 1; edge <= ned; edge++)
|
|
|
|
{
|
|
|
|
topology.GetEdgeVertices (edge, v1, v2);
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
2012-06-21 20:19:25 +06:00
|
|
|
if (IsExchangeVert (dest, v1) && IsExchangeVert (dest, v2))
|
|
|
|
cnt_send[dest-1]+=2;
|
2011-07-15 14:04:25 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
TABLE<int> send_edges(cnt_send);
|
2012-06-21 20:19:25 +06:00
|
|
|
INDEX_2_HASHTABLE<int> gv2e(2*ned);
|
|
|
|
|
2011-07-15 14:04:25 +06:00
|
|
|
for (int edge = 1; edge <= ned; edge++)
|
|
|
|
{
|
|
|
|
topology.GetEdgeVertices (edge, v1, v2);
|
2016-02-28 16:21:36 +05:00
|
|
|
INDEX_2 es(GetGlobalPNum(v1), GetGlobalPNum(v2));
|
|
|
|
es.Sort();
|
2012-06-21 20:19:25 +06:00
|
|
|
|
2016-02-28 16:21:36 +05:00
|
|
|
gv2e.Set (es, edge);
|
2012-06-21 20:19:25 +06:00
|
|
|
|
2011-07-15 14:04:25 +06:00
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
2012-08-20 20:10:23 +06:00
|
|
|
if (IsExchangeVert (dest, v1) && IsExchangeVert (dest, v2))
|
|
|
|
{
|
2016-02-28 16:21:36 +05:00
|
|
|
// SetDistantEdgeNum(dest, edge);
|
|
|
|
send_edges.Add (dest-1, es[0]);
|
|
|
|
send_edges.Add (dest-1, es[1]);
|
2012-08-20 20:10:23 +06:00
|
|
|
}
|
2011-07-15 14:04:25 +06:00
|
|
|
}
|
2011-07-15 22:26:32 +06:00
|
|
|
|
2011-07-15 14:04:25 +06:00
|
|
|
TABLE<int> recv_edges(ntasks-1);
|
2012-06-16 18:04:04 +06:00
|
|
|
MyMPI_ExchangeTable (send_edges, recv_edges, MPI_TAG_MESH+9, MPI_LocalComm);
|
2011-07-15 14:04:25 +06:00
|
|
|
|
|
|
|
for (int sender = 1; sender < ntasks; sender ++)
|
|
|
|
if (id != sender)
|
|
|
|
{
|
|
|
|
FlatArray<int> recvarray = recv_edges[sender-1];
|
2012-06-21 20:19:25 +06:00
|
|
|
for (int ii = 0; ii < recvarray.Size(); ii+=2)
|
2011-07-15 14:04:25 +06:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
INDEX_2 gv12 (recvarray[ii],recvarray[ii+1]);
|
|
|
|
if (gv2e.Used (gv12))
|
|
|
|
SetDistantEdgeNum (sender, gv2e.Get(gv12));
|
2011-07-15 14:04:25 +06:00
|
|
|
}
|
2012-06-21 20:19:25 +06:00
|
|
|
}
|
2011-07-15 22:26:32 +06:00
|
|
|
|
2011-07-15 03:36:19 +06:00
|
|
|
NgProfiler::StopTimer (timere);
|
2011-07-17 05:13:26 +06:00
|
|
|
|
2012-09-28 18:39:41 +06:00
|
|
|
// MPI_Barrier (MPI_LocalComm);
|
2011-07-17 05:13:26 +06:00
|
|
|
|
2012-08-20 20:10:23 +06:00
|
|
|
|
2011-07-17 05:13:26 +06:00
|
|
|
if (mesh.GetDimension() == 3)
|
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
NgProfiler::StartTimer (timerf);
|
2016-02-28 16:21:36 +05:00
|
|
|
Array<int> verts;
|
2012-08-20 20:10:23 +06:00
|
|
|
|
|
|
|
// exchange faces
|
|
|
|
cnt_send = 0;
|
|
|
|
for (int face = 1; face <= nfa; face++)
|
|
|
|
{
|
|
|
|
topology.GetFaceVertices (face, verts);
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
|
|
|
if (IsExchangeVert (dest, verts[0]) &&
|
|
|
|
IsExchangeVert (dest, verts[1]) &&
|
|
|
|
IsExchangeVert (dest, verts[2]))
|
|
|
|
cnt_send[dest-1]+=3;
|
|
|
|
}
|
2016-02-28 16:21:36 +05:00
|
|
|
|
2012-08-20 20:10:23 +06:00
|
|
|
TABLE<int> send_faces(cnt_send);
|
|
|
|
INDEX_3_HASHTABLE<int> gv2f(2*nfa);
|
|
|
|
|
|
|
|
for (int face = 1; face <= nfa; face++)
|
|
|
|
{
|
|
|
|
topology.GetFaceVertices (face, verts);
|
2016-02-28 16:21:36 +05:00
|
|
|
|
2012-08-20 20:10:23 +06:00
|
|
|
INDEX_3 fs (GetGlobalPNum(verts[0]),
|
|
|
|
GetGlobalPNum(verts[1]),
|
|
|
|
GetGlobalPNum(verts[2]));
|
|
|
|
fs.Sort();
|
|
|
|
|
|
|
|
gv2f.Set (fs, face);
|
|
|
|
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
|
|
|
if (IsExchangeVert (dest, verts[0]) &&
|
|
|
|
IsExchangeVert (dest, verts[1]) &&
|
|
|
|
IsExchangeVert (dest, verts[2]))
|
|
|
|
{
|
2016-02-28 16:21:36 +05:00
|
|
|
// SetDistantFaceNum (dest, face);
|
2012-08-20 20:10:23 +06:00
|
|
|
send_faces.Add (dest-1, fs[0]);
|
|
|
|
send_faces.Add (dest-1, fs[1]);
|
|
|
|
send_faces.Add (dest-1, fs[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TABLE<int> recv_faces(ntasks-1);
|
|
|
|
MyMPI_ExchangeTable (send_faces, recv_faces, MPI_TAG_MESH+9, MPI_LocalComm);
|
2012-06-21 20:19:25 +06:00
|
|
|
|
2012-08-20 20:10:23 +06:00
|
|
|
for (int sender = 1; sender < ntasks; sender ++)
|
|
|
|
if (id != sender)
|
|
|
|
{
|
|
|
|
FlatArray<int> recvarray = recv_faces[sender-1];
|
|
|
|
for (int ii = 0; ii < recvarray.Size(); ii+=3)
|
|
|
|
{
|
|
|
|
INDEX_3 gv123 (recvarray[ii],recvarray[ii+1],recvarray[ii+2]);
|
|
|
|
if (gv2f.Used (gv123))
|
|
|
|
SetDistantFaceNum (sender, gv2f.Get(gv123));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Array<int,1> glob2loc;
|
|
|
|
|
2012-06-21 20:19:25 +06:00
|
|
|
int maxface = 0;
|
|
|
|
for (int face = 1; face <= nfa; face++)
|
|
|
|
maxface = max (maxface, GetGlobalFaceNum (face));
|
|
|
|
|
|
|
|
// glob2loc.SetSize (nfaglob);
|
|
|
|
glob2loc.SetSize (maxface);
|
|
|
|
glob2loc = -1;
|
|
|
|
|
|
|
|
for (int loc = 1; loc <= nfa; loc++)
|
|
|
|
glob2loc[GetGlobalFaceNum(loc)] = loc;
|
|
|
|
|
|
|
|
cnt_send = 0;
|
|
|
|
Array<int> verts;
|
|
|
|
for (int face = 1; face <= nfa; face++)
|
2011-07-15 03:36:19 +06:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
topology.GetFaceVertices (face, verts);
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
|
|
|
if (IsExchangeVert (dest, verts[0]) &&
|
|
|
|
IsExchangeVert (dest, verts[1]) &&
|
|
|
|
IsExchangeVert (dest, verts[2]))
|
|
|
|
{
|
|
|
|
cnt_send[dest-1]+=2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TABLE<int> send_faces(cnt_send);
|
|
|
|
for (int face = 1; face <= nfa; face++)
|
|
|
|
{
|
|
|
|
topology.GetFaceVertices (face, verts);
|
|
|
|
for (int dest = 1; dest < ntasks; dest++)
|
2011-07-15 03:36:19 +06:00
|
|
|
{
|
2012-06-21 20:19:25 +06:00
|
|
|
if (IsExchangeVert (dest, verts[0]) &&
|
|
|
|
IsExchangeVert (dest, verts[1]) &&
|
|
|
|
IsExchangeVert (dest, verts[2]))
|
|
|
|
{
|
|
|
|
send_faces.Add (dest-1, GetGlobalFaceNum(face));
|
|
|
|
send_faces.Add (dest-1, face);
|
|
|
|
}
|
2011-07-15 03:36:19 +06:00
|
|
|
}
|
2012-08-20 20:10:23 +06:00
|
|
|
}
|
2012-06-21 20:19:25 +06:00
|
|
|
TABLE<int> recv_faces(ntasks-1);
|
|
|
|
MyMPI_ExchangeTable (send_faces, recv_faces, MPI_TAG_MESH+8, MPI_LocalComm);
|
|
|
|
|
|
|
|
for (int sender = 1; sender < ntasks; sender ++)
|
|
|
|
if (id != sender)
|
|
|
|
{
|
|
|
|
FlatArray<int> recvarray = recv_faces[sender-1];
|
|
|
|
|
|
|
|
for (int ii = 0; ii < recvarray.Size(); )
|
|
|
|
{
|
|
|
|
int globf = recvarray[ii++];
|
|
|
|
int distf = recvarray[ii++];
|
|
|
|
|
|
|
|
if (globf <= maxface)
|
|
|
|
{
|
|
|
|
int locf = glob2loc[globf];
|
|
|
|
if (locf != -1)
|
|
|
|
SetDistantFaceNum (sender, locf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-20 20:10:23 +06:00
|
|
|
*/
|
2012-06-21 20:19:25 +06:00
|
|
|
|
|
|
|
NgProfiler::StopTimer (timerf);
|
2011-07-17 05:13:26 +06:00
|
|
|
}
|
2012-06-21 20:19:25 +06:00
|
|
|
|
|
|
|
is_updated = true;
|
2009-01-26 00:37:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|