|
AFEPack
|
00001 00011 #ifndef __Migration_h__ 00012 #define __Migration_h__ 00013 00014 #include <map> 00015 #include "BinaryBuffer.h" 00016 #include "TemplateElement.h" 00017 00040 namespace Migration { 00041 00042 typedef int data_id_t; 00043 typedef std::string data_name_t; 00044 typedef BinaryBuffer<> data_buffer_t; 00045 00048 typedef std::map<data_id_t, data_buffer_t> buffer_t; 00049 00050 data_id_t name_to_id(const data_name_t& dn); 00051 data_id_t register_data_name(const data_name_t& dn, bool); 00052 void initialize(); 00053 bool is_valid(const data_id_t&); 00054 00055 namespace details { 00068 template <class MESH> BinaryBuffer<>& 00069 get_buffer(MESH& mesh, 00070 const data_id_t& data_id, 00071 u_int dimension, 00072 u_int geo_idx, 00073 bool is_save) { 00074 buffer_t& buffer = mesh.h_geometry(dimension, geo_idx)->buffer; 00075 if (is_save) { 00076 return buffer[data_id]; 00077 } else { 00078 buffer_t::iterator it = buffer.find(data_id); 00079 if (it == buffer.end()) { 00080 return *((BinaryBuffer<> *)NULL); 00081 } 00082 return it->second; 00083 } 00084 } 00085 00086 } 00087 00097 template <class MESH, class STREAM> void 00098 get_export_stream(MESH& mesh, 00099 const data_id_t& data_id, 00100 u_int dimension, 00101 u_int geo_idx, 00102 STREAM& os) { 00103 os.set_buffer(details::get_buffer(mesh, data_id, dimension, geo_idx, true)); 00104 } 00105 00115 template <class MESH, class STREAM> void 00116 get_import_stream(MESH& mesh, 00117 const data_id_t& data_id, 00118 u_int dimension, 00119 u_int geo_idx, 00120 STREAM& is) { 00121 is.set_buffer(details::get_buffer(mesh, data_id, dimension, geo_idx, false)); 00122 } 00123 00133 template <class MESH, class SP, class STREAM> void 00134 get_dof_export_stream(MESH& mesh, 00135 SP& sp, 00136 const data_id_t& data_id, 00137 int dof, 00138 STREAM& os) { 00139 const DOFIndex& di = sp.dofIndex(dof); 00140 get_export_stream(mesh, data_id, di.dimension, di.geometry_index, os); 00141 } 00142 00152 template <class MESH, class SP, class STREAM> void 00153 get_dof_import_stream(MESH& mesh, 00154 SP& sp, 00155 const data_id_t& data_id, 00156 int dof, 00157 STREAM& is) { 00158 const DOFIndex& di = sp.dofIndex(dof); 00159 get_import_stream(mesh, data_id, di.dimension, di.geometry_index, is); 00160 } 00161 00162 } // end of namespace Migration 00163 00164 #endif // __Migration_h__ 00165
1.7.4