Changeset 2184
- Timestamp:
- 07/15/21 14:57:08 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/domain_algorithm/domain_algorithm_reorder.cpp
r2174 r2184 44 44 TRY 45 45 { 46 // Input data for checkAttributes() 47 // checkDomain 48 domainDestination->type.setValue( CDomain::type_attr::rectilinear ); 49 // Keep a 2D point of view for this transformation 50 domainDestination->ni_glo = domainSource->ni_glo; 51 domainDestination->nj_glo = domainSource->nj_glo; 52 //domainDestination->ni = domainSource->ni; // Will be computed by checkAttributes 53 //domainDestination->nj = domainSource->nj; // in function of : 54 //domainDestination->ibegin = domainSource->ibegin;>ibegin; // - domainDestination->i_index 55 //domainDestination->jbegin = domainSource->jbegin;>jbegin; // - domainDestination->j_index 56 CArray<size_t,1> sourceGlobalIdx = domainSource->getLocalElement()->getGlobalIndex(); 57 int indexSize = sourceGlobalIdx.numElements(); 58 domainDestination->i_index.resize( indexSize ); 59 domainDestination->j_index.resize( indexSize ); 60 for (size_t i = 0; i < indexSize ; ++i) { 61 domainDestination->i_index(i) = sourceGlobalIdx(i)%domainSource->ni_glo; 62 domainDestination->j_index(i) = sourceGlobalIdx(i)/domainSource->ni_glo; 63 } 64 // else 65 // - domainDestination->ni_glo = domainSource->ni_glo * domainSource->nj_glo; 66 // - domainDestination->nj_glo = 1; 67 // - domainDestination->i_index = sourceGlobalIdx; 68 // - domainDestination->i_index = 0; 69 70 CArray<int,1> sourceWorkflowIdx = domainSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 71 CArray<int,1> sourceFullIdx = domainSource->getLocalView(CElementView::FULL )->getIndex(); 72 73 // checkMask -> define domainMask 74 domainDestination->mask_1d.resize( indexSize ); 75 //domainDestination->mask_2d.resize( domainSource->mask_2d.numElements() ); 76 //domainDestination->mask_2d = domainSource->mask_2d; 77 78 // checkDomainData 79 domainDestination->data_dim = 1;//domainSource->data_dim; 80 //domainDestination->data_ni = domainSource->data_ni; 81 //domainDestination->data_nj = domainSource->data_nj; 82 //domainDestination->data_ibegin = domainSource->data_ibegin; 83 //domainDestination->data_jbegin = domainSource->data_ibegin; 84 // checkCompression 85 domainDestination->data_i_index.resize( indexSize ); 86 domainDestination->data_j_index.resize( indexSize ); 87 domainDestination->data_j_index = 0; 88 int countMasked(0); 89 for (size_t i = 0; i < indexSize ; ++i) { 90 if ( sourceFullIdx(i)==sourceWorkflowIdx(i-countMasked) ) { 91 domainDestination->mask_1d(i) = 1; 92 domainDestination->data_i_index(i) = sourceFullIdx(i); 93 //domainDestination->data_i_index(i) = sourceFullIdx(i)%domainSource->ni - domainSource->data_ibegin; 94 //domainDestination->data_j_index(i) = sourceFullIdx(i)/domainSource->ni - domainSource->data_jbegin; 95 } 96 else { 97 domainDestination->mask_1d(i) = 0; 98 domainDestination->data_i_index(i) = -1; 99 //domainDestination->data_j_index(i) = -1; 100 countMasked++; 101 } 102 } 103 104 105 // checkLonLat -> define (bounds_)lon/latvalue 106 domainDestination->latvalue_1d.resize( domainSource->latvalue_1d.numElements() ); 107 domainDestination->lonvalue_1d.resize( domainSource->lonvalue_1d.numElements() ); 108 domainDestination->latvalue_1d = domainSource->latvalue_1d; 109 domainDestination->lonvalue_1d = domainSource->lonvalue_1d; 110 domainDestination->latvalue_2d.resize( domainSource->latvalue_2d.numElements() ); 111 domainDestination->lonvalue_2d.resize( domainSource->lonvalue_2d.numElements() ); 112 domainDestination->latvalue_2d = domainSource->latvalue_2d; 113 domainDestination->lonvalue_2d = domainSource->lonvalue_2d; 114 // checkBounds 115 domainDestination->bounds_lon_1d.resize( domainSource->bounds_lon_1d.numElements() ); 116 domainDestination->bounds_lat_1d.resize( domainSource->bounds_lat_1d.numElements() ); 117 domainDestination->bounds_lon_1d = domainSource->bounds_lon_1d; 118 domainDestination->bounds_lat_1d = domainSource->bounds_lat_1d; 119 domainDestination->bounds_lon_2d.resize( domainSource->bounds_lon_2d.numElements() ); 120 domainDestination->bounds_lat_2d.resize( domainSource->bounds_lat_2d.numElements() ); 121 domainDestination->bounds_lon_2d = domainSource->bounds_lon_2d; 122 domainDestination->bounds_lat_2d = domainSource->bounds_lat_2d; 123 // checkArea 124 46 // Reset geometrical attributes to avoid incompatible (user/domainSource) attributs 47 // attributs will be defined using domainSource and/or transformation attributs 48 domainDestination->type.reset(); 49 domainDestination->ni_glo.reset(); 50 domainDestination->nj_glo.reset(); 51 52 domainDestination->i_index.reset(); // defined using domainSource->getLocalElement() 53 domainDestination->j_index.reset(); // " 54 domainDestination->ibegin.reset(); // will be computed in domainDestination->checkDomain() (from checkAttributes()) 55 domainDestination->ni.reset(); // " 56 domainDestination->jbegin.reset(); // " 57 domainDestination->nj.reset(); // " 58 59 domainDestination->mask_1d.reset(); // defined scanning domainSource->getFullView() & domainSource->getWorkflowView() differencies 60 domainDestination->mask_2d.reset(); // in all case domainDestination->mask_1d used as reference 61 62 // domainDestination->data_* attributes will be computed in : 63 domainDestination->data_dim.reset(); // domainDestination->checkDomainData() (from checkAttributes()) 64 domainDestination->data_ni.reset(); 65 domainDestination->data_nj.reset(); 66 domainDestination->data_ibegin.reset(); 67 domainDestination->data_jbegin.reset(); 68 domainDestination->data_i_index.reset(); // domainDestination->checkCompression() (from checkAttributes()) 69 domainDestination->data_j_index.reset(); 70 71 // Next attributes will be set using domainSource->attributes 72 domainDestination->lonvalue_1d.reset(); 73 domainDestination->latvalue_1d.reset(); 74 domainDestination->lonvalue_2d.reset(); 75 domainDestination->latvalue_2d.reset(); 76 domainDestination->nvertex.reset(); 77 domainDestination->bounds_lon_1d.reset(); 78 domainDestination->bounds_lat_1d.reset(); 79 domainDestination->bounds_lon_2d.reset(); 80 domainDestination->bounds_lat_2d.reset(); 81 domainDestination->area.reset(); 82 domainDestination->radius.reset(); 83 84 85 // Set attributes for this transformation 86 domainDestination->type.setValue( domainSource->type ); 87 88 // Keep a 2D point of view for this transformation which is intrinsically 2D 89 domainDestination->ni_glo = domainSource->ni_glo; 90 domainDestination->nj_glo = domainSource->nj_glo; 91 // Set attributes required to define domainDestination->localElement_ and associated views, full and workflow) 92 CArray<size_t,1> sourceGlobalIdx = domainSource->getLocalElement()->getGlobalIndex(); 93 int indexSize = sourceGlobalIdx.numElements(); 94 domainDestination->i_index.resize( indexSize ); 95 domainDestination->j_index.resize( indexSize ); 96 for (size_t i = 0; i < indexSize ; ++i) { 97 domainDestination->i_index(i) = sourceGlobalIdx(i)%domainSource->ni_glo; 98 domainDestination->j_index(i) = sourceGlobalIdx(i)/domainSource->ni_glo; 99 } 100 // else 101 // - domainDestination->ni_glo = domainSource->ni_glo * domainSource->nj_glo; 102 // - domainDestination->nj_glo = 1; 103 // - domainDestination->i_index = sourceGlobalIdx; 104 // - domainDestination->j_index = 0; 105 106 // set mask_1d to enable domainMask computing (in checkMask()) 107 CArray<int,1> sourceWorkflowIdx = domainSource->getLocalView(CElementView::WORKFLOW)->getIndex(); 108 CArray<int,1> sourceFullIdx = domainSource->getLocalView(CElementView::FULL )->getIndex(); 109 domainDestination->mask_1d.resize( indexSize ); 110 int countMasked(0); // countMasked will store the offset index between full and workflow views 111 for (size_t i = 0; i < indexSize ; ++i) { 112 if ( sourceFullIdx(i)==sourceWorkflowIdx(i-countMasked) ) { 113 domainDestination->mask_1d(i) = 1; 114 } 115 else { 116 domainDestination->mask_1d(i) = 0; 117 countMasked++; 118 } 119 } 120 121 122 // Set lon/lat values 123 if (!domainSource->lonvalue_1d.isEmpty() ) 124 { 125 domainDestination->latvalue_1d.resize( domainSource->latvalue_1d.numElements() ); 126 domainDestination->lonvalue_1d.resize( domainSource->lonvalue_1d.numElements() ); 127 domainDestination->latvalue_1d = domainSource->latvalue_1d; 128 domainDestination->lonvalue_1d = domainSource->lonvalue_1d; 129 } 130 else if (!domainSource->lonvalue_2d.isEmpty() ) 131 { 132 domainDestination->latvalue_2d.resize( domainSource->latvalue_2d.numElements() ); 133 domainDestination->lonvalue_2d.resize( domainSource->lonvalue_2d.numElements() ); 134 domainDestination->latvalue_2d = domainSource->latvalue_2d; 135 domainDestination->lonvalue_2d = domainSource->lonvalue_2d; 136 } 137 // Set bounds_lon/lat values 138 if (!domainSource->nvertex.isEmpty() ) 139 domainDestination->nvertex = domainSource->nvertex; 140 if (!domainSource->bounds_lon_1d.isEmpty() ) 141 { 142 domainDestination->bounds_lon_1d.resize( domainSource->bounds_lon_1d.numElements() ); 143 domainDestination->bounds_lat_1d.resize( domainSource->bounds_lat_1d.numElements() ); 144 domainDestination->bounds_lon_1d = domainSource->bounds_lon_1d; 145 domainDestination->bounds_lat_1d = domainSource->bounds_lat_1d; 146 } 147 else if (!domainSource->bounds_lon_2d.isEmpty() ) 148 { 149 domainDestination->bounds_lon_2d.resize( domainSource->bounds_lon_2d.numElements() ); 150 domainDestination->bounds_lat_2d.resize( domainSource->bounds_lat_2d.numElements() ); 151 domainDestination->bounds_lon_2d = domainSource->bounds_lon_2d; 152 domainDestination->bounds_lat_2d = domainSource->bounds_lat_2d; 153 } 154 // set area 155 if (!domainSource->area.isEmpty() ) 156 { 157 domainDestination->area.resize( domainSource->area.numElements() ); 158 domainDestination->area = domainSource->area; 159 } 160 if (!domainSource->radius.isEmpty() ) 161 domainDestination->radius = domainSource->radius; 162 163 125 164 reorderDomain->checkValid(domainSource); 126 165 // domainDestination->checkAttributes() will be operated at the end of the transformation definition to define correctly domainDestination views 127 //domainDestination->checkAttributes() ; // for now but maybe use domainSource as template for domain destination128 166 129 167 if (domainSource->type != CDomain::type_attr::rectilinear)
Note: See TracChangeset
for help on using the changeset viewer.