00001 #ifndef TRANSFERER_DATA_HPP_
00002 #define TRANSFERER_DATA_HPP_
00003
00004 #include <vector>
00005 #include <map>
00006
00007 #include "EntitiesOwnership.hpp"
00008
00009
00010 namespace mmpt{
00011
00012 enum TRANSFER_POLICY {
00013 TRANSFER_MOVE,
00014 TRANSFER_COPY,
00015 TRANSFER_MOVE_RR
00016 };
00017
00018
00021
00024
00025 struct TransferElement {
00026 int type;
00027 int vertices[MMC_MAXELVNO];
00028 int BCs[MMC_MAXELFAC];
00029 int id_at_prev_owner;
00030 int groupID;
00031
00032 TransferElement() ;
00033 TransferElement(const int t,const int *v,const int* bc,const int old_id, const int gID)
00034 : type(t), id_at_prev_owner(old_id), groupID(gID)
00035 {
00036 if(type == MMC_PRISM) {
00037 memcpy(vertices,v,sizeof(int) * MMC_MAXELVNO);
00038 memcpy(BCs,bc,sizeof(int)* MMC_MAXELFAC);
00039 }
00040 else {
00041 memcpy(vertices,v,sizeof(int) * 4);
00042 memcpy(BCs,bc,sizeof(int)* 4);
00043 }
00044 }
00045 };
00046
00047
00048
00049
00050
00051
00052
00057 class TransferOrder
00058 {
00059
00060 static const int n_ints_to_serialize_empty=4;
00061 public:
00062 TransferOrder() : Source_id(-1),Destination_id(-1),t_policy(TRANSFER_COPY)
00063 {}
00064 TransferOrder(const TransferOrder& o)
00065 : Source_id(o.Source_id),Destination_id(o.Destination_id),
00066 t_policy(o.t_policy),Elements(o.Elements)
00067 {}
00068 TransferOrder(const int Sourceproc_id, const int Destproc_id,
00069 const TRANSFER_POLICY Policy,
00070 const int* elements = NULL, const int n_elements=0);
00071
00072
00073 int Source_id,Destination_id;
00074 TRANSFER_POLICY t_policy;
00075 std::vector<int> Elements;
00076
00078 int n_ints_to_serialize() const {
00079 return n_ints_to_serialize_empty+Elements.size();
00080 }
00081
00083 int* serialize(int * buffer) const {
00084 buffer[0] = Source_id;
00085 buffer[1] = Destination_id;
00086 buffer[2] = t_policy;
00087 buffer[3] = Elements.size();
00088 memcpy(buffer+n_ints_to_serialize_empty, Elements.data(), Elements.size() * sizeof(int) );
00089 return buffer+n_ints_to_serialize();
00090 }
00091
00093 int* deserialize(int * buffer) {
00094 Source_id = buffer[0];
00095 Destination_id = buffer[1];
00096 t_policy = static_cast<TRANSFER_POLICY>(buffer[2]);
00097 Elements.resize(buffer[3]);
00098 memcpy(Elements.data(), buffer+n_ints_to_serialize_empty, Elements.size() * sizeof(int) );
00099 return buffer+n_ints_to_serialize();
00100 }
00101
00102 std::vector<TransferOrder> relative_transfer_orders;
00103 };
00104
00105
00106 bool operator==(const TransferOrder& first, const TransferOrder& second);
00107
00108 enum FaceSubdomainSide {
00109 FaceSide0=0,
00110 FaceSide1=1,
00111 FaceSideBoth=2,
00112 FaceSideNone=-1
00113 };
00114
00116 struct TransferResult
00117 {
00118 TransferResult() : wasApplied(false) {}
00119
00120
00121
00122
00123
00124
00125 typedef std::map<int,FaceSubdomainSide> mmpt_faceSideMap;
00126 mmpt_faceSideMap new_sub_bdn_faces;
00127 std::vector<double> new_vertices_coords;
00128 std::vector<int> new_vertices_transfered_ids;
00129 std::vector<TransferElement> new_elems;
00130 mutable bool wasApplied;
00131
00132 std::vector<EntOwn> transfer_vertices_ownerships;
00133 std::vector<int> ownerships2vtx_trans_id;
00134 };
00135
00136 }
00137
00138 #endif // TRANSFERER_DATA_HPP_