[591] | 1 | #ifndef __XIOS_CGrid__ |
---|
| 2 | #define __XIOS_CGrid__ |
---|
[219] | 3 | |
---|
[591] | 4 | /// XIOS headers /// |
---|
| 5 | #include "xios_spl.hpp" |
---|
[219] | 6 | #include "group_factory.hpp" |
---|
| 7 | |
---|
| 8 | #include "declare_group.hpp" |
---|
| 9 | #include "domain.hpp" |
---|
| 10 | #include "axis.hpp" |
---|
[887] | 11 | #include "scalar.hpp" |
---|
[369] | 12 | #include "array_new.hpp" |
---|
| 13 | #include "attribute_array.hpp" |
---|
[552] | 14 | #include "distribution_server.hpp" |
---|
[553] | 15 | #include "client_server_mapping.hpp" |
---|
[567] | 16 | #include "utils.hpp" |
---|
[619] | 17 | #include "transformation_enum.hpp" |
---|
[219] | 18 | |
---|
[335] | 19 | namespace xios { |
---|
[509] | 20 | |
---|
[219] | 21 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 22 | |
---|
| 23 | class CGridGroup; |
---|
| 24 | class CGridAttributes; |
---|
[540] | 25 | class CDomainGroup; |
---|
| 26 | class CAxisGroup; |
---|
[887] | 27 | class CScalarGroup; |
---|
[219] | 28 | class CGrid; |
---|
[551] | 29 | class CDistributionClient; |
---|
[552] | 30 | class CDistributionServer; |
---|
[553] | 31 | class CServerDistributionDescription; |
---|
| 32 | class CClientServerMapping; |
---|
[620] | 33 | class CGridTransformation; |
---|
[219] | 34 | |
---|
| 35 | ///-------------------------------------------------------------- |
---|
| 36 | |
---|
| 37 | // Declare/Define CGridAttribute |
---|
| 38 | BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
| 39 | # include "grid_attribute.conf" |
---|
| 40 | END_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
| 41 | |
---|
| 42 | ///-------------------------------------------------------------- |
---|
| 43 | |
---|
| 44 | class CGrid |
---|
| 45 | : public CObjectTemplate<CGrid> |
---|
| 46 | , public CGridAttributes |
---|
| 47 | { |
---|
| 48 | /// typedef /// |
---|
| 49 | typedef CObjectTemplate<CGrid> SuperClass; |
---|
| 50 | typedef CGridAttributes SuperClassAttribute; |
---|
| 51 | |
---|
[676] | 52 | public: |
---|
[219] | 53 | |
---|
| 54 | typedef CGridAttributes RelAttributes; |
---|
| 55 | typedef CGridGroup RelGroup; |
---|
| 56 | |
---|
[300] | 57 | enum EEventId |
---|
| 58 | { |
---|
[887] | 59 | EVENT_ID_INDEX, EVENT_ID_ADD_DOMAIN, EVENT_ID_ADD_AXIS, EVENT_ID_ADD_SCALAR |
---|
[650] | 60 | }; |
---|
[509] | 61 | |
---|
[219] | 62 | /// Constructeurs /// |
---|
| 63 | CGrid(void); |
---|
[650] | 64 | explicit CGrid(const StdString& id); |
---|
| 65 | CGrid(const CGrid& grid); // Not implemented yet. |
---|
| 66 | CGrid(const CGrid* const grid); // Not implemented yet. |
---|
[219] | 67 | |
---|
| 68 | /// Traitements /// |
---|
[509] | 69 | // void solveReference(void); |
---|
[219] | 70 | |
---|
[676] | 71 | void checkEligibilityForCompressedOutput(); |
---|
| 72 | |
---|
[509] | 73 | void solveDomainAxisRef(bool areAttributesChecked); |
---|
| 74 | |
---|
| 75 | void checkMaskIndex(bool doCalculateIndex); |
---|
| 76 | |
---|
[650] | 77 | // virtual void toBinary (StdOStream& os) const; |
---|
| 78 | // virtual void fromBinary(StdIStream& is); |
---|
[219] | 79 | |
---|
[676] | 80 | void addRelFileCompressed(const StdString& filename); |
---|
| 81 | |
---|
[219] | 82 | /// Tests /// |
---|
[676] | 83 | bool isCompressible(void) const; |
---|
| 84 | bool isWrittenCompressed(const StdString& filename) const; |
---|
[219] | 85 | |
---|
[676] | 86 | public: |
---|
[219] | 87 | |
---|
| 88 | /// Accesseurs /// |
---|
| 89 | StdSize getDimension(void) const; |
---|
[509] | 90 | |
---|
[286] | 91 | StdSize getDataSize(void) const; |
---|
[219] | 92 | |
---|
| 93 | /// Entrées-sorties de champs /// |
---|
[369] | 94 | template <int n> |
---|
[593] | 95 | void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; |
---|
| 96 | template <int n> |
---|
| 97 | void outputField(const CArray<double,1>& stored, CArray<double,n>& field) const; |
---|
[509] | 98 | |
---|
[599] | 99 | void outputField(int rank, const CArray<double,1>& stored, double* field); |
---|
| 100 | void inputField(int rank, const double* const field, CArray<double,1>& stored); |
---|
[509] | 101 | |
---|
[676] | 102 | void outputCompressedField(int rank, const CArray<double,1>& stored, double* field); |
---|
| 103 | |
---|
[650] | 104 | virtual void parse(xml::CXMLNode& node); |
---|
[540] | 105 | |
---|
[219] | 106 | /// Destructeur /// |
---|
| 107 | virtual ~CGrid(void); |
---|
| 108 | |
---|
[676] | 109 | public: |
---|
[219] | 110 | |
---|
| 111 | /// Accesseurs statiques /// |
---|
| 112 | static StdString GetName(void); |
---|
| 113 | static StdString GetDefName(void); |
---|
[509] | 114 | |
---|
[219] | 115 | static ENodeType GetType(void); |
---|
| 116 | |
---|
| 117 | /// Instanciateurs Statiques /// |
---|
[347] | 118 | static CGrid* createGrid(CDomain* domain); |
---|
| 119 | static CGrid* createGrid(CDomain* domain, CAxis* axis); |
---|
[745] | 120 | static CGrid* createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
[887] | 121 | const CArray<int,1>& axisDomainOrder = CArray<int,1>()); |
---|
[745] | 122 | static CGrid* createGrid(StdString id, const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
[887] | 123 | const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder = CArray<int,1>()); |
---|
| 124 | static CGrid* createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
| 125 | const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder); |
---|
[745] | 126 | static StdString generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
[887] | 127 | const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder = CArray<int,1>()); |
---|
[823] | 128 | static StdString generateId(const CGrid* gridSrc, const CGrid* gridDest); |
---|
| 129 | static CGrid* cloneGrid(const StdString& idNewGrid, CGrid* gridSrc); |
---|
[219] | 130 | |
---|
[676] | 131 | public: |
---|
[219] | 132 | |
---|
| 133 | /// Entrées-sorties de champs (interne) /// |
---|
[650] | 134 | void storeField_arr(const double* const data, CArray<double,1>& stored) const; |
---|
| 135 | void restoreField_arr(const CArray<double,1>& stored, double* const data) const; |
---|
[219] | 136 | |
---|
| 137 | /// Traitements protégés /// |
---|
| 138 | void computeIndexServer(void); |
---|
| 139 | void computeIndex(void); |
---|
[586] | 140 | void computeIndexScalarGrid(); |
---|
[676] | 141 | void computeCompressedIndex(); |
---|
[219] | 142 | |
---|
[509] | 143 | void solveDomainRef(bool checkAtt); |
---|
| 144 | void solveAxisRef(bool checkAtt); |
---|
[887] | 145 | void solveScalarRef(bool checkAtt); |
---|
[540] | 146 | void solveDomainAxisRefInheritance(bool apply = true); |
---|
[619] | 147 | void solveTransformations(); |
---|
[775] | 148 | void solveDomainAxisBaseRef(); |
---|
[509] | 149 | |
---|
[835] | 150 | CDomain* addDomain(const std::string& id=StdString()); |
---|
| 151 | CAxis* addAxis(const std::string& id=StdString()); |
---|
[887] | 152 | CScalar* addScalar(const std::string& id=StdString()); |
---|
[540] | 153 | void sendAddDomain(const std::string& id=""); |
---|
| 154 | void sendAddAxis(const std::string& id=""); |
---|
[887] | 155 | void sendAddScalar(const std::string& id=""); |
---|
[540] | 156 | void sendAllDomains(); |
---|
| 157 | void sendAllAxis(); |
---|
[887] | 158 | void sendAllScalars(); |
---|
[540] | 159 | |
---|
[650] | 160 | static void recvAddDomain(CEventServer& event); |
---|
| 161 | void recvAddDomain(CBufferIn& buffer); |
---|
| 162 | static void recvAddAxis(CEventServer& event); |
---|
| 163 | void recvAddAxis(CBufferIn& buffer); |
---|
[887] | 164 | static void recvAddScalar(CEventServer& event); |
---|
| 165 | void recvAddScalar(CBufferIn& buffer); |
---|
[540] | 166 | |
---|
[650] | 167 | static bool dispatchEvent(CEventServer& event); |
---|
| 168 | static void recvIndex(CEventServer& event); |
---|
| 169 | void recvIndex(vector<int> ranks, vector<CBufferIn*> buffers); |
---|
| 170 | void sendIndex(void); |
---|
[586] | 171 | void sendIndexScalarGrid(); |
---|
[509] | 172 | |
---|
| 173 | void computeDomConServer(); |
---|
| 174 | std::map<int, int> getDomConServerSide(); |
---|
[731] | 175 | std::map<int, StdSize> getAttributesBufferSize(); |
---|
| 176 | std::map<int, StdSize> getDataBufferSize(const std::string& id = ""); |
---|
[540] | 177 | std::vector<StdString> getDomainList(); |
---|
| 178 | std::vector<StdString> getAxisList(); |
---|
[887] | 179 | std::vector<StdString> getScalarList(); |
---|
[540] | 180 | std::vector<CDomain*> getDomains(); |
---|
| 181 | std::vector<CAxis*> getAxis(); |
---|
[887] | 182 | std::vector<CScalar*> getScalars(); |
---|
[943] | 183 | CDomain* getDomain(int domainIndex); |
---|
| 184 | CAxis* getAxis(int axisIndex); |
---|
| 185 | CScalar* getScalar(int scalarIndex); |
---|
[551] | 186 | std::vector<int> getAxisOrder(); |
---|
[567] | 187 | std::vector<int> getGlobalDimension(); |
---|
[600] | 188 | bool isScalarGrid() const; |
---|
[620] | 189 | std::vector<int> getAxisPositionInGrid() const; |
---|
[540] | 190 | |
---|
[567] | 191 | bool doGridHaveDataToWrite(); |
---|
| 192 | bool doGridHaveDataDistributed(); |
---|
| 193 | size_t getWrittenDataSize() const; |
---|
[676] | 194 | int getNumberWrittenIndexes() const; |
---|
| 195 | int getTotalNumberWrittenIndexes() const; |
---|
| 196 | int getOffsetWrittenIndexes() const; |
---|
[567] | 197 | |
---|
[834] | 198 | CDistributionServer* getDistributionServer(); |
---|
| 199 | CDistributionClient* getDistributionClient(); |
---|
[620] | 200 | CGridTransformation* getTransformations(); |
---|
[567] | 201 | |
---|
[632] | 202 | void transformGrid(CGrid* transformGridSrc); |
---|
[775] | 203 | void completeGrid(CGrid* transformGridSrc = 0); |
---|
[687] | 204 | void doAutoDistribution(CGrid* transformGridSrc); |
---|
[619] | 205 | bool isTransformed(); |
---|
| 206 | void setTransformed(); |
---|
[890] | 207 | bool isGenerated(); |
---|
| 208 | void setGenerated(); |
---|
[823] | 209 | void addTransGridSource(CGrid* gridSrc); |
---|
| 210 | std::map<CGrid*, std::pair<bool,StdString> >& getTransGridSource(); |
---|
[824] | 211 | bool hasTransform(); |
---|
[619] | 212 | |
---|
[219] | 213 | public: |
---|
| 214 | |
---|
| 215 | /// Propriétés privées /// |
---|
| 216 | bool isChecked; |
---|
[509] | 217 | bool isDomainAxisChecked; |
---|
[551] | 218 | bool isIndexSent; |
---|
[219] | 219 | |
---|
[650] | 220 | CArray<int, 1> storeIndex_client; |
---|
[509] | 221 | |
---|
[650] | 222 | map<int, CArray<int, 1> > storeIndex_toSrv; |
---|
| 223 | map<int,int> nbSenders; |
---|
[509] | 224 | |
---|
[676] | 225 | map<int, CArray<size_t, 1> > outIndexFromClient, compressedOutIndexFromClient; |
---|
[650] | 226 | void checkMask(void); |
---|
[821] | 227 | void createMask(void); |
---|
[623] | 228 | void modifyMask(const CArray<int,1>& indexToModify); |
---|
[509] | 229 | |
---|
[742] | 230 | void computeGridGlobalDimension(const std::vector<CDomain*>& domains, |
---|
| 231 | const std::vector<CAxis*>& axis, |
---|
[887] | 232 | const std::vector<CScalar*>& scalars, |
---|
| 233 | const CArray<int,1>& axisDomainOrder); |
---|
[742] | 234 | |
---|
[540] | 235 | private: |
---|
[567] | 236 | template<int N> |
---|
| 237 | void checkGridMask(CArray<bool,N>& gridMask, |
---|
[664] | 238 | const std::vector<CArray<bool,1>* >& domainMasks, |
---|
[567] | 239 | const std::vector<CArray<bool,1>* >& axisMasks, |
---|
[887] | 240 | const CArray<int,1>& axisDomainOrder, |
---|
[821] | 241 | bool createMask = false); |
---|
[623] | 242 | template<int N> |
---|
| 243 | void modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify); |
---|
| 244 | |
---|
[540] | 245 | void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); |
---|
| 246 | void setVirtualAxisGroup(CAxisGroup* newVAxisGroup); |
---|
[887] | 247 | void setVirtualScalarGroup(CScalarGroup* newVScalarGroup); |
---|
[567] | 248 | |
---|
[887] | 249 | void setDomainList(const std::vector<CDomain*> domains = std::vector<CDomain*>()); |
---|
[540] | 250 | void setAxisList(const std::vector<CAxis*> axis = std::vector<CAxis*>()); |
---|
[887] | 251 | void setScalarList(const std::vector<CScalar*> scalars = std::vector<CScalar*>()); |
---|
[540] | 252 | |
---|
[887] | 253 | CDomainGroup* getVirtualDomainGroup() const; |
---|
[540] | 254 | CAxisGroup* getVirtualAxisGroup() const; |
---|
[887] | 255 | CScalarGroup* getVirtualScalarGroup() const; |
---|
[619] | 256 | |
---|
[657] | 257 | void checkAttributesAfterTransformation(); |
---|
[619] | 258 | void setTransformationAlgorithms(); |
---|
[865] | 259 | void computeIndexByElement(const std::vector<boost::unordered_map<size_t,std::vector<int> > >& indexServerOnElement, |
---|
| 260 | CClientServerMapping::GlobalIndexMap& globalIndexOnServer); |
---|
[619] | 261 | |
---|
[540] | 262 | private: |
---|
| 263 | CDomainGroup* vDomainGroup_; |
---|
| 264 | CAxisGroup* vAxisGroup_; |
---|
[887] | 265 | CScalarGroup* vScalarGroup_; |
---|
| 266 | std::vector<std::string> axisList_, domList_, scalarList_; |
---|
| 267 | bool isAxisListSet, isDomListSet, isScalarListSet; |
---|
[567] | 268 | |
---|
[551] | 269 | CDistributionClient* clientDistribution_; |
---|
[552] | 270 | CDistributionServer* serverDistribution_; |
---|
[568] | 271 | CClientServerMapping* clientServerMap_; |
---|
[567] | 272 | size_t writtenDataSize_; |
---|
[676] | 273 | int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
[584] | 274 | std::map<int,size_t> connectedDataSize_; |
---|
| 275 | std::vector<int> connectedServerRank_; |
---|
[586] | 276 | bool isDataDistributed_; |
---|
[657] | 277 | int positionDimensionDistributed_; |
---|
[676] | 278 | //! True if and only if the data defined on the grid can be outputted in a compressed way |
---|
| 279 | bool isCompressible_; |
---|
| 280 | std::set<std::string> relFilesCompressed; |
---|
[619] | 281 | |
---|
| 282 | bool isTransformed_; |
---|
[890] | 283 | bool isGenerated_; |
---|
[620] | 284 | std::vector<int> axisPositionInGrid_; |
---|
| 285 | CGridTransformation* transformations_; |
---|
[775] | 286 | bool hasDomainAxisBaseRef_; |
---|
[823] | 287 | std::vector<int> globalDim_; |
---|
| 288 | std::map<CGrid*, std::pair<bool,StdString> > gridSrc_; |
---|
[824] | 289 | bool hasTransform_; |
---|
[865] | 290 | CClientServerMapping::GlobalIndexMap globalIndexOnServer_; |
---|
[835] | 291 | // List order of axis and domain in a grid, if there is a domain, it will take value 1 (true), axis 0 (false) |
---|
[887] | 292 | std::vector<int> order_; |
---|
[219] | 293 | }; // class CGrid |
---|
| 294 | |
---|
| 295 | ///-------------------------------------------------------------- |
---|
| 296 | |
---|
[369] | 297 | template <int n> |
---|
[567] | 298 | void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const |
---|
[219] | 299 | { |
---|
[369] | 300 | if (this->getDataSize() != field.numElements()) |
---|
| 301 | ERROR("void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const", |
---|
[680] | 302 | << "[ Awaiting data of size = " << this->getDataSize() << ", " |
---|
[421] | 303 | << "Received data size = " << field.numElements() << " ] " |
---|
[955] | 304 | << "The data array does not have the right size! " |
---|
| 305 | << "Grid = " << this->GetName()) |
---|
[650] | 306 | this->storeField_arr(field.dataFirst(), stored); |
---|
[219] | 307 | } |
---|
| 308 | |
---|
[593] | 309 | template <int n> |
---|
| 310 | void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const |
---|
| 311 | { |
---|
| 312 | if (this->getDataSize() != field.numElements()) |
---|
| 313 | ERROR("void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const", |
---|
| 314 | << "[ Size of the data = " << this->getDataSize() << ", " |
---|
| 315 | << "Output data size = " << field.numElements() << " ] " |
---|
[955] | 316 | << "The ouput array does not have the right size! " |
---|
| 317 | << "Grid = " << this->GetName()) |
---|
[593] | 318 | this->restoreField_arr(stored, field.dataFirst()); |
---|
| 319 | } |
---|
| 320 | |
---|
[567] | 321 | template<int N> |
---|
| 322 | void CGrid::checkGridMask(CArray<bool,N>& gridMask, |
---|
[664] | 323 | const std::vector<CArray<bool,1>* >& domainMasks, |
---|
[567] | 324 | const std::vector<CArray<bool,1>* >& axisMasks, |
---|
[887] | 325 | const CArray<int,1>& axisDomainOrder, |
---|
[821] | 326 | bool createMask) |
---|
[567] | 327 | { |
---|
| 328 | int idx = 0; |
---|
| 329 | int numElement = axisDomainOrder.numElements(); |
---|
[650] | 330 | int dim = domainMasks.size() * 2 + axisMasks.size(); |
---|
[664] | 331 | std::vector<CDomain*> domainP = this->getDomains(); |
---|
[567] | 332 | |
---|
| 333 | std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); |
---|
| 334 | std::vector<int> currentIndex(dim); |
---|
| 335 | int idxDomain = 0, idxAxis = 0; |
---|
| 336 | for (int i = 0; i < numElement; ++i) |
---|
| 337 | { |
---|
| 338 | indexMap[i] = idx; |
---|
[887] | 339 | if (2 == axisDomainOrder(i)) { |
---|
[664] | 340 | eachDimSize[indexMap[i]] = domainP[idxDomain]->ni; |
---|
| 341 | eachDimSize[indexMap[i]+1] = domainP[idxDomain]->nj; |
---|
[567] | 342 | idx += 2; ++idxDomain; |
---|
| 343 | } |
---|
[887] | 344 | else if (1 == axisDomainOrder(i)) { |
---|
[567] | 345 | eachDimSize[indexMap[i]] = axisMasks[idxAxis]->numElements(); |
---|
| 346 | ++idx; ++idxAxis; |
---|
| 347 | } |
---|
[976] | 348 | else {}; |
---|
[567] | 349 | } |
---|
| 350 | |
---|
[821] | 351 | if (!gridMask.isEmpty() && !createMask) |
---|
[567] | 352 | { |
---|
| 353 | for (int i = 0; i < dim; ++i) |
---|
| 354 | { |
---|
| 355 | if (gridMask.extent(i) != eachDimSize[i]) |
---|
[680] | 356 | ERROR("CGrid::checkMask(void)", |
---|
| 357 | << "The mask has one dimension whose size is different from the one of the local grid." << std::endl |
---|
| 358 | << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl |
---|
[955] | 359 | << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl |
---|
| 360 | << "Grid = " << this->GetName()) |
---|
[567] | 361 | } |
---|
| 362 | } |
---|
| 363 | else { |
---|
| 364 | CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); |
---|
| 365 | gridMask = true; |
---|
| 366 | } |
---|
| 367 | |
---|
| 368 | int ssize = gridMask.numElements(); |
---|
| 369 | idx = 0; |
---|
| 370 | while (idx < ssize) |
---|
| 371 | { |
---|
| 372 | for (int i = 0; i < dim-1; ++i) |
---|
| 373 | { |
---|
| 374 | if (idxLoop[i] == eachDimSize[i]) |
---|
| 375 | { |
---|
| 376 | idxLoop[i] = 0; |
---|
| 377 | ++idxLoop[i+1]; |
---|
| 378 | } |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | // Find out outer index |
---|
| 382 | idxDomain = idxAxis = 0; |
---|
| 383 | bool maskValue = true; |
---|
| 384 | for (int i = 0; i < numElement; ++i) |
---|
| 385 | { |
---|
[887] | 386 | if (2 == axisDomainOrder(i)) |
---|
[567] | 387 | { |
---|
[664] | 388 | maskValue = maskValue && (*domainMasks[idxDomain])(idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]); |
---|
[567] | 389 | ++idxDomain; |
---|
| 390 | } |
---|
[887] | 391 | else if (1 == axisDomainOrder(i)) |
---|
[567] | 392 | { |
---|
| 393 | maskValue = maskValue && (*axisMasks[idxAxis])(idxLoop[indexMap[i]]); |
---|
| 394 | ++idxAxis; |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | int maskIndex = idxLoop[0]; |
---|
| 399 | int mulDim = 1; |
---|
| 400 | for (int k = 1; k < dim; ++k) |
---|
| 401 | { |
---|
| 402 | mulDim *= eachDimSize[k-1]; |
---|
| 403 | maskIndex += idxLoop[k]*mulDim; |
---|
| 404 | } |
---|
[623] | 405 | *(gridMask.dataFirst()+maskIndex) &= maskValue; |
---|
[567] | 406 | |
---|
| 407 | ++idxLoop[0]; |
---|
| 408 | ++idx; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | } |
---|
| 412 | |
---|
[623] | 413 | /*! |
---|
| 414 | Modify the current mask of grid, the local index to be modified will take value false |
---|
| 415 | \param [in/out] gridMask current mask of grid |
---|
| 416 | \param [in] indexToModify local index to modify |
---|
| 417 | */ |
---|
| 418 | template<int N> |
---|
| 419 | void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify) |
---|
| 420 | { |
---|
| 421 | bool valueToModify = false; |
---|
| 422 | int num = indexToModify.numElements(); |
---|
| 423 | for (int idx = 0; idx < num; ++idx) |
---|
| 424 | { |
---|
| 425 | *(gridMask.dataFirst()+indexToModify(idx)) = valueToModify; |
---|
| 426 | } |
---|
| 427 | } |
---|
[219] | 428 | ///-------------------------------------------------------------- |
---|
| 429 | |
---|
| 430 | // Declare/Define CGridGroup and CGridDefinition |
---|
| 431 | DECLARE_GROUP(CGrid); |
---|
| 432 | |
---|
| 433 | ///-------------------------------------------------------------- |
---|
| 434 | |
---|
[335] | 435 | } // namespace xios |
---|
[219] | 436 | |
---|
[591] | 437 | #endif // __XIOS_CGrid__ |
---|