[cig-commits] r19484 - short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology

brad at geodynamics.org brad at geodynamics.org
Thu Jan 26 16:23:13 PST 2012


Author: brad
Date: 2012-01-26 16:23:13 -0800 (Thu, 26 Jan 2012)
New Revision: 19484

Modified:
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/MeshRefiner.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineEdges2.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineUniform.cc
   short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/ReverseCuthillMcKee.cc
Log:
Added some more consistency tests for the overlap and refinement.

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/MeshRefiner.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/MeshRefiner.cc	2012-01-26 18:25:18 UTC (rev 19483)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/MeshRefiner.cc	2012-01-27 00:23:13 UTC (rev 19484)
@@ -22,6 +22,8 @@
 
 #include "MeshOrder.hh" // USES MeshOrder
 
+#include "pylith/utils/petscerror.h" // USES CHECK_PETSC_ERROR
+
 #include <cassert> // USES assert()
 
 // ----------------------------------------------------------------------
@@ -705,10 +707,12 @@
       
       if (localPoint >= oldVerticesStartNormal && localPoint < oldVerticesStartFault) {
         assert(remotePoint >= oldVerticesStartNormalP[rank] && remotePoint < oldVerticesStartFaultP[rank]);
+	assert(remotePoint+remoteOffsetNormal >= 0);
         newSendOverlap->addArrow(localPoint+localOffsetNormal, rank, remotePoint+remoteOffsetNormal);
       } else {
         assert(localPoint  >= oldVerticesStartFault);
         assert(remotePoint >= oldVerticesStartFaultP[rank]);
+	assert(remotePoint+remoteOffsetFault >= 0);
         newSendOverlap->addArrow(localPoint+localOffsetFault,  rank, remotePoint+remoteOffsetFault);
       }
     } // for
@@ -752,10 +756,12 @@
 
       if (localPoint >= oldVerticesStartNormal && localPoint < oldVerticesStartFault) {
         assert(remotePoint >= oldVerticesStartNormalP[rank] && remotePoint < oldVerticesStartFaultP[rank]);
+	assert(remotePoint+remoteOffsetNormal >= 0);
         newSendOverlap->addArrow(localPoint+localOffsetNormal, rank, remotePoint+remoteOffsetNormal);
       } else {
         assert(localPoint  >= oldVerticesStartFault);
         assert(remotePoint >= oldVerticesStartFaultP[rank]);
+	assert(remotePoint+remoteOffsetFault >= 0);
         newSendOverlap->addArrow(localPoint+localOffsetFault,  rank, remotePoint+remoteOffsetFault);
       }
     }
@@ -799,32 +805,40 @@
 
   // Verify size of new send/recv overlaps are at least as big as the
   // original ones.
+  PetscErrorCode err = 0;
   if (newSendOverlap->getNumRanks() != sendOverlap->getNumRanks() ||
       newRecvOverlap->getNumRanks() != recvOverlap->getNumRanks() ||
       newSendOverlap->getNumRanks() != newRecvOverlap->getNumRanks()) {
     
-    std::cerr << "DEBUGGING INFO"
-	      << ", newSendOverlap: " << newSendOverlap->getNumRanks()
-	      << ", sendOverlap: " << sendOverlap->getNumRanks()
-	      << ", newRecvOverlap: " << newRecvOverlap->getNumRanks()
-	      << ", recvOverlap: " << recvOverlap->getNumRanks()
-	      << std::endl;
     throw std::logic_error("Error in constructing new overlaps during mesh "
 			   "refinement.\nMismatch in number of ranks.");
   } // if
 
   const int numRanks = newSendOverlap->getNumRanks();
   for (int isend=0; isend < numRanks; ++isend) {
-    const int rank = newSendOverlap->getRank(isend);
-    const int irecv = newRecvOverlap->getRankIndex(rank);
-    if (rank != sendOverlap->getRank(isend) ||
-	rank != recvOverlap->getRank(irecv)) {
+    int rank = 0;
+    err = newSendOverlap->getRank(isend, &rank); CHECK_PETSC_ERROR(err);
+    int irecv = 0;
+    err = newRecvOverlap->getRankIndex(rank, &irecv);
+
+    int sendRank = 0;
+    int recvRank = 0;
+    err = sendOverlap->getRank(isend, &sendRank); CHECK_PETSC_ERROR(err);
+    err = recvOverlap->getRank(irecv, &recvRank); CHECK_PETSC_ERROR(err);
+    if (rank != sendRank || rank != recvRank) {
       throw std::logic_error("Error in constructing new overlaps during mesh "
 			     "refinement.\nMismatch in ranks.");
     } // if
   
-    if (newSendOverlap->getNumPointsByRank(rank) < sendOverlap->getNumPointsByRank(rank) ||
-	newRecvOverlap->getNumPointsByRank(rank) < sendOverlap->getNumPointsByRank(rank)) {
+    int newSendNumPoints = 0;
+    int oldSendNumPoints = 0;
+    int newRecvNumPoints = 0;
+    int oldRecvNumPoints = 0;
+    err = sendOverlap->getNumPointsByRank(rank, &oldSendNumPoints); CHECK_PETSC_ERROR(err);
+    err = newSendOverlap->getNumPointsByRank(rank, &newSendNumPoints); CHECK_PETSC_ERROR(err);
+    err = recvOverlap->getNumPointsByRank(rank, &oldRecvNumPoints); CHECK_PETSC_ERROR(err);
+    err = newRecvOverlap->getNumPointsByRank(rank, &newRecvNumPoints); CHECK_PETSC_ERROR(err);
+    if (newSendNumPoints < oldSendNumPoints || newRecvNumPoints < oldRecvNumPoints) {
       throw std::logic_error("Error in constructing new overlaps during mesh "
 			     "refinement.\nInvalid size for new overlaps.");
     } // if
@@ -835,6 +849,32 @@
   recvOverlap->view("OLD RECV OVERLAP");
   newSendOverlap->view("NEW SEND OVERLAP");
   newRecvOverlap->view("NEW RECV OVERLAP");
+
+  int rank = 0;
+  int nprocs = 0;
+  MPI_Comm_rank(mesh->comm(), &rank);
+  MPI_Comm_size(mesh->comm(), &nprocs);
+  MPI_Barrier(mesh->comm());
+  for (int i=0; i < nprocs; ++i) {
+    if (rank == i) {
+      int numNeighbors = newSendOverlap->getNumRanks();
+      assert(numNeighbors == newRecvOverlap->getNumRanks());
+      for (int j=0; j < numNeighbors; ++j) {
+	int sendRank = 0;
+	int recvRank = 0;
+	err = newSendOverlap->getRank(j, &sendRank);CHECK_PETSC_ERROR(err);
+	err = newRecvOverlap->getRank(j, &recvRank);CHECK_PETSC_ERROR(err);
+	std::cout << "["<<rank<<"]: "
+		  << "send: " << sendRank
+		  << ", npts: " << newSendOverlap->getNumPoints(j)
+		  << "; recv: " << recvRank
+		  << ", npts: " << newRecvOverlap->getNumPoints(j)
+		  << std::endl;
+      } // for
+    } // if
+    MPI_Barrier(mesh->comm());
+  } // for
+  
 #endif
 } // _calcNewOverlap
 

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineEdges2.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineEdges2.cc	2012-01-26 18:25:18 UTC (rev 19483)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineEdges2.cc	2012-01-27 00:23:13 UTC (rev 19484)
@@ -197,7 +197,7 @@
       std::set_intersection(leftRanks.begin(), leftRanks.end(), rightRanks.begin(), rightRanks.end(),
                             std::insert_iterator<std::set<int> >(ranks, ranks.begin()));
 
-#if 0
+#if 0 // DEBUGGING
       std::cout << "[" << myrank << "]   Checking edge " << e_iter->first << std::endl;
       for(std::set<int>::const_iterator r_iter = leftRanks.begin(); r_iter != leftRanks.end(); ++r_iter) {
         std::cout << "[" << myrank << "]     left rank " << *r_iter << std::endl;
@@ -212,7 +212,11 @@
         newVerticesSection->addFiberDimension(edgeMin+localMinOffset, 1);
         for(std::set<int>::const_iterator r_iter = ranks.begin(); r_iter != ranks.end(); ++r_iter) {
           bndryEdgeToRank[e_iter->first].push_back(*r_iter);
-          //std::cout << "[" << myrank << "] Added edge " << e_iter->first << " with rank " << *r_iter << std::endl;
+#if 0 // DEBUGGING
+	  const point_type edgeMax = std::max(e_iter->first.first, e_iter->first.second);
+	  const int localMaxOffset = (orderOldMesh.verticesNormal().hasPoint(edgeMax)) ? localNormalOffset : localCensoredOffset;
+          std::cout << "[" << myrank << "] Added edge " << e_iter->first << " now (" << edgeMin+localMinOffset << ", " << edgeMax+localMaxOffset << ") with rank " << *r_iter << std::endl;
+#endif
         } // for
       } // if
     } // if
@@ -245,8 +249,10 @@
   Obj<ALE::Section<overlap_point_type, EdgeType> > overlapVertices = new ALE::Section<overlap_point_type, EdgeType>(oldMesh->comm());
 
   ALE::Pullback::SimpleCopy::copy(newSendOverlap, newRecvOverlap, newVerticesSection, overlapVertices);
-  //newVerticesSection->view("NEW VERTICES");
-  //overlapVertices->view("OVERLAP VERTICES");
+#if 0 // DEBUGGING
+  newVerticesSection->view("NEW VERTICES");
+  overlapVertices->view("OVERLAP VERTICES");
+#endif
 
   // Merge by translating edge to local points, finding edge in _edgeToVertex, and adding (local new vetex, remote new vertex) to overlap
   for(std::map<EdgeType, std::vector<int> >::const_iterator e_iter = bndryEdgeToRank.begin(); e_iter != bndryEdgeToRank.end(); ++e_iter) {
@@ -284,9 +290,10 @@
           break;
         } // if
       } // for
-#if 0
+#if 0 // DEBUGGING
       if (-1 == newRemotePoint) {
-        std::cout << "remoteLeft: " << remoteLeft
+        std::cout << "["<< myrank << "] DISMISSING newLocalPoint: " << newLocalPoint
+		  << ", remoteLeft: " << remoteLeft
                   << ", remoteRight: " << remoteRight
                   << ", rank: " << rank
                   << ", remoteSize: " << remoteSize

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineUniform.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineUniform.cc	2012-01-26 18:25:18 UTC (rev 19483)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/RefineUniform.cc	2012-01-27 00:23:13 UTC (rev 19484)
@@ -119,6 +119,7 @@
     break;
 
   default :
+    assert(0);
     throw std::logic_error("Unknown dimension.");
   } // switch
 

Modified: short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/ReverseCuthillMcKee.cc
===================================================================
--- short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/ReverseCuthillMcKee.cc	2012-01-26 18:25:18 UTC (rev 19483)
+++ short/3D/PyLith/branches/v1.6-stable/libsrc/pylith/topology/ReverseCuthillMcKee.cc	2012-01-27 00:23:13 UTC (rev 19484)
@@ -33,7 +33,7 @@
 void
 pylith::topology::ReverseCuthillMcKee::reorder(topology::Mesh* mesh)
 { // reorder
-  assert(0 != mesh);
+  assert(mesh);
 
   ALE::MemoryLogger& logger = ALE::MemoryLogger::singleton();
   //logger.setDebug(1);



More information about the CIG-COMMITS mailing list