[3408] | 1 | #ifndef __XMLIO_CGrid__ |
---|
| 2 | #define __XMLIO_CGrid__ |
---|
| 3 | |
---|
| 4 | /// xios headers /// |
---|
| 5 | #include "xmlioserver_spl.hpp" |
---|
| 6 | #include "group_factory.hpp" |
---|
| 7 | |
---|
| 8 | #include "declare_group.hpp" |
---|
| 9 | #include "domain.hpp" |
---|
| 10 | #include "axis.hpp" |
---|
| 11 | |
---|
| 12 | namespace xios { |
---|
| 13 | |
---|
| 14 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 15 | |
---|
| 16 | class CGridGroup; |
---|
| 17 | class CGridAttributes; |
---|
| 18 | class CGrid; |
---|
| 19 | |
---|
| 20 | ///-------------------------------------------------------------- |
---|
| 21 | |
---|
| 22 | // Declare/Define CGridAttribute |
---|
| 23 | BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
| 24 | # include "grid_attribute.conf" |
---|
| 25 | END_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
| 26 | |
---|
| 27 | ///-------------------------------------------------------------- |
---|
| 28 | |
---|
| 29 | class CGrid |
---|
| 30 | : public CObjectTemplate<CGrid> |
---|
| 31 | , public CGridAttributes |
---|
| 32 | { |
---|
| 33 | /// typedef /// |
---|
| 34 | typedef CObjectTemplate<CGrid> SuperClass; |
---|
| 35 | typedef CGridAttributes SuperClassAttribute; |
---|
| 36 | |
---|
| 37 | public : |
---|
| 38 | |
---|
| 39 | typedef CGridAttributes RelAttributes; |
---|
| 40 | typedef CGridGroup RelGroup; |
---|
| 41 | |
---|
| 42 | enum EEventId |
---|
| 43 | { |
---|
| 44 | EVENT_ID_INDEX |
---|
| 45 | } ; |
---|
| 46 | |
---|
| 47 | /// Constructeurs /// |
---|
| 48 | CGrid(void); |
---|
| 49 | explicit CGrid(const StdString & id); |
---|
| 50 | CGrid(const CGrid & grid); // Not implemented yet. |
---|
| 51 | CGrid(const CGrid * const grid); // Not implemented yet. |
---|
| 52 | |
---|
| 53 | /// Traitements /// |
---|
| 54 | void solveReference(void); |
---|
| 55 | |
---|
| 56 | virtual void toBinary (StdOStream & os) const; |
---|
| 57 | virtual void fromBinary(StdIStream & is); |
---|
| 58 | |
---|
| 59 | /// Tests /// |
---|
| 60 | bool hasAxis(void) const; |
---|
| 61 | |
---|
| 62 | public : |
---|
| 63 | |
---|
| 64 | /// Accesseurs /// |
---|
| 65 | const std::deque<ARRAY(int, 1)> & getStoreIndex(void) const; |
---|
| 66 | const std::deque<ARRAY(int, 1)> & getOutIIndex(void) const; |
---|
| 67 | const std::deque<ARRAY(int, 1)> & getOutJIndex(void) const; |
---|
| 68 | const std::deque<ARRAY(int, 1)> & getOutLIndex(void) const; |
---|
| 69 | |
---|
| 70 | const CAxis* getRelAxis (void) const; |
---|
| 71 | const CDomain* getRelDomain(void) const; |
---|
| 72 | |
---|
| 73 | StdSize getDimension(void) const; |
---|
| 74 | |
---|
| 75 | StdSize getLocalSize(void) const; |
---|
| 76 | StdSize getGlobalSize(void) const; |
---|
| 77 | StdSize getDataSize(void) const; |
---|
| 78 | std::vector<StdSize> getLocalShape(void) const; |
---|
| 79 | std::vector<StdSize> getGlobalShape(void) const; |
---|
| 80 | |
---|
| 81 | /// Entrées-sorties de champs /// |
---|
| 82 | template <StdSize n> |
---|
| 83 | void inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const; |
---|
| 84 | |
---|
| 85 | void inputFieldServer(const std::deque<ARRAY(double, 1)> storedClient, |
---|
| 86 | ARRAY(double, 1) storedServer) const; |
---|
| 87 | /* |
---|
| 88 | template <StdSize n> |
---|
| 89 | void outputField(const ARRAY(double, 1) stored, ARRAY(double, n) field) const; |
---|
| 90 | */ |
---|
| 91 | void outputField(int rank, const ARRAY(double, 1) stored, ARRAY(double, 3) field) ; |
---|
| 92 | void outputField(int rank, const ARRAY(double, 1) stored, ARRAY(double, 2) field) ; |
---|
| 93 | void outputField(int rank,const ARRAY(double, 1) stored, ARRAY(double, 1) field) ; |
---|
| 94 | |
---|
| 95 | /// Destructeur /// |
---|
| 96 | virtual ~CGrid(void); |
---|
| 97 | |
---|
| 98 | public : |
---|
| 99 | |
---|
| 100 | /// Accesseurs statiques /// |
---|
| 101 | static StdString GetName(void); |
---|
| 102 | static StdString GetDefName(void); |
---|
| 103 | |
---|
| 104 | static ENodeType GetType(void); |
---|
| 105 | |
---|
| 106 | /// Instanciateurs Statiques /// |
---|
| 107 | static CGrid* createGrid(CDomain* domain); |
---|
| 108 | static CGrid* createGrid(CDomain* domain, CAxis* axis); |
---|
| 109 | |
---|
| 110 | public : |
---|
| 111 | |
---|
| 112 | /// Entrées-sorties de champs (interne) /// |
---|
| 113 | void storeField_arr(const double * const data, ARRAY(double, 1) stored) const; |
---|
| 114 | |
---|
| 115 | /// Traitements protégés /// |
---|
| 116 | void computeIndexServer(void); |
---|
| 117 | void computeIndex(void); |
---|
| 118 | void solveDomainRef(void); |
---|
| 119 | void solveAxisRef(void); |
---|
| 120 | |
---|
| 121 | static bool dispatchEvent(CEventServer& event) ; |
---|
| 122 | void outputFieldToServer(ARRAY(double, 1) fieldIn, int rank, ARRAY(double, 1) fieldOut) ; |
---|
| 123 | static void recvIndex(CEventServer& event) ; |
---|
| 124 | void recvIndex(int rank, CBufferIn& buffer) ; |
---|
| 125 | void sendIndex(void) ; |
---|
| 126 | |
---|
| 127 | public: |
---|
| 128 | |
---|
| 129 | /// Propriétés privées /// |
---|
| 130 | bool withAxis ; |
---|
| 131 | bool isChecked; |
---|
| 132 | |
---|
| 133 | CAxis* axis ; |
---|
| 134 | CDomain* domain ; |
---|
| 135 | |
---|
| 136 | std::deque<ARRAY(int, 1)> storeIndex ; |
---|
| 137 | std::deque<ARRAY(int, 1)> out_i_index ; |
---|
| 138 | std::deque<ARRAY(int, 1)> out_j_index ; |
---|
| 139 | std::deque<ARRAY(int, 1)> out_l_index ; |
---|
| 140 | ARRAY(int, 1) storeIndex_client ; |
---|
| 141 | ARRAY(int, 1) out_i_client ; |
---|
| 142 | ARRAY(int, 1) out_j_client ; |
---|
| 143 | ARRAY(int, 1) out_l_client ; |
---|
| 144 | |
---|
| 145 | map<int,ARRAY(int, 1)> storeIndex_toSrv ; |
---|
| 146 | map<int,int> nbSenders ; |
---|
| 147 | // std::deque<ARRAY(int, 1)> out_i_toSrv ; |
---|
| 148 | // std::deque<ARRAY(int, 1)> out_j_toSrv ; |
---|
| 149 | // std::deque<ARRAY(int, 1)> out_l_toSrv ; |
---|
| 150 | |
---|
| 151 | map<int,ARRAY(int, 1)> out_i_fromClient ; |
---|
| 152 | map<int,ARRAY(int, 1)> out_j_fromClient ; |
---|
| 153 | map<int,ARRAY(int, 1)> out_l_fromClient ; |
---|
| 154 | |
---|
| 155 | }; // class CGrid |
---|
| 156 | |
---|
| 157 | ///-------------------------------------------------------------- |
---|
| 158 | |
---|
| 159 | template <StdSize n> |
---|
| 160 | void CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored) const |
---|
| 161 | { |
---|
| 162 | if (this->getDataSize() != field->num_elements()) |
---|
| 163 | ERROR("CGrid::inputField(const ARRAY(double, n) field, ARRAY(double, 1) stored)", |
---|
| 164 | << "[ Taille des données attendue = " << this->getDataSize() << ", " |
---|
| 165 | << "Taille des données reçue = " << field->num_elements() << " ] " |
---|
| 166 | << "Le tableau de données n'a pas la bonne taille !") ; |
---|
| 167 | this->storeField_arr(field->data(), stored) ; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | ///-------------------------------------------------------------- |
---|
| 171 | |
---|
| 172 | // Declare/Define CGridGroup and CGridDefinition |
---|
| 173 | DECLARE_GROUP(CGrid); |
---|
| 174 | |
---|
| 175 | ///-------------------------------------------------------------- |
---|
| 176 | |
---|
| 177 | } // namespace xios |
---|
| 178 | |
---|
| 179 | #endif // __XMLIO_CGrid__ |
---|