00001 #ifndef MMPH_MESH_H_
00002 #define MMPH_MESH_H_
00003
00004 #include <memory>
00005 #include <vector>
00006 #include <set>
00007 #include <map>
00008
00009 #include "mmh_intf.h"
00010 #include "uth_log.h"
00011
00012
00013 #include "fpcm/compressed_mesh.hpp"
00014 #include "EntitiesOwnership.hpp"
00015 #include "mmph_ipid.h"
00016
00017
00018 namespace mmpt {
00019 class Transferer;
00020 class TransferOrder;
00021 class TransferResult;
00022 class TransferWithOwnershipResult;
00023 class CompositeTransferWithOwnershipResult;
00024 }
00025
00026 using namespace mmpt;
00027
00028
00029
00030
00031
00032
00033
00034
00044
00045 struct ApplyChanges {
00046 std::vector<int> vertices_old2newIds,
00047 element_pos2newIds;
00048
00049 std::vector<TransferOrder> transfer_directions;
00050 };
00051
00052
00053 typedef EntitiesOwnership<mmpt_ipid> EntOwnerships;
00054 typedef EntitiesOwnership<mmpt_ipid>::EntOwn EntOwn;
00055
00056 typedef int LID;
00057
00058 typedef fpcm::CompressedMesh::GID GID;
00059
00060
00061 class mmpt_mesh{
00062 static const int N_TYPES = MMC_ALL_N_TYPES+1;
00063 public:
00064
00065 int mesh_id;
00066
00067 Transferer* transferer;
00068
00069 EntOwnerships ownership;
00070
00071
00072
00073 mmpt_mesh() ;
00074
00075 mmpt_mesh(const mmpt_mesh & other) ;
00076
00077 ~mmpt_mesh();
00078
00079 void init();
00080
00081 void clear();
00082
00083 const ApplyChanges& apply(const TransferOrder &o, const TransferResult &r);
00084 const ApplyChanges& apply(const TransferOrder &o, const TransferWithOwnershipResult &r);
00085 const ApplyChanges& apply(const TransferOrder &o, const CompositeTransferWithOwnershipResult &r);
00086
00087 void findContestedExternalVerticesOfElements(const std::vector<int> & element_ids, std::vector<int> & externalVertices) const;
00088 void findContestedVerticesAssigmentToProcs(const std::vector<TransferOrder> &orders,
00089 std::map<int, mmpt_ipid> &contested_vrts_glob_ids) const;
00090
00091 typedef std::set<int> NEIG_SET;
00092 NEIG_SET neighbours;
00093
00094 template<int type>
00095 void GetOffspring( std::vector<EntOwn> & parents,
00096 std::vector<LID> & offspring,
00097 std::vector<GID> & offspring_gids) const ;
00098
00099 template<int type>
00100 void SetOffspring(const std::vector<EntOwn> & parents,
00101 const std::vector<LID> & offspring,
00102 const std::vector<GID> & offspring_gids);
00103
00104
00105 bool check() const;
00106
00107
00108 GID GlobID_Node(const LID Loc_id) const {
00109 double coords[3];
00110 mmr_node_coor(mesh_id,Loc_id,coords);
00111 return glob_ids.encode(coords);
00112 }
00113
00114 private:
00115 std::vector<ApplyChanges*> history;
00116 fpcm::CompressedMesh::CoordMesh glob_ids;
00117
00118 } ;
00119
00120
00121
00122
00123 #endif //MMPH_MESH_H_