From 846542c45ce880ff33516c01f9d036b1486df829 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 14 Feb 2011 12:27:18 +0000 Subject: [PATCH] parallel programming --- Makefile.am | 4 +- configure.ac | 12 +- libsrc/general/profiler.cpp | 1 - libsrc/geom2d/Makefile.am | 2 +- libsrc/geom2d/splinegeometry.cpp | 4 +- libsrc/geom2d/splinegeometry.hpp | 5 +- libsrc/include/mystdlib.h | 6 +- libsrc/interface/writeOpenFOAM15x.cpp | 7 +- libsrc/meshing/Makefile.am | 4 +- libsrc/meshing/parallelmesh.cpp | 37 ++++-- libsrc/meshing/topology.cpp | 178 ++++++++++++++++++++------ libsrc/visualization/mvdraw.cpp | 3 +- libsrc/visualization/vsmesh.cpp | 19 ++- ng/Makefile.am | 8 +- ng/ngappinit.cpp | 4 +- ng/parallelfunc.cpp | 80 +++++------- ng/parallelinterface.cpp | 7 +- 17 files changed, 253 insertions(+), 128 deletions(-) diff --git a/Makefile.am b/Makefile.am index e2a56938..faa9e55c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,8 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 METASOURCES = AUTO -SUBDIRS = libsrc ng nglib tutorials doc windows - +SUBDIRS = libsrc ng tutorials doc windows +# nglib # TESTS = ng/netgen -batchmode diff --git a/configure.ac b/configure.ac index 3542ce4b..6eff10dc 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_PREFIX_DEFAULT(["/opt/netgen"]) # Tcl/Tk configuration: -TEA_INIT([3.6]) +TEA_INIT([3.9]) TEA_PATH_TCLCONFIG TEA_LOAD_TCLCONFIG TEA_PATH_TKCONFIG @@ -89,11 +89,15 @@ AC_ARG_ENABLE([nglib], AC_ARG_ENABLE([parallel], [AC_HELP_STRING([--enable-parallel],[enable mpi parallelization])], - [AC_SUBST([MPI_INCLUDES], "-I/opt/mpich/include -DPARALLEL -I/usr/share/metis/Lib -DMETIS") - AC_SUBST([MPI_LIBS], "-lmetis -L/opt/mpich/ch-p4/lib -lmpich") + [AC_SUBST([MPI_INCLUDES], "-I/usr/lib64/mpi/gcc/openmpi/include -DPARALLEL -I/usr/include/metis -DMETIS") + AC_SUBST([MPI_LIBS], "-L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi_cxx -lmetis") ] ) - +# [AC_SUBST([MPI_INCLUDES], "-I/opt/mpich/include -DPARALLEL -I/usr/include/metis -DMETIS") +# AC_SUBST([MPI_LIBS], " -L/opt/mpich/ch-p4/lib64 -lmpich -lmetis") +# [AC_SUBST([MPI_INCLUDES], "-DPARALLEL -DNO_PARALLEL_THREADS -I/opt/mpich/include") +# AC_SUBST([MPI_LIBS], "") +# -lmetis # [AC_SUBST([MPI_INCLUDES], "-I/opt/mpich/include -DPARALLEL -I/home/joachim/download/metis-4.0/Lib -DMETIS") # AC_SUBST([MPI_LIBS], "-L/home/joachim/download/metis-4.0 -lmetis -L/opt/mpich/ch-p4/lib64 -lmpich") diff --git a/libsrc/general/profiler.cpp b/libsrc/general/profiler.cpp index 60efaa08..4f65d51c 100644 --- a/libsrc/general/profiler.cpp +++ b/libsrc/general/profiler.cpp @@ -41,7 +41,6 @@ namespace netgen // which leads to an "order of destruction"-problem, // thus we use the C-variant: - if (getenv ("NGPROFILE")) { char filename[100]; diff --git a/libsrc/geom2d/Makefile.am b/libsrc/geom2d/Makefile.am index d80710f8..761cc52a 100644 --- a/libsrc/geom2d/Makefile.am +++ b/libsrc/geom2d/Makefile.am @@ -1,4 +1,4 @@ -noinst_HEADERS = geom2dmesh.hpp spline2d.hpp splinegeometry.hpp spline.hpp geometry2d.hpp vsgeom2d.hpp +noinst_HEADERS = geom2dmesh.hpp splinegeometry.hpp spline.hpp geometry2d.hpp vsgeom2d.hpp AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES) diff --git a/libsrc/geom2d/splinegeometry.cpp b/libsrc/geom2d/splinegeometry.cpp index d2caee24..f0ea24ee 100644 --- a/libsrc/geom2d/splinegeometry.cpp +++ b/libsrc/geom2d/splinegeometry.cpp @@ -976,9 +976,9 @@ void SplineGeometry :: LoadData ( ifstream & infile ) -template -void SplineGeometry :: PartitionBoundary (double h, Mesh & mesh2d) +void SplineGeometry2d :: PartitionBoundary (double h, Mesh & mesh2d) { + enum { D = 2 }; Box bbox; GetBoundingBox (bbox); double dist = Dist (bbox.PMin(), bbox.PMax()); diff --git a/libsrc/geom2d/splinegeometry.hpp b/libsrc/geom2d/splinegeometry.hpp index 6216c744..11a2b82c 100644 --- a/libsrc/geom2d/splinegeometry.hpp +++ b/libsrc/geom2d/splinegeometry.hpp @@ -38,6 +38,7 @@ namespace netgen template < int D > class SplineGeometry { + protected: Array < GeomPoint > geompoints; Array < SplineSeg* > splines; double elto0; @@ -48,7 +49,6 @@ namespace netgen Array tensormeshing; Array layer; - private: void AppendSegment(SplineSeg * spline, const int leftdomain, const int rightdomain, const int bc, const double reffac, const bool hprefleft, const bool hprefright, @@ -65,7 +65,6 @@ namespace netgen void LoadDataNew ( ifstream & infile ); void LoadDataV2 ( ifstream & infile ); - void PartitionBoundary (double h, Mesh & mesh2d); void GetRawData (Array & raw_data) const; @@ -151,6 +150,8 @@ namespace netgen virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam, int perfstepsstart, int perfstepsend); + + void PartitionBoundary (double h, Mesh & mesh2d); virtual Refinement & GetRefinement () const; }; diff --git a/libsrc/include/mystdlib.h b/libsrc/include/mystdlib.h index ec6521be..a3a9103a 100644 --- a/libsrc/include/mystdlib.h +++ b/libsrc/include/mystdlib.h @@ -27,9 +27,9 @@ #include #ifdef PARALLEL -#undef SEEK_SET -#undef SEEK_CUR -#undef SEEK_END +// #undef SEEK_SET +// #undef SEEK_CUR +// #undef SEEK_END #include #endif diff --git a/libsrc/interface/writeOpenFOAM15x.cpp b/libsrc/interface/writeOpenFOAM15x.cpp index 4ae523b5..337e49ef 100644 --- a/libsrc/interface/writeOpenFOAM15x.cpp +++ b/libsrc/interface/writeOpenFOAM15x.cpp @@ -137,7 +137,7 @@ namespace netgen for(int elind = 1; elind <= ne; elind++) { // Extract the current volume element - const Element & el = mesh.VolumeElement(elind); + // const Element & el = mesh.VolumeElement(elind); // Get the face numbers of the faces of the current volume element // The values returned are given a sign depending on the orientation @@ -596,7 +596,6 @@ namespace netgen void WriteOpenFOAM15xFormat (const Mesh & mesh, const string & casename) { - int i,j; bool error = false; char casefiles[256]; @@ -627,8 +626,8 @@ namespace netgen return; } - if((mesh.SurfaceElement(nse/2).GetType() != TRIG) - && (mesh.SurfaceElement(nse/2).GetType() != QUAD) + if(( (mesh.SurfaceElement(nse/2).GetType() != TRIG) + && (mesh.SurfaceElement(nse/2).GetType() != QUAD) ) || (mesh.VolumeElement(ne/2).GetType() == TET10) || (mesh.VolumeElement(ne/2).GetType() == PRISM12)) { diff --git a/libsrc/meshing/Makefile.am b/libsrc/meshing/Makefile.am index e673802a..2ff94a95 100644 --- a/libsrc/meshing/Makefile.am +++ b/libsrc/meshing/Makefile.am @@ -14,7 +14,9 @@ clusters.hpp hprefinement.hpp improve3.hpp meshtype.hpp \ METASOURCES = AUTO -noinst_LTLIBRARIES = libmesh.la + +lib_LTLIBRARIES = libmesh.la + libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \ clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp \ geomsearch.cpp global.cpp hprefinement.cpp improve2.cpp \ diff --git a/libsrc/meshing/parallelmesh.cpp b/libsrc/meshing/parallelmesh.cpp index ea99c035..f05d08e9 100644 --- a/libsrc/meshing/parallelmesh.cpp +++ b/libsrc/meshing/parallelmesh.cpp @@ -5,14 +5,17 @@ #ifdef METIS -namespace metis { extern "C" { +namespace metis +{ + extern "C" { #include -} } + } +} +using namespace metis; + #endif -using namespace metis; - namespace netgen { @@ -309,8 +312,6 @@ namespace netgen - - // distribute the mesh to the slave processors @@ -326,7 +327,12 @@ namespace netgen // partition mesh +#ifdef METIS ParallelMetis (); +#else + for (ElementIndex ei = 0; ei < GetNE(); ei++) + (*this)[ei].SetPartition(ntasks * ei/GetNE() + 1); +#endif #ifdef SCALASCA #pragma pomp inst end(metis) @@ -349,7 +355,7 @@ namespace netgen - +#ifdef METIS void Mesh :: ParallelMetis ( ) { int timer = NgProfiler::CreateTimer ("Mesh::Partition"); @@ -475,12 +481,12 @@ namespace netgen delete [] epart; delete [] npart; } - +#endif void Mesh :: PartHybridMesh () // Array & neloc ) { - +#ifdef METIS int ne = GetNE(); int nn = GetNP(); @@ -571,11 +577,15 @@ namespace netgen delete [] xadj; delete [] part; delete [] adjacency; +#else + cout << "parthybridmesh not available" << endl; +#endif } void Mesh :: PartDualHybridMesh ( ) // Array & neloc ) { +#ifdef METIS int ne = GetNE(); // int nn = GetNP(); @@ -677,6 +687,10 @@ namespace netgen delete [] xadj; delete [] part; delete [] adjacency; +#else + cout << "partdualmesh not available" << endl; +#endif + } @@ -685,6 +699,7 @@ namespace netgen void Mesh :: PartDualHybridMesh2D ( ) { +#ifdef METIS int ne = GetNSE(); int nv = GetNV(); @@ -758,6 +773,10 @@ namespace netgen for (SurfaceElementIndex sei = 0; sei < ne; sei++) (*this) [sei].SetPartition (part[sei]+1); +#else + cout << "partdualmesh not available" << endl; +#endif + } diff --git a/libsrc/meshing/topology.cpp b/libsrc/meshing/topology.cpp index 67aa6c76..b4f7bdb0 100644 --- a/libsrc/meshing/topology.cpp +++ b/libsrc/meshing/topology.cpp @@ -7,6 +7,44 @@ namespace netgen { + + + template + void QuickSortRec (FlatArray & data, + int left, int right) + { + int i = left; + int j = right; + T midval = data[(left+right)/2]; + + do + { + while (data[i] < midval) i++; + while (midval < data[j]) j--; + + if (i <= j) + { + Swap (data[i], data[j]); + i++; j--; + } + } + while (i <= j); + if (left < j) QuickSortRec (data, left, j); + if (i < right) QuickSortRec (data, i, right); + } + + template + void QuickSort (FlatArray & data) + { + if (data.Size() > 1) + QuickSortRec (data, 0, data.Size()-1); + } + + + + + + MeshTopology :: MeshTopology (const Mesh & amesh) : mesh(amesh) { @@ -85,8 +123,7 @@ namespace netgen for (ElementIndex ei = 0; ei < ne; ei++) { const Element & el = mesh[ei]; - int nelv = el.GetNV(); - for (int j = 0; j < nelv; j++) + for (int j = 0; j < el.GetNV(); j++) cnt[el[j]]++; } @@ -94,8 +131,7 @@ namespace netgen for (ElementIndex ei = 0; ei < ne; ei++) { const Element & el = mesh[ei]; - int nelv = el.GetNV(); - for (int j = 0; j < nelv; j++) + for (int j = 0; j < el.GetNV(); j++) vert2element->AddSave (el[j], ei+1); } @@ -103,8 +139,7 @@ namespace netgen for (SurfaceElementIndex sei = 0; sei < nse; sei++) { const Element2d & el = mesh[sei]; - int nelv = el.GetNV(); - for (int j = 0; j < nelv; j++) + for (int j = 0; j < el.GetNV(); j++) cnt[el[j]]++; } @@ -112,8 +147,7 @@ namespace netgen for (SurfaceElementIndex sei = 0; sei < nse; sei++) { const Element2d & el = mesh[sei]; - int nelv = el.GetNV(); - for (int j = 0; j < nelv; j++) + for (int j = 0; j < el.GetNV(); j++) vert2surfelement->AddSave (el[j], sei+1); } @@ -133,7 +167,6 @@ namespace netgen vert2segment->AddSave (seg[1], i); } - if (buildedges) { @@ -197,6 +230,8 @@ namespace netgen Array edgenr(nv); Array edgeflag(nv); + Array vertex2; + edgeflag = 0; ned = edge2vert.Size(); @@ -204,6 +239,8 @@ namespace netgen for (int i = PointIndex::BASE; i < nv+PointIndex::BASE; i++) { + vertex2.SetSize (0); + for (int j = 0; j < vert2edge[i].Size(); j++) { int ednr = vert2edge[i][j]; @@ -211,15 +248,95 @@ namespace netgen edgeflag[i2] = i; edgenr[i2] = ednr; } + for (int j = 0; j < vert2vertcoarse[i].Size(); j++) // fix by Markus { int v2 = vert2vertcoarse[i][j]; if (edgeflag[v2] < i) { - ned++; - edgenr[v2] = ned; + *testout << "do we really need that ??????????????" << endl; + // ned++; + // edgenr[v2] = ned; edgeflag[v2] = i; - missing.Append (INDEX_3(i,v2,ned)); + vertex2.Append (v2); + // missing.Append (INDEX_3(i,v2,ned)); + } + } + + for (int j = 0; j < (*vert2element)[i].Size(); j++) + { + int elnr = (*vert2element)[i][j]; + const Element & el = mesh.VolumeElement (elnr); + + int neledges = GetNEdges (el.GetType()); + const ELEMENT_EDGE * eledges = GetEdges0 (el.GetType()); + + for (int k = 0; k < neledges; k++) + { + INDEX_2 edge(el[eledges[k][0]], el[eledges[k][1]]); + edge.Sort(); + if (edge.I1() != i) continue; + + if (edgeflag[edge.I2()] < i) + { + vertex2.Append (edge.I2()); + edgeflag[edge.I2()] = i; + } + } + } + + for (int j = 0; j < (*vert2surfelement)[i].Size(); j++) + { + int elnr = (*vert2surfelement)[i][j]; + const Element2d & el = mesh.SurfaceElement (elnr); + + int neledges = GetNEdges (el.GetType()); + const ELEMENT_EDGE * eledges = GetEdges0 (el.GetType()); + + for (int k = 0; k < neledges; k++) + { + INDEX_2 edge(el[eledges[k][0]], el[eledges[k][1]]); + edge.Sort(); + if (edge.I1() != i) continue; + + if (edgeflag[edge.I2()] < i) + { + vertex2.Append (edge.I2()); + edgeflag[edge.I2()] = i; + } + } + } + + for (int j = 0; j < (*vert2segment)[i].Size(); j++) + { + int elnr = (*vert2segment)[i][j]; + const Segment & el = mesh.LineSegment (elnr); + + INDEX_2 edge(el[0], el[1]); + edge.Sort(); + if (edge.I1() != i) continue; + + if (edgeflag[edge.I2()] < i) + { + vertex2.Append (edge.I2()); + edgeflag[edge.I2()] = i; + } + } + + + QuickSort (vertex2); + for (int j = 0; j < vertex2.Size(); j++) + edgenr[vertex2[j]] = ++ned; + + for (int j = 0; j < vert2vertcoarse[i].Size(); j++) // fix by Markus + { + int v2 = vert2vertcoarse[i][j]; + if (edgeflag[v2] < i) + { + // ned++; + // edgenr[v2] = ned; + // edgeflag[v2] = i; + missing.Append (INDEX_3(i,v2,edgenr[v2])); } } @@ -240,13 +357,6 @@ namespace netgen if (edge.I1() != i) continue; - - if (edgeflag[edge.I2()] < i) - { - ned++; - edgenr[edge.I2()] = ned; - edgeflag[edge.I2()] = i; - } int edgenum = edgenr[edge.I2()]; if (edgedir) edgenum *= -1; @@ -269,16 +379,8 @@ namespace netgen int edgedir = (edge.I1() > edge.I2()); if (edgedir) swap (edge.I1(), edge.I2()); - if (edge.I1() != i) - continue; - - if (edgeflag[edge.I2()] < i) - { - ned++; - edgenr[edge.I2()] = ned; - edgeflag[edge.I2()] = i; - } - + if (edge.I1() != i) continue; + int edgenum = edgenr[edge.I2()]; if (edgedir) edgenum *= -1; surfedges.Elem(elnr)[k] = edgenum; @@ -295,23 +397,16 @@ namespace netgen int edgedir = (edge.I1() > edge.I2()); if (edgedir) swap (edge.I1(), edge.I2()); - if (edge.I1() != i) - continue; - - if (edgeflag[edge.I2()] < i) - { - ned++; - edgenr[edge.I2()] = ned; - edgeflag[edge.I2()] = i; - } - int edgenum = edgenr[edge.I2()]; + if (edge.I1() != i) continue; + int edgenum = edgenr[edge.I2()]; if (edgedir) edgenum *= -1; segedges.Elem(elnr) = edgenum; } } + edge2vert.SetSize (ned); for (int i = 1; i <= ne; i++) { @@ -333,6 +428,11 @@ namespace netgen edge2vert.Elem(edgenum)[1] = edge.I2(); } } + + *testout << "edge 2 vert:" << endl; + for (int i = 0; i < edge2vert.Size(); i++) + *testout << edge2vert[i][0] << " " << edge2vert[i][1] << endl; + for (int i = 1; i <= nse; i++) { const Element2d & el = mesh.SurfaceElement (i); diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 796bfa2a..f4978250 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -752,7 +752,7 @@ namespace netgen GLXContextID xid = glXGetContextIDEXT (ctx); displname = XDisplayName (0); - + /* cout << "Init Parallel GL" << endl; cout << "DisplayName = " << displname << endl; cout << "current display = " << dpy << endl; @@ -762,6 +762,7 @@ namespace netgen cout << "contextid = " << xid << endl; cout << "isdirect = " << glXIsDirect ( dpy, ctx ) << endl; cout << "extensionstring = " << glXQueryExtensionsString( dpy, 0 ) << endl; + */ Array request(ntasks); MPI_Status status; diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index a96dd1c4..5e9ceae1 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -1020,6 +1020,7 @@ namespace netgen #ifdef PARALLEL + /* if ( el.IsGhost() ) { if ( faceindex == selface ) @@ -1028,6 +1029,7 @@ namespace netgen glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_coll_transp); } else + */ { if ( faceindex == selface ) glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matcolsel); @@ -1894,9 +1896,20 @@ namespace netgen for (ElementIndex ei = 0; ei < mesh->GetNE(); ei++) { - if (vispar.drawtetsdomain > 0 && - vispar.drawtetsdomain != (*mesh)[ei].GetIndex()) - continue; + if (vispar.drawtetsdomain > 0) + { + int tetid = +#ifdef PARALLEL + vispar.drawmetispartition ? + (*mesh)[ei].GetPartition() + : +#endif + (*mesh)[ei].GetIndex(); + + if (vispar.drawtetsdomain != tetid) + continue; + } + const Element & el = (*mesh)[ei]; diff --git a/ng/Makefile.am b/ng/Makefile.am index ba48a84a..b90e9c86 100644 --- a/ng/Makefile.am +++ b/ng/Makefile.am @@ -12,15 +12,17 @@ netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \ $(top_builddir)/libsrc/geom2d/libgeom2dvis.la \ $(top_builddir)/libsrc/geom2d/libgeom2d.la \ $(top_builddir)/libsrc/interface/libinterface.la \ - $(top_builddir)/libsrc/occ/liboccvis.la \ - $(top_builddir)/libsrc/occ/libocc.la \ $(top_builddir)/libsrc/stlgeom/libstlvis.la \ $(top_builddir)/libsrc/stlgeom/libstl.la \ $(top_builddir)/libsrc/meshing/libmesh.la \ $(top_builddir)/libsrc/gprim/libgprim.la \ $(top_builddir)/libsrc/linalg/libla.la \ $(top_builddir)/libsrc/general/libgen.la \ - $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS) + $(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS) + +# $(top_builddir)/libsrc/occ/liboccvis.la +# $(top_builddir)/libsrc/occ/libocc.la + # add for static linkage of ngsolve: # /opt/netgen/lib/libngsolve.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngcomp.a /opt/netgen/lib/libngfemng.a /opt/netgen/lib/libngmg.a /opt/netgen/lib/libngla.a /opt/netgen/lib/libngbla.a /opt/netgen/lib/libngstd.a -L/opt/intel/mkl/10.2.1.017/lib/em64t /opt/intel/mkl/10.2.1.017/lib/em64t/libmkl_solver_lp64.a -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core diff --git a/ng/ngappinit.cpp b/ng/ngappinit.cpp index aa39ee6e..5de522ce 100644 --- a/ng/ngappinit.cpp +++ b/ng/ngappinit.cpp @@ -129,8 +129,8 @@ int main(int argc, char ** argv) #ifdef PARALLEL - cout << "Including MPI " << endl; - cout << "Using " << netgen::ntasks << " processor" + cout << "Running MPI - parallel using " + << netgen::ntasks << " processor" << ((netgen::ntasks > 1) ? "s " : " ") << endl; #endif } diff --git a/ng/parallelfunc.cpp b/ng/parallelfunc.cpp index ea4abd75..3175f10b 100644 --- a/ng/parallelfunc.cpp +++ b/ng/parallelfunc.cpp @@ -1,5 +1,7 @@ #ifdef PARALLEL +#include "dlfcn.h" + #ifdef OCCGEOMETRY #include #endif @@ -29,7 +31,6 @@ #endif - #include #include @@ -48,11 +49,8 @@ #include "parallelfunc.hpp" - - - - - +// extern "C" void NGS_ParallelRun (const string & message); +void (*NGS_ParallelRun) (const string & message) = NULL; @@ -71,49 +69,17 @@ void Parallel_Exit(); namespace netgen { extern AutoPtr mesh; - - // geometry: either CSG, or, if an other is non-null, - // then the other - extern AutoPtr geometry ; - - extern STLGeometry * stlgeometry; - extern AutoPtr geometry2d ; - -#ifdef OCCGEOMETRY - extern OCCGeometry * occgeometry; -#endif - -#ifdef ACIS - extern ACISGeometry * acisgeometry; -#endif - } using namespace netgen; using netgen::RegisterUserFormats; + + #ifdef PARALLEL void Ng_Exit () { -#ifdef NGSOLVE - Parallel_Exit(); -#endif - - delete stlgeometry; - stlgeometry = NULL; - - -#ifdef OCCGEOMETRY - delete occgeometry; - occgeometry = 0; -#endif - - - geometry.Reset (NULL); - geometry2d.Reset (NULL); - - // delete testout; - return; + // Parallel_Exit(); } #endif @@ -152,15 +118,31 @@ void ParallelRun() #pragma pomp inst end (message) #endif -#ifdef NGSOLVE if ( message.compare(0, 3, "ngs") == 0 ) { - PrintMessage ( 2, "Starting NgSolve routine ", message ) ; - NGS_ParallelRun (message); + PrintMessage ( 1, "Starting NgSolve routine ", message ) ; + + if (NGS_ParallelRun == NULL) + { + void * handle = dlopen ("libngsolve.so", RTLD_NOW | RTLD_GLOBAL); + if (!handle) + { + cerr << "cannot load shared library libngsolve.so" << endl; + exit(1); + } + + NGS_ParallelRun = (void (*) (const string & message)) dlsym (handle, "NGS_ParallelRun"); + + if (!NGS_ParallelRun) + { + cerr << "cannot bind function NGS_ParallelRun" << endl; + exit(1); + } + } + (*NGS_ParallelRun) (message); } else -#endif if ( message == "mesh" ) { @@ -274,14 +256,16 @@ void ParallelRun() Window win; int wx, wy; unsigned int ww, wh, bw, depth; - cout << "got drawable: " << curDrawable << endl; + // cout << "got drawable: " << curDrawable << endl; XGetGeometry(display, curDrawable, &win, &wx, &wy, &ww, &wh, &bw, &depth); + /* cout << "P" << id << ": window-props: x = " << wx << ", y = " << wy << ", w = " << ww << ", h = " << wh << ", depth = " << depth << endl; + */ #define VISUAL #ifdef VISUAL @@ -348,7 +332,7 @@ void ParallelRun() // context = glXCreateContext( display, visinfo, 0, /* curContext, */ False ); context = glXCreateContext( display, visinfo, glXImportContextEXT ( display, contextid ), False ); - cout << "context = " << context << endl; + // cout << "context = " << context << endl; glXMakeCurrent (display, curDrawable, context); @@ -387,7 +371,7 @@ void ParallelRun() if (redraw_cmd == "filledlist") { glXMakeCurrent (display, curDrawable, context); - vsmesh.BuildFilledList(); + vsmesh.BuildFilledList (0); glXMakeCurrent (display, None, NULL); } diff --git a/ng/parallelinterface.cpp b/ng/parallelinterface.cpp index f5903615..954a1cf9 100644 --- a/ng/parallelinterface.cpp +++ b/ng/parallelinterface.cpp @@ -10,7 +10,6 @@ namespace netgen extern AutoPtr mesh; - using namespace netgen; // int NgPar_Glob2Loc_SurfEl ( int globnum ) @@ -32,7 +31,9 @@ namespace netgen // { // return mesh->GetParallelTopology().Glob2Loc_Vert(globnum+1) -1; // } - +} + + using namespace netgen; int NgPar_GetLoc2Glob_VolEl ( int locnum ) { @@ -152,6 +153,6 @@ namespace netgen return mesh -> GetParallelTopology().IsGhostEdge ( edgenum+1); } -} + #endif