cgma
CGMMemFile.hpp
Go to the documentation of this file.
00001 //
00002 // class CGMMemFile
00003 //
00004 // This class mimics the  MemFile construct, but for general CGM
00005 // entities.  This class supports the saving and restoring of entities
00006 // to/from memory buffers, and the passing of these memory buffers to
00007 // processors using mpi.
00008 //
00009 
00010 #ifndef CGMMEMFILE
00011 #define CGMMEMFILE
00012 //#include <vector>
00013 #include "CubitDefines.h"
00014 #include "DLIList.hpp"
00015 
00016 class RefEntity;
00017 
00018 class CGMMemFile 
00019 {
00020 public:
00021   CGMMemFile(void* buffer = NULL,
00022              size_t bufSize = 0);
00023     //- constructor, with optional buffer passed in; if buffer is passed in, it
00024     //- will be used for the writing operation; if NULL, the next writing operation
00025     //- will create a buffer of the right size.  NOTE: buffer is deleted in the
00026     //- destructor, even if it was passed in
00027 
00028   virtual ~CGMMemFile();
00029     //- destructor; deletes m_pBuffer
00030   
00031   CubitStatus bcast_entity_list(DLIList<RefEntity*> &ref_entity_list);
00032     //- broadcasts the entity list; root takes list as input, 
00033     //- others write as output; uses read_refentity_list and write_refentity_list
00034     //- functions
00035   
00036   CubitStatus bcast_and_delete_entity_list(DLIList<RefEntity*> &ref_entity_list,
00037                        DLIList<RefEntity*> &ref_entity_list_master);
00038   //- broadcasts the entity list; delete the rest that this processor doesn't need
00039 
00040   //CubitStatus send_body_to_procs(DLIList<RefEntity*> &ref_entity_list);
00041 
00042   //CubitStatus send_body_to_procs_balanced(DLIList<RefEntity*> &ref_entity_list);
00043 
00044   //CubitStatus vol_balace_send_body_processors(DLIList<RefEntity*> &ref_entity_list);
00045   
00046   CubitStatus scatter_entity_list(DLIList<RefEntity*> &ref_entity_list);
00047   //- scatter the exact amount of entity that each processors need;
00048   
00049   CubitStatus scatter_balanced_entity_list(DLIList<RefEntity*> &ref_entity_list,
00050                        DLIList<RefEntity*> &ref_entity_list_master,
00051                        DLIList<RefEntity*> **balanced_lists);
00052   
00053   CubitStatus scatter_test(DLIList<RefEntity*> &ref_entity_list);
00054   
00055   //static int *get_body_to_proc();
00056   static DLIList <int> *get_body_to_proc();
00057   //static std::vector<int> *get_body_to_proc();
00058 
00059   //static std::vector<int> get_num_body_to_proc();
00060 
00061 
00062 protected:
00063   //int balanceSurf;
00064   //- load balance surfaces
00065 
00066   //double *totalLoads;
00067 
00068   //DLIList<RefEntity*> **balancedLists;
00069 
00070   unsigned char *m_pBuffer;
00071     //- the memory buffer
00072 
00073   size_t m_sizeBuffer;
00074     //- the size of the buffer in bytes
00075   
00076   unsigned long m_currentPosition;
00077     //- the current position in the buffer
00078 
00079   static DLIList <int> bodyToProc;
00080     //static std::vector<int> bodyToProc;
00081     //- body to processor assignment vector
00082 
00083   //static int *bodyToProc;
00084 
00085   //static int nBodyToProc;
00086 
00087   //static DLIList <int> *bodyToProcPtr;
00088     //- body to processor assignment vector pointer
00089 
00090   virtual CubitStatus read_refentity_list(DLIList<RefEntity*> &ref_entity_list) = 0;
00091     //- read a RefEntity list from the buffer into ref_entity_list; relies on engine-
00092     //- specific implementation
00093 
00094   virtual CubitStatus write_refentity_list(DLIList<RefEntity*> &ref_entity_list) = 0;
00095     //- write a RefEntity list to the buffer from ref_entity_list; relies on engine-
00096     //- specific implementation
00097   
00098   virtual CubitStatus append_refentity_list(DLIList<RefEntity*> &ref_entity_list,
00099                                             int &buffer_size) = 0;
00100 
00101   virtual CubitStatus get_refentity_list(DLIList<RefEntity*> &ref_entity_list) = 0;
00102 
00103   virtual int get_refentity_list_size(DLIList<RefEntity*> ref_entity_list) = 0;
00104   //- get the size of the requested entity list in the buffer
00105 
00106   CubitStatus bcast_buffer();
00107     //- broadcasts the buffer contained in this object; uses ProcData singleton class
00108 
00109   CubitStatus check_size(int &target_size, CubitBoolean keep = CUBIT_FALSE);
00110     //- check the size of the buffer and, if necessary, expand it
00111 };
00112 
00113 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines