[266] | 1 | |
---|
[219] | 2 | #include "grid.hpp" |
---|
| 3 | |
---|
[352] | 4 | #include "attribute_template.hpp" |
---|
| 5 | #include "object_template.hpp" |
---|
| 6 | #include "group_template.hpp" |
---|
| 7 | #include "message.hpp" |
---|
[286] | 8 | #include <iostream> |
---|
[591] | 9 | #include "xios_spl.hpp" |
---|
[352] | 10 | #include "type.hpp" |
---|
| 11 | #include "context.hpp" |
---|
| 12 | #include "context_client.hpp" |
---|
[552] | 13 | #include "context_server.hpp" |
---|
[369] | 14 | #include "array_new.hpp" |
---|
[657] | 15 | #include "server_distribution_description.hpp" |
---|
[568] | 16 | #include "client_server_mapping_distributed.hpp" |
---|
[660] | 17 | #include "distribution_client.hpp" |
---|
[1340] | 18 | #include "server.hpp" |
---|
[1930] | 19 | #include "distribution_type.hpp" |
---|
| 20 | #include "grid_remote_connector.hpp" |
---|
| 21 | #include "grid_elements.hpp" |
---|
| 22 | #include "grid_local_view.hpp" |
---|
[1943] | 23 | #include "grid_mask_connector.hpp" |
---|
[1984] | 24 | #include "transformation_path.hpp" |
---|
| 25 | #include "grid_transformation_factory_impl.hpp" |
---|
| 26 | #include "transform_filter.hpp" |
---|
[1999] | 27 | #include "grid_algorithm.hpp" |
---|
[2007] | 28 | #include "grid_algorithm_generic.hpp" |
---|
| 29 | #include "generic_algorithm_transformation.hpp" |
---|
| 30 | #include "algo_types.hpp" |
---|
[219] | 31 | |
---|
[1930] | 32 | |
---|
[1984] | 33 | namespace xios |
---|
| 34 | { |
---|
[219] | 35 | |
---|
[742] | 36 | /// ////////////////////// Dfinitions ////////////////////// /// |
---|
[219] | 37 | |
---|
| 38 | CGrid::CGrid(void) |
---|
| 39 | : CObjectTemplate<CGrid>(), CGridAttributes() |
---|
[650] | 40 | , isChecked(false), isDomainAxisChecked(false) |
---|
[887] | 41 | , vDomainGroup_(), domList_(), isDomListSet(false) |
---|
| 42 | , vAxisGroup_(), axisList_(), isAxisListSet(false) |
---|
| 43 | , vScalarGroup_(), scalarList_(), isScalarListSet(false) |
---|
[1973] | 44 | , clientDistribution_(0), isIndexSent(false) |
---|
[1330] | 45 | , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() |
---|
[1870] | 46 | , isCompressible_(false) |
---|
[1158] | 47 | , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) |
---|
[2011] | 48 | , gridSrc_(), order_() |
---|
[1294] | 49 | , clients() |
---|
[540] | 50 | { |
---|
[957] | 51 | setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); |
---|
| 52 | setVirtualAxisGroup(CAxisGroup::create(getId() + "_virtual_axis_group")); |
---|
| 53 | setVirtualScalarGroup(CScalarGroup::create(getId() + "_virtual_scalar_group")); |
---|
[540] | 54 | } |
---|
[219] | 55 | |
---|
[650] | 56 | CGrid::CGrid(const StdString& id) |
---|
[219] | 57 | : CObjectTemplate<CGrid>(id), CGridAttributes() |
---|
[650] | 58 | , isChecked(false), isDomainAxisChecked(false) |
---|
[887] | 59 | , vDomainGroup_(), domList_(), isDomListSet(false) |
---|
| 60 | , vAxisGroup_(), axisList_(), isAxisListSet(false) |
---|
| 61 | , vScalarGroup_(), scalarList_(), isScalarListSet(false) |
---|
[1973] | 62 | , clientDistribution_(0), isIndexSent(false) |
---|
[1330] | 63 | , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_() |
---|
[1870] | 64 | , isCompressible_(false) |
---|
[1158] | 65 | , axisPositionInGrid_(), hasDomainAxisBaseRef_(false) |
---|
[2011] | 66 | , gridSrc_(), order_() |
---|
[1294] | 67 | , clients() |
---|
[540] | 68 | { |
---|
[957] | 69 | setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group")); |
---|
| 70 | setVirtualAxisGroup(CAxisGroup::create(getId() + "_virtual_axis_group")); |
---|
| 71 | setVirtualScalarGroup(CScalarGroup::create(getId() + "_virtual_scalar_group")); |
---|
[540] | 72 | } |
---|
[219] | 73 | |
---|
| 74 | CGrid::~CGrid(void) |
---|
[509] | 75 | { |
---|
[551] | 76 | if (0 != clientDistribution_) delete clientDistribution_; |
---|
[219] | 77 | } |
---|
| 78 | |
---|
| 79 | ///--------------------------------------------------------------- |
---|
| 80 | |
---|
[650] | 81 | StdString CGrid::GetName(void) { return StdString("grid"); } |
---|
| 82 | StdString CGrid::GetDefName(void) { return CGrid::GetName(); } |
---|
| 83 | ENodeType CGrid::GetType(void) { return eGrid; } |
---|
[219] | 84 | |
---|
| 85 | |
---|
[1930] | 86 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 87 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 88 | ///////// MEMBER FUNCTION RELATED TO GRID CONSTRUCTION by ELEMNTS AND MANAGEMENT ///// |
---|
| 89 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 90 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | CGrid* CGrid::createGrid(CDomain* domain) |
---|
| 94 | TRY |
---|
| 95 | { |
---|
| 96 | std::vector<CDomain*> vecDom(1, domain); |
---|
| 97 | std::vector<CAxis*> vecAxis; |
---|
| 98 | return createGrid(vecDom, vecAxis); |
---|
| 99 | } |
---|
| 100 | CATCH |
---|
| 101 | |
---|
| 102 | CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis) |
---|
| 103 | TRY |
---|
| 104 | { |
---|
| 105 | std::vector<CDomain*> vecDom(1, domain); |
---|
| 106 | std::vector<CAxis*> vecAxis(1, axis); |
---|
| 107 | |
---|
| 108 | return createGrid(vecDom, vecAxis); |
---|
| 109 | } |
---|
| 110 | CATCH |
---|
| 111 | |
---|
| 112 | CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
| 113 | const CArray<int,1>& axisDomainOrder) |
---|
| 114 | TRY |
---|
| 115 | { |
---|
| 116 | std::vector<CScalar*> vecScalar; |
---|
| 117 | return createGrid(generateId(domains, axis, vecScalar, axisDomainOrder), domains, axis, vecScalar, axisDomainOrder); |
---|
| 118 | } |
---|
| 119 | CATCH |
---|
| 120 | |
---|
| 121 | CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
| 122 | const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) |
---|
| 123 | TRY |
---|
| 124 | { |
---|
| 125 | return createGrid(generateId(domains, axis, scalars, axisDomainOrder), domains, axis, scalars, axisDomainOrder); |
---|
| 126 | } |
---|
| 127 | CATCH |
---|
| 128 | |
---|
| 129 | CGrid* CGrid::createGrid(StdString id, const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
| 130 | const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) |
---|
| 131 | TRY |
---|
| 132 | { |
---|
| 133 | if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) |
---|
| 134 | ERROR("CGrid* CGrid::createGrid(...)", |
---|
| 135 | << "The size of axisDomainOrder (" << axisDomainOrder.numElements() |
---|
| 136 | << ") is not coherent with the number of elements (" << domains.size() + axis.size() <<")."); |
---|
| 137 | |
---|
| 138 | CGrid* grid = CGridGroup::get("grid_definition")->createChild(id); |
---|
| 139 | grid->setDomainList(domains); |
---|
| 140 | grid->setAxisList(axis); |
---|
| 141 | grid->setScalarList(scalars); |
---|
| 142 | |
---|
| 143 | // By default, domains are always the first elements of a grid |
---|
| 144 | if (0 == axisDomainOrder.numElements()) |
---|
| 145 | { |
---|
| 146 | int size = domains.size() + axis.size() + scalars.size(); |
---|
| 147 | int nb = 0; |
---|
| 148 | grid->axis_domain_order.resize(size); |
---|
| 149 | for (int i = 0; i < size; ++i) |
---|
| 150 | { |
---|
[1934] | 151 | if (i < domains.size()) |
---|
| 152 | { |
---|
[1930] | 153 | grid->axis_domain_order(i) = 2; |
---|
[1934] | 154 | grid->order_.push_back(2) ; |
---|
[1930] | 155 | } |
---|
[1934] | 156 | else if ((scalars.size() < (size-nb)) < size) |
---|
| 157 | { |
---|
[1930] | 158 | grid->axis_domain_order(i) = 1; |
---|
[1934] | 159 | grid->order_.push_back(1) ; |
---|
[1930] | 160 | } |
---|
| 161 | else |
---|
[1934] | 162 | { |
---|
[1930] | 163 | grid->axis_domain_order(i) = 0; |
---|
[1934] | 164 | grid->order_.push_back(0) ; |
---|
| 165 | } |
---|
[1930] | 166 | ++nb; |
---|
| 167 | } |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | grid->axis_domain_order.resize(axisDomainOrder.numElements()); |
---|
| 172 | grid->axis_domain_order = axisDomainOrder; |
---|
[1934] | 173 | grid->order_.clear() ; |
---|
| 174 | for(int i=0; i<axisDomainOrder.numElements();i++) grid->order_.push_back(axisDomainOrder(i)) ; |
---|
| 175 | |
---|
[1930] | 176 | } |
---|
[1988] | 177 | |
---|
[1930] | 178 | // grid->solveElementsRefInheritance(true); |
---|
[1988] | 179 | grid->computeElements() ; |
---|
[1930] | 180 | return grid; |
---|
| 181 | } |
---|
| 182 | CATCH |
---|
| 183 | |
---|
| 184 | //---------------------------------------------------------------- |
---|
| 185 | |
---|
| 186 | //! Change virtual field group to a new one |
---|
| 187 | void CGrid::setVirtualDomainGroup(CDomainGroup* newVDomainGroup) |
---|
| 188 | TRY |
---|
| 189 | { |
---|
| 190 | this->vDomainGroup_ = newVDomainGroup; |
---|
| 191 | } |
---|
| 192 | CATCH_DUMP_ATTR |
---|
| 193 | |
---|
| 194 | //! Change virtual variable group to new one |
---|
| 195 | void CGrid::setVirtualAxisGroup(CAxisGroup* newVAxisGroup) |
---|
| 196 | TRY |
---|
| 197 | { |
---|
| 198 | this->vAxisGroup_ = newVAxisGroup; |
---|
| 199 | } |
---|
| 200 | CATCH_DUMP_ATTR |
---|
| 201 | |
---|
| 202 | //! Change virtual variable group to new one |
---|
| 203 | void CGrid::setVirtualScalarGroup(CScalarGroup* newVScalarGroup) |
---|
| 204 | TRY |
---|
| 205 | { |
---|
| 206 | this->vScalarGroup_ = newVScalarGroup; |
---|
| 207 | } |
---|
| 208 | CATCH_DUMP_ATTR |
---|
| 209 | |
---|
| 210 | //---------------------------------------------------------------- |
---|
| 211 | |
---|
| 212 | CDomainGroup* CGrid::getVirtualDomainGroup() const |
---|
| 213 | TRY |
---|
| 214 | { |
---|
| 215 | return this->vDomainGroup_; |
---|
| 216 | } |
---|
| 217 | CATCH |
---|
| 218 | |
---|
| 219 | CAxisGroup* CGrid::getVirtualAxisGroup() const |
---|
| 220 | TRY |
---|
| 221 | { |
---|
| 222 | return this->vAxisGroup_; |
---|
| 223 | } |
---|
| 224 | CATCH |
---|
| 225 | |
---|
| 226 | CScalarGroup* CGrid::getVirtualScalarGroup() const |
---|
| 227 | TRY |
---|
| 228 | { |
---|
| 229 | return this->vScalarGroup_; |
---|
| 230 | } |
---|
| 231 | CATCH |
---|
| 232 | |
---|
| 233 | ///--------------------------------------------------------------- |
---|
| 234 | |
---|
| 235 | CDomain* CGrid::addDomain(const std::string& id) |
---|
| 236 | TRY |
---|
| 237 | { |
---|
| 238 | order_.push_back(2); |
---|
| 239 | axis_domain_order.resize(order_.size()); |
---|
| 240 | for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; |
---|
[1984] | 241 | CDomain* domain = vDomainGroup_->createChild(id); |
---|
[1999] | 242 | isDomListSet=false ; |
---|
[1984] | 243 | computeElements(); |
---|
| 244 | return domain ; |
---|
[1930] | 245 | } |
---|
| 246 | CATCH_DUMP_ATTR |
---|
| 247 | |
---|
| 248 | CAxis* CGrid::addAxis(const std::string& id) |
---|
| 249 | TRY |
---|
| 250 | { |
---|
| 251 | order_.push_back(1); |
---|
| 252 | axis_domain_order.resize(order_.size()); |
---|
| 253 | for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; |
---|
[1984] | 254 | CAxis* axis=vAxisGroup_->createChild(id); |
---|
[1999] | 255 | isAxisListSet=false ; |
---|
[1984] | 256 | computeElements(); |
---|
| 257 | return axis ; |
---|
[1930] | 258 | } |
---|
| 259 | CATCH_DUMP_ATTR |
---|
| 260 | |
---|
| 261 | CScalar* CGrid::addScalar(const std::string& id) |
---|
| 262 | TRY |
---|
| 263 | { |
---|
| 264 | order_.push_back(0); |
---|
| 265 | axis_domain_order.resize(order_.size()); |
---|
| 266 | for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; |
---|
[1984] | 267 | CScalar* scalar = vScalarGroup_->createChild(id); |
---|
[1999] | 268 | isScalarListSet=false ; |
---|
[1984] | 269 | computeElements(); |
---|
| 270 | return scalar; |
---|
[1930] | 271 | } |
---|
| 272 | CATCH_DUMP_ATTR |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | /*! |
---|
| 278 | \brief Get the list of domain pointers |
---|
| 279 | \return list of domain pointers |
---|
| 280 | */ |
---|
| 281 | std::vector<CDomain*> CGrid::getDomains() |
---|
| 282 | TRY |
---|
| 283 | { |
---|
[1943] | 284 | setDomainList(); |
---|
[1930] | 285 | std::vector<CDomain*> domList; |
---|
| 286 | if (!domList_.empty()) |
---|
| 287 | { |
---|
| 288 | for (int i = 0; i < domList_.size(); ++i) domList.push_back(CDomain::get(domList_[i])); |
---|
| 289 | } |
---|
| 290 | return domList; |
---|
| 291 | } |
---|
| 292 | CATCH_DUMP_ATTR |
---|
| 293 | |
---|
| 294 | /*! |
---|
| 295 | \brief Get the list of axis pointers |
---|
| 296 | \return list of axis pointers |
---|
| 297 | */ |
---|
| 298 | std::vector<CAxis*> CGrid::getAxis() |
---|
| 299 | TRY |
---|
| 300 | { |
---|
[1943] | 301 | setAxisList(); |
---|
[1930] | 302 | std::vector<CAxis*> aList; |
---|
| 303 | if (!axisList_.empty()) |
---|
| 304 | for (int i =0; i < axisList_.size(); ++i) aList.push_back(CAxis::get(axisList_[i])); |
---|
| 305 | |
---|
| 306 | return aList; |
---|
| 307 | } |
---|
| 308 | CATCH_DUMP_ATTR |
---|
| 309 | |
---|
| 310 | /*! |
---|
| 311 | \brief Get the list of axis pointers |
---|
| 312 | \return list of axis pointers |
---|
| 313 | */ |
---|
| 314 | std::vector<CScalar*> CGrid::getScalars() |
---|
| 315 | TRY |
---|
| 316 | { |
---|
[1943] | 317 | setScalarList() ; |
---|
[1930] | 318 | std::vector<CScalar*> sList; |
---|
| 319 | if (!scalarList_.empty()) |
---|
| 320 | for (int i =0; i < scalarList_.size(); ++i) sList.push_back(CScalar::get(scalarList_[i])); |
---|
| 321 | |
---|
| 322 | return sList; |
---|
| 323 | } |
---|
| 324 | CATCH_DUMP_ATTR |
---|
| 325 | |
---|
| 326 | /*! |
---|
| 327 | \brief Get domain pointer with index |
---|
| 328 | \return domain pointer |
---|
| 329 | */ |
---|
| 330 | CDomain* CGrid::getDomain(int domainIndex) |
---|
| 331 | TRY |
---|
| 332 | { |
---|
| 333 | std::vector<CDomain*> domainListP = this->getDomains(); |
---|
| 334 | if (domainListP.empty()) |
---|
| 335 | { |
---|
| 336 | ERROR("CGrid::getDomain(int domainIndex)", |
---|
| 337 | << "No domain associated to this grid. " << std::endl |
---|
| 338 | << "Grid id = " << this->getId()); |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | if (domainIndex >= domainListP.size() || (domainIndex < 0)) |
---|
| 342 | ERROR("CGrid::getDomain(int domainIndex)", |
---|
| 343 | << "Domain with the index doesn't exist " << std::endl |
---|
| 344 | << "Grid id = " << this->getId() << std::endl |
---|
| 345 | << "Grid has only " << domainListP.size() << " domain but domain index required is " << domainIndex << std::endl); |
---|
| 346 | |
---|
| 347 | return domainListP[domainIndex]; |
---|
| 348 | } |
---|
| 349 | CATCH_DUMP_ATTR |
---|
| 350 | |
---|
| 351 | /*! |
---|
| 352 | \brief Get the axis pointer with index |
---|
| 353 | \return axis pointer |
---|
| 354 | */ |
---|
| 355 | CAxis* CGrid::getAxis(int axisIndex) |
---|
| 356 | TRY |
---|
| 357 | { |
---|
| 358 | std::vector<CAxis*> axisListP = this->getAxis(); |
---|
| 359 | if (axisListP.empty()) |
---|
| 360 | { |
---|
| 361 | ERROR("CGrid::getDomain(int axisIndex)", |
---|
| 362 | << "No axis associated to this grid. " << std::endl |
---|
| 363 | << "Grid id = " << this->getId()); |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | if (axisIndex >= axisListP.size() || (axisIndex < 0)) |
---|
| 367 | ERROR("CGrid::getDomain(int axisIndex)", |
---|
| 368 | << "Domain with the index doesn't exist " << std::endl |
---|
| 369 | << "Grid id = " << this->getId() << std::endl |
---|
| 370 | << "Grid has only " << axisListP.size() << " axis but axis index required is " << axisIndex << std::endl); |
---|
| 371 | |
---|
| 372 | return axisListP[axisIndex]; |
---|
| 373 | } |
---|
| 374 | CATCH_DUMP_ATTR |
---|
| 375 | |
---|
| 376 | /*! |
---|
| 377 | \brief Get the a scalar pointer |
---|
| 378 | \return scalar pointer |
---|
| 379 | */ |
---|
| 380 | CScalar* CGrid::getScalar(int scalarIndex) |
---|
| 381 | TRY |
---|
| 382 | { |
---|
| 383 | std::vector<CScalar*> scalarListP = this->getScalars(); |
---|
| 384 | if (scalarListP.empty()) |
---|
| 385 | { |
---|
| 386 | ERROR("CGrid::getScalar(int scalarIndex)", |
---|
| 387 | << "No scalar associated to this grid. " << std::endl |
---|
| 388 | << "Grid id = " << this->getId()); |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | if (scalarIndex >= scalarListP.size() || (scalarIndex < 0)) |
---|
| 392 | ERROR("CGrid::getScalar(int scalarIndex)", |
---|
| 393 | << "Scalar with the index doesn't exist " << std::endl |
---|
| 394 | << "Grid id = " << this->getId() << std::endl |
---|
| 395 | << "Grid has only " << scalarListP.size() << " scalar but scalar index required is " << scalarIndex << std::endl); |
---|
| 396 | |
---|
| 397 | return scalarListP[scalarIndex]; |
---|
| 398 | } |
---|
| 399 | CATCH_DUMP_ATTR |
---|
| 400 | |
---|
| 401 | /*! |
---|
| 402 | \brief Set domain(s) of a grid from a list |
---|
| 403 | \param[in] domains list of domains |
---|
| 404 | */ |
---|
| 405 | void CGrid::setDomainList(const std::vector<CDomain*> domains) |
---|
| 406 | TRY |
---|
| 407 | { |
---|
| 408 | if (isDomListSet) return; |
---|
| 409 | std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren(); |
---|
| 410 | if (!domains.empty() && domList.empty()) |
---|
| 411 | { |
---|
| 412 | for (int i = 0; i < domains.size(); ++i) |
---|
| 413 | this->getVirtualDomainGroup()->addChild(domains[i]); |
---|
| 414 | domList = this->getVirtualDomainGroup()->getAllChildren(); |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | if (!domList.empty()) |
---|
| 418 | { |
---|
| 419 | int sizeDom = domList.size(); |
---|
| 420 | domList_.resize(sizeDom); |
---|
| 421 | for (int i = 0; i < sizeDom; ++i) |
---|
| 422 | { |
---|
| 423 | domList_[i] = domList[i]->getId(); |
---|
| 424 | } |
---|
| 425 | isDomListSet = true; |
---|
| 426 | } |
---|
| 427 | } |
---|
| 428 | CATCH_DUMP_ATTR |
---|
| 429 | |
---|
| 430 | /*! |
---|
| 431 | \brief Set axis(s) of a grid from a list |
---|
| 432 | \param[in] axis list of axis |
---|
| 433 | */ |
---|
| 434 | void CGrid::setAxisList(const std::vector<CAxis*> axis) |
---|
| 435 | TRY |
---|
| 436 | { |
---|
| 437 | if (isAxisListSet) return; |
---|
| 438 | std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren(); |
---|
| 439 | if (!axis.empty() && aList.empty()) |
---|
| 440 | { |
---|
| 441 | for (int i = 0; i < axis.size(); ++i) |
---|
| 442 | this->getVirtualAxisGroup()->addChild(axis[i]); |
---|
| 443 | aList = this->getVirtualAxisGroup()->getAllChildren(); |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | if (!aList.empty()) |
---|
| 447 | { |
---|
| 448 | int sizeAxis = aList.size(); |
---|
| 449 | axisList_.resize(sizeAxis); |
---|
| 450 | for (int i = 0; i < sizeAxis; ++i) |
---|
| 451 | { |
---|
| 452 | axisList_[i] = aList[i]->getId(); |
---|
| 453 | } |
---|
| 454 | isAxisListSet = true; |
---|
| 455 | } |
---|
| 456 | } |
---|
| 457 | CATCH_DUMP_ATTR |
---|
| 458 | |
---|
| 459 | /*! |
---|
| 460 | \brief Set scalar(s) of a grid from a list |
---|
| 461 | \param[in] scalars list of scalars |
---|
| 462 | */ |
---|
| 463 | void CGrid::setScalarList(const std::vector<CScalar*> scalars) |
---|
| 464 | TRY |
---|
| 465 | { |
---|
| 466 | if (isScalarListSet) return; |
---|
| 467 | std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren(); |
---|
| 468 | if (!scalars.empty() && sList.empty()) |
---|
| 469 | { |
---|
| 470 | for (int i = 0; i < scalars.size(); ++i) |
---|
| 471 | this->getVirtualScalarGroup()->addChild(scalars[i]); |
---|
| 472 | sList = this->getVirtualScalarGroup()->getAllChildren(); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | if (!sList.empty()) |
---|
| 476 | { |
---|
| 477 | int sizeScalar = sList.size(); |
---|
| 478 | scalarList_.resize(sizeScalar); |
---|
| 479 | for (int i = 0; i < sizeScalar; ++i) |
---|
| 480 | { |
---|
| 481 | scalarList_[i] = sList[i]->getId(); |
---|
| 482 | } |
---|
| 483 | isScalarListSet = true; |
---|
| 484 | } |
---|
| 485 | } |
---|
| 486 | CATCH_DUMP_ATTR |
---|
| 487 | |
---|
| 488 | /*! |
---|
| 489 | \brief Get list of id of domains |
---|
| 490 | \return id list of domains |
---|
| 491 | */ |
---|
| 492 | std::vector<StdString> CGrid::getDomainList() |
---|
| 493 | TRY |
---|
| 494 | { |
---|
| 495 | setDomainList(); |
---|
| 496 | return domList_; |
---|
| 497 | } |
---|
| 498 | CATCH |
---|
| 499 | |
---|
| 500 | /*! |
---|
| 501 | \brief Get list of id of axis |
---|
| 502 | \return id list of axis |
---|
| 503 | */ |
---|
| 504 | std::vector<StdString> CGrid::getAxisList() |
---|
| 505 | TRY |
---|
| 506 | { |
---|
| 507 | setAxisList(); |
---|
| 508 | return axisList_; |
---|
| 509 | } |
---|
| 510 | CATCH |
---|
| 511 | |
---|
| 512 | /*! |
---|
| 513 | \brief Get list of id of scalar |
---|
| 514 | \return id list of scalar |
---|
| 515 | */ |
---|
| 516 | std::vector<StdString> CGrid::getScalarList() |
---|
| 517 | TRY |
---|
| 518 | { |
---|
| 519 | setScalarList(); |
---|
| 520 | return scalarList_; |
---|
| 521 | } |
---|
| 522 | CATCH |
---|
| 523 | |
---|
| 524 | |
---|
| 525 | void CGrid::computeElements(void) |
---|
| 526 | { |
---|
| 527 | const auto& domains = getDomains() ; |
---|
| 528 | const auto& axis = getAxis() ; |
---|
| 529 | const auto& scalars = getScalars() ; |
---|
| 530 | int idxDomain = 0, idxAxis=0 , idxScalar=0 ; |
---|
| 531 | |
---|
[1984] | 532 | elements_.clear() ; |
---|
[1930] | 533 | for(auto type : order_) |
---|
| 534 | { |
---|
| 535 | if (type == 0) { elements_.push_back({scalars[idxScalar], TYPE_SCALAR, scalars[idxScalar], nullptr, nullptr } ) ; idxScalar++;} |
---|
| 536 | else if (type == 1) { elements_.push_back({axis[idxAxis], TYPE_AXIS, nullptr, axis[idxAxis], nullptr}) ; idxAxis++;} |
---|
| 537 | else if (type == 2) { elements_.push_back({domains[idxDomain], TYPE_DOMAIN, nullptr, nullptr, domains[idxDomain] }) ; idxDomain++;} |
---|
| 538 | } |
---|
| 539 | elementsComputed_ = true ; |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | |
---|
| 543 | /*! |
---|
| 544 | Parse a grid, for now, it contains only domain, axis and scalar |
---|
| 545 | */ |
---|
| 546 | void CGrid::parse(xml::CXMLNode& node) |
---|
| 547 | TRY |
---|
| 548 | { |
---|
| 549 | SuperClass::parse(node); |
---|
| 550 | |
---|
| 551 | if (node.goToChildElement()) |
---|
| 552 | { |
---|
| 553 | StdString domainName("domain"); |
---|
| 554 | StdString axisName("axis"); |
---|
| 555 | StdString scalarName("scalar"); |
---|
| 556 | do |
---|
| 557 | { |
---|
| 558 | if (node.getElementName() == domainName) { |
---|
| 559 | order_.push_back(2); |
---|
| 560 | this->getVirtualDomainGroup()->parseChild(node); |
---|
| 561 | } |
---|
| 562 | if (node.getElementName() == axisName) { |
---|
| 563 | order_.push_back(1); |
---|
| 564 | this->getVirtualAxisGroup()->parseChild(node); |
---|
| 565 | } |
---|
| 566 | if (node.getElementName() == scalarName) { |
---|
| 567 | order_.push_back(0); |
---|
| 568 | this->getVirtualScalarGroup()->parseChild(node); |
---|
| 569 | } |
---|
| 570 | } while (node.goToNextElement()); |
---|
| 571 | node.goToParentElement(); |
---|
| 572 | } |
---|
| 573 | |
---|
| 574 | if (!order_.empty()) |
---|
| 575 | { |
---|
| 576 | int sizeOrd = order_.size(); |
---|
| 577 | axis_domain_order.resize(sizeOrd); |
---|
| 578 | for (int i = 0; i < sizeOrd; ++i) |
---|
| 579 | { |
---|
| 580 | axis_domain_order(i) = order_[i]; |
---|
| 581 | } |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | setDomainList(); |
---|
| 585 | setAxisList(); |
---|
| 586 | setScalarList(); |
---|
[1984] | 587 | computeElements() ; |
---|
[1930] | 588 | } |
---|
| 589 | CATCH_DUMP_ATTR |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 593 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 594 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 595 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 596 | |
---|
| 597 | |
---|
| 598 | |
---|
[1158] | 599 | StdSize CGrid::getDimension(void) |
---|
[1622] | 600 | TRY |
---|
[219] | 601 | { |
---|
[1158] | 602 | return getGlobalDimension().size(); |
---|
[219] | 603 | } |
---|
[1622] | 604 | CATCH_DUMP_ATTR |
---|
[219] | 605 | |
---|
| 606 | //--------------------------------------------------------------- |
---|
| 607 | |
---|
[1869] | 608 | StdSize CGrid::getDataSize(void) |
---|
[1622] | 609 | TRY |
---|
[286] | 610 | { |
---|
[586] | 611 | StdSize retvalue = 1; |
---|
[600] | 612 | if (!isScalarGrid()) |
---|
| 613 | { |
---|
[1870] | 614 | std::vector<int> dataNindex = getClientDistribution()->getDataNIndex(); |
---|
[1250] | 615 | for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i]; |
---|
[600] | 616 | } |
---|
| 617 | return retvalue; |
---|
[286] | 618 | } |
---|
[1622] | 619 | CATCH |
---|
[1875] | 620 | |
---|
| 621 | /*! |
---|
| 622 | * Get the local data grid size, ie the size of the compressed grid (inside the workflow) |
---|
| 623 | * \return The size od the compressed grid |
---|
| 624 | */ |
---|
| 625 | StdSize CGrid::getLocalDataSize(void) { return getClientDistribution()->getLocalDataSize();} |
---|
[286] | 626 | |
---|
[1875] | 627 | |
---|
[731] | 628 | /*! |
---|
| 629 | * Compute the minimum buffer size required to send the attributes to the server(s). |
---|
| 630 | * |
---|
| 631 | * \return A map associating the server rank with its minimum buffer size. |
---|
[1099] | 632 | * TODO: Refactor code |
---|
[731] | 633 | */ |
---|
[1330] | 634 | std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting) |
---|
[1622] | 635 | TRY |
---|
[509] | 636 | { |
---|
[1330] | 637 | std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client); |
---|
[586] | 638 | |
---|
[731] | 639 | // The grid indexes require a similar size as the actual data |
---|
[1330] | 640 | std::map<int, StdSize> dataSizes = getDataBufferSize(client, "", bufferForWriting); |
---|
[1371] | 641 | std::map<int, StdSize>::iterator it, itE = dataSizes.end(); |
---|
| 642 | for (it = dataSizes.begin(); it != itE; ++it) |
---|
| 643 | { |
---|
| 644 | it->second += 2 * sizeof(bool); |
---|
| 645 | if (it->second > attributesSizes[it->first]) |
---|
| 646 | attributesSizes[it->first] = it->second; |
---|
| 647 | } |
---|
[1236] | 648 | |
---|
[731] | 649 | // Account for the axis attributes |
---|
| 650 | std::vector<CAxis*> axisList = getAxis(); |
---|
| 651 | for (size_t i = 0; i < axisList.size(); ++i) |
---|
[586] | 652 | { |
---|
[1870] | 653 | std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client, getGlobalDimension(),getAxisPositionInGrid()[i]); |
---|
[731] | 654 | for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it) |
---|
[586] | 655 | { |
---|
[1371] | 656 | it->second += 2 * sizeof(bool); |
---|
[731] | 657 | if (it->second > attributesSizes[it->first]) |
---|
| 658 | attributesSizes[it->first] = it->second; |
---|
[586] | 659 | } |
---|
| 660 | } |
---|
| 661 | |
---|
[731] | 662 | // Account for the domain attributes |
---|
| 663 | std::vector<CDomain*> domList = getDomains(); |
---|
| 664 | for (size_t i = 0; i < domList.size(); ++i) |
---|
[657] | 665 | { |
---|
[1236] | 666 | std::map<int, StdSize> domAttBuffSize = domList[i]->getAttributesBufferSize(client); |
---|
[731] | 667 | for (it = domAttBuffSize.begin(), itE = domAttBuffSize.end(); it != itE; ++it) |
---|
[657] | 668 | { |
---|
[1371] | 669 | it->second += 2 * sizeof(bool); |
---|
[731] | 670 | if (it->second > attributesSizes[it->first]) |
---|
| 671 | attributesSizes[it->first] = it->second; |
---|
[657] | 672 | } |
---|
| 673 | } |
---|
[742] | 674 | |
---|
[731] | 675 | return attributesSizes; |
---|
[1236] | 676 | } |
---|
[1622] | 677 | CATCH_DUMP_ATTR |
---|
[657] | 678 | |
---|
[731] | 679 | /*! |
---|
[1263] | 680 | * Compute the minimum buffer size required to send the data. |
---|
| 681 | * \param client contextClient used to determine the size of connected receivers |
---|
[731] | 682 | * \param id the id used to tag the data |
---|
[1330] | 683 | * \param bufferForWriting flag indicating if a buffer is used to send data for writing |
---|
[1263] | 684 | * \return A map associating the sender rank with its minimum buffer size. |
---|
[731] | 685 | */ |
---|
[1330] | 686 | std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/) |
---|
[1622] | 687 | TRY |
---|
[1099] | 688 | { |
---|
[739] | 689 | // The record index is sometimes sent along with the data but we always |
---|
| 690 | // include it in the size calculation for the sake of simplicity |
---|
[1232] | 691 | const size_t extraSize = CEventClient::headerSize + (id.empty() ? getId() : id).size() |
---|
| 692 | + 2 * sizeof(size_t) |
---|
| 693 | + sizeof(size_t); |
---|
[1236] | 694 | |
---|
| 695 | std::map<int, StdSize> dataSizes; |
---|
[1263] | 696 | int receiverSize = client->serverSize; |
---|
[1330] | 697 | std::map<int,size_t>& dataSizeMap = bufferForWriting ? connectedDataSize_[receiverSize]: connectedDataSizeRead_; |
---|
| 698 | std::vector<int>& connectedServerRanks = bufferForWriting ? connectedServerRank_[receiverSize] : connectedServerRankRead_; |
---|
| 699 | |
---|
| 700 | std::map<int, size_t>::const_iterator itEnd = dataSizeMap.end(); |
---|
| 701 | for (size_t k = 0; k < connectedServerRanks.size(); ++k) |
---|
[764] | 702 | { |
---|
[1330] | 703 | int rank = connectedServerRanks[k]; |
---|
| 704 | std::map<int, size_t>::const_iterator it = dataSizeMap.find(rank); |
---|
[1236] | 705 | size_t count = (it != itEnd) ? it->second : 0; |
---|
[731] | 706 | |
---|
[1236] | 707 | dataSizes.insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); |
---|
[764] | 708 | } |
---|
| 709 | |
---|
[731] | 710 | return dataSizes; |
---|
[509] | 711 | } |
---|
[1622] | 712 | CATCH_DUMP_ATTR |
---|
[509] | 713 | |
---|
[1215] | 714 | size_t CGrid::getGlobalWrittenSize(void) |
---|
[1622] | 715 | TRY |
---|
[1215] | 716 | { |
---|
| 717 | std::vector<CDomain*> domainP = this->getDomains(); |
---|
| 718 | std::vector<CAxis*> axisP = this->getAxis(); |
---|
| 719 | |
---|
| 720 | size_t globalGridSize=1 ; |
---|
| 721 | for (std::vector<CDomain*>::iterator it=domainP.begin(); it!=domainP.end();++it) globalGridSize*=(*it)->getGlobalWrittenSize() ; |
---|
| 722 | for (std::vector<CAxis*>::iterator it=axisP.begin(); it!=axisP.end();++it) globalGridSize*=(*it)->getGlobalWrittenSize() ; |
---|
| 723 | return globalGridSize ; |
---|
| 724 | } |
---|
[1622] | 725 | CATCH_DUMP_ATTR |
---|
[1215] | 726 | |
---|
[1870] | 727 | |
---|
| 728 | void CGrid::computeAxisPositionInGrid(void) |
---|
| 729 | { |
---|
| 730 | axisPositionInGrid_.resize(0); |
---|
| 731 | int idx = 0; |
---|
| 732 | for (int i = 0; i < axis_domain_order.numElements(); ++i) |
---|
| 733 | { |
---|
| 734 | int elementDimension = axis_domain_order(i); |
---|
| 735 | if (1 == elementDimension) |
---|
| 736 | { |
---|
| 737 | axisPositionInGrid_.push_back(idx); |
---|
| 738 | ++idx; |
---|
| 739 | } |
---|
| 740 | else if (2 == elementDimension) idx += 2; |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | |
---|
[1974] | 744 | |
---|
[676] | 745 | /*! |
---|
| 746 | * Test whether the data defined on the grid can be outputted in a compressed way. |
---|
[720] | 747 | * |
---|
[676] | 748 | * \return true if and only if a mask was defined for this grid |
---|
| 749 | */ |
---|
| 750 | bool CGrid::isCompressible(void) const |
---|
[1622] | 751 | TRY |
---|
[676] | 752 | { |
---|
| 753 | return isCompressible_; |
---|
| 754 | } |
---|
[1622] | 755 | CATCH |
---|
[676] | 756 | |
---|
| 757 | //--------------------------------------------------------------- |
---|
| 758 | |
---|
| 759 | void CGrid::addRelFileCompressed(const StdString& filename) |
---|
[1622] | 760 | TRY |
---|
[676] | 761 | { |
---|
| 762 | this->relFilesCompressed.insert(filename); |
---|
| 763 | } |
---|
[1622] | 764 | CATCH_DUMP_ATTR |
---|
[676] | 765 | |
---|
| 766 | bool CGrid::isWrittenCompressed(const StdString& filename) const |
---|
[1622] | 767 | TRY |
---|
[676] | 768 | { |
---|
| 769 | return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end()); |
---|
| 770 | } |
---|
[1622] | 771 | CATCH |
---|
[676] | 772 | |
---|
| 773 | //--------------------------------------------------------------- |
---|
[1236] | 774 | /* |
---|
| 775 | Find all reference of grid's components and inherite attributes if necessary |
---|
| 776 | */ |
---|
[509] | 777 | void CGrid::solveDomainAxisRef(bool areAttributesChecked) |
---|
[1622] | 778 | TRY |
---|
[219] | 779 | { |
---|
[509] | 780 | if (this->isDomainAxisChecked) return; |
---|
[369] | 781 | |
---|
[887] | 782 | this->solveScalarRef(areAttributesChecked); |
---|
[584] | 783 | this->solveAxisRef(areAttributesChecked); |
---|
[1158] | 784 | this->solveDomainRef(areAttributesChecked); |
---|
[509] | 785 | this->isDomainAxisChecked = areAttributesChecked; |
---|
| 786 | } |
---|
[1622] | 787 | CATCH_DUMP_ATTR |
---|
[509] | 788 | |
---|
[1236] | 789 | /* |
---|
| 790 | Go up hierachy reference and fill in the base reference with attributes of the children |
---|
| 791 | This function should be only used after reading component's attributes from file |
---|
| 792 | */ |
---|
[775] | 793 | void CGrid::solveDomainAxisBaseRef() |
---|
[1622] | 794 | TRY |
---|
[775] | 795 | { |
---|
| 796 | if (this->hasDomainAxisBaseRef_) return; |
---|
[887] | 797 | // Account for the scalar attributes |
---|
| 798 | std::vector<CScalar*> scalarList = getScalars(); |
---|
| 799 | for (size_t i = 0; i < scalarList.size(); ++i) |
---|
| 800 | { |
---|
| 801 | scalarList[i]->setAttributesReference(); |
---|
| 802 | } |
---|
| 803 | |
---|
[775] | 804 | // Account for the axis attributes |
---|
| 805 | std::vector<CAxis*> axisList = getAxis(); |
---|
| 806 | for (size_t i = 0; i < axisList.size(); ++i) |
---|
| 807 | { |
---|
[777] | 808 | axisList[i]->setAttributesReference(); |
---|
[775] | 809 | } |
---|
| 810 | |
---|
| 811 | // Account for the domain attributes |
---|
| 812 | std::vector<CDomain*> domList = getDomains(); |
---|
| 813 | for (size_t i = 0; i < domList.size(); ++i) |
---|
| 814 | { |
---|
[777] | 815 | domList[i]->setAttributesReference(); |
---|
[775] | 816 | } |
---|
[887] | 817 | |
---|
[775] | 818 | this->hasDomainAxisBaseRef_ = true; |
---|
| 819 | } |
---|
[1622] | 820 | CATCH_DUMP_ATTR |
---|
[775] | 821 | |
---|
[676] | 822 | void CGrid::checkEligibilityForCompressedOutput() |
---|
[1622] | 823 | TRY |
---|
[676] | 824 | { |
---|
| 825 | // We don't check if the mask is valid here, just if a mask has been defined at this point. |
---|
[817] | 826 | isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty(); |
---|
[676] | 827 | } |
---|
[1622] | 828 | CATCH_DUMP_ATTR |
---|
[676] | 829 | |
---|
[1875] | 830 | //ym obsolete -> to be removed later |
---|
[509] | 831 | void CGrid::checkMaskIndex(bool doSendingIndex) |
---|
[1622] | 832 | TRY |
---|
[509] | 833 | { |
---|
[650] | 834 | CContext* context = CContext::getCurrent(); |
---|
[1974] | 835 | |
---|
[1030] | 836 | if (this->isChecked) return; |
---|
[1974] | 837 | this->checkElementsAttributes(); |
---|
[2002] | 838 | this->isChecked = true; |
---|
[219] | 839 | } |
---|
[1622] | 840 | CATCH_DUMP_ATTR |
---|
[1784] | 841 | |
---|
| 842 | |
---|
[1637] | 843 | bool CGrid::hasMask() const |
---|
| 844 | TRY |
---|
| 845 | { |
---|
| 846 | return (!mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty() || |
---|
| 847 | !mask_4d.isEmpty() || !mask_5d.isEmpty() || !mask_6d.isEmpty() || !mask_7d.isEmpty()); |
---|
| 848 | } |
---|
| 849 | CATCH |
---|
[219] | 850 | |
---|
[1918] | 851 | |
---|
| 852 | CArray<bool,1>& CGrid::getMask(void) |
---|
| 853 | { |
---|
| 854 | |
---|
| 855 | if (mask_.isEmpty()) |
---|
| 856 | { |
---|
| 857 | if (!mask_0d.isEmpty()) mask_.reference(CArray<bool,1>(mask_0d.dataFirst(),shape(mask_0d.numElements()), neverDeleteData)) ; |
---|
| 858 | if (!mask_1d.isEmpty()) mask_.reference(CArray<bool,1>(mask_1d.dataFirst(),shape(mask_1d.numElements()), neverDeleteData)) ; |
---|
| 859 | if (!mask_2d.isEmpty()) mask_.reference(CArray<bool,1>(mask_2d.dataFirst(),shape(mask_2d.numElements()), neverDeleteData)) ; |
---|
| 860 | if (!mask_3d.isEmpty()) mask_.reference(CArray<bool,1>(mask_3d.dataFirst(),shape(mask_3d.numElements()), neverDeleteData)) ; |
---|
| 861 | if (!mask_4d.isEmpty()) mask_.reference(CArray<bool,1>(mask_4d.dataFirst(),shape(mask_4d.numElements()), neverDeleteData)) ; |
---|
| 862 | if (!mask_5d.isEmpty()) mask_.reference(CArray<bool,1>(mask_5d.dataFirst(),shape(mask_5d.numElements()), neverDeleteData)) ; |
---|
| 863 | if (!mask_6d.isEmpty()) mask_.reference(CArray<bool,1>(mask_6d.dataFirst(),shape(mask_6d.numElements()), neverDeleteData)) ; |
---|
| 864 | if (!mask_7d.isEmpty()) mask_.reference(CArray<bool,1>(mask_7d.dataFirst(),shape(mask_7d.numElements()), neverDeleteData)) ; |
---|
| 865 | } |
---|
| 866 | return mask_ ; |
---|
| 867 | } |
---|
[821] | 868 | |
---|
[1973] | 869 | |
---|
[219] | 870 | //--------------------------------------------------------------- |
---|
| 871 | |
---|
[509] | 872 | void CGrid::solveDomainRef(bool sendAtt) |
---|
[1622] | 873 | TRY |
---|
[219] | 874 | { |
---|
[540] | 875 | setDomainList(); |
---|
[567] | 876 | std::vector<CDomain*> domListP = this->getDomains(); |
---|
| 877 | if (!domListP.empty()) |
---|
[1974] | 878 | for (int i = 0; i < domListP.size(); ++i) domListP[i]->checkAttributes(); |
---|
[219] | 879 | } |
---|
[1622] | 880 | CATCH_DUMP_ATTR |
---|
[219] | 881 | |
---|
| 882 | //--------------------------------------------------------------- |
---|
| 883 | |
---|
[567] | 884 | void CGrid::solveAxisRef(bool sendAtt) |
---|
[1622] | 885 | TRY |
---|
[219] | 886 | { |
---|
[540] | 887 | setAxisList(); |
---|
[567] | 888 | std::vector<CAxis*> axisListP = this->getAxis(); |
---|
| 889 | if (!axisListP.empty()) |
---|
[1974] | 890 | for (int i = 0; i < axisListP.size(); ++i) axisListP[i]->checkAttributes(); |
---|
[219] | 891 | } |
---|
[1622] | 892 | CATCH_DUMP_ATTR |
---|
[219] | 893 | |
---|
[887] | 894 | //--------------------------------------------------------------- |
---|
| 895 | |
---|
| 896 | void CGrid::solveScalarRef(bool sendAtt) |
---|
[1622] | 897 | TRY |
---|
[887] | 898 | { |
---|
| 899 | setScalarList(); |
---|
| 900 | std::vector<CScalar*> scalarListP = this->getScalars(); |
---|
| 901 | if (!scalarListP.empty()) |
---|
[1974] | 902 | for (int i = 0; i < scalarListP.size(); ++i) scalarListP[i]->checkAttributes() ; |
---|
[887] | 903 | } |
---|
[1622] | 904 | CATCH_DUMP_ATTR |
---|
[887] | 905 | |
---|
[1973] | 906 | |
---|
| 907 | //--------------------------------------------------------------- |
---|
| 908 | CDistributionClient* CGrid::getClientDistribution() |
---|
[1622] | 909 | TRY |
---|
[1973] | 910 | { |
---|
| 911 | if (!computeClientDistribution_done_) computeClientDistribution() ; |
---|
| 912 | return clientDistribution_; |
---|
[1129] | 913 | } |
---|
[1622] | 914 | CATCH_DUMP_ATTR |
---|
[1869] | 915 | |
---|
| 916 | void CGrid::computeClientDistribution(void) |
---|
| 917 | { |
---|
| 918 | if (computeClientDistribution_done_) return ; |
---|
| 919 | else computeClientDistribution_done_ = true ; |
---|
| 920 | |
---|
| 921 | CContext* context = CContext::getCurrent(); |
---|
| 922 | int rank = context-> getIntraCommRank(); |
---|
| 923 | clientDistribution_ = new CDistributionClient(rank, this); |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | |
---|
[1870] | 927 | bool CGrid::isDataDistributed(void) |
---|
| 928 | { |
---|
| 929 | return getClientDistribution()->isDataDistributed() ; |
---|
| 930 | } |
---|
| 931 | |
---|
[1973] | 932 | |
---|
[219] | 933 | |
---|
[823] | 934 | CGrid* CGrid::cloneGrid(const StdString& idNewGrid, CGrid* gridSrc) |
---|
[1622] | 935 | TRY |
---|
[823] | 936 | { |
---|
[887] | 937 | std::vector<CDomain*> domainSrcTmp = gridSrc->getDomains(), domainSrc; |
---|
[823] | 938 | std::vector<CAxis*> axisSrcTmp = gridSrc->getAxis(), axisSrc; |
---|
[887] | 939 | std::vector<CScalar*> scalarSrcTmp = gridSrc->getScalars(), scalarSrc; |
---|
| 940 | |
---|
| 941 | for (int idx = 0; idx < domainSrcTmp.size(); ++idx) |
---|
| 942 | { |
---|
| 943 | CDomain* domain = CDomain::createDomain(); |
---|
| 944 | domain->duplicateAttributes(domainSrcTmp[idx]); |
---|
| 945 | domain->duplicateTransformation(domainSrcTmp[idx]); |
---|
| 946 | domain->solveRefInheritance(true); |
---|
| 947 | domain->solveInheritanceTransformation(); |
---|
| 948 | domainSrc.push_back(domain); |
---|
| 949 | } |
---|
| 950 | |
---|
[823] | 951 | for (int idx = 0; idx < axisSrcTmp.size(); ++idx) |
---|
| 952 | { |
---|
| 953 | CAxis* axis = CAxis::createAxis(); |
---|
| 954 | axis->duplicateAttributes(axisSrcTmp[idx]); |
---|
| 955 | axis->duplicateTransformation(axisSrcTmp[idx]); |
---|
| 956 | axis->solveRefInheritance(true); |
---|
| 957 | axis->solveInheritanceTransformation(); |
---|
| 958 | axisSrc.push_back(axis); |
---|
| 959 | } |
---|
| 960 | |
---|
[887] | 961 | for (int idx = 0; idx < scalarSrcTmp.size(); ++idx) |
---|
[823] | 962 | { |
---|
[887] | 963 | CScalar* scalar = CScalar::createScalar(); |
---|
| 964 | scalar->duplicateAttributes(scalarSrcTmp[idx]); |
---|
| 965 | scalar->duplicateTransformation(scalarSrcTmp[idx]); |
---|
| 966 | scalar->solveRefInheritance(true); |
---|
| 967 | scalar->solveInheritanceTransformation(); |
---|
| 968 | scalarSrc.push_back(scalar); |
---|
[823] | 969 | } |
---|
| 970 | |
---|
[887] | 971 | CGrid* grid = CGrid::createGrid(idNewGrid, domainSrc, axisSrc, scalarSrc, gridSrc->axis_domain_order); |
---|
[823] | 972 | |
---|
| 973 | return grid; |
---|
| 974 | } |
---|
[1622] | 975 | CATCH |
---|
[823] | 976 | |
---|
[745] | 977 | StdString CGrid::generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis, |
---|
[887] | 978 | const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder) |
---|
[1622] | 979 | TRY |
---|
[745] | 980 | { |
---|
[887] | 981 | if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size())) |
---|
[745] | 982 | ERROR("CGrid* CGrid::generateId(...)", |
---|
| 983 | << "The size of axisDomainOrder (" << axisDomainOrder.numElements() |
---|
| 984 | << ") is not coherent with the number of elements (" << domains.size() + axis.size() <<")."); |
---|
| 985 | |
---|
| 986 | std::ostringstream id; |
---|
| 987 | |
---|
[887] | 988 | if (domains.empty() && axis.empty() && !scalars.empty()) |
---|
| 989 | id << "__scalar_"; |
---|
| 990 | |
---|
| 991 | if (0 != (domains.size() + axis.size() + scalars.size())) |
---|
[745] | 992 | { |
---|
| 993 | id << "__grid"; |
---|
| 994 | |
---|
| 995 | if (0 == axisDomainOrder.numElements()) |
---|
| 996 | { |
---|
| 997 | for (size_t i = 0; i < domains.size(); ++i) id << "_" << domains[i]->getId(); |
---|
| 998 | for (size_t i = 0; i < axis.size(); ++i) id << "_" << axis[i]->getId(); |
---|
[887] | 999 | for (size_t i = 0; i < scalars.size(); ++i) id << "_" << scalars[i]->getId(); |
---|
[745] | 1000 | } |
---|
| 1001 | else |
---|
| 1002 | { |
---|
[887] | 1003 | size_t iDomain = 0, iAxis = 0, iScalar = 0; |
---|
[745] | 1004 | for (size_t i = 0; i < axisDomainOrder.numElements(); ++i) |
---|
| 1005 | { |
---|
[887] | 1006 | if (2 == axisDomainOrder(i)) |
---|
[745] | 1007 | id << "_" << domains[iDomain++]->getId(); |
---|
[887] | 1008 | else if (1 == axisDomainOrder(i)) |
---|
| 1009 | id << "_" << axis[iAxis++]->getId(); |
---|
[745] | 1010 | else |
---|
[887] | 1011 | id << "_" << scalars[iScalar++]->getId(); |
---|
[745] | 1012 | } |
---|
| 1013 | } |
---|
| 1014 | |
---|
| 1015 | id << "__"; |
---|
| 1016 | } |
---|
| 1017 | |
---|
| 1018 | return id.str(); |
---|
| 1019 | } |
---|
[1622] | 1020 | CATCH |
---|
[745] | 1021 | |
---|
[823] | 1022 | StdString CGrid::generateId(const CGrid* gridSrc, const CGrid* gridDest) |
---|
[1622] | 1023 | TRY |
---|
[823] | 1024 | { |
---|
| 1025 | StdString idSrc = gridSrc->getId(); |
---|
| 1026 | StdString idDest = gridDest->getId(); |
---|
| 1027 | |
---|
| 1028 | std::ostringstream id; |
---|
| 1029 | id << idSrc << "__" << idDest; |
---|
| 1030 | |
---|
| 1031 | return id.str(); |
---|
| 1032 | } |
---|
[1622] | 1033 | CATCH |
---|
[823] | 1034 | |
---|
[745] | 1035 | |
---|
[1158] | 1036 | //---------------------------------------------------------------- |
---|
| 1037 | |
---|
[1875] | 1038 | |
---|
[1871] | 1039 | |
---|
[1881] | 1040 | |
---|
[1158] | 1041 | /* |
---|
| 1042 | Compute on the fly the global dimension of a grid with its elements |
---|
| 1043 | \param[in/out] globalDim global dimension of grid |
---|
| 1044 | \param[in] domains list of its domains |
---|
| 1045 | \param[in] axiss list of its axis |
---|
| 1046 | \param[in] scalars list of its scalars |
---|
| 1047 | \param[in] axisDomainOrder the order of element in a grid (e.g: scalar then axis) |
---|
| 1048 | \return The dimension of which we do distribution (often for server) |
---|
| 1049 | */ |
---|
| 1050 | int CGrid::computeGridGlobalDimension(std::vector<int>& globalDim, |
---|
| 1051 | const std::vector<CDomain*> domains, |
---|
| 1052 | const std::vector<CAxis*> axis, |
---|
| 1053 | const std::vector<CScalar*> scalars, |
---|
| 1054 | const CArray<int,1>& axisDomainOrder) |
---|
[1622] | 1055 | TRY |
---|
| 1056 | { |
---|
[1311] | 1057 | // globalDim.resize(domains.size()*2+axis.size()+scalars.size()); |
---|
| 1058 | globalDim.resize(domains.size()*2+axis.size()); |
---|
[1158] | 1059 | int positionDimensionDistributed = 1; |
---|
[887] | 1060 | int idx = 0, idxDomain = 0, idxAxis = 0, idxScalar = 0; |
---|
[567] | 1061 | for (int i = 0; i < axisDomainOrder.numElements(); ++i) |
---|
| 1062 | { |
---|
[887] | 1063 | if (2 == axisDomainOrder(i)) |
---|
[567] | 1064 | { |
---|
[657] | 1065 | if (!(domains[idxDomain]->type.isEmpty()) && (domains[idxDomain]->type==CDomain::type_attr::unstructured)) |
---|
| 1066 | { |
---|
[1158] | 1067 | positionDimensionDistributed = idx; |
---|
[657] | 1068 | } |
---|
| 1069 | else |
---|
| 1070 | { |
---|
[1158] | 1071 | positionDimensionDistributed = idx +1; |
---|
[657] | 1072 | } |
---|
| 1073 | |
---|
[1158] | 1074 | globalDim[idx] = domains[idxDomain]->ni_glo.getValue(); |
---|
| 1075 | globalDim[idx+1] = domains[idxDomain]->nj_glo.getValue(); |
---|
[657] | 1076 | |
---|
[567] | 1077 | ++idxDomain; |
---|
| 1078 | idx += 2; |
---|
| 1079 | } |
---|
[887] | 1080 | else if (1 == axisDomainOrder(i)) |
---|
[567] | 1081 | { |
---|
[1158] | 1082 | globalDim[idx] = axis[idxAxis]->n_glo.getValue(); |
---|
[567] | 1083 | ++idxAxis; |
---|
| 1084 | ++idx; |
---|
| 1085 | } |
---|
[887] | 1086 | else |
---|
| 1087 | { |
---|
[1311] | 1088 | // globalDim[idx] = 1; |
---|
[887] | 1089 | ++idxScalar; |
---|
[1311] | 1090 | // ++idx; |
---|
[887] | 1091 | } |
---|
[567] | 1092 | } |
---|
[1158] | 1093 | |
---|
| 1094 | return positionDimensionDistributed; |
---|
[567] | 1095 | } |
---|
[1622] | 1096 | CATCH_DUMP_ATTR |
---|
[567] | 1097 | |
---|
[1158] | 1098 | // Retrieve the global dimension of grid |
---|
[567] | 1099 | std::vector<int> CGrid::getGlobalDimension() |
---|
[1622] | 1100 | TRY |
---|
[567] | 1101 | { |
---|
[1158] | 1102 | std::vector<int> globalDim; |
---|
| 1103 | computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order); |
---|
| 1104 | |
---|
| 1105 | return globalDim; |
---|
[567] | 1106 | } |
---|
[1622] | 1107 | CATCH_DUMP_ATTR |
---|
[567] | 1108 | |
---|
[1158] | 1109 | // Retrieve dimension on which we do distribution (Very often, it should be 2nd dimension) |
---|
| 1110 | int CGrid::getDistributedDimension() |
---|
[1622] | 1111 | TRY |
---|
[1158] | 1112 | { |
---|
| 1113 | std::vector<int> globalDim; |
---|
| 1114 | return computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order); |
---|
| 1115 | } |
---|
[1622] | 1116 | CATCH_DUMP_ATTR |
---|
[1158] | 1117 | |
---|
[600] | 1118 | bool CGrid::isScalarGrid() const |
---|
[1622] | 1119 | TRY |
---|
[600] | 1120 | { |
---|
| 1121 | return (axisList_.empty() && domList_.empty()); |
---|
| 1122 | } |
---|
[1622] | 1123 | CATCH |
---|
[600] | 1124 | |
---|
[567] | 1125 | /*! |
---|
| 1126 | Verify whether one server need to write data |
---|
| 1127 | There are some cases on which one server has nodata to write. For example, when we |
---|
[650] | 1128 | just only want to zoom on a domain. |
---|
[567] | 1129 | */ |
---|
| 1130 | bool CGrid::doGridHaveDataToWrite() |
---|
[1622] | 1131 | TRY |
---|
[567] | 1132 | { |
---|
[1930] | 1133 | return (0 != getGridLocalElements()->getView(CElementView::FULL)->getSize()); |
---|
[567] | 1134 | } |
---|
[1622] | 1135 | CATCH_DUMP_ATTR |
---|
[567] | 1136 | |
---|
[1973] | 1137 | |
---|
[1235] | 1138 | bool CGrid::doGridHaveDataDistributed(CContextClient* client) |
---|
[1622] | 1139 | TRY |
---|
[567] | 1140 | { |
---|
[1794] | 1141 | // This function is now useless because it will return false only if server and client size are equal to 1 |
---|
| 1142 | // to be seriously check in future |
---|
| 1143 | |
---|
[600] | 1144 | if (isScalarGrid()) return false; |
---|
[1235] | 1145 | else if (0 != client) |
---|
| 1146 | { |
---|
[1870] | 1147 | return (isDataDistributed() || (1 != client->clientSize) || (1 != client->serverSize)); |
---|
[1235] | 1148 | } |
---|
[586] | 1149 | else |
---|
[1870] | 1150 | return isDataDistributed(); |
---|
[567] | 1151 | } |
---|
[1622] | 1152 | CATCH_DUMP_ATTR |
---|
[567] | 1153 | |
---|
[540] | 1154 | /*! |
---|
| 1155 | \brief Dispatch event received from client |
---|
| 1156 | Whenever a message is received in buffer of server, it will be processed depending on |
---|
| 1157 | its event type. A new event type should be added in the switch list to make sure |
---|
| 1158 | it processed on server side. |
---|
| 1159 | \param [in] event: Received message |
---|
| 1160 | */ |
---|
[300] | 1161 | bool CGrid::dispatchEvent(CEventServer& event) |
---|
[1622] | 1162 | TRY |
---|
[300] | 1163 | { |
---|
[509] | 1164 | |
---|
[650] | 1165 | if (SuperClass::dispatchEvent(event)) return true; |
---|
[300] | 1166 | else |
---|
| 1167 | { |
---|
| 1168 | switch(event.type) |
---|
| 1169 | { |
---|
[540] | 1170 | case EVENT_ID_ADD_DOMAIN : |
---|
[650] | 1171 | recvAddDomain(event); |
---|
| 1172 | return true; |
---|
| 1173 | break; |
---|
[540] | 1174 | |
---|
| 1175 | case EVENT_ID_ADD_AXIS : |
---|
[650] | 1176 | recvAddAxis(event); |
---|
| 1177 | return true; |
---|
| 1178 | break; |
---|
[887] | 1179 | |
---|
| 1180 | case EVENT_ID_ADD_SCALAR : |
---|
| 1181 | recvAddScalar(event); |
---|
| 1182 | return true; |
---|
| 1183 | break; |
---|
[1943] | 1184 | |
---|
| 1185 | case EVENT_ID_SEND_MASK : |
---|
| 1186 | recvMask(event); |
---|
| 1187 | return true; |
---|
| 1188 | break; |
---|
[300] | 1189 | default : |
---|
[1943] | 1190 | ERROR("bool CGrid::dispatchEvent(CEventServer& event)", |
---|
[650] | 1191 | << "Unknown Event"); |
---|
| 1192 | return false; |
---|
[300] | 1193 | } |
---|
| 1194 | } |
---|
| 1195 | } |
---|
[1622] | 1196 | CATCH |
---|
[300] | 1197 | |
---|
[1930] | 1198 | |
---|
[219] | 1199 | |
---|
[1870] | 1200 | void CGrid::sendGridToFileServer(CContextClient* client) |
---|
| 1201 | { |
---|
| 1202 | if (sendGridToFileServer_done_.count(client)!=0) return ; |
---|
| 1203 | else sendGridToFileServer_done_.insert(client) ; |
---|
| 1204 | |
---|
| 1205 | StdString gridDefRoot("grid_definition"); |
---|
| 1206 | CGridGroup* gridPtr = CGridGroup::get(gridDefRoot); |
---|
| 1207 | gridPtr->sendCreateChild(this->getId(),client); |
---|
| 1208 | this->sendAllAttributesToServer(client); |
---|
[2022] | 1209 | distributeGridToServer(client) ; |
---|
[1870] | 1210 | } |
---|
| 1211 | |
---|
[1930] | 1212 | |
---|
[2022] | 1213 | void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId) |
---|
[1930] | 1214 | { |
---|
[2022] | 1215 | if (sendGridToCouplerOut_done_.count(client)!=0) return ; |
---|
| 1216 | else sendGridToCouplerOut_done_.insert(client) ; |
---|
| 1217 | this->sendAllAttributesToServer(client, getCouplingAlias(fieldId)); |
---|
| 1218 | distributeGridToServer(client,fieldId) ; |
---|
| 1219 | } |
---|
| 1220 | |
---|
| 1221 | |
---|
| 1222 | void CGrid::distributeGridToServer(CContextClient* client, const string& fieldId) |
---|
| 1223 | { |
---|
[1930] | 1224 | CContext* context = CContext::getCurrent(); |
---|
[2022] | 1225 | bool isCoupling = !fieldId.empty() ; |
---|
[1930] | 1226 | // simple Distribution for now |
---|
| 1227 | // distribute over the fisrt element except if it is a scalar |
---|
| 1228 | auto& elements = getElements() ; |
---|
| 1229 | int posDistributed = 0 ; |
---|
| 1230 | for(auto& element : elements) |
---|
| 1231 | { |
---|
| 1232 | if (element.type==TYPE_DOMAIN) break ; |
---|
| 1233 | else if (element.type==TYPE_AXIS) break ; |
---|
| 1234 | else if (element.type==TYPE_SCALAR) posDistributed++ ; |
---|
| 1235 | } |
---|
| 1236 | |
---|
| 1237 | vector<CLocalView*> localViews ; |
---|
| 1238 | vector<CDistributedView*> remoteViews ; |
---|
| 1239 | |
---|
| 1240 | for(int i=0 ; i<elements.size() ; i++) |
---|
| 1241 | { |
---|
| 1242 | if (elements[i].type==TYPE_DOMAIN) |
---|
| 1243 | { |
---|
| 1244 | CDomain* domain = (CDomain*) elements[i].ptr ; |
---|
| 1245 | domain->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ; |
---|
| 1246 | remoteViews.push_back(domain->getRemoteElement(client)->getView(CElementView::FULL)) ; |
---|
| 1247 | localViews.push_back(domain->getLocalView(CElementView::FULL)) ; |
---|
| 1248 | } |
---|
| 1249 | else if (elements[i].type==TYPE_AXIS) |
---|
| 1250 | { |
---|
| 1251 | CAxis* axis = (CAxis*) elements[i].ptr ; |
---|
| 1252 | axis->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ; |
---|
| 1253 | remoteViews.push_back(axis->getRemoteElement(client)->getView(CElementView::FULL)) ; |
---|
| 1254 | localViews.push_back(axis->getLocalView(CElementView::FULL)) ; |
---|
| 1255 | } |
---|
| 1256 | else if (elements[i].type==TYPE_SCALAR) |
---|
| 1257 | { |
---|
| 1258 | CScalar* scalar = (CScalar*) elements[i].ptr ; |
---|
| 1259 | scalar->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ; |
---|
| 1260 | remoteViews.push_back(scalar->getRemoteElement(client)->getView(CElementView::FULL)) ; |
---|
| 1261 | localViews.push_back(scalar->getLocalView(CElementView::FULL)) ; |
---|
| 1262 | } |
---|
| 1263 | } |
---|
[1938] | 1264 | CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm(), client->getRemoteSize()) ; |
---|
[1930] | 1265 | gridRemoteConnector.computeConnector() ; |
---|
| 1266 | |
---|
[1943] | 1267 | vector<CScattererConnector*> scattererConnectors ; |
---|
[1956] | 1268 | CScattererConnector* scattererConnector; |
---|
[1930] | 1269 | for(int i=0 ; i<elements.size() ; i++) |
---|
| 1270 | { |
---|
| 1271 | if (elements[i].type==TYPE_DOMAIN) |
---|
| 1272 | { |
---|
[2022] | 1273 | CDomain* domain = (CDomain*) elements[i].ptr ; |
---|
| 1274 | if (isCoupling) domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector, domain->getCouplingAlias(fieldId,i)) ; |
---|
| 1275 | else |
---|
| 1276 | { |
---|
| 1277 | sendAddDomain(domain->getId(),client) ; |
---|
| 1278 | domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; |
---|
| 1279 | } |
---|
| 1280 | scattererConnectors.push_back(scattererConnector) ; |
---|
[1930] | 1281 | } |
---|
| 1282 | else if (elements[i].type==TYPE_AXIS) |
---|
| 1283 | { |
---|
| 1284 | CAxis* axis = (CAxis*) elements[i].ptr ; |
---|
[2022] | 1285 | if (isCoupling) axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector, axis->getCouplingAlias(fieldId,i)) ; |
---|
| 1286 | else |
---|
| 1287 | { |
---|
| 1288 | sendAddAxis(axis->getId(),client) ; |
---|
| 1289 | axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; |
---|
| 1290 | } |
---|
[1956] | 1291 | scattererConnectors.push_back(scattererConnector) ; |
---|
[1930] | 1292 | } |
---|
| 1293 | else if (elements[i].type==TYPE_SCALAR) |
---|
| 1294 | { |
---|
| 1295 | CScalar* scalar = (CScalar*) elements[i].ptr ; |
---|
[2022] | 1296 | if (isCoupling) scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector, scalar->getCouplingAlias(fieldId,i)) ; |
---|
| 1297 | else |
---|
| 1298 | { |
---|
| 1299 | sendAddScalar(scalar->getId(),client) ; |
---|
| 1300 | scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ; |
---|
| 1301 | } |
---|
[1956] | 1302 | scattererConnectors.push_back(scattererConnector) ; |
---|
[1930] | 1303 | } |
---|
| 1304 | } |
---|
[1943] | 1305 | |
---|
| 1306 | CGridScattererConnector gridScattererConnector(scattererConnectors) ; |
---|
| 1307 | CGridLocalConnector* workflowToFull = getGridLocalElements()->getConnector(CElementView::WORKFLOW, CElementView::FULL) ; |
---|
| 1308 | CArray<bool,1> maskIn(workflowToFull->getSrcSize()) ; |
---|
| 1309 | CArray<bool,1> maskOut(workflowToFull->getDstSize()) ; |
---|
| 1310 | maskIn = true ; |
---|
| 1311 | workflowToFull->transfer(maskIn,maskOut,false) ; |
---|
| 1312 | |
---|
| 1313 | CEventClient event(getType(), EVENT_ID_SEND_MASK); |
---|
| 1314 | CMessage message ; |
---|
[2022] | 1315 | if (isCoupling) message<<getCouplingAlias(fieldId) ; |
---|
| 1316 | else message<<getId() ; |
---|
[1943] | 1317 | gridScattererConnector.transfer(maskOut, client, event, message) ; |
---|
[1956] | 1318 | for(auto& it : scattererConnectors) delete it ; |
---|
[1943] | 1319 | |
---|
| 1320 | vector<CScattererConnector*> clientToServerConnectors ; |
---|
| 1321 | vector<CGathererConnector*> clientFromServerConnectors ; |
---|
| 1322 | for(auto& element : elements) |
---|
| 1323 | { |
---|
| 1324 | if (element.type==TYPE_DOMAIN) |
---|
| 1325 | { |
---|
| 1326 | clientToServerConnectors.push_back(element.domain->getClientToServerConnector(client)) ; |
---|
| 1327 | clientFromServerConnectors.push_back(element.domain->getClientFromServerConnector(client)) ; |
---|
| 1328 | } |
---|
| 1329 | else if (element.type==TYPE_AXIS) |
---|
| 1330 | { |
---|
| 1331 | clientToServerConnectors.push_back(element.axis->getClientToServerConnector(client)) ; |
---|
| 1332 | clientFromServerConnectors.push_back(element.axis->getClientFromServerConnector(client)) ; |
---|
| 1333 | |
---|
| 1334 | } |
---|
| 1335 | else if (element.type==TYPE_SCALAR) |
---|
| 1336 | { |
---|
| 1337 | clientToServerConnectors.push_back(element.scalar->getClientToServerConnector(client)) ; |
---|
| 1338 | clientFromServerConnectors.push_back(element.scalar->getClientFromServerConnector(client)) ; |
---|
| 1339 | } |
---|
| 1340 | } |
---|
[1930] | 1341 | |
---|
| 1342 | // compute the grid clientToServerConnector to send flux from client to servers |
---|
| 1343 | clientToServerConnector_[client] = new CGridScattererConnector(clientToServerConnectors) ; |
---|
[1934] | 1344 | clientFromServerConnector_[client] = new CGridGathererConnector(clientFromServerConnectors) ; |
---|
[1930] | 1345 | |
---|
| 1346 | } |
---|
| 1347 | |
---|
[2022] | 1348 | |
---|
[1943] | 1349 | void CGrid::recvMask(CEventServer& event) |
---|
| 1350 | { |
---|
| 1351 | string gridId; |
---|
| 1352 | for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> gridId ; |
---|
| 1353 | get(gridId)->receiveMask(event); |
---|
| 1354 | } |
---|
| 1355 | |
---|
| 1356 | void CGrid::receiveMask(CEventServer& event) |
---|
| 1357 | { |
---|
| 1358 | vector<CGathererConnector*> gathererConnectors ; |
---|
| 1359 | vector<CLocalView*> fullViews ; |
---|
[1930] | 1360 | |
---|
[1943] | 1361 | for(auto& element : getElements()) |
---|
| 1362 | { |
---|
| 1363 | if (element.type==TYPE_DOMAIN) |
---|
| 1364 | { |
---|
| 1365 | gathererConnectors.push_back(element.domain->getGathererConnector()); |
---|
| 1366 | fullViews.push_back(element.domain->getLocalElement()->getView(CElementView::FULL)); |
---|
| 1367 | |
---|
| 1368 | } |
---|
| 1369 | else if (element.type==TYPE_AXIS) |
---|
| 1370 | { |
---|
| 1371 | gathererConnectors.push_back(element.axis->getGathererConnector()); |
---|
| 1372 | fullViews.push_back(element.axis->getLocalElement()->getView(CElementView::FULL)); |
---|
| 1373 | } |
---|
| 1374 | else if (element.type==TYPE_SCALAR) |
---|
| 1375 | { |
---|
| 1376 | gathererConnectors.push_back(element.scalar->getGathererConnector()); |
---|
| 1377 | fullViews.push_back(element.scalar->getLocalElement()->getView(CElementView::FULL)); |
---|
| 1378 | } |
---|
| 1379 | } |
---|
| 1380 | CGridGathererConnector gridGathererConnector(gathererConnectors) ; |
---|
| 1381 | CGridMaskConnector gridMaskConnector(fullViews) ; |
---|
| 1382 | |
---|
| 1383 | CArray<bool,1> maskOut ; |
---|
[2011] | 1384 | gridGathererConnector.transfer_or(event,maskOut) ; |
---|
[1943] | 1385 | gridMaskConnector.computeConnector(maskOut) ; |
---|
| 1386 | |
---|
| 1387 | CContextClient* client = event.getContextServer()->getAssociatedClient() ; |
---|
| 1388 | int i=0 ; |
---|
| 1389 | for(auto& element : getElements()) |
---|
| 1390 | { |
---|
| 1391 | if (element.type==TYPE_DOMAIN) element.domain->setServerMask(gridMaskConnector.getElementMask(i),client); |
---|
| 1392 | else if (element.type==TYPE_AXIS) element.axis->setServerMask(gridMaskConnector.getElementMask(i),client); |
---|
| 1393 | else if (element.type==TYPE_SCALAR) element.scalar->setServerMask(gridMaskConnector.getElementMask(i),client); |
---|
| 1394 | i++ ; |
---|
| 1395 | } |
---|
| 1396 | } |
---|
| 1397 | |
---|
[2022] | 1398 | string CGrid::getCouplingAlias(const string& fieldId) |
---|
[1875] | 1399 | { |
---|
[2022] | 1400 | return "_grid_of_"+fieldId; |
---|
[1875] | 1401 | } |
---|
| 1402 | |
---|
| 1403 | void CGrid::makeAliasForCoupling(const string& fieldId) |
---|
| 1404 | { |
---|
[2022] | 1405 | string gridId=getCouplingAlias(fieldId) ; |
---|
[1875] | 1406 | createAlias(gridId) ; |
---|
| 1407 | |
---|
[2022] | 1408 | auto& elements = getElements() ; |
---|
| 1409 | for(int i=0 ; i<elements.size() ; i++) |
---|
| 1410 | { |
---|
| 1411 | if (elements[i].type==TYPE_DOMAIN) elements[i].domain->makeAliasForCoupling(fieldId, i); |
---|
| 1412 | else if (elements[i].type==TYPE_AXIS) elements[i].axis->makeAliasForCoupling(fieldId, i); |
---|
| 1413 | else if (elements[i].type==TYPE_SCALAR) elements[i].scalar->makeAliasForCoupling(fieldId, i); |
---|
| 1414 | } |
---|
[1875] | 1415 | } |
---|
| 1416 | |
---|
[540] | 1417 | /*! |
---|
| 1418 | \brief Send a message to create a domain on server side |
---|
| 1419 | \param[in] id String identity of domain that will be created on server |
---|
| 1420 | */ |
---|
[1784] | 1421 | void CGrid::sendAddDomain(const string& id, CContextClient* contextClient) |
---|
[1622] | 1422 | TRY |
---|
| 1423 | { |
---|
[1784] | 1424 | sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN, contextClient); |
---|
[540] | 1425 | } |
---|
[1622] | 1426 | CATCH_DUMP_ATTR |
---|
[540] | 1427 | |
---|
| 1428 | /*! |
---|
| 1429 | \brief Send a message to create an axis on server side |
---|
| 1430 | \param[in] id String identity of axis that will be created on server |
---|
| 1431 | */ |
---|
[1784] | 1432 | void CGrid::sendAddAxis(const string& id, CContextClient* contextClient) |
---|
[1622] | 1433 | TRY |
---|
[540] | 1434 | { |
---|
[1784] | 1435 | sendAddItem(id, (int)EVENT_ID_ADD_AXIS, contextClient); |
---|
[540] | 1436 | } |
---|
[1622] | 1437 | CATCH_DUMP_ATTR |
---|
[540] | 1438 | |
---|
| 1439 | /*! |
---|
[887] | 1440 | \brief Send a message to create a scalar on server side |
---|
| 1441 | \param[in] id String identity of scalar that will be created on server |
---|
| 1442 | */ |
---|
[1784] | 1443 | void CGrid::sendAddScalar(const string& id, CContextClient* contextClient) |
---|
[1622] | 1444 | TRY |
---|
[887] | 1445 | { |
---|
[1784] | 1446 | sendAddItem(id, (int)EVENT_ID_ADD_SCALAR, contextClient); |
---|
[887] | 1447 | } |
---|
[1622] | 1448 | CATCH_DUMP_ATTR |
---|
[887] | 1449 | |
---|
| 1450 | /*! |
---|
[540] | 1451 | \brief Receive a message annoucing the creation of a domain on server side |
---|
| 1452 | \param[in] event Received event |
---|
| 1453 | */ |
---|
| 1454 | void CGrid::recvAddDomain(CEventServer& event) |
---|
[1622] | 1455 | TRY |
---|
[540] | 1456 | { |
---|
| 1457 | |
---|
[650] | 1458 | CBufferIn* buffer = event.subEvents.begin()->buffer; |
---|
[540] | 1459 | string id; |
---|
[650] | 1460 | *buffer >> id; |
---|
| 1461 | get(id)->recvAddDomain(*buffer); |
---|
[540] | 1462 | } |
---|
[1622] | 1463 | CATCH |
---|
[540] | 1464 | |
---|
| 1465 | /*! |
---|
| 1466 | \brief Receive a message annoucing the creation of a domain on server side |
---|
| 1467 | \param[in] buffer Buffer containing message |
---|
| 1468 | */ |
---|
| 1469 | void CGrid::recvAddDomain(CBufferIn& buffer) |
---|
[1622] | 1470 | TRY |
---|
[540] | 1471 | { |
---|
[650] | 1472 | string id; |
---|
| 1473 | buffer >> id; |
---|
| 1474 | addDomain(id); |
---|
[540] | 1475 | } |
---|
[1622] | 1476 | CATCH_DUMP_ATTR |
---|
[540] | 1477 | |
---|
| 1478 | /*! |
---|
| 1479 | \brief Receive a message annoucing the creation of an axis on server side |
---|
| 1480 | \param[in] event Received event |
---|
| 1481 | */ |
---|
| 1482 | void CGrid::recvAddAxis(CEventServer& event) |
---|
[1622] | 1483 | TRY |
---|
[540] | 1484 | { |
---|
| 1485 | |
---|
[650] | 1486 | CBufferIn* buffer = event.subEvents.begin()->buffer; |
---|
[540] | 1487 | string id; |
---|
[650] | 1488 | *buffer >> id; |
---|
| 1489 | get(id)->recvAddAxis(*buffer); |
---|
[540] | 1490 | } |
---|
[1622] | 1491 | CATCH |
---|
[540] | 1492 | |
---|
| 1493 | /*! |
---|
| 1494 | \brief Receive a message annoucing the creation of an axis on server side |
---|
| 1495 | \param[in] buffer Buffer containing message |
---|
| 1496 | */ |
---|
| 1497 | void CGrid::recvAddAxis(CBufferIn& buffer) |
---|
[1622] | 1498 | TRY |
---|
[540] | 1499 | { |
---|
[650] | 1500 | string id; |
---|
| 1501 | buffer >> id; |
---|
| 1502 | addAxis(id); |
---|
[540] | 1503 | } |
---|
[1622] | 1504 | CATCH_DUMP_ATTR |
---|
[540] | 1505 | |
---|
[887] | 1506 | /*! |
---|
| 1507 | \brief Receive a message annoucing the creation of an scalar on server side |
---|
| 1508 | \param[in] event Received event |
---|
| 1509 | */ |
---|
| 1510 | void CGrid::recvAddScalar(CEventServer& event) |
---|
[1622] | 1511 | TRY |
---|
[887] | 1512 | { |
---|
| 1513 | |
---|
| 1514 | CBufferIn* buffer = event.subEvents.begin()->buffer; |
---|
| 1515 | string id; |
---|
| 1516 | *buffer >> id; |
---|
| 1517 | get(id)->recvAddScalar(*buffer); |
---|
| 1518 | } |
---|
[1622] | 1519 | CATCH |
---|
[887] | 1520 | |
---|
| 1521 | /*! |
---|
| 1522 | \brief Receive a message annoucing the creation of an scalar on server side |
---|
| 1523 | \param[in] buffer Buffer containing message |
---|
| 1524 | */ |
---|
| 1525 | void CGrid::recvAddScalar(CBufferIn& buffer) |
---|
[1622] | 1526 | TRY |
---|
[887] | 1527 | { |
---|
| 1528 | string id; |
---|
| 1529 | buffer >> id; |
---|
| 1530 | addScalar(id); |
---|
| 1531 | } |
---|
[1622] | 1532 | CATCH_DUMP_ATTR |
---|
[887] | 1533 | |
---|
[551] | 1534 | /*! |
---|
[1869] | 1535 | \brief Check if all elements of the grid are complete |
---|
| 1536 | Before make any grid processing, we must be sure that all grid information elements have |
---|
| 1537 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
| 1538 | other context (coupling) |
---|
| 1539 | */ |
---|
[1875] | 1540 | bool CGrid::isCompleted(void) |
---|
[1869] | 1541 | { |
---|
| 1542 | setDomainList(); |
---|
[1875] | 1543 | for (auto domainId : domList_) if (!CDomain::get(domainId)->isCompleted()) return false ; |
---|
[1869] | 1544 | setAxisList() ; |
---|
[1875] | 1545 | for (auto axisId : axisList_) if (!CAxis::get(axisId)->isCompleted()) return false ; |
---|
[1869] | 1546 | setScalarList() ; |
---|
[1875] | 1547 | for (auto scalarId : scalarList_) if (!CScalar::get(scalarId)->isCompleted()) return false ; |
---|
[1869] | 1548 | return true ; |
---|
| 1549 | } |
---|
| 1550 | |
---|
| 1551 | /*! |
---|
[1875] | 1552 | \brief impose that all elements of the grid are complete |
---|
| 1553 | Before make any grid processing, we must be sure that all grid information elements have |
---|
| 1554 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
| 1555 | other context (coupling) |
---|
| 1556 | */ |
---|
| 1557 | void CGrid::setCompleted(void) |
---|
| 1558 | { |
---|
| 1559 | setDomainList(); |
---|
| 1560 | for (auto domainId : domList_) CDomain::get(domainId)->setCompleted() ; |
---|
| 1561 | setAxisList() ; |
---|
| 1562 | for (auto axisId : axisList_) CAxis::get(axisId)->setCompleted() ; |
---|
| 1563 | setScalarList() ; |
---|
| 1564 | for (auto scalarId : scalarList_) CScalar::get(scalarId)->setCompleted() ; |
---|
| 1565 | } |
---|
| 1566 | |
---|
| 1567 | /*! |
---|
| 1568 | \brief impose that all elements of the grid are incomplete |
---|
| 1569 | Before make any grid processing, we must be sure that all grid information elements have |
---|
| 1570 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
| 1571 | other context (coupling) |
---|
| 1572 | */ |
---|
| 1573 | void CGrid::unsetCompleted(void) |
---|
| 1574 | { |
---|
| 1575 | setDomainList(); |
---|
| 1576 | for (auto domainId : domList_) CDomain::get(domainId)->unsetCompleted() ; |
---|
| 1577 | setAxisList() ; |
---|
| 1578 | for (auto axisId : axisList_) CAxis::get(axisId)->unsetCompleted() ; |
---|
| 1579 | setScalarList() ; |
---|
| 1580 | for (auto scalarId : scalarList_) CScalar::get(scalarId)->unsetCompleted() ; |
---|
| 1581 | } |
---|
| 1582 | |
---|
| 1583 | /*! |
---|
[551] | 1584 | \brief Solve domain and axis references |
---|
| 1585 | As field, domain and axis can refer to other domains or axis. In order to inherit correctly |
---|
| 1586 | all attributes from their parents, they should be processed with this function |
---|
| 1587 | \param[in] apply inherit all attributes of parents (true) |
---|
| 1588 | */ |
---|
[1869] | 1589 | void CGrid::solveElementsRefInheritance(bool apply) |
---|
[1622] | 1590 | TRY |
---|
[540] | 1591 | { |
---|
| 1592 | setDomainList(); |
---|
[1869] | 1593 | for (auto domainId : domList_) |
---|
[540] | 1594 | { |
---|
[1869] | 1595 | CDomain* pDom = CDomain::get(domainId); |
---|
| 1596 | pDom->solveRefInheritance(apply); |
---|
| 1597 | pDom->solveInheritanceTransformation(); |
---|
[540] | 1598 | } |
---|
| 1599 | |
---|
| 1600 | setAxisList(); |
---|
[1869] | 1601 | for (auto axisId : axisList_) |
---|
[540] | 1602 | { |
---|
[1869] | 1603 | CAxis* pAxis = CAxis::get(axisId); |
---|
| 1604 | pAxis->solveRefInheritance(apply); |
---|
| 1605 | pAxis->solveInheritanceTransformation(); |
---|
[540] | 1606 | } |
---|
[887] | 1607 | |
---|
| 1608 | setScalarList(); |
---|
[1869] | 1609 | for (auto scalarId : scalarList_) |
---|
[887] | 1610 | { |
---|
[1869] | 1611 | CScalar* pScalar = CScalar::get(scalarId); |
---|
| 1612 | pScalar->solveRefInheritance(apply); |
---|
| 1613 | pScalar->solveInheritanceTransformation(); |
---|
[887] | 1614 | } |
---|
[540] | 1615 | } |
---|
[1622] | 1616 | CATCH_DUMP_ATTR |
---|
[540] | 1617 | |
---|
[1869] | 1618 | /*! |
---|
| 1619 | \brief check attributes of all elements of the grid |
---|
| 1620 | */ |
---|
| 1621 | void CGrid::checkElementsAttributes(void) |
---|
| 1622 | TRY |
---|
| 1623 | { |
---|
| 1624 | setDomainList(); |
---|
| 1625 | for (auto domainId : domList_) CDomain::get(domainId)->checkAttributes(); |
---|
| 1626 | |
---|
| 1627 | setAxisList(); |
---|
| 1628 | for (auto axisId : axisList_) CAxis::get(axisId)->checkAttributes(); |
---|
| 1629 | |
---|
| 1630 | setScalarList(); |
---|
| 1631 | for (auto scalarId : scalarList_) CScalar::get(scalarId)->checkAttributes(); |
---|
| 1632 | } |
---|
| 1633 | CATCH_DUMP_ATTR |
---|
| 1634 | |
---|
[619] | 1635 | |
---|
[1869] | 1636 | |
---|
[1984] | 1637 | //********************************************************** |
---|
| 1638 | //************** New transformation method ************** |
---|
| 1639 | //********************************************************** |
---|
| 1640 | |
---|
| 1641 | std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > |
---|
[1988] | 1642 | CGrid::buildTransformationGraph(CGarbageCollector& gc, bool isSource, CGrid* gridSrc, double detectMissingValues, double defaultValue, CGrid*& newGrid) |
---|
[1984] | 1643 | TRY |
---|
| 1644 | { |
---|
[2007] | 1645 | registerAlgorithmTransformation() ; // needed to enable self-registration of the transformations |
---|
| 1646 | // big mystery why it doesn't work witout that... |
---|
| 1647 | // problem with the linker ?? |
---|
[2011] | 1648 | |
---|
[1984] | 1649 | std::shared_ptr<CFilter> inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc)); |
---|
| 1650 | std::shared_ptr<CFilter> outputFilter = inputFilter ; |
---|
[2007] | 1651 | |
---|
| 1652 | |
---|
[1990] | 1653 | string newId ; |
---|
| 1654 | if (gridSrc!=nullptr) newId = gridSrc->getId() + " --> " + this->getId() ; |
---|
| 1655 | else newId = " --> " + this->getId() ; |
---|
| 1656 | bool isNewGrid ; |
---|
| 1657 | if (CGrid::has(newId)) |
---|
| 1658 | { |
---|
[2016] | 1659 | cout<<"Retrive existing grid : "<<newId<<endl ; |
---|
[1990] | 1660 | newGrid = CGrid::get(newId); |
---|
| 1661 | isNewGrid = false ; |
---|
| 1662 | } |
---|
| 1663 | else |
---|
| 1664 | { |
---|
[2016] | 1665 | cout<<"Create new grid : "<<newId<<endl ; |
---|
[1999] | 1666 | newGrid = CGrid::create(newId) ; |
---|
[1990] | 1667 | isNewGrid = true ; |
---|
| 1668 | } |
---|
| 1669 | |
---|
[1984] | 1670 | bool hadTransform=false ; |
---|
| 1671 | bool hasTransform=false ; |
---|
[1990] | 1672 | bool hasRemainTransform=false ; |
---|
[1984] | 1673 | CGenericAlgorithmTransformation* algo ; |
---|
[1999] | 1674 | int pos ; |
---|
[1984] | 1675 | |
---|
| 1676 | for(int i=0 ; i<elements_.size(); i++) |
---|
| 1677 | { |
---|
| 1678 | CTransformationPaths transformationPath ; |
---|
| 1679 | auto dstElement = elements_[i] ; |
---|
| 1680 | |
---|
| 1681 | if (dstElement.type==TYPE_DOMAIN) transformationPath = dstElement.domain->getTransformationPaths() ; |
---|
| 1682 | else if (dstElement.type==TYPE_AXIS) transformationPath = dstElement.axis->getTransformationPaths() ; |
---|
| 1683 | else if (dstElement.type==TYPE_SCALAR) transformationPath = dstElement.scalar->getTransformationPaths() ; |
---|
| 1684 | |
---|
| 1685 | SElement srcElement ; |
---|
| 1686 | if (gridSrc==nullptr) srcElement = this->elements_[i] ; |
---|
| 1687 | else srcElement = gridSrc->elements_[i] ; |
---|
| 1688 | |
---|
| 1689 | if (gridSrc==nullptr) transformationPath.mergePaths() ; |
---|
| 1690 | else |
---|
| 1691 | { |
---|
| 1692 | if (srcElement.type==TYPE_DOMAIN) transformationPath.mergePaths(srcElement.domain->getTransformationPaths()) ; |
---|
| 1693 | else if (srcElement.type==TYPE_AXIS) transformationPath.mergePaths(srcElement.axis->getTransformationPaths()) ; |
---|
| 1694 | else if (srcElement.type==TYPE_SCALAR) transformationPath.mergePaths(srcElement.scalar->getTransformationPaths()) ; |
---|
| 1695 | } |
---|
| 1696 | |
---|
| 1697 | hasTransform=transformationPath.hasTransform() ; |
---|
| 1698 | |
---|
| 1699 | if (hasTransform && !hadTransform) |
---|
| 1700 | { |
---|
[1999] | 1701 | pos=i ; |
---|
[1984] | 1702 | EElement dstElementType=transformationPath.getNextElementType() ; |
---|
| 1703 | string dstElementId=transformationPath.getNextElementId() ; |
---|
| 1704 | string srcElementId=transformationPath.getNextElementSrcId() ; |
---|
| 1705 | auto transType = transformationPath.getNextTransformationType() ; |
---|
| 1706 | auto transId = transformationPath.getNextTransformationId() ; |
---|
| 1707 | |
---|
| 1708 | CGrid* tmpGridSrc=CGrid::create(); // source grid |
---|
| 1709 | if (srcElement.type==TYPE_DOMAIN) tmpGridSrc->addDomain(srcElement.domain->getId()) ; |
---|
| 1710 | else if (srcElement.type==TYPE_AXIS) tmpGridSrc->addAxis(srcElement.axis->getId()) ; |
---|
| 1711 | else if (srcElement.type==TYPE_SCALAR) tmpGridSrc->addScalar(srcElement.scalar->getId()) ; |
---|
[2128] | 1712 | // WARNING -> suppress checkElement attribute ? What append ? |
---|
| 1713 | // tmpGridSrc->checkElementsAttributes() ; |
---|
[1984] | 1714 | CGrid* tmpGridDst=CGrid::create(); // destination Grid |
---|
| 1715 | map<int,int> posInGrid={{0,0}} ; |
---|
| 1716 | |
---|
| 1717 | cout<<"--> New transform from "<<srcElementId<<" to "<<dstElementId<<endl ; |
---|
| 1718 | if (dstElementType==EElement::DOMAIN) |
---|
| 1719 | { |
---|
| 1720 | CDomain* dstDomain ; |
---|
[2016] | 1721 | CDomain* lastDstDomain ; |
---|
| 1722 | bool isGenerate=false ; |
---|
| 1723 | |
---|
| 1724 | do |
---|
[1984] | 1725 | { |
---|
| 1726 | |
---|
[2016] | 1727 | if (CDomain::has(dstElementId)) |
---|
| 1728 | { |
---|
| 1729 | dstDomain = CDomain::get(dstElementId) ; |
---|
| 1730 | cout<<"Retrive existing domain : "<<dstElementId<<endl ; |
---|
| 1731 | } |
---|
| 1732 | else |
---|
| 1733 | { |
---|
| 1734 | dstDomain = CDomain::create() ; |
---|
| 1735 | dstDomain->createAlias(dstElementId) ; |
---|
| 1736 | cout<<"Create new domain : "<<dstDomain->getId()<<" with alias : "<<dstElementId<<endl ; |
---|
| 1737 | |
---|
| 1738 | if (isGenerate) dstDomain->duplicateAttributes(lastDstDomain) ; |
---|
| 1739 | else if (srcElementId=="" && srcElement.type==TYPE_DOMAIN) dstDomain->duplicateAttributes(srcElement.domain) ; // make a copy |
---|
| 1740 | else dstDomain->duplicateAttributes(dstElement.domain) ; // make a copy |
---|
| 1741 | CTransformation<CDomain>* transformation = CTransformation<CDomain>::createTransformation(transType,"") ; |
---|
| 1742 | auto srcTransform = CTransformation<CDomain>::getTransformation(transType, transId) ; |
---|
| 1743 | transformation->inheritFrom(srcTransform) ; |
---|
| 1744 | CGrid* tmpGridDst=CGrid::create(); // destination Grid |
---|
| 1745 | tmpGridDst->addDomain(dstDomain->getId()) ; |
---|
| 1746 | |
---|
| 1747 | algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0, |
---|
| 1748 | posInGrid,posInGrid,posInGrid, |
---|
| 1749 | posInGrid,posInGrid,posInGrid ); |
---|
| 1750 | |
---|
| 1751 | |
---|
| 1752 | dstDomain->setTransformationAlgorithm(algo) ; |
---|
| 1753 | dstDomain->setTransformationPaths(transformationPath) ; |
---|
| 1754 | } |
---|
| 1755 | algo=dstDomain->getTransformationAlgorithm() ; |
---|
| 1756 | isGenerate = algo->isGenerateTransformation() ; |
---|
[1984] | 1757 | transformationPath.removeNextTransform() ; |
---|
[2016] | 1758 | dstElementId=transformationPath.getNextElementId() ; |
---|
| 1759 | srcElementId=transformationPath.getNextElementSrcId() ; |
---|
| 1760 | transType = transformationPath.getNextTransformationType() ; |
---|
| 1761 | transId = transformationPath.getNextTransformationId() ; |
---|
| 1762 | lastDstDomain=dstDomain ; |
---|
[1984] | 1763 | dstDomain->setTransformationPaths(transformationPath) ; |
---|
[2016] | 1764 | } while(transformationPath.hasTransform() && isGenerate) ; |
---|
| 1765 | |
---|
[1990] | 1766 | if (isNewGrid) newGrid->addDomain(dstDomain->getId()) ; |
---|
[1984] | 1767 | algo = dstDomain->getTransformationAlgorithm() ; |
---|
| 1768 | } |
---|
| 1769 | else if (dstElementType==EElement::AXIS) |
---|
| 1770 | { |
---|
| 1771 | CAxis* dstAxis ; |
---|
[2016] | 1772 | CAxis* lastDstAxis ; |
---|
| 1773 | bool isGenerate=false ; |
---|
| 1774 | |
---|
| 1775 | do |
---|
[1984] | 1776 | { |
---|
[2016] | 1777 | if (CAxis::has(dstElementId)) |
---|
| 1778 | { |
---|
| 1779 | dstAxis = CAxis::get(dstElementId) ; |
---|
| 1780 | cout<<"Retrive existing axis : "<<dstElementId<<endl ; |
---|
| 1781 | } |
---|
| 1782 | else |
---|
| 1783 | { |
---|
| 1784 | dstAxis = CAxis::create() ; |
---|
| 1785 | dstAxis->createAlias(dstElementId) ; |
---|
| 1786 | cout<<"Create new axis : "<<dstAxis->getId()<<" with alias : "<<dstElementId<<endl ; |
---|
| 1787 | |
---|
| 1788 | if (isGenerate) dstAxis->duplicateAttributes(lastDstAxis) ; |
---|
| 1789 | else if (srcElementId=="" && srcElement.type==TYPE_AXIS) dstAxis->duplicateAttributes(srcElement.axis) ; // make a copy |
---|
| 1790 | else dstAxis->duplicateAttributes(dstElement.axis) ; // make a copy |
---|
| 1791 | CTransformation<CAxis>* transformation = CTransformation<CAxis>::createTransformation(transType,"") ; |
---|
| 1792 | auto srcTransform = CTransformation<CAxis>::getTransformation(transType, transId) ; |
---|
| 1793 | transformation->inheritFrom(srcTransform) ; |
---|
| 1794 | tmpGridDst->addAxis(dstAxis->getId()) ; |
---|
[1984] | 1795 | |
---|
[2016] | 1796 | algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0, |
---|
| 1797 | posInGrid,posInGrid,posInGrid, |
---|
| 1798 | posInGrid,posInGrid,posInGrid ); |
---|
[2011] | 1799 | |
---|
[2016] | 1800 | dstAxis->setTransformationAlgorithm(algo) ; |
---|
| 1801 | dstAxis->setTransformationPaths(transformationPath) ; |
---|
| 1802 | } |
---|
| 1803 | |
---|
| 1804 | algo=dstAxis->getTransformationAlgorithm() ; |
---|
| 1805 | isGenerate = algo->isGenerateTransformation() ; |
---|
[1984] | 1806 | transformationPath.removeNextTransform() ; |
---|
[2016] | 1807 | dstElementId=transformationPath.getNextElementId() ; |
---|
| 1808 | srcElementId=transformationPath.getNextElementSrcId() ; |
---|
| 1809 | transType = transformationPath.getNextTransformationType() ; |
---|
| 1810 | transId = transformationPath.getNextTransformationId() ; |
---|
| 1811 | lastDstAxis=dstAxis ; |
---|
[1984] | 1812 | dstAxis->setTransformationPaths(transformationPath) ; |
---|
[2016] | 1813 | } while(transformationPath.hasTransform() && isGenerate) ; |
---|
| 1814 | |
---|
| 1815 | if (isNewGrid) newGrid->addAxis(dstAxis->getId()) ; |
---|
[1984] | 1816 | algo = dstAxis->getTransformationAlgorithm() ; |
---|
| 1817 | } |
---|
| 1818 | else if (dstElementType==EElement::SCALAR) |
---|
| 1819 | { |
---|
| 1820 | CScalar* dstScalar ; |
---|
[2016] | 1821 | CScalar* lastDstScalar ; |
---|
| 1822 | bool isGenerate=false ; |
---|
| 1823 | |
---|
| 1824 | do |
---|
[1984] | 1825 | { |
---|
[2016] | 1826 | if (CScalar::has(dstElementId)) |
---|
| 1827 | { |
---|
| 1828 | dstScalar = CScalar::get(dstElementId) ; |
---|
| 1829 | cout<<"Retrive existing scalar : "<<dstElementId<<endl ; |
---|
| 1830 | } |
---|
| 1831 | else |
---|
| 1832 | { |
---|
| 1833 | dstScalar = CScalar::create() ; |
---|
| 1834 | dstScalar->createAlias(dstElementId) ; |
---|
| 1835 | cout<<"Create new scalar : "<<dstScalar->getId()<<" with alias : "<<dstElementId<<endl ; |
---|
| 1836 | |
---|
| 1837 | if (isGenerate) dstScalar->duplicateAttributes(lastDstScalar) ; |
---|
| 1838 | else if (srcElementId=="" && srcElement.type==TYPE_SCALAR) dstScalar->duplicateAttributes(srcElement.scalar) ; // make a copy |
---|
| 1839 | else dstScalar->duplicateAttributes(dstElement.scalar) ; // make a copy |
---|
| 1840 | CTransformation<CScalar>* transformation = CTransformation<CScalar>::createTransformation(transType,"") ; |
---|
| 1841 | auto srcTransform = CTransformation<CScalar>::getTransformation(transType, transId) ; |
---|
| 1842 | transformation->inheritFrom(srcTransform) ; |
---|
| 1843 | tmpGridDst->addScalar(dstScalar->getId()) ; |
---|
[1984] | 1844 | |
---|
[2016] | 1845 | algo = transformation -> createAlgorithm(false, tmpGridDst, tmpGridSrc, 0, |
---|
| 1846 | posInGrid,posInGrid,posInGrid, |
---|
| 1847 | posInGrid,posInGrid,posInGrid ); |
---|
| 1848 | |
---|
| 1849 | dstScalar->setTransformationAlgorithm(algo) ; |
---|
| 1850 | dstScalar->setTransformationPaths(transformationPath) ; |
---|
| 1851 | } |
---|
| 1852 | algo=dstScalar->getTransformationAlgorithm() ; |
---|
| 1853 | isGenerate = algo->isGenerateTransformation() ; |
---|
[1984] | 1854 | transformationPath.removeNextTransform() ; |
---|
[2016] | 1855 | dstElementId=transformationPath.getNextElementId() ; |
---|
| 1856 | srcElementId=transformationPath.getNextElementSrcId() ; |
---|
| 1857 | transType = transformationPath.getNextTransformationType() ; |
---|
| 1858 | transId = transformationPath.getNextTransformationId() ; |
---|
| 1859 | lastDstScalar=dstScalar ; |
---|
[1984] | 1860 | dstScalar->setTransformationPaths(transformationPath) ; |
---|
[2016] | 1861 | } while(transformationPath.hasTransform() && isGenerate) ; |
---|
| 1862 | |
---|
| 1863 | if (isNewGrid) newGrid->addScalar(dstScalar->getId()) ; |
---|
[1984] | 1864 | algo = dstScalar->getTransformationAlgorithm() ; |
---|
| 1865 | } |
---|
| 1866 | // here create a new spatial filter with algo |
---|
| 1867 | |
---|
| 1868 | hadTransform=true ; |
---|
| 1869 | hasTransform=false ; |
---|
| 1870 | } |
---|
| 1871 | else |
---|
| 1872 | { |
---|
| 1873 | string srcElementId=transformationPath.getNextElementSrcId() ; |
---|
[1994] | 1874 | |
---|
[1984] | 1875 | if (srcElement.type==TYPE_DOMAIN) |
---|
| 1876 | { |
---|
| 1877 | CDomain* domain ; |
---|
[1994] | 1878 | if (srcElementId=="") srcElementId=srcElement.domain->getId() ; |
---|
[1984] | 1879 | if (!CDomain::has(srcElementId)) |
---|
| 1880 | { |
---|
| 1881 | domain=srcElement.domain ; |
---|
| 1882 | domain->createAlias(srcElementId) ; |
---|
| 1883 | } |
---|
| 1884 | else domain = CDomain::get(srcElementId) ; |
---|
| 1885 | domain->checkAttributes() ; |
---|
| 1886 | |
---|
[1990] | 1887 | if (isNewGrid) newGrid->addDomain(srcElementId) ; |
---|
[1984] | 1888 | } |
---|
| 1889 | else if (srcElement.type==TYPE_AXIS) |
---|
| 1890 | { |
---|
| 1891 | CAxis* axis ; |
---|
[1994] | 1892 | if (srcElementId=="") srcElementId=srcElement.axis->getId() ; |
---|
[1984] | 1893 | if (!CAxis::has(srcElementId)) |
---|
| 1894 | { |
---|
| 1895 | axis=srcElement.axis ; |
---|
| 1896 | axis->createAlias(srcElementId) ; |
---|
| 1897 | } |
---|
| 1898 | else axis = CAxis::get(srcElementId) ; |
---|
| 1899 | axis->checkAttributes() ; |
---|
| 1900 | |
---|
[1990] | 1901 | if (isNewGrid) newGrid->addAxis(srcElementId) ; |
---|
[1984] | 1902 | } |
---|
| 1903 | else if (srcElement.type==TYPE_SCALAR) |
---|
| 1904 | { |
---|
| 1905 | CScalar* scalar ; |
---|
[1994] | 1906 | if (srcElementId=="") srcElementId=srcElement.scalar->getId() ; |
---|
[1984] | 1907 | if (!CScalar::has(srcElementId)) |
---|
| 1908 | { |
---|
| 1909 | scalar=srcElement.scalar ; |
---|
| 1910 | scalar->createAlias(srcElementId) ; |
---|
| 1911 | } |
---|
| 1912 | else scalar = CScalar::get(srcElementId) ; |
---|
| 1913 | scalar->checkAttributes() ; |
---|
| 1914 | |
---|
[1990] | 1915 | if (isNewGrid) newGrid->addScalar(srcElementId) ; |
---|
[1984] | 1916 | } |
---|
| 1917 | } |
---|
[1994] | 1918 | |
---|
| 1919 | if (transformationPath.hasTransform() && hadTransform) hasRemainTransform=true ; |
---|
[1984] | 1920 | } |
---|
| 1921 | |
---|
[1994] | 1922 | |
---|
[1984] | 1923 | if (hadTransform) |
---|
| 1924 | { |
---|
[2011] | 1925 | |
---|
[1988] | 1926 | if (!isSource) |
---|
| 1927 | { |
---|
[1999] | 1928 | CGridAlgorithm* gridAlgorithm ; |
---|
| 1929 | if (isNewGrid) |
---|
| 1930 | { |
---|
| 1931 | gridAlgorithm = algo->createGridAlgorithm(gridSrc, newGrid, pos) ; |
---|
| 1932 | newGrid->setGridAlgorithm(gridAlgorithm); |
---|
| 1933 | } |
---|
| 1934 | else gridAlgorithm = newGrid->getGridAlgorithm() ; |
---|
| 1935 | |
---|
[2007] | 1936 | shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(gridAlgorithm->createTransformFilter(gc, detectMissingValues, defaultValue)) ; |
---|
[1988] | 1937 | outputFilter->connectOutput(transformFilter,0) ; |
---|
[2011] | 1938 | vector<string> auxFieldId = algo->getAuxFieldId() ; // better to do that at transformation not algo ?? |
---|
| 1939 | int i=1; |
---|
| 1940 | for (auto& it : auxFieldId) |
---|
| 1941 | { |
---|
| 1942 | CField* auxField = CField::get(it) ; |
---|
| 1943 | auxField->buildWorkflowGraph(gc) ; |
---|
| 1944 | auxField->getInstantDataFilter()->connectOutput(transformFilter,i) ; |
---|
| 1945 | i++ ; |
---|
| 1946 | } |
---|
[1988] | 1947 | outputFilter = transformFilter ; |
---|
| 1948 | } |
---|
[1984] | 1949 | |
---|
[1990] | 1950 | if (hasRemainTransform) |
---|
| 1951 | { |
---|
| 1952 | gridSrc=newGrid ; |
---|
[1999] | 1953 | pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = this->buildTransformationGraph(gc, isSource, gridSrc, detectMissingValues, defaultValue, newGrid) ; |
---|
[1990] | 1954 | outputFilter->connectOutput(filters.first,0) ; |
---|
| 1955 | outputFilter=filters.second ; |
---|
| 1956 | } |
---|
[1984] | 1957 | } |
---|
| 1958 | |
---|
| 1959 | return {inputFilter,outputFilter} ; |
---|
| 1960 | } |
---|
| 1961 | CATCH_DUMP_ATTR |
---|
| 1962 | |
---|
| 1963 | |
---|
| 1964 | //**************************************************************** |
---|
| 1965 | //**************************************************************** |
---|
| 1966 | |
---|
| 1967 | //---------------------------------------------------------------- |
---|
| 1968 | |
---|
| 1969 | CGrid* CGrid::duplicateSentGrid(void) |
---|
| 1970 | { |
---|
| 1971 | CGrid* newGrid ; |
---|
| 1972 | string sentGridId="sent__"+getId() ; |
---|
| 1973 | if (has(sentGridId)) newGrid = get(sentGridId) ; |
---|
| 1974 | else |
---|
| 1975 | { |
---|
| 1976 | newGrid = CGrid::create(sentGridId) ; |
---|
| 1977 | for(auto element : elements_) |
---|
| 1978 | { |
---|
| 1979 | if (element.type==TYPE_DOMAIN) |
---|
| 1980 | { |
---|
| 1981 | CDomain* domain = CDomain::create(); |
---|
| 1982 | domain->duplicateAttributes(element.domain) ; |
---|
| 1983 | domain->name = element.domain->getId() ; |
---|
| 1984 | newGrid->addDomain(domain->getId()) ; |
---|
| 1985 | } |
---|
| 1986 | else if (element.type==TYPE_AXIS) |
---|
| 1987 | { |
---|
| 1988 | CAxis* axis = CAxis::create(); |
---|
| 1989 | axis->duplicateAttributes(element.axis) ; |
---|
| 1990 | axis->name = element.axis->getId() ; |
---|
| 1991 | newGrid->addAxis(axis->getId()) ; |
---|
| 1992 | } |
---|
| 1993 | else if (element.type==TYPE_SCALAR) |
---|
| 1994 | { |
---|
| 1995 | CScalar* scalar = CScalar::create(); |
---|
| 1996 | scalar->duplicateAttributes(element.scalar) ; |
---|
| 1997 | scalar->name = element.scalar->getId() ; |
---|
| 1998 | newGrid->addScalar(scalar->getId()) ; |
---|
| 1999 | } |
---|
| 2000 | } |
---|
| 2001 | newGrid->checkElementsAttributes() ; |
---|
| 2002 | } |
---|
| 2003 | return newGrid ; |
---|
| 2004 | } |
---|
| 2005 | |
---|
| 2006 | |
---|
[1294] | 2007 | void CGrid::setContextClient(CContextClient* contextClient) |
---|
[1622] | 2008 | TRY |
---|
[1294] | 2009 | { |
---|
[1353] | 2010 | if (clientsSet.find(contextClient)==clientsSet.end()) |
---|
| 2011 | { |
---|
| 2012 | clients.push_back(contextClient) ; |
---|
| 2013 | clientsSet.insert(contextClient); |
---|
| 2014 | } |
---|
[1875] | 2015 | for (auto domain : getDomains()) domain->setContextClient(contextClient); |
---|
| 2016 | for (auto axis : getAxis()) axis->setContextClient(contextClient); |
---|
| 2017 | for (auto scalar : getScalars()) scalar->setContextClient(contextClient); |
---|
| 2018 | |
---|
[1294] | 2019 | } |
---|
[1622] | 2020 | CATCH_DUMP_ATTR |
---|
[1294] | 2021 | |
---|
[1930] | 2022 | |
---|
[1918] | 2023 | void CGrid::computeGridLocalElements() |
---|
| 2024 | { |
---|
| 2025 | std::vector<CDomain*> domainList = this->getDomains(); |
---|
| 2026 | std::vector<CAxis*> axisList = this->getAxis(); |
---|
[1940] | 2027 | std::vector<CScalar*> scalarList = this->getScalars(); |
---|
[1918] | 2028 | auto domain=domainList.begin() ; |
---|
| 2029 | auto axis=axisList.begin() ; |
---|
[1940] | 2030 | auto scalar=scalarList.begin() ; |
---|
[1918] | 2031 | vector<CLocalElement*> elements; |
---|
| 2032 | for(auto order : order_) |
---|
| 2033 | { |
---|
| 2034 | if (order==2) |
---|
| 2035 | { |
---|
| 2036 | elements.push_back((*domain)->getLocalElement()); |
---|
| 2037 | domain++ ; |
---|
| 2038 | } |
---|
| 2039 | else if (order==1) |
---|
| 2040 | { |
---|
| 2041 | elements.push_back((*axis)->getLocalElement()); |
---|
| 2042 | axis++ ; |
---|
| 2043 | } |
---|
| 2044 | else if (order==0) |
---|
| 2045 | { |
---|
[1940] | 2046 | elements.push_back((*scalar)->getLocalElement()); |
---|
| 2047 | scalar++ ; |
---|
[1918] | 2048 | } |
---|
| 2049 | } |
---|
| 2050 | if (hasMask()) |
---|
| 2051 | { |
---|
| 2052 | vector<bool> mask(getMask().getVector()) ; |
---|
| 2053 | gridLocalElements_ = new CGridLocalElements(elements, mask) ; |
---|
| 2054 | } |
---|
| 2055 | else gridLocalElements_ = new CGridLocalElements(elements) ; |
---|
| 2056 | } |
---|
| 2057 | |
---|
| 2058 | void CGrid::computeModelToWorkflowConnector(void) |
---|
| 2059 | { |
---|
[1960] | 2060 | modelToWorkflowConnector_ = getGridLocalElements()->getConnector(CElementView::MODEL,CElementView::WORKFLOW,true) ; |
---|
[1918] | 2061 | } |
---|
[1930] | 2062 | |
---|
| 2063 | void CGrid::computeWorkflowToFullConnector(void) |
---|
| 2064 | { |
---|
| 2065 | workflowToFullConnector_ = getGridLocalElements()->getConnector(CElementView::WORKFLOW,CElementView::FULL) ; |
---|
| 2066 | } |
---|
| 2067 | |
---|
| 2068 | void CGrid::computeWorkflowToModelConnector(void) |
---|
| 2069 | { |
---|
[1960] | 2070 | workflowToModelConnector_ = getGridLocalElements()->getConnector(CElementView::WORKFLOW,CElementView::MODEL,true) ; |
---|
[1930] | 2071 | } |
---|
| 2072 | |
---|
| 2073 | void CGrid::computeFullToWorkflowConnector(void) |
---|
| 2074 | { |
---|
| 2075 | fullToWorkflowConnector_ = getGridLocalElements()->getConnector(CElementView::FULL,CElementView::WORKFLOW) ; |
---|
| 2076 | } |
---|
| 2077 | |
---|
| 2078 | void CGrid::computeServerFromClientConnector(void) |
---|
| 2079 | { |
---|
| 2080 | vector<CGathererConnector*> connectors ; |
---|
| 2081 | for(auto& element : getElements()) |
---|
| 2082 | { |
---|
| 2083 | if (element.type==TYPE_DOMAIN) connectors.push_back(element.domain->getServerFromClientConnector()) ; |
---|
| 2084 | else if (element.type==TYPE_AXIS) connectors.push_back(element.axis->getServerFromClientConnector()) ; |
---|
| 2085 | else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerFromClientConnector()) ; |
---|
| 2086 | } |
---|
| 2087 | serverFromClientConnector_ = new CGridGathererConnector(connectors) ; |
---|
| 2088 | } |
---|
| 2089 | |
---|
[1934] | 2090 | void CGrid::computeServerToClientConnector(void) |
---|
| 2091 | { |
---|
| 2092 | vector<CScattererConnector*> connectors ; |
---|
| 2093 | for(auto& element : getElements()) |
---|
| 2094 | { |
---|
| 2095 | if (element.type==TYPE_DOMAIN) connectors.push_back(element.domain->getServerToClientConnector()) ; |
---|
| 2096 | else if (element.type==TYPE_AXIS) connectors.push_back(element.axis->getServerToClientConnector()) ; |
---|
| 2097 | else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerToClientConnector()) ; |
---|
| 2098 | } |
---|
| 2099 | serverToClientConnector_ = new CGridScattererConnector(connectors) ; |
---|
| 2100 | } |
---|
| 2101 | |
---|
[1930] | 2102 | void CGrid::computeClientFromClientConnector(void) |
---|
| 2103 | { |
---|
| 2104 | vector<CGathererConnector*> connectors ; |
---|
| 2105 | for(auto& element : getElements()) |
---|
| 2106 | { |
---|
| 2107 | if (element.type==TYPE_DOMAIN) connectors.push_back(element.domain->getServerFromClientConnector()) ; |
---|
| 2108 | else if (element.type==TYPE_AXIS) connectors.push_back(element.axis->getServerFromClientConnector()) ; |
---|
| 2109 | else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerFromClientConnector()) ; |
---|
| 2110 | } |
---|
| 2111 | clientFromClientConnector_ = new CGridGathererConnector(connectors) ; |
---|
| 2112 | } |
---|
[1934] | 2113 | |
---|
| 2114 | |
---|
[335] | 2115 | } // namespace xios |
---|