[219] | 1 | #ifndef __XMLIO_CGrid__ |
---|
| 2 | #define __XMLIO_CGrid__ |
---|
| 3 | |
---|
[335] | 4 | /// xios headers /// |
---|
[219] | 5 | #include "xmlioserver_spl.hpp" |
---|
| 6 | #include "group_factory.hpp" |
---|
| 7 | |
---|
| 8 | #include "declare_group.hpp" |
---|
| 9 | #include "domain.hpp" |
---|
| 10 | #include "axis.hpp" |
---|
[369] | 11 | #include "array_new.hpp" |
---|
| 12 | #include "attribute_array.hpp" |
---|
[551] | 13 | #include "distribution_client.hpp" |
---|
[552] | 14 | #include "distribution_server.hpp" |
---|
[553] | 15 | #include "server_distribution_description.hpp" |
---|
| 16 | #include "client_server_mapping.hpp" |
---|
[219] | 17 | |
---|
[335] | 18 | namespace xios { |
---|
[509] | 19 | |
---|
[219] | 20 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 21 | |
---|
| 22 | class CGridGroup; |
---|
| 23 | class CGridAttributes; |
---|
[540] | 24 | class CDomainGroup; |
---|
| 25 | class CAxisGroup; |
---|
[219] | 26 | class CGrid; |
---|
[551] | 27 | class CDistributionClient; |
---|
[552] | 28 | class CDistributionServer; |
---|
[553] | 29 | class CServerDistributionDescription; |
---|
| 30 | class CClientServerMapping; |
---|
[219] | 31 | |
---|
| 32 | ///-------------------------------------------------------------- |
---|
| 33 | |
---|
| 34 | // Declare/Define CGridAttribute |
---|
| 35 | BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
| 36 | # include "grid_attribute.conf" |
---|
| 37 | END_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
| 38 | |
---|
| 39 | ///-------------------------------------------------------------- |
---|
| 40 | |
---|
| 41 | class CGrid |
---|
| 42 | : public CObjectTemplate<CGrid> |
---|
| 43 | , public CGridAttributes |
---|
| 44 | { |
---|
| 45 | /// typedef /// |
---|
| 46 | typedef CObjectTemplate<CGrid> SuperClass; |
---|
| 47 | typedef CGridAttributes SuperClassAttribute; |
---|
| 48 | |
---|
| 49 | public : |
---|
| 50 | |
---|
| 51 | typedef CGridAttributes RelAttributes; |
---|
| 52 | typedef CGridGroup RelGroup; |
---|
| 53 | |
---|
[300] | 54 | enum EEventId |
---|
| 55 | { |
---|
[540] | 56 | EVENT_ID_INDEX, EVENT_ID_ADD_DOMAIN, EVENT_ID_ADD_AXIS |
---|
[300] | 57 | } ; |
---|
[509] | 58 | |
---|
[219] | 59 | /// Constructeurs /// |
---|
| 60 | CGrid(void); |
---|
| 61 | explicit CGrid(const StdString & id); |
---|
| 62 | CGrid(const CGrid & grid); // Not implemented yet. |
---|
| 63 | CGrid(const CGrid * const grid); // Not implemented yet. |
---|
| 64 | |
---|
| 65 | /// Traitements /// |
---|
[509] | 66 | // void solveReference(void); |
---|
[219] | 67 | |
---|
[509] | 68 | void solveDomainAxisRef(bool areAttributesChecked); |
---|
| 69 | |
---|
| 70 | void checkMaskIndex(bool doCalculateIndex); |
---|
| 71 | |
---|
[369] | 72 | // virtual void toBinary (StdOStream & os) const; |
---|
| 73 | // virtual void fromBinary(StdIStream & is); |
---|
[219] | 74 | |
---|
| 75 | /// Tests /// |
---|
| 76 | bool hasAxis(void) const; |
---|
| 77 | |
---|
| 78 | public : |
---|
| 79 | |
---|
| 80 | /// Accesseurs /// |
---|
[369] | 81 | const std::deque< CArray<int, 1>* > & getStoreIndex(void) const; |
---|
| 82 | const std::deque< CArray<int, 1>* > & getOutIIndex(void) const; |
---|
| 83 | const std::deque< CArray<int, 1>* > & getOutJIndex(void) const; |
---|
| 84 | const std::deque< CArray<int, 1>* > & getOutLIndex(void) const; |
---|
[219] | 85 | |
---|
[347] | 86 | const CAxis* getRelAxis (void) const; |
---|
| 87 | const CDomain* getRelDomain(void) const; |
---|
[219] | 88 | |
---|
| 89 | StdSize getDimension(void) const; |
---|
[509] | 90 | |
---|
[351] | 91 | // StdSize getLocalSize(void) const; |
---|
| 92 | // StdSize getGlobalSize(void) const; |
---|
[286] | 93 | StdSize getDataSize(void) const; |
---|
[351] | 94 | // std::vector<StdSize> getLocalShape(void) const; |
---|
| 95 | // std::vector<StdSize> getGlobalShape(void) const; |
---|
[219] | 96 | |
---|
| 97 | /// Entrées-sorties de champs /// |
---|
[369] | 98 | template <int n> |
---|
| 99 | void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; |
---|
[509] | 100 | |
---|
[369] | 101 | void inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, |
---|
| 102 | CArray<double, 1>& storedServer) const; |
---|
| 103 | |
---|
| 104 | void outputField(int rank, const CArray<double,1>& stored, CArray<double,3>& field) ; |
---|
| 105 | void outputField(int rank, const CArray<double,1>& stored, CArray<double,2>& field) ; |
---|
[509] | 106 | void outputField(int rank, const CArray<double,1>& stored, CArray<double,1>& field) ; |
---|
[551] | 107 | void outputField(int rank, const CArray<double,1>& stored, double* field); |
---|
[509] | 108 | |
---|
[540] | 109 | virtual void parse(xml::CXMLNode & node); |
---|
| 110 | |
---|
[219] | 111 | /// Destructeur /// |
---|
| 112 | virtual ~CGrid(void); |
---|
| 113 | |
---|
| 114 | public : |
---|
| 115 | |
---|
| 116 | /// Accesseurs statiques /// |
---|
| 117 | static StdString GetName(void); |
---|
| 118 | static StdString GetDefName(void); |
---|
[509] | 119 | |
---|
[219] | 120 | static ENodeType GetType(void); |
---|
| 121 | |
---|
| 122 | /// Instanciateurs Statiques /// |
---|
[347] | 123 | static CGrid* createGrid(CDomain* domain); |
---|
| 124 | static CGrid* createGrid(CDomain* domain, CAxis* axis); |
---|
[540] | 125 | static CGrid* createGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis); |
---|
[219] | 126 | |
---|
[300] | 127 | public : |
---|
[219] | 128 | |
---|
| 129 | /// Entrées-sorties de champs (interne) /// |
---|
[369] | 130 | void storeField_arr(const double * const data, CArray<double,1>& stored) const; |
---|
[219] | 131 | |
---|
| 132 | /// Traitements protégés /// |
---|
| 133 | void computeIndexServer(void); |
---|
| 134 | void computeIndex(void); |
---|
[509] | 135 | // void solveDomainRef(void); //TODO temporarily comment |
---|
| 136 | // void solveAxisRef(void); // TODO: temporarily comment |
---|
[219] | 137 | |
---|
[509] | 138 | void solveDomainRef(bool checkAtt); |
---|
| 139 | void solveAxisRef(bool checkAtt); |
---|
[540] | 140 | void solveDomainAxisRefInheritance(bool apply = true); |
---|
[509] | 141 | |
---|
[540] | 142 | void sendAddDomain(const std::string& id=""); |
---|
| 143 | void sendAddAxis(const std::string& id=""); |
---|
| 144 | void sendAllDomains(); |
---|
| 145 | void sendAllAxis(); |
---|
| 146 | |
---|
| 147 | static void recvAddDomain(CEventServer& event) ; |
---|
| 148 | void recvAddDomain(CBufferIn& buffer) ; |
---|
| 149 | static void recvAddAxis(CEventServer& event) ; |
---|
| 150 | void recvAddAxis(CBufferIn& buffer) ; |
---|
| 151 | |
---|
[300] | 152 | static bool dispatchEvent(CEventServer& event) ; |
---|
[369] | 153 | void outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) ; |
---|
[300] | 154 | static void recvIndex(CEventServer& event) ; |
---|
| 155 | void recvIndex(int rank, CBufferIn& buffer) ; |
---|
| 156 | void sendIndex(void) ; |
---|
[509] | 157 | |
---|
| 158 | void computeDomConServer(); |
---|
| 159 | std::map<int, int> getDomConServerSide(); |
---|
| 160 | std::map<int, StdSize> getConnectedServerDataSize(); |
---|
[540] | 161 | std::vector<StdString> getDomainList(); |
---|
| 162 | std::vector<StdString> getAxisList(); |
---|
| 163 | std::vector<CDomain*> getDomains(); |
---|
| 164 | std::vector<CAxis*> getAxis(); |
---|
[551] | 165 | std::vector<int> getAxisOrder(); |
---|
[540] | 166 | |
---|
[219] | 167 | public: |
---|
| 168 | |
---|
| 169 | /// Propriétés privées /// |
---|
| 170 | bool withAxis ; |
---|
| 171 | bool isChecked; |
---|
[509] | 172 | bool isDomainAxisChecked; |
---|
[551] | 173 | bool isIndexSent; |
---|
[219] | 174 | |
---|
[347] | 175 | CAxis* axis ; |
---|
| 176 | CDomain* domain ; |
---|
[219] | 177 | |
---|
[369] | 178 | std::deque< CArray<int, 1>* > storeIndex ; |
---|
| 179 | std::deque< CArray<int, 1>* > out_i_index ; |
---|
| 180 | std::deque< CArray<int, 1>* > out_j_index ; |
---|
| 181 | std::deque< CArray<int, 1>* > out_l_index ; |
---|
[509] | 182 | |
---|
[369] | 183 | CArray<int, 1> storeIndex_client ; |
---|
| 184 | CArray<int, 1> out_i_client ; |
---|
| 185 | CArray<int, 1> out_j_client ; |
---|
| 186 | CArray<int, 1> out_l_client ; |
---|
[509] | 187 | |
---|
[369] | 188 | map<int, CArray<int, 1>* > storeIndex_toSrv ; |
---|
[300] | 189 | map<int,int> nbSenders ; |
---|
| 190 | // std::deque<ARRAY(int, 1)> out_i_toSrv ; |
---|
| 191 | // std::deque<ARRAY(int, 1)> out_j_toSrv ; |
---|
| 192 | // std::deque<ARRAY(int, 1)> out_l_toSrv ; |
---|
[509] | 193 | |
---|
[369] | 194 | map<int, CArray<int, 1>* > out_i_fromClient ; |
---|
| 195 | map<int, CArray<int, 1>* > out_j_fromClient ; |
---|
| 196 | map<int, CArray<int, 1>* > out_l_fromClient ; |
---|
[551] | 197 | |
---|
| 198 | map<int, CArray<size_t, 1>* > outIndexFromClient; |
---|
[415] | 199 | void checkMask(void) ; |
---|
[509] | 200 | |
---|
| 201 | std::map<int, int> domConnectedServerSide_; |
---|
| 202 | bool isDomConServerComputed_; |
---|
[540] | 203 | |
---|
| 204 | private: |
---|
| 205 | void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); |
---|
| 206 | void setVirtualDomainGroup(); |
---|
| 207 | void setVirtualAxisGroup(CAxisGroup* newVAxisGroup); |
---|
| 208 | void setVirtualAxisGroup(); |
---|
| 209 | // void setAxisList(); |
---|
| 210 | void setAxisList(const std::vector<CAxis*> axis = std::vector<CAxis*>()); |
---|
| 211 | // void setDomainList(); |
---|
| 212 | void setDomainList(const std::vector<CDomain*> domains = std::vector<CDomain*>()); |
---|
| 213 | |
---|
| 214 | CDomain* addDomain(const std::string& id); |
---|
| 215 | CAxis* addAxis(const std::string& id); |
---|
| 216 | |
---|
| 217 | CAxisGroup* getVirtualAxisGroup() const; |
---|
| 218 | CDomainGroup* getVirtualDomainGroup() const; |
---|
| 219 | private: |
---|
| 220 | CDomainGroup* vDomainGroup_; |
---|
| 221 | CAxisGroup* vAxisGroup_; |
---|
| 222 | std::vector<std::string> axisList_, domList_; |
---|
| 223 | bool isAxisListSet, isDomListSet; |
---|
[551] | 224 | CDistributionClient* clientDistribution_; |
---|
[552] | 225 | CDistributionServer* serverDistribution_; |
---|
[553] | 226 | CServerDistributionDescription* serverDistributionDescription_; |
---|
| 227 | CClientServerMapping clientServerMap_; |
---|
[219] | 228 | }; // class CGrid |
---|
| 229 | |
---|
| 230 | ///-------------------------------------------------------------- |
---|
| 231 | |
---|
[369] | 232 | template <int n> |
---|
| 233 | void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const |
---|
[219] | 234 | { |
---|
[369] | 235 | if (this->getDataSize() != field.numElements()) |
---|
| 236 | ERROR("void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const", |
---|
[421] | 237 | << "[ Awaiting size of the data = " << this->getDataSize() << ", " |
---|
| 238 | << "Received data size = " << field.numElements() << " ] " |
---|
| 239 | << "The array of data has not the good size !") |
---|
[369] | 240 | this->storeField_arr(field.dataFirst(), stored) ; |
---|
[219] | 241 | } |
---|
| 242 | |
---|
| 243 | ///-------------------------------------------------------------- |
---|
| 244 | |
---|
| 245 | // Declare/Define CGridGroup and CGridDefinition |
---|
| 246 | DECLARE_GROUP(CGrid); |
---|
| 247 | |
---|
| 248 | ///-------------------------------------------------------------- |
---|
| 249 | |
---|
[335] | 250 | } // namespace xios |
---|
[219] | 251 | |
---|
| 252 | #endif // __XMLIO_CGrid__ |
---|