cgma
TDParallel.cpp
Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include "TDParallel.hpp"
00003 #include "DLIList.hpp"
00004 #include "ToolDataUser.hpp"
00005 #include "CubitAttribUser.hpp"
00006 #include "CubitAttrib.hpp"
00007 #include "RefEntity.hpp"
00008 #include "TopologyEntity.hpp"
00009 #include "CastTo.hpp"
00010 #include "Body.hpp"
00011 #include "TDUniqueId.hpp"
00012 #include "CADefines.hpp"
00013 #include "CubitMessage.hpp"
00014 
00015 #include <stdio.h>
00016 #include <time.h>
00017 
00018 TDParallel::TDParallel(ToolDataUser *owner, DLIList<int> *shared_bodies,
00019                DLIList<int> *shared_procs, DLIList<int> *ghost_procs,
00020                        int unique_id, int interface)
00021   : m_uniqueId(unique_id), m_interface(interface)
00022 {
00023   ownerEntity = owner;
00024 
00025   // shared bodies
00026   if (shared_bodies == NULL) {
00027     CubitStatus status = set_shared_body_list();
00028     if (CUBIT_SUCCESS != status) {
00029       PRINT_ERROR("Failed to set shared body list.\n");
00030     }
00031   }
00032   else {
00033     int size = shared_bodies->size();
00034     shared_bodies->reset();
00035     m_sharedBodyList.clean_out();
00036     for (int i = 0; i < size; i++) {
00037       m_sharedBodyList.append(shared_bodies->get_and_step());
00038     }
00039   }
00040 
00041   if (shared_procs != NULL) {
00042     int shared_size = shared_procs->size();
00043     shared_procs->reset();
00044     m_sharedProcList.clean_out();
00045     for (int i = 0; i < shared_size; i++) {
00046       m_sharedProcList.append(shared_procs->get_and_step());
00047     }
00048   }
00049 
00050   if (ghost_procs != NULL) {
00051     int ghost_size = ghost_procs->size();
00052     ghost_procs->reset();
00053     m_ghostProcList.clean_out();
00054     for (int i = 0; i < ghost_size; i++) {
00055       m_ghostProcList.append(ghost_procs->get_and_step());
00056     }
00057   }
00058 
00059   //set_local_non_local_body_list();
00060   ownerEntity->add_TD(this);
00061   
00062     // update the attribute if this is a CAU
00063   CubitAttribUser *cau = CAST_TO(owner, CubitAttribUser);
00064   
00065   if (cau) {
00066     CubitAttrib *attrib = cau->get_cubit_attrib(CA_BODIES);
00067     attrib->has_updated(CUBIT_FALSE);
00068     attrib->update();
00069   }
00070 }
00071 
00072 int TDParallel::is_parallel(const ToolData* td)
00073 {
00074   return (CAST_TO(const_cast<ToolData*>(td), TDParallel) != NULL);
00075 }
00076 
00077 TDParallel::~TDParallel()
00078 {
00079 }
00080 
00081 DLIList<int>* TDParallel::get_shared_body_list()
00082 {
00083   return &m_sharedBodyList;
00084 }
00085 
00086 CubitStatus TDParallel::set_shared_body_list()
00087 {  
00088   // get the bodies containing ownerEntity
00089   Body *body;
00090   DLIList<Body*> body_list;
00091   int i;
00092 
00093   CubitStatus result = (dynamic_cast<TopologyEntity*> (ownerEntity))->bodies(body_list);
00094   if (CUBIT_SUCCESS != result) return result;
00095 
00096   // write the data for the bodies to this TD
00097   for(i = body_list.size(); i > 0; i--)
00098   {
00099     // get the body which gets assigned to this TDParallel
00100     body = body_list.get_and_step();
00101 
00102     // append to this TDParallel the id of the body;
00103     m_sharedBodyList.append(TDUniqueId::get_unique_id(body));
00104   }
00105 
00106   return CUBIT_SUCCESS;
00107 }
00108 
00109 void TDParallel::set_shared_proc_list(DLIList<int> list)
00110 {
00111   m_sharedProcList.clean_out();
00112   list.reset();
00113   for (int i = list.size(); i > 0; i--) {
00114     m_sharedProcList.append(list.get_and_step());
00115   }
00116 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines