parallel visualization

This commit is contained in:
Joachim Schoeberl 2011-02-15 16:22:05 +00:00
parent 894df4cb84
commit 2261c36684
7 changed files with 954 additions and 801 deletions

View File

@ -87,8 +87,8 @@ AC_ARG_ENABLE([nglib],
AC_ARG_ENABLE([parallel], AC_ARG_ENABLE([parallel],
[AC_HELP_STRING([--enable-parallel],[enable mpi parallelization])], [AC_HELP_STRING([--enable-parallel],[enable mpi parallelization])],
[AC_SUBST([MPI_INCLUDES], "-I/usr/lib64/mpi/gcc/openmpi/include -DPARALLEL -I/usr/include/metis -DMETIS") [AC_SUBST([MPI_INCLUDES], "-I/usr/lib64/mpi/gcc/openmpi/include -DPARALLEL -I/usr/include/metis -DMETIS -DVTRACE -I/usr/local/include/vampirtrace")
AC_SUBST([MPI_LIBS], "-L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi_cxx -lmetis") AC_SUBST([MPI_LIBS], "-L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi_cxx -lmetis -lvt-hyb")
] ]
) )

View File

@ -52,15 +52,15 @@ namespace netgen
int nelglob, nelloc, nvglob, nedglob, nfaglob; int nelglob, nelloc, nvglob, nedglob, nfaglob;
// receive global values // receive global values
MPI_Bcast( &nelglob, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast (&nelglob, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast( &nvglob, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast (&nvglob, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast( &nedglob, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast (&nedglob, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast( &nfaglob, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast (&nfaglob, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast( &dimension, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast (&dimension, 1, MPI_INT, 0, MPI_COMM_WORLD);
MyMPI_Recv ( nelloc, 0 ); MyMPI_Recv (nelloc, 0);
paralleltop -> SetNVGlob ( nvglob ); paralleltop -> SetNVGlob (nvglob);
paralleltop -> SetNEGlob ( nelglob ); paralleltop -> SetNEGlob (nelglob);
INDEX_CLOSED_HASHTABLE<int> glob2loc_vert_ht (1); INDEX_CLOSED_HASHTABLE<int> glob2loc_vert_ht (1);
@ -69,7 +69,7 @@ namespace netgen
// int ve = 0; // int ve = 0;
while (!endmesh) while (!endmesh)
{ {
MyMPI_Recv ( st, 0 ); MyMPI_Recv (st, 0);
// receive vertices // receive vertices
if (st == "vertex") if (st == "vertex")
@ -77,14 +77,14 @@ namespace netgen
NgProfiler::RegionTimer reg(timer_pts); NgProfiler::RegionTimer reg(timer_pts);
Array<double> pointarray; Array<double> pointarray;
MyMPI_Recv ( pointarray, 0 ); MyMPI_Recv (pointarray, 0);
int numvert = pointarray.Size() / 5; int numvert = pointarray.Size() / 5;
paralleltop -> SetNV (numvert); paralleltop -> SetNV (numvert);
glob2loc_vert_ht.SetSize (3*numvert+1); glob2loc_vert_ht.SetSize (3*numvert+1);
for ( int vert=0; vert<numvert; vert++ ) for (int vert = 0; vert < numvert; vert++)
{ {
int globvert = int (pointarray[ vert*5 ]); int globvert = int (pointarray[ vert*5 ]);
paralleltop->SetLoc2Glob_Vert ( vert+1, globvert ); paralleltop->SetLoc2Glob_Vert ( vert+1, globvert );
@ -99,16 +99,14 @@ namespace netgen
} }
Array<int> dist_pnums; Array<int> dist_pnums;
MyMPI_Recv ( dist_pnums, 0); MyMPI_Recv (dist_pnums, 0);
for (int hi = 0; hi < dist_pnums.Size(); hi += 3) for (int hi = 0; hi < dist_pnums.Size(); hi += 3)
{
paralleltop -> paralleltop ->
SetDistantPNum ( dist_pnums[hi+1], dist_pnums[hi], dist_pnums[hi+2]); SetDistantPNum (dist_pnums[hi+1], dist_pnums[hi], dist_pnums[hi+2]);
}
} }
if ( strcmp (st.c_str(), "volumeelements" ) == 0 ) if (strcmp (st.c_str(), "volumeelements" ) == 0 )
{ {
NgProfiler::RegionTimer reg(timer_els); NgProfiler::RegionTimer reg(timer_els);
@ -117,7 +115,7 @@ namespace netgen
Element el; Element el;
Array<int> elarray; Array<int> elarray;
MyMPI_Recv ( elarray, 0); MyMPI_Recv (elarray, 0);
int ind = 0; int ind = 0;
int elnum = 1; int elnum = 1;
@ -125,7 +123,7 @@ namespace netgen
paralleltop -> SetNE (nelloc); paralleltop -> SetNE (nelloc);
while ( ind < elarray.Size() ) while (ind < elarray.Size())
{ {
paralleltop->SetLoc2Glob_VolEl ( elnum, elarray[ind++]); paralleltop->SetLoc2Glob_VolEl ( elnum, elarray[ind++]);
@ -816,7 +814,7 @@ namespace netgen
MPI_Request sendrequest[ntasks]; MPI_Request sendrequest[ntasks];
for ( int dest = 1; dest < ntasks; dest++) for (int dest = 1; dest < ntasks; dest++)
MyMPI_Send ("mesh", dest); MyMPI_Send ("mesh", dest);
// MPI_Barrier (MPI_COMM_WORLD); // MPI_Barrier (MPI_COMM_WORLD);
@ -832,12 +830,12 @@ namespace netgen
int nedges = (GetTopology().GetNEdges()); int nedges = (GetTopology().GetNEdges());
int nfaces = GetTopology().GetNFaces(); int nfaces = GetTopology().GetNFaces();
int dim = dimension; int dim = dimension;
MPI_Bcast( &nel, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast(&nel, 1, MPI_INT, 0, MPI_COMM_WORLD );
MPI_Bcast( &nv, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast(&nv, 1, MPI_INT, 0, MPI_COMM_WORLD );
MPI_Bcast( &nedges, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast(&nedges, 1, MPI_INT, 0, MPI_COMM_WORLD );
MPI_Bcast( &nfaces, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast(&nfaces, 1, MPI_INT, 0, MPI_COMM_WORLD );
MPI_Bcast( &dim, 1, MPI_INT, 0, MPI_COMM_WORLD ); MPI_Bcast(&dim, 1, MPI_INT, 0, MPI_COMM_WORLD );
for ( int dest = 1; dest < ntasks; dest++ ) for (int dest = 1; dest < ntasks; dest++)
MyMPI_Send (num_els_on_proc[dest], dest); MyMPI_Send (num_els_on_proc[dest], dest);

View File

@ -88,7 +88,7 @@ namespace netgen
isghostface.Clear(); isghostface.Clear();
} }
} }
ParallelMeshTopology :: ~ParallelMeshTopology () ParallelMeshTopology :: ~ParallelMeshTopology ()
@ -103,7 +103,7 @@ namespace netgen
ParallelMeshTopology :: ParallelMeshTopology ( const netgen::Mesh & amesh ) ParallelMeshTopology :: ParallelMeshTopology ( const netgen::Mesh & amesh )
: mesh(amesh) : mesh(amesh)
{ {
ned = 0; //mesh.GetTopology().GetNEdges(); ned = 0; //mesh.GetTopology().GetNEdges();
nfa = 0; //mesh.GetTopology().GetNFaces(); nfa = 0; //mesh.GetTopology().GetNFaces();
nv = 0; nv = 0;
@ -127,7 +127,7 @@ namespace netgen
isghostface.SetSize(0); isghostface.SetSize(0);
overlap = 0; overlap = 0;
} }
int ParallelMeshTopology :: Glob2Loc_Vert (int globnum ) int ParallelMeshTopology :: Glob2Loc_Vert (int globnum )
@ -139,8 +139,8 @@ namespace netgen
return -1; return -1;
} }
int ParallelMeshTopology :: Glob2Loc_VolEl (int globnum ) int ParallelMeshTopology :: Glob2Loc_VolEl (int globnum )
{ {
int locnum = -1; int locnum = -1;
for (int i = 0; i < ne; i++) for (int i = 0; i < ne; i++)
{ {
@ -150,9 +150,9 @@ int ParallelMeshTopology :: Glob2Loc_VolEl (int globnum )
} }
} }
return locnum; return locnum;
} }
int ParallelMeshTopology :: Glob2Loc_SurfEl (int globnum ) int ParallelMeshTopology :: Glob2Loc_SurfEl (int globnum )
{ {
int locnum = -1; int locnum = -1;
for (int i = 0; i < nsurfel; i++) for (int i = 0; i < nsurfel; i++)
@ -165,7 +165,7 @@ int ParallelMeshTopology :: Glob2Loc_SurfEl (int globnum )
return locnum; return locnum;
} }
int ParallelMeshTopology :: Glob2Loc_Segm (int globnum ) int ParallelMeshTopology :: Glob2Loc_Segm (int globnum )
{ {
int locnum = -1; int locnum = -1;
for (int i = 0; i < nseg; i++) for (int i = 0; i < nseg; i++)
@ -253,7 +253,7 @@ int ParallelMeshTopology :: Glob2Loc_Segm (int globnum )
int ParallelMeshTopology :: GetDistantPNum ( int proc, int locpnum ) const int ParallelMeshTopology :: GetDistantPNum ( int proc, int locpnum ) const
{ {
if ( proc == 0 ) if ( proc == 0 )
return loc2distvert[locpnum][0]; return loc2distvert[locpnum][0];
@ -265,7 +265,7 @@ int ParallelMeshTopology :: GetDistantPNum ( int proc, int locpnum ) const
return -1; return -1;
} }
int ParallelMeshTopology :: GetDistantFaceNum ( int proc, int locfacenum ) const int ParallelMeshTopology :: GetDistantFaceNum ( int proc, int locfacenum ) const
{ {
if ( proc == 0 ) if ( proc == 0 )
return loc2distface[locfacenum-1][0]; return loc2distface[locfacenum-1][0];
@ -277,7 +277,7 @@ int ParallelMeshTopology :: GetDistantFaceNum ( int proc, int locfacenum ) cons
return -1; return -1;
} }
int ParallelMeshTopology :: GetDistantEdgeNum ( int proc, int locedgenum ) const int ParallelMeshTopology :: GetDistantEdgeNum ( int proc, int locedgenum ) const
{ {
if ( proc == 0 ) if ( proc == 0 )
return loc2distedge[locedgenum-1][0]; return loc2distedge[locedgenum-1][0];
@ -289,7 +289,7 @@ int ParallelMeshTopology :: GetDistantEdgeNum ( int proc, int locedgenum ) cons
return -1; return -1;
} }
int ParallelMeshTopology :: GetDistantElNum ( int proc, int locelnum ) const int ParallelMeshTopology :: GetDistantElNum ( int proc, int locelnum ) const
{ {
if ( proc == 0 ) if ( proc == 0 )
return loc2distel[locelnum-1][0]; return loc2distel[locelnum-1][0];
@ -304,41 +304,41 @@ int ParallelMeshTopology :: GetDistantElNum ( int proc, int locelnum ) const
/* /*
// //
// gibt anzahl an distant pnums zurueck // gibt anzahl an distant pnums zurueck
int ParallelMeshTopology :: GetNDistantPNums ( int locpnum ) const int ParallelMeshTopology :: GetNDistantPNums ( int locpnum ) const
{ {
return loc2distvert[locpnum].Size() / 2 + 1; return loc2distvert[locpnum].Size() / 2 + 1;
} }
int ParallelMeshTopology :: GetNDistantFaceNums ( int locfacenum ) const int ParallelMeshTopology :: GetNDistantFaceNums ( int locfacenum ) const
{ {
int size = loc2distface[locfacenum-1].Size() / 2 + 1; int size = loc2distface[locfacenum-1].Size() / 2 + 1;
return size; return size;
} }
int ParallelMeshTopology :: GetNDistantEdgeNums ( int locedgenum ) const int ParallelMeshTopology :: GetNDistantEdgeNums ( int locedgenum ) const
{ {
int size = loc2distedge[locedgenum-1].Size() / 2 + 1; int size = loc2distedge[locedgenum-1].Size() / 2 + 1;
return size; return size;
} }
int ParallelMeshTopology :: GetNDistantElNums ( int locelnum ) const int ParallelMeshTopology :: GetNDistantElNums ( int locelnum ) const
{ {
int size = loc2distel[locelnum-1].Size() / 2 + 1; int size = loc2distel[locelnum-1].Size() / 2 + 1;
return size; return size;
} }
*/ */
// gibt anzahl an distant pnums zurueck // gibt anzahl an distant pnums zurueck
// * pnums entspricht Array<int[2] > // * pnums entspricht Array<int[2] >
int ParallelMeshTopology :: GetDistantPNums ( int locpnum, int * distpnums ) const int ParallelMeshTopology :: GetDistantPNums ( int locpnum, int * distpnums ) const
{ {
// distpnums[0] = loc2distvert[locpnum][0]; // distpnums[0] = loc2distvert[locpnum][0];
// for (int i = 1; i < loc2distvert[locpnum].Size(); i += 2) // for (int i = 1; i < loc2distvert[locpnum].Size(); i += 2)
// distpnums[ loc2distvert[locpnum][i] ] = loc2distvert[locpnum][i+1]; // distpnums[ loc2distvert[locpnum][i] ] = loc2distvert[locpnum][i+1];
distpnums[0] = 0; distpnums[0] = 0;
distpnums[1] = loc2distvert[locpnum][0]; distpnums[1] = loc2distvert[locpnum][0];
for ( int i = 1; i < loc2distvert[locpnum].Size(); i++ ) for ( int i = 1; i < loc2distvert[locpnum].Size(); i++ )
@ -348,12 +348,12 @@ int ParallelMeshTopology :: GetDistantPNums ( int locpnum, int * distpnums ) co
return size; return size;
} }
int ParallelMeshTopology :: GetDistantFaceNums ( int locfacenum, int * distfacenums ) const int ParallelMeshTopology :: GetDistantFaceNums ( int locfacenum, int * distfacenums ) const
{ {
// distfacenums[0] = loc2distface[locfacenum-1][0]; // distfacenums[0] = loc2distface[locfacenum-1][0];
// for ( int i = 1; i < loc2distface[locfacenum-1].Size(); i+=2 ) // for ( int i = 1; i < loc2distface[locfacenum-1].Size(); i+=2 )
// distfacenums[loc2distface[locfacenum-1][i]] = loc2distface[locfacenum-1][i+1]; // distfacenums[loc2distface[locfacenum-1][i]] = loc2distface[locfacenum-1][i+1];
distfacenums[0] = 0; distfacenums[0] = 0;
distfacenums[1] = loc2distface[locfacenum-1][0]; distfacenums[1] = loc2distface[locfacenum-1][0];
@ -365,12 +365,12 @@ int ParallelMeshTopology :: GetDistantFaceNums ( int locfacenum, int * distface
return size; return size;
} }
int ParallelMeshTopology :: GetDistantEdgeNums ( int locedgenum, int * distedgenums ) const int ParallelMeshTopology :: GetDistantEdgeNums ( int locedgenum, int * distedgenums ) const
{ {
// distedgenums[0] = loc2distedge[locedgenum-1][0]; // distedgenums[0] = loc2distedge[locedgenum-1][0];
// for ( int i = 1; i < loc2distedge[locedgenum-1].Size(); i+=2 ) // for ( int i = 1; i < loc2distedge[locedgenum-1].Size(); i+=2 )
// distedgenums[loc2distedge[locedgenum-1][i]] = loc2distedge[locedgenum-1][i+1]; // distedgenums[loc2distedge[locedgenum-1][i]] = loc2distedge[locedgenum-1][i+1];
distedgenums[0] = 0; distedgenums[0] = 0;
distedgenums[1] = loc2distedge[locedgenum-1][0]; distedgenums[1] = loc2distedge[locedgenum-1][0];
@ -382,12 +382,12 @@ int ParallelMeshTopology :: GetDistantEdgeNums ( int locedgenum, int * distedge
return size; return size;
} }
int ParallelMeshTopology :: GetDistantElNums ( int locelnum, int * distelnums ) const int ParallelMeshTopology :: GetDistantElNums ( int locelnum, int * distelnums ) const
{ {
// distelnums[0] = loc2distel[locelnum-1][0]; // distelnums[0] = loc2distel[locelnum-1][0];
// for ( int i = 1; i < loc2distel[locelnum-1].Size(); i+=2 ) // for ( int i = 1; i < loc2distel[locelnum-1].Size(); i+=2 )
// distelnums[loc2distel[locelnum-1][i]] = loc2distel[locelnum-1][i+1]; // distelnums[loc2distel[locelnum-1][i]] = loc2distel[locelnum-1][i+1];
distelnums[0] = 0; distelnums[0] = 0;
distelnums[1] = loc2distel[locelnum-1][0]; distelnums[1] = loc2distel[locelnum-1][0];
@ -549,16 +549,16 @@ int ParallelMeshTopology :: GetDistantElNums ( int locelnum, int * distelnums )
void ParallelMeshTopology :: UpdateRefinement () void ParallelMeshTopology :: UpdateRefinement ()
{ {
; ;
} }
void ParallelMeshTopology :: UpdateCoarseGridGlobal () void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
{ {
PrintMessage ( 1, "UPDATE GLOBAL COARSEGRID STARTS" ); // JS PrintMessage ( 1, "UPDATE GLOBAL COARSEGRID STARTS" ); // JS
// MPI_Barrier (MPI_COMM_WORLD); // MPI_Barrier (MPI_COMM_WORLD);
@ -836,7 +836,7 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
#ifdef SCALASCA #ifdef SCALASCA
#pragma pomp inst end(updatecoarsegrid) #pragma pomp inst end(updatecoarsegrid)
#endif #endif
} }
@ -851,8 +851,9 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
#ifdef SCALASCA #ifdef SCALASCA
#pragma pomp inst begin(updatecoarsegrid) #pragma pomp inst begin(updatecoarsegrid)
#endif #endif
(*testout) << "UPDATE COARSE GRID PARALLEL TOPOLOGY " << endl; (*testout) << "UPDATE COARSE GRID PARALLEL TOPOLOGY " << endl;
PrintMessage ( 1, "UPDATE COARSE GRID PARALLEL TOPOLOGY " ); PrintMessage (1, "UPDATE COARSE GRID PARALLEL TOPOLOGY ");
// find exchange edges - first send exchangeedges locnum, v1, v2 // find exchange edges - first send exchangeedges locnum, v1, v2
// receive distant distnum, v1, v2 // receive distant distnum, v1, v2
@ -865,9 +866,7 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
if ( id == 0 ) return; if ( id == 0 ) return;
Array<int> * sendarray, *recvarray; Array<int> sendarray, recvarray;
sendarray = new Array<int> (0);
recvarray = new Array<int>;
nfa = topology . GetNFaces(); nfa = topology . GetNFaces();
ned = topology . GetNEdges(); ned = topology . GetNEdges();
@ -878,54 +877,163 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
nsurfel = mesh.GetNSE(); nsurfel = mesh.GetNSE();
sendarray->SetSize (0); // exchange vertices
BitArray recvface(nfa); for (int vertex = 1; vertex <= nv; vertex++)
recvface.Clear(); if (IsExchangeVert (vertex) )
for ( int fa = 1; fa <= nfa; fa++ )
{ {
sendarray.Append (GetLoc2Glob_Vert (vertex));
sendarray.Append (vertex);
}
Array<int,1> glob2loc;
glob2loc.SetSize (nvglob);
glob2loc = -1;
for (int locv = 1; locv <= nv; locv++)
if (IsExchangeVert (locv) )
glob2loc[GetDistantPNum(0, locv)] = locv;
for (int sender = 1; sender < ntasks; sender ++)
{
if (id == sender)
MyMPI_Bcast (sendarray, sender-1, MPI_HIGHORDER_COMM);
else
{
MyMPI_Bcast (recvarray, sender-1, MPI_HIGHORDER_COMM);
for (int ii = 0; ii < recvarray.Size(); )
{
int globv = recvarray[ii++];
int distv = recvarray[ii++];
int locv = glob2loc[globv];
if (locv != -1)
SetDistantPNum (sender, locv, distv);
}
}
}
sendarray.SetSize (0);
recvarray.SetSize (0);
// exchange edges
int maxedge = 0;
for (int edge = 1; edge <= ned; edge++)
if (IsExchangeEdge (edge) )
{
sendarray.Append (GetDistantEdgeNum (0, edge));
sendarray.Append (edge);
maxedge = max (maxedge, GetDistantEdgeNum (0, edge));
}
glob2loc.SetSize (maxedge+1);
glob2loc = -1;
for (int loc = 1; loc <= ned; loc++)
if (IsExchangeEdge (loc) )
glob2loc[GetDistantEdgeNum(0, loc)] = loc;
for (int sender = 1; sender < ntasks; sender ++)
{
if (id == sender)
MyMPI_Bcast (sendarray, sender-1, MPI_HIGHORDER_COMM);
else
{
MyMPI_Bcast (recvarray, sender-1, MPI_HIGHORDER_COMM);
for (int ii = 0; ii < recvarray.Size(); )
{
int globe = recvarray[ii++];
int diste = recvarray[ii++];
if (globe > maxedge) continue;
int loce = glob2loc[globe];
if (loce != -1)
SetDistantEdgeNum (sender, loce, diste);
}
}
}
sendarray.SetSize (0);
recvarray.SetSize (0);
// exchange faces
for (int face = 1; face <= nfa; face++)
if (IsExchangeFace (face) )
{
sendarray.Append (GetDistantFaceNum (0, face));
sendarray.Append (face);
}
glob2loc.SetSize (nfaglob);
glob2loc = -1;
for (int loc = 1; loc <= nfa; loc++)
if (IsExchangeFace (loc) )
glob2loc[GetDistantFaceNum(0, loc)] = loc;
for (int sender = 1; sender < ntasks; sender ++)
{
if (id == sender)
MyMPI_Bcast (sendarray, sender-1, MPI_HIGHORDER_COMM);
else
{
MyMPI_Bcast (recvarray, sender-1, MPI_HIGHORDER_COMM);
for (int ii = 0; ii < recvarray.Size(); )
{
int globf = recvarray[ii++];
int distf = recvarray[ii++];
int locf = glob2loc[globf];
if (locf != -1)
SetDistantFaceNum (sender, locf, distf);
}
}
}
#ifdef OLD
// BitArray recvface(nfa);
// recvface.Clear();
for (int fa = 1; fa <= nfa; fa++ )
{
if ( !IsExchangeFace ( fa ) ) continue; if ( !IsExchangeFace ( fa ) ) continue;
Array<int> edges, pnums; Array<int> edges, pnums;
int globfa = GetDistantFaceNum ( 0, fa ); int globfa = GetDistantFaceNum (0, fa);
topology.GetFaceEdges ( fa, edges );
topology.GetFaceVertices ( fa, pnums );
topology.GetFaceEdges (fa, edges);
topology.GetFaceVertices (fa, pnums);
// send : // send :
// localfacenum // localfacenum globalfacenum np ned globalpnums localpnums
// globalfacenum
// np
// ned
// globalpnums
// localpnums
// localedgenums mit globalv1, globalv2 // localedgenums mit globalv1, globalv2
//
sendarray -> Append ( fa ); sendarray.Append ( fa );
sendarray -> Append ( globfa ); sendarray.Append ( globfa );
sendarray -> Append ( pnums.Size() ); sendarray.Append ( pnums.Size() );
sendarray -> Append ( edges.Size() ); sendarray.Append ( edges.Size() );
for (int i = 0; i < pnums.Size(); i++ )
sendarray.Append( GetLoc2Glob_Vert(pnums[i]) );
for ( int i = 0; i < pnums.Size(); i++ ) for ( int i = 0; i < pnums.Size(); i++ )
{ sendarray.Append(pnums[i]);
sendarray -> Append( GetLoc2Glob_Vert(pnums[i]) );
}
for ( int i = 0; i < pnums.Size(); i++ )
{
sendarray -> Append(pnums[i] );
}
for ( int i = 0; i < edges.Size(); i++ ) for ( int i = 0; i < edges.Size(); i++ )
{ {
sendarray -> Append(edges[i] ); sendarray.Append(edges[i]);
int v1, v2; int v1, v2;
topology . GetEdgeVertices ( edges[i], v1, v2 ); topology.GetEdgeVertices ( edges[i], v1, v2 );
int dv1 = GetLoc2Glob_Vert ( v1 ); int dv1 = GetLoc2Glob_Vert ( v1 );
int dv2 = GetLoc2Glob_Vert ( v2 ); int dv2 = GetLoc2Glob_Vert ( v2 );
sendarray -> Append ( dv1 ); sendarray.Append ( dv1 );
sendarray -> Append ( dv2 ); sendarray.Append ( dv2 );
} }
} }
@ -936,49 +1044,38 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
// Array for temporary use, to find local from global element fast // Array for temporary use, to find local from global element fast
// only for not too big meshes // only for not too big meshes
// seems ok, as low-order space is treated on one proc // seems ok, as low-order space is treated on one proc
Array<int,1> * glob2locfa; Array<int,1> glob2locfa (nfaglob);
glob2locfa = new Array<int,1> ( nfaglob ); glob2locfa = -1;
(*glob2locfa) = -1;
for ( int locfa = 1; locfa <= nfa; locfa++) for (int locfa = 1; locfa <= nfa; locfa++)
if (IsExchangeFace (locfa) )
glob2locfa[GetDistantFaceNum(0, locfa)] = locfa;
for (int sender = 1; sender < ntasks; sender ++)
{ {
if ( !IsExchangeFace ( locfa ) ) continue; if (id == sender)
(*glob2locfa)[GetDistantFaceNum(0, locfa) ] = locfa; MyMPI_Bcast (sendarray, sender-1, MPI_HIGHORDER_COMM);
} else
for ( int sender = 1; sender < ntasks; sender ++ )
{ {
MyMPI_Bcast ( recvarray, sender-1, MPI_HIGHORDER_COMM);
if ( id == sender )
MyMPI_Bcast ( *sendarray, sender-1, MPI_HIGHORDER_COMM);
if ( id != sender )
{
MyMPI_Bcast ( *recvarray, sender-1, MPI_HIGHORDER_COMM);
// compare received vertices with own ones // compare received vertices with own ones
int ii = 0; int ii = 0;
int cntel = 0; int cntel = 0;
int locfa = 1; int locfa = 1;
while ( ii< recvarray -> Size() ) while (ii < recvarray.Size())
{ {
// receive list : // receive list :
// distant facenum // distant_facenum global_facenum np ned globalpnums distant_pnums
// global facenum
// np
// ned
// globalpnums
// distant pnums
// distant edgenums mit globalv1, globalv2 // distant edgenums mit globalv1, globalv2
int distfa = (*recvarray)[ii++]; int distfa = recvarray[ii++];
int globfa = (*recvarray)[ii++]; int globfa = recvarray[ii++];
int distnp = (*recvarray)[ii++]; int distnp = recvarray[ii++];
int distned =(*recvarray)[ii++]; int distned =recvarray[ii++];
int locfa = (*glob2locfa) [globfa]; int locfa = (glob2locfa) [globfa];
if ( locfa == -1 ) if ( locfa == -1 )
{ {
@ -994,7 +1091,6 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
topology.GetFaceEdges ( fa, edges ); topology.GetFaceEdges ( fa, edges );
topology.GetFaceVertices ( fa, pnums ); topology.GetFaceVertices ( fa, pnums );
globalpnums.SetSize ( distnp ); globalpnums.SetSize ( distnp );
for ( int i = 0; i < distnp; i++) for ( int i = 0; i < distnp; i++)
globalpnums[i] = GetLoc2Glob_Vert ( pnums[i] ); globalpnums[i] = GetLoc2Glob_Vert ( pnums[i] );
@ -1004,18 +1100,17 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
// find exchange points // find exchange points
for ( int i = 0; i < distnp; i++) for ( int i = 0; i < distnp; i++)
{ {
int distglobalpnum = (*recvarray)[ii+i]; int distglobalpnum = recvarray[ii+i];
for ( int j = 0; j < distnp; j++ ) for ( int j = 0; j < distnp; j++ )
if ( globalpnums[j] == distglobalpnum ) if ( globalpnums[j] == distglobalpnum )
{ {
// set sender -- distpnum ---- locpnum // set sender -- distpnum ---- locpnum
int distpnum = (*recvarray)[ii + i +distnp]; int distpnum = recvarray[ii + i +distnp];
SetDistantPNum ( sender, pnums[j], distpnum ); // SetDistantPNum ( sender, pnums[j], distpnum );
}
} }
} Array<int> distedgenums(distned);
int * distedgenums = new int [distned];
// find exchange edges // find exchange edges
for ( int i = 0; i < edges.Size(); i++) for ( int i = 0; i < edges.Size(); i++)
{ {
@ -1026,9 +1121,9 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
if ( dv1 > dv2 ) swap ( dv1, dv2 ); if ( dv1 > dv2 ) swap ( dv1, dv2 );
for ( int ed = 0; ed < distned; ed++) for ( int ed = 0; ed < distned; ed++)
{ {
distedgenums[ed] = (*recvarray)[ii + 2*distnp + 3*ed]; distedgenums[ed] = recvarray[ii + 2*distnp + 3*ed];
int ddv1 = (*recvarray)[ii + 2*distnp + 3*ed + 1]; int ddv1 = recvarray[ii + 2*distnp + 3*ed + 1];
int ddv2 = (*recvarray)[ii + 2*distnp + 3*ed + 2]; int ddv2 = recvarray[ii + 2*distnp + 3*ed + 2];
if ( ddv1 > ddv2 ) swap ( ddv1, ddv2 ); if ( ddv1 > ddv2 ) swap ( ddv1, ddv2 );
if ( dv1 == ddv1 && dv2 == ddv2 ) if ( dv1 == ddv1 && dv2 == ddv2 )
{ {
@ -1036,28 +1131,22 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
SetDistantEdgeNum ( sender, edges[i], distedgenums[ed] ); SetDistantEdgeNum ( sender, edges[i], distedgenums[ed] );
} }
} }
} }
delete [] distedgenums;
ii += 2*distnp + 3*distned; ii += 2*distnp + 3*distned;
} }
} }
} }
#endif
// set which elements are where for the master processor // set which elements are where for the master processor
delete sendarray; delete recvarray;
if ( id > 0 )
delete glob2locfa;
coarseupdate = 1; coarseupdate = 1;
#ifdef SCALASCA #ifdef SCALASCA
#pragma pomp inst end(updatecoarsegrid) #pragma pomp inst end(updatecoarsegrid)
#endif #endif
} }
void ParallelMeshTopology :: UpdateCoarseGridOverlap () void ParallelMeshTopology :: UpdateCoarseGridOverlap ()
@ -1093,7 +1182,7 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
sendarray = new Array<int> (0); sendarray = new Array<int> (0);
recvarray = new Array<int>; recvarray = new Array<int>;
sendarray->SetSize (0); sendarray -> SetSize (0);
BitArray recvface(nfa); BitArray recvface(nfa);
recvface.Clear(); recvface.Clear();
@ -1174,17 +1263,17 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
if ( id == sender ) if ( id == sender )
MyMPI_Bcast (*sendarray, sender-1, MPI_HIGHORDER_COMM); MyMPI_Bcast (*sendarray, sender-1, MPI_HIGHORDER_COMM);
// { // {
// for ( int dest = 1; dest < ntasks; dest ++ ) // for ( int dest = 1; dest < ntasks; dest ++ )
// if ( dest != id) // if ( dest != id)
// { // {
// MyMPI_Send (*sendarray, dest); // MyMPI_Send (*sendarray, dest);
// } // }
// } // }
if ( id != sender ) if ( id != sender )
{ {
// MyMPI_Recv ( *recvarray, sender); // MyMPI_Recv ( *recvarray, sender);
MyMPI_Bcast (*recvarray, sender-1, MPI_HIGHORDER_COMM); MyMPI_Bcast (*recvarray, sender-1, MPI_HIGHORDER_COMM);
// compare received vertices with own ones // compare received vertices with own ones
int ii = 0; int ii = 0;
@ -1329,13 +1418,13 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
// send global-local el/face/edge/vert-info to id 0 // send global-local el/face/edge/vert-info to id 0
// nfa = topology . GetNFaces(); // nfa = topology . GetNFaces();
// ned = topology . GetNEdges(); // ned = topology . GetNEdges();
// np = mesh . GetNP(); // np = mesh . GetNP();
// nv = mesh . GetNV(); // nv = mesh . GetNV();
// ne = mesh . GetNE(); // ne = mesh . GetNE();
// nseg = mesh.GetNSeg(); // nseg = mesh.GetNSeg();
// nsurfel = mesh.GetNSE(); // nsurfel = mesh.GetNSE();
if ( id != 0 ) if ( id != 0 )
{ {
Array<int> * sendarray; Array<int> * sendarray;
@ -1456,8 +1545,8 @@ void ParallelMeshTopology :: UpdateCoarseGridGlobal ()
} }
void ParallelMeshTopology :: UpdateExchangeElements() void ParallelMeshTopology :: UpdateExchangeElements()
{ {
(*testout) << "UPDATE EXCHANGE ELEMENTS " << endl; (*testout) << "UPDATE EXCHANGE ELEMENTS " << endl;
const MeshTopology & topology = mesh.GetTopology(); const MeshTopology & topology = mesh.GetTopology();
@ -1620,12 +1709,12 @@ void ParallelMeshTopology :: UpdateExchangeElements()
delete [] elementonproc; delete [] elementonproc;
delete [] recvelonproc; delete [] recvelonproc;
} }
void ParallelMeshTopology :: SetNV ( const int anv ) void ParallelMeshTopology :: SetNV ( const int anv )
{ {
*testout << "called setnv" << endl *testout << "called setnv" << endl
<< "old size: " << loc2distvert.Size() << endl << "old size: " << loc2distvert.Size() << endl
@ -1650,7 +1739,7 @@ void ParallelMeshTopology :: SetNV ( const int anv )
} }
void ParallelMeshTopology :: SetNE ( const int ane ) void ParallelMeshTopology :: SetNE ( const int ane )
{ {
loc2distel.ChangeSize (ane); loc2distel.ChangeSize (ane);
for (int i = 0; i < ane; i++) for (int i = 0; i < ane; i++)
@ -1672,7 +1761,7 @@ void ParallelMeshTopology :: SetNE ( const int ane )
} }
void ParallelMeshTopology :: SetNSE ( int anse ) void ParallelMeshTopology :: SetNSE ( int anse )
{ {
loc2distsurfel.ChangeSize (anse); loc2distsurfel.ChangeSize (anse);
for (int i = 0; i < anse; i++) for (int i = 0; i < anse; i++)
@ -1682,8 +1771,8 @@ void ParallelMeshTopology :: SetNSE ( int anse )
nsurfel = anse; nsurfel = anse;
} }
void ParallelMeshTopology :: SetNSegm ( int anseg ) void ParallelMeshTopology :: SetNSegm ( int anseg )
{ {
loc2distsegm.ChangeSize (anseg); loc2distsegm.ChangeSize (anseg);
for (int i = 0; i < anseg; i++) for (int i = 0; i < anseg; i++)
if (loc2distsegm[i].Size() == 0) if (loc2distsegm[i].Size() == 0)

View File

@ -35,7 +35,8 @@ namespace netgen
{ {
surfellist = 0; surfellist = 0;
linelist = 0; linelist = 0;
clipplanelist = 0; clipplanelist_scal = 0;
clipplanelist_vec = 0;
isolinelist = 0; isolinelist = 0;
clipplane_isolinelist = 0; clipplane_isolinelist = 0;
surface_vector_list = 0; surface_vector_list = 0;
@ -417,7 +418,12 @@ namespace netgen
} }
if (showclipsolution) if (showclipsolution)
glCallList (clipplanelist); {
if (clipsolution == 1)
glCallList (clipplanelist_scal);
if (clipsolution == 2)
glCallList (clipplanelist_vec);
}
if (draw_fieldlines) if (draw_fieldlines)
@ -696,31 +702,16 @@ namespace netgen
// lock->Lock(); // lock->Lock();
} }
if (clipplanelist)
glDeleteLists (clipplanelist, 1);
clipplanelist = glGenLists (1);
glNewList (clipplanelist, GL_COMPILE);
if (vispar.clipenable && clipsolution == 1 && sol) if (vispar.clipenable && clipsolution == 1 && sol)
{ DrawClipPlaneTrigs (); // sol, scalcomp);
glDisable(GL_CLIP_PLANE0);
Array<ClipPlaneTrig> cpt;
Array<ClipPlanePoint> pts;
GetClippingPlaneTrigs (cpt, pts);
glNormal3d (-clipplane[0], -clipplane[1], -clipplane[2]); if (clipplanelist_vec)
glColor3d (1.0, 1.0, 1.0); glDeleteLists (clipplanelist_vec, 1);
SetTextureMode (usetexture);
DrawClipPlaneTrigs (sol, scalcomp, cpt, pts);
glEnable(GL_CLIP_PLANE0);
}
clipplanelist_vec = glGenLists (1);
glNewList (clipplanelist_vec, GL_COMPILE);
if (vispar.clipenable && clipsolution == 2 && vsol) if (vispar.clipenable && clipsolution == 2 && vsol)
{ {
@ -3719,10 +3710,65 @@ namespace netgen
void VisualSceneSolution :: void VisualSceneSolution ::
DrawClipPlaneTrigs (const SolData * sol, int comp, DrawClipPlaneTrigs () // const SolData * sol, int comp)
const Array<ClipPlaneTrig> & trigs,
const Array<ClipPlanePoint> & points)
{ {
#ifdef PARALLELGL
if (id == 0 && ntasks > 1)
{
InitParallelGL();
Array<int> parlists (ntasks);
for ( int dest = 1; dest < ntasks; dest++ )
{
MyMPI_Send ("redraw", dest);
MyMPI_Send ("clipplanetrigs", dest);
}
for ( int dest = 1; dest < ntasks; dest++ )
MyMPI_Recv (parlists[dest], dest);
if (clipplanelist_scal)
glDeleteLists (clipplanelist_scal, 1);
clipplanelist_scal = glGenLists (1);
glNewList (clipplanelist_scal, GL_COMPILE);
for ( int dest = 1; dest < ntasks; dest++ )
glCallList (parlists[dest]);
glEndList();
return;
}
#endif
if (clipplanelist_scal)
glDeleteLists (clipplanelist_scal, 1);
clipplanelist_scal = glGenLists (1);
glNewList (clipplanelist_scal, GL_COMPILE);
Array<ClipPlaneTrig> trigs;
Array<ClipPlanePoint> points;
GetClippingPlaneTrigs (trigs, points);
glNormal3d (-clipplane[0], -clipplane[1], -clipplane[2]);
glColor3d (1.0, 1.0, 1.0);
SetTextureMode (usetexture);
SolData * sol = NULL;
if (scalfunction != -1)
sol = soldata[scalfunction];
glBegin (GL_TRIANGLES); glBegin (GL_TRIANGLES);
int maxlpnr = 0; int maxlpnr = 0;
@ -3817,6 +3863,15 @@ namespace netgen
} }
glEnd(); glEnd();
glEndList ();
#ifdef PARALLELGL
glFinish();
if (id > 0)
MyMPI_Send (clipplanelist_scal, 0);
#endif
} }
@ -4058,6 +4113,11 @@ namespace netgen
MyMPI_Bcast (maxval); MyMPI_Bcast (maxval);
MyMPI_Bcast (numisolines); MyMPI_Bcast (numisolines);
MyMPI_Bcast (subdivisions); MyMPI_Bcast (subdivisions);
MyMPI_Bcast (clipplane[0]);
MyMPI_Bcast (clipplane[1]);
MyMPI_Bcast (clipplane[2]);
MyMPI_Bcast (clipplane[3]);
} }
#endif #endif
@ -4321,6 +4381,11 @@ namespace netgen
} }
vsmesh.SetClippingPlane (); // for computing parameters
vssolution.SetClippingPlane (); // for computing parameters
glDisable(GL_CLIP_PLANE0);
#ifdef PARALLELGL #ifdef PARALLELGL
vsmesh.Broadcast (); vsmesh.Broadcast ();
#endif #endif

View File

@ -43,7 +43,8 @@ class VisualSceneSolution : public VisualScene
int surfellist; int surfellist;
int linelist; int linelist;
int clipplanelist; int clipplanelist_scal;
int clipplanelist_vec;
int isolinelist; int isolinelist;
int clipplane_isolinelist; int clipplane_isolinelist;
int surface_vector_list; int surface_vector_list;
@ -299,9 +300,7 @@ public:
double val1, double val2, double val3, double val4); double val1, double val2, double val3, double val4);
void DrawClipPlaneTrigs (const SolData * sol, int comp, void DrawClipPlaneTrigs (); // const SolData * sol, int comp);
const Array<ClipPlaneTrig> & trigs,
const Array<ClipPlanePoint> & points);
void SetOpenGlColor(double val); void SetOpenGlColor(double val);

View File

@ -72,6 +72,7 @@ proc popupcheckredraw2 { vari boolvar { x 0 } } {
set varname 0 set varname 0
} { } {
Ng_SetVisParameters Ng_SetVisParameters
Ng_Vis_Set parameters
if { $boolvar == 1 } { redraw } if { $boolvar == 1 } { redraw }
Ng_SetVisParameters Ng_SetVisParameters
} }

View File

@ -249,11 +249,13 @@ void ParallelRun()
display = XOpenDisplay (displname.c_str()); display = XOpenDisplay (displname.c_str());
/*
PrintMessage (3, "displ - name = ", displname); PrintMessage (3, "displ - name = ", displname);
PrintMessage (3, "display = ", display, PrintMessage (3, "display = ", display,
" display props: ", " display props: ",
" screen w = ", XDisplayWidth (display, 0), " screen w = ", XDisplayWidth (display, 0),
" , h = ", XDisplayHeight (display, 0)); " , h = ", XDisplayHeight (display, 0));
*/
Window win; Window win;
int wx, wy; int wx, wy;
@ -328,7 +330,6 @@ void ParallelRun()
break; break;
} }
} }
if (!visinfo) if (!visinfo)
cerr << "no VISINFO found" << endl; cerr << "no VISINFO found" << endl;
@ -365,26 +366,26 @@ void ParallelRun()
if (redraw_cmd == "linelist") if (redraw_cmd == "linelist")
{ {
glXMakeCurrent (display, curDrawable, context); // glXMakeCurrent (display, curDrawable, context);
vsmesh.BuildLineList(); vsmesh.BuildLineList();
glXMakeCurrent (display, None, NULL); // glXMakeCurrent (display, None, NULL);
} }
if (redraw_cmd == "filledlist") if (redraw_cmd == "filledlist")
{ {
glXMakeCurrent (display, curDrawable, context);
vsmesh.BuildFilledList (false); vsmesh.BuildFilledList (false);
glXMakeCurrent (display, None, NULL);
} }
if (redraw_cmd == "solsurfellist") if (redraw_cmd == "solsurfellist")
{ {
glXMakeCurrent (display, curDrawable, context);
vssolution.DrawSurfaceElements(); vssolution.DrawSurfaceElements();
glXMakeCurrent (display, None, NULL);
} }
if (redraw_cmd == "clipplanetrigs")
{
vssolution.DrawClipPlaneTrigs();
}
} }
#endif #endif