00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ELCCODER_H
00014 #define ELCCODER_H
00015 #include "MShell.h"
00016 #include "SVertexFunctors.h"
00017
00018 #include <vector>
00019 #include <map>
00020 #include <algorithm>
00021 #include <functional>
00022 #include <ostream>
00023
00024
00025 namespace shells {
00026 class ELCCoder;
00027 struct ELCContainer;
00028
00029 struct SVertexS;
00030 }
00031
00032
00033 struct shells::ELCContainer {
00034 ELCContainer(){}
00035 ~ELCContainer(){}
00036
00037 typedef std::vector<double> VecDCont;
00038 typedef std::vector<int> VecICont;
00039 typedef std::map<int, int> MapICont;
00040
00041 VecDCont coordinates;
00042 VecDCont velocities;
00043
00044 VecDCont mass;
00045
00046 VecICont connectivity;
00047 VecICont globalNodeIDs;
00048
00049 MapICont globalToLocalIDs;
00050
00051
00052 private:
00053 ELCContainer(const ELCContainer &);
00054 const ELCContainer & operator=(const ELCContainer &);
00055 };
00056
00057
00058
00059 class shells::ELCCoder {
00060 public:
00061 ELCCoder(MShell * const mshell, const unsigned numSurf,
00062 const MShell::ElementType type=shells::MShell::active);
00063 ~ELCCoder();
00064
00065
00066 shells::ELCContainer * decode();
00067
00068
00069 void encodeVertexPressure(std::vector<double>& vertexPressures);
00070 void encodeElementPressure(std::vector<double>& elementPressures);
00071
00072
00073 template <typename VarType, typename Inserter>
00074 void decodeVariable(Inserter ins);
00075
00076 template <typename VarType, typename Iterator>
00077 void encodeVariable(Iterator itb, Iterator ite);
00078
00079
00080 void dumpTecplot(std::ostream& os, double *elementData=NULL, int dataSize=0);
00081
00082 private:
00083 typedef std::vector<shells::SVertexS*> _SVertexCont;
00084 typedef _SVertexCont::const_iterator _SVertexConstIt;
00085 typedef _SVertexCont::iterator _SVertexIt;
00086
00087
00088 ELCContainer *_elb;
00089
00090
00091 _SVertexCont _vertices;
00092
00093
00094 MShell * const _mshell;
00095
00096
00097 const MShell::ElementType _type;
00098
00099
00100 const unsigned _numSurf;
00101
00102
00103 std::vector<double> _dvariables;
00104
00105
00106 private:
00107 void initialize();
00108
00109
00110 private:
00111 class PressureFunctor;
00112 friend class PressureFunctor;
00113 };
00114
00115
00116
00117
00118 template <typename VarType, typename Inserter>
00119 void shells::ELCCoder::decodeVariable(Inserter ins)
00120 {
00121
00122 SVertexCollector<Inserter, VarType> getVariable;
00123 std::for_each(_vertices.begin(), _vertices.end(), std::bind2nd(getVariable, ins));
00124
00125 return;
00126 }
00127
00128
00129 template <typename VarType, typename Iterator>
00130 void shells::ELCCoder::encodeVariable(Iterator itb, Iterator ite)
00131 {
00132
00133 SVertexDistributor<Iterator, VarType> setVariable(itb, ite);
00134 std::for_each(_vertices.begin(), _vertices.end(), setVariable);
00135
00136 return;
00137 }
00138
00139 #endif