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