[cgma-dev] r3269 - in cgm/trunk: geom/parallel itaps

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Tue Nov 3 10:05:08 CST 2009


Author: kraftche
Date: 2009-11-03 10:05:07 -0600 (Tue, 03 Nov 2009)
New Revision: 3269

Modified:
   cgm/trunk/geom/parallel/CGMParallelComm.cpp
   cgm/trunk/geom/parallel/CGMParallelComm.hpp
   cgm/trunk/geom/parallel/ParallelGeomTool.cpp
   cgm/trunk/geom/parallel/ParallelGeomTool.hpp
   cgm/trunk/itaps/CATag.hpp
Log:
o Move vector of CGMParallelComm instances from member of CGMTagManager
  to static member of CGMParallelComm

o Remove all dependencies on CGMTagManager from geom/parallel code

o Remove some unnecessary #includes and unused definitions



Modified: cgm/trunk/geom/parallel/CGMParallelComm.cpp
===================================================================
--- cgm/trunk/geom/parallel/CGMParallelComm.cpp	2009-11-03 16:03:06 UTC (rev 3268)
+++ cgm/trunk/geom/parallel/CGMParallelComm.cpp	2009-11-03 16:05:07 UTC (rev 3269)
@@ -1,18 +1,11 @@
 #include "CGMParallelComm.hpp"
-//#include "CubitAttrib.hpp"
-//#include "OCCQueryEngine.hpp"
 #include "TopologyEntity.hpp"
 #include "GeometryQueryEngine.hpp"
 #include "RefEntity.hpp"
+#include "GeometryQueryTool.hpp"
 
-//#include <iostream>
-#include <sstream>
-#include <algoritm>
+#include <algorithm>
 
-#ifdef USE_MPI
-#include "CGMmpi.h"
-#endif
-
 #define INITIAL_BUFF_SIZE 1024
 #define RRA(a) if (CUBIT_SUCCESS != result) {	\
     std::string tmp_str;			\
@@ -20,9 +13,10 @@
     PRINT_ERROR(tmp_str.c_str());		\
     return result;}
 
-CGMParallelComm::CGMParallelComm(CGMTagManager *impl,
-				 MPI_Comm comm, int* id )
-  : cgmImpl(impl), procConfig(comm)
+std::vector<CGMParallelComm*> CGMParallelComm::instanceList;
+
+CGMParallelComm::CGMParallelComm(MPI_Comm comm, int* id )
+  : procConfig(comm)
 {
   myBuffer.resize(INITIAL_BUFF_SIZE);
   
@@ -45,11 +39,10 @@
   m_currentPosition = 0;
 }
 
-CGMParallelComm::CGMParallelComm(CGMTagManager *impl,
-				 std::vector<unsigned char> &tmp_buff, 
+CGMParallelComm::CGMParallelComm(std::vector<unsigned char> &tmp_buff, 
 				 MPI_Comm comm,
 				 int* id) 
-  : cgmImpl(impl), procConfig(comm)
+  : procConfig(comm)
 {
   myBuffer.swap(tmp_buff);
   int flag = 1;
@@ -79,48 +72,34 @@
 
 int CGMParallelComm::add_pcomm(CGMParallelComm *pc) 
 {
-  // add this pcomm to instance tag
-  std::vector<CGMParallelComm *> pc_array;
-  pc_array = cgmImpl->get_pc_array();
-  pc_array.push_back(pc);
-
-  return pc_array.size() - 1;
+  instanceList.push_back(pc);
+  return instanceList.size() - 1;
 }
 
 void CGMParallelComm::remove_pcomm(CGMParallelComm *pc) 
 {
-  // remove this pcomm from instance tag
-  std::vector<CGMParallelComm *> pc_array;
-  pc_array = cgmImpl->get_pc_array();
-
   std::vector<CGMParallelComm*>::iterator pc_it = 
-    std::find(pc_array.begin(), pc_array.end(), pc);
-  assert(pc_it != pc_array.end());
-  pc_array.erase(pc_it);
+    std::find(instanceList.begin(), instanceList.end(), pc);
+  assert(pc_it != instanceList.end());
+  instanceList.erase(pc_it);
 }
 
 //! get the indexed pcomm object from the interface
-CGMParallelComm *CGMParallelComm::get_pcomm(CGMTagManager *impl,
-					    const int index) 
+CGMParallelComm *CGMParallelComm::get_pcomm(const int index) 
 {  
-  std::vector<CGMParallelComm *> pc_array;
-  pc_array = impl->get_pc_array();
-
-  if (pc_array.size() < (unsigned int) (index + 1)) return NULL;
-  else return pc_array[index];
+  if (instanceList.size() < (unsigned int) (index + 1)) return NULL;
+  else return instanceList[index];
 }
 
-CubitStatus CGMParallelComm::get_all_pcomm(CGMTagManager *impl,
-					   std::vector<CGMParallelComm*>& list )
+CubitStatus CGMParallelComm::get_all_pcomm(std::vector<CGMParallelComm*>& list )
 {
-  list = impl->get_pc_array();
+  list = instanceList;
   return CUBIT_SUCCESS;
 }
   
 
 //! get the indexed pcomm object from the interface
-CGMParallelComm *CGMParallelComm::get_pcomm(CGMTagManager *impl,
-					    //MBEntityHandle prtn,
+CGMParallelComm *CGMParallelComm::get_pcomm(//MBEntityHandle prtn,
 					    const MPI_Comm* comm ) 
 {
   //MBErrorCode rval;
@@ -139,8 +118,7 @@
   int pcomm_id;
   //rval = impl->tag_get_data( prtn_tag, &prtn, 1, &pcomm_id );
   //if (MB_SUCCESS == rval) {
-    result= get_pcomm(impl, 
-		      pcomm_id );
+    result= get_pcomm( pcomm_id );
     //}
     /*
   else if (MB_TAG_NOT_FOUND == rval && comm) {

Modified: cgm/trunk/geom/parallel/CGMParallelComm.hpp
===================================================================
--- cgm/trunk/geom/parallel/CGMParallelComm.hpp	2009-11-03 16:03:06 UTC (rev 3268)
+++ cgm/trunk/geom/parallel/CGMParallelComm.hpp	2009-11-03 16:05:07 UTC (rev 3269)
@@ -10,41 +10,24 @@
 #ifndef CGM_PARALLEL_COMM_HPP
 #define CGM_PARALLEL_COMM_HPP
 
-//#include "CGMForward.hpp"
-#include "GeometryQueryTool.hpp"
-//#include "CGMRange.hpp"
 #include "CGMProcConfig.hpp"
-#include "CATag.hpp"
-#include <map>
-#include <set>
-#include <vector>
-#include "math.h"
 #include "CGMmpi.h"
+#include "DLIList.hpp"
+#include <vector>
 
+class GeometryQueryTool;
+class RefEntity;
 
-extern "C" {
-  struct tuple_list;
-}
-
-//class TagServer;
-//class SequenceManager;
-//template <typename KeyType, typename ValType, ValType NullVal> class RangeMap;
-//typedef RangeMap<CGMEntityHandle, CGMEntityHandle, 0> HandleMap;
-
-#define MAX_SHARING_PROCS 64
-
 class CGMParallelComm 
 {
 public:
 
     //! constructor
-  CGMParallelComm(CGMTagManager *impl,
-		  MPI_Comm comm = MPI_COMM_WORLD,
+  CGMParallelComm(MPI_Comm comm = MPI_COMM_WORLD,
 		  int* pcomm_id_out = 0);
   
   //! constructor taking buffer, for testing
-  CGMParallelComm(CGMTagManager *impl,
-		  std::vector<unsigned char> &tmp_buff,
+  CGMParallelComm(std::vector<unsigned char> &tmp_buff,
 		  MPI_Comm comm = MPI_COMM_WORLD,
 		  int* pcomm_id_out = 0);
   
@@ -52,18 +35,15 @@
   int get_id() const { return pcommID; }
 
     //! get the indexed pcomm object from the interface
-  static CGMParallelComm *get_pcomm(CGMTagManager *impl,
-				    const int index);
+  static CGMParallelComm *get_pcomm(const int index);
   
     //! Get CGMParallelComm instance associated with partition handle
     //! Will create CGMParallelComm instance if a) one does not already
     //! exist and b) a valid value for MPI_Comm is passed.
-  static CGMParallelComm *get_pcomm(CGMTagManager *impl,
-                                    //CGMEntityHandle partitioning,
+  static CGMParallelComm *get_pcomm(//CGMEntityHandle partitioning,
                                     const MPI_Comm* comm = 0 );
 
-  static CubitStatus get_all_pcomm(CGMTagManager *impl,
-				   std::vector<CGMParallelComm*>& list );
+  static CubitStatus get_all_pcomm(std::vector<CGMParallelComm*>& list );
   
   //! destructor
   ~CGMParallelComm();
@@ -129,30 +109,22 @@
   
 private:  
 
+  static std::vector<CGMParallelComm*> instanceList;
+
     //! add a pc to the iface instance tag PARALLEL_COMM
-  int add_pcomm(CGMParallelComm *pc);
+  static int add_pcomm(CGMParallelComm *pc);
   
     //! remove a pc from the iface instance tag PARALLEL_COMM
-  void remove_pcomm(CGMParallelComm *pc);
+  static void remove_pcomm(CGMParallelComm *pc);
 
   CubitStatus check_size(int& target_size, const CubitBoolean keep = CUBIT_FALSE);
   
     //! CGM query tool interface associated with this writer
   GeometryQueryTool *gqt;
 
-    //! CGM tag manager interface associated with this writer
-  CGMTagManager *cgmImpl;
-
     //! Proc config object, keeps info on parallel stuff
   CGMProcConfig procConfig;
-
-    //! Tag server, so we can get more info about tags
-  //TagServer *tagServer;
-
-    //! Sequence manager, to get more efficient access to entities
-  //SequenceManager *sequenceManager;
   
-  
     //! data buffer used to communicate
   std::vector<unsigned char> myBuffer;
 
@@ -161,32 +133,7 @@
   int m_nBufferSize;
   
   int m_currentPosition;
-
-  //std::ofstream mOfstream;
-
-    //! more data buffers, proc-specific
-  //std::vector<unsigned char> ownerRBuffs[MAX_SHARING_PROCS],
-  //ownerSBuffs[MAX_SHARING_PROCS], ghostRBuffs[MAX_SHARING_PROCS],
-  // ghostSBuffs[MAX_SHARING_PROCS];
-
-    //! request objects, may be used if store_remote_handles is used
-  //MPI_Request sendReqs[2*MAX_SHARING_PROCS];
-
-    //! processor rank for each buffer index
-  //std::vector<int> buffProcs;
-
-    //! the partition, interface sets for this comm'n instance
-  //CGMRange partitionSets, interfaceSets;
   
-    //! local entities ghosted to other procs
-  //std::map<unsigned int, CGMRange> ghostedEnts;
-  
-    //! tags used to save sharing procs and handles
-  //CGMTag sharedpTag, sharedpsTag, sharedhTag, sharedhsTag, pstatusTag, 
-  //ifaceSetsTag, partitionTag;
-    
-  //int globalPartCount; //!< Cache of global part count
-  
   //CGMEntityHandle partitioningSet; //!< entity set containing all parts
   DLIList<RefEntity*> partitioningSurfList; // ref entity list containing all parts
   DLIList<RefEntity*> partitioningBodyList; // ref entity list containing all parts

Modified: cgm/trunk/geom/parallel/ParallelGeomTool.cpp
===================================================================
--- cgm/trunk/geom/parallel/ParallelGeomTool.cpp	2009-11-03 16:03:06 UTC (rev 3268)
+++ cgm/trunk/geom/parallel/ParallelGeomTool.cpp	2009-11-03 16:05:07 UTC (rev 3269)
@@ -12,7 +12,6 @@
 #include "GeometryQueryTool.hpp"
 #include "ParallelGeomTool.hpp"
 #include "CGMParallelConventions.h"
-#include "CATag.hpp"
 #include "CGMParallelComm.hpp"
 
 const bool debug = true;
@@ -45,12 +44,12 @@
 
 //ParallelGeomTool *ParallelGeomTool::instance_ = NULL;
 
-ParallelGeomTool::ParallelGeomTool(CGMTagManager* impl, CGMParallelComm *pc)
-  : cgmImpl(impl), myPcomm(pc) 
+ParallelGeomTool::ParallelGeomTool(CGMParallelComm *pc)
+  : myPcomm(pc) 
 {
   if (!myPcomm) {
-    myPcomm = CGMParallelComm::get_pcomm(impl, 0);
-    if (NULL == myPcomm) myPcomm = new CGMParallelComm(cgmImpl);
+    myPcomm = CGMParallelComm::get_pcomm(0);
+    if (NULL == myPcomm) myPcomm = new CGMParallelComm();
   }
   //gqt = GeometryQueryTool::instfance();
 }

Modified: cgm/trunk/geom/parallel/ParallelGeomTool.hpp
===================================================================
--- cgm/trunk/geom/parallel/ParallelGeomTool.hpp	2009-11-03 16:03:06 UTC (rev 3268)
+++ cgm/trunk/geom/parallel/ParallelGeomTool.hpp	2009-11-03 16:05:07 UTC (rev 3269)
@@ -4,19 +4,13 @@
 #include <vector>
 #include "CubitDefines.h"
 #include "CGMParallelComm.hpp"
-//#include "ProcData.hpp"
 #include "FileOptions.hpp"
-//#include "CATag.hpp"
-//#include "CGMParallelComm.hpp"
 
-//class CGMTagManager;
-//class CGMParallelComm;
-
 class ParallelGeomTool 
 {
 public:
 
-  ParallelGeomTool(CGMTagManager* impl = NULL, CGMParallelComm *pc = NULL);
+  ParallelGeomTool(CGMParallelComm *pc = NULL);
 
   //static ParallelGeomTool *instance();
 
@@ -70,8 +64,6 @@
 
   //static ParallelGeomTool *instance_;
 
-  CGMTagManager *cgmImpl;
-
   // each reader can keep track of its own pcomm
   CGMParallelComm *myPcomm;
 

Modified: cgm/trunk/itaps/CATag.hpp
===================================================================
--- cgm/trunk/itaps/CATag.hpp	2009-11-03 16:03:06 UTC (rev 3268)
+++ cgm/trunk/itaps/CATag.hpp	2009-11-03 16:05:07 UTC (rev 3269)
@@ -42,7 +42,6 @@
 class RefEntity;
 class RefGroup;
 class CATag;
-class CGMParallelComm;
 
 class CGMTagManager 
 {
@@ -117,8 +116,6 @@
     return static_instance;
   }
 
-  inline std::vector<CGMParallelComm*>& get_pc_array() { return pc_array; }
-
 private:
   CGMTagManager();
 
@@ -132,9 +129,6 @@
   static const char *CATag_NAME_INTERNAL;
   RefGroup *interfaceGroup;
 
-  // list of parallel comm
-  std::vector<CGMParallelComm*> pc_array;
-
   bool getPresetTagData(const RefEntity *entity, const long tag_num, 
                         char *tag_value, int &tag_size);
 



More information about the cgma-dev mailing list