[687] | 1 | #include "generate_rectilinear_domain.hpp" |
---|
[2011] | 2 | #include "domain_algorithm_generate_rectilinear.hpp" |
---|
[687] | 3 | #include "type.hpp" |
---|
| 4 | |
---|
| 5 | namespace xios { |
---|
| 6 | |
---|
| 7 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 8 | |
---|
| 9 | CGenerateRectilinearDomain::CGenerateRectilinearDomain(void) |
---|
| 10 | : CObjectTemplate<CGenerateRectilinearDomain>(), CGenerateRectilinearDomainAttributes(), CTransformation<CDomain>() |
---|
| 11 | { /* Ne rien faire de plus */ } |
---|
| 12 | |
---|
| 13 | CGenerateRectilinearDomain::CGenerateRectilinearDomain(const StdString & id) |
---|
| 14 | : CObjectTemplate<CGenerateRectilinearDomain>(id), CGenerateRectilinearDomainAttributes(), CTransformation<CDomain>() |
---|
| 15 | { /* Ne rien faire de plus */ } |
---|
| 16 | |
---|
| 17 | CGenerateRectilinearDomain::~CGenerateRectilinearDomain(void) |
---|
| 18 | {} |
---|
| 19 | |
---|
[836] | 20 | CTransformation<CDomain>* CGenerateRectilinearDomain::create(const StdString& id, xml::CXMLNode* node) |
---|
| 21 | { |
---|
| 22 | CGenerateRectilinearDomain* genDomain = CGenerateRectilinearDomainGroup::get("generate_rectilinear_domain_definition")->createChild(id); |
---|
| 23 | if (node) genDomain->parse(*node); |
---|
| 24 | return static_cast<CTransformation<CDomain>*>(genDomain); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | bool CGenerateRectilinearDomain::_dummyRegistered = CGenerateRectilinearDomain::registerTrans(); |
---|
| 28 | bool CGenerateRectilinearDomain::registerTrans() |
---|
| 29 | { |
---|
[2196] | 30 | return registerTransformation(TRANS_GENERATE_RECTILINEAR_DOMAIN, {create, getTransformation}); |
---|
[836] | 31 | } |
---|
| 32 | |
---|
[687] | 33 | //---------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | StdString CGenerateRectilinearDomain::GetName(void) { return StdString("generate_rectilinear_domain"); } |
---|
| 36 | StdString CGenerateRectilinearDomain::GetDefName(void) { return StdString("generate_rectilinear_domain"); } |
---|
| 37 | ENodeType CGenerateRectilinearDomain::GetType(void) { return eGenerateRectilinearDomain; } |
---|
| 38 | |
---|
[727] | 39 | void CGenerateRectilinearDomain::checkValid(CDomain* domainDst) |
---|
[687] | 40 | { |
---|
[727] | 41 | const double defaultBndsLonStart = 0; |
---|
| 42 | const double defaultBndsLonEnd = 360; |
---|
| 43 | |
---|
| 44 | const double defaultBndsLatStart = -90; |
---|
| 45 | const double defaultBndsLatEnd = 90; |
---|
| 46 | |
---|
| 47 | |
---|
[838] | 48 | int niGlo = domainDst->ni_glo; |
---|
| 49 | int njGlo = domainDst->nj_glo; |
---|
[727] | 50 | |
---|
| 51 | |
---|
[838] | 52 | double deltaLon=(defaultBndsLonEnd-defaultBndsLonStart)/niGlo ; |
---|
| 53 | if (!lon_start.isEmpty() && !lon_end.isEmpty() ) deltaLon=(lon_end-lon_start)/(niGlo-1) ; |
---|
| 54 | if (!bounds_lon_start.isEmpty() && !bounds_lon_end.isEmpty()) deltaLon=(bounds_lon_end-bounds_lon_start)/niGlo ; |
---|
| 55 | if (!lon_start.isEmpty() && !bounds_lon_end.isEmpty()) deltaLon=(bounds_lon_end-bounds_lon_start)/(niGlo-0.5) ; |
---|
| 56 | if (!bounds_lon_start.isEmpty() && !lon_end.isEmpty()) deltaLon=(bounds_lon_end-bounds_lon_start)/(niGlo-0.5) ; |
---|
[727] | 57 | |
---|
[838] | 58 | if (lon_start.isEmpty()) |
---|
| 59 | { |
---|
| 60 | if (!bounds_lon_start.isEmpty()) domainDst->lon_start=bounds_lon_start+0.5*deltaLon ; |
---|
| 61 | else if (!lon_end.isEmpty()) domainDst->lon_start= lon_end-(niGlo-1.)*deltaLon ; |
---|
| 62 | else if (!bounds_lon_end.isEmpty()) domainDst->lon_start=bounds_lon_end-(niGlo-0.5)*deltaLon ; |
---|
| 63 | else domainDst->lon_start=defaultBndsLonStart+0.5*deltaLon ; |
---|
| 64 | } |
---|
| 65 | else domainDst->lon_start=lon_start ; |
---|
[727] | 66 | |
---|
[838] | 67 | if (bounds_lon_start.isEmpty()) |
---|
| 68 | { |
---|
| 69 | if (!lon_start.isEmpty()) domainDst->bounds_lon_start=lon_start-0.5*deltaLon ; |
---|
| 70 | else if (!lon_end.isEmpty()) domainDst->bounds_lon_start= lon_end-(niGlo-0.5)*deltaLon ; |
---|
| 71 | else if (!bounds_lon_end.isEmpty()) domainDst->bounds_lon_start=bounds_lon_end-niGlo*deltaLon ; |
---|
| 72 | else domainDst->bounds_lon_start=defaultBndsLonStart ; |
---|
| 73 | } |
---|
| 74 | else domainDst->bounds_lon_start=bounds_lon_start ; |
---|
[727] | 75 | |
---|
[838] | 76 | if (lon_end.isEmpty()) |
---|
[727] | 77 | { |
---|
[838] | 78 | if (!bounds_lon_end.isEmpty()) domainDst->lon_end=bounds_lon_end-0.5*deltaLon ; |
---|
| 79 | else if (!bounds_lon_start.isEmpty()) domainDst->lon_end=bounds_lon_start+(niGlo-0.5)*deltaLon ; |
---|
| 80 | else if (!lon_start.isEmpty()) domainDst->lon_end=lon_start+(niGlo-1.)*deltaLon ; |
---|
| 81 | else domainDst->lon_end=defaultBndsLonEnd-0.5*deltaLon ; |
---|
[734] | 82 | } |
---|
[838] | 83 | else domainDst->lon_end=lon_end ; |
---|
[734] | 84 | |
---|
[838] | 85 | if (bounds_lon_end.isEmpty()) |
---|
[734] | 86 | { |
---|
[838] | 87 | if (!lon_end.isEmpty()) domainDst->bounds_lon_end=lon_end+0.5*deltaLon ; |
---|
| 88 | else if (!bounds_lon_start.isEmpty()) domainDst->bounds_lon_end=bounds_lon_start+niGlo*deltaLon ; |
---|
| 89 | else if (!lon_start.isEmpty()) domainDst->bounds_lon_end=lon_start+(niGlo-0.5)*deltaLon ; |
---|
| 90 | else domainDst->bounds_lon_end=defaultBndsLonEnd ; |
---|
[727] | 91 | } |
---|
[838] | 92 | else domainDst->bounds_lon_end=bounds_lon_end; |
---|
[727] | 93 | |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | |
---|
[838] | 97 | double deltaLat=(defaultBndsLatEnd-defaultBndsLatStart)/njGlo ; |
---|
| 98 | if (!lat_start.isEmpty() && !lat_end.isEmpty() ) deltaLat=(lat_end-lat_start)/(njGlo-1) ; |
---|
| 99 | if (!bounds_lat_start.isEmpty() && !bounds_lat_end.isEmpty()) deltaLat=(bounds_lat_end-bounds_lat_start)/njGlo ; |
---|
| 100 | if (!lat_start.isEmpty() && !bounds_lat_end.isEmpty()) deltaLat=(bounds_lat_end-bounds_lat_start)/(njGlo-0.5) ; |
---|
| 101 | if (!bounds_lat_start.isEmpty() && !lat_end.isEmpty()) deltaLat=(bounds_lat_end-bounds_lat_start)/(njGlo-0.5) ; |
---|
[727] | 102 | |
---|
[838] | 103 | if (lat_start.isEmpty()) |
---|
[727] | 104 | { |
---|
[838] | 105 | if (!bounds_lat_start.isEmpty()) domainDst->lat_start=bounds_lat_start+0.5*deltaLat ; |
---|
| 106 | else if (!lat_end.isEmpty()) domainDst->lat_start= lat_end-(njGlo-1.)*deltaLat ; |
---|
| 107 | else if (!bounds_lat_end.isEmpty()) domainDst->lat_start=bounds_lat_end-(njGlo-0.5)*deltaLat ; |
---|
| 108 | else domainDst->lat_start=defaultBndsLatStart+0.5*deltaLat ; |
---|
[727] | 109 | } |
---|
[838] | 110 | else domainDst->lat_start=lat_start; |
---|
[727] | 111 | |
---|
[838] | 112 | if (bounds_lat_start.isEmpty()) |
---|
[727] | 113 | { |
---|
[838] | 114 | if (!lat_start.isEmpty()) domainDst->bounds_lat_start=lat_start-0.5*deltaLat ; |
---|
| 115 | else if (!lat_end.isEmpty()) domainDst->bounds_lat_start= lat_end-(njGlo-0.5)*deltaLat ; |
---|
| 116 | else if (!bounds_lat_end.isEmpty()) domainDst->bounds_lat_start=bounds_lat_end-njGlo*deltaLat ; |
---|
| 117 | else domainDst->bounds_lat_start=defaultBndsLatStart ; |
---|
| 118 | } |
---|
| 119 | else domainDst->bounds_lat_start=bounds_lat_start; |
---|
| 120 | |
---|
| 121 | if (lat_end.isEmpty()) |
---|
| 122 | { |
---|
| 123 | if (!bounds_lat_end.isEmpty()) domainDst->lat_end=bounds_lat_end-0.5*deltaLat ; |
---|
| 124 | else if (!bounds_lat_start.isEmpty()) domainDst->lat_end=bounds_lat_start+(njGlo-0.5)*deltaLat ; |
---|
| 125 | else if (!lat_start.isEmpty()) domainDst->lat_end=lat_start+(njGlo-1.)*deltaLat ; |
---|
| 126 | else domainDst->lat_end=defaultBndsLatEnd-0.5*deltaLat ; |
---|
| 127 | } |
---|
| 128 | else domainDst->lat_end=lat_end; |
---|
| 129 | |
---|
| 130 | if (bounds_lat_end.isEmpty()) |
---|
| 131 | { |
---|
| 132 | if (!lat_end.isEmpty()) domainDst->bounds_lat_end=lat_end+0.5*deltaLat ; |
---|
| 133 | else if (!bounds_lat_start.isEmpty()) domainDst->bounds_lat_end=bounds_lat_start+njGlo*deltaLat ; |
---|
| 134 | else if (!lat_start.isEmpty()) domainDst->bounds_lat_end=lat_start+(njGlo-0.5)*deltaLat ; |
---|
| 135 | else domainDst->bounds_lat_end=defaultBndsLatEnd ; |
---|
| 136 | } |
---|
| 137 | else domainDst->bounds_lat_end=bounds_lat_end; |
---|
[727] | 138 | |
---|
[687] | 139 | } |
---|
| 140 | |
---|
[2270] | 141 | shared_ptr<CGenericAlgorithmTransformation> CGenerateRectilinearDomain::createAlgorithm(bool isSource, |
---|
[2011] | 142 | CGrid* gridDst, CGrid* gridSrc, |
---|
| 143 | int elementPositionInGrid, |
---|
| 144 | std::map<int, int>& elementPositionInGridSrc2ScalarPosition, |
---|
| 145 | std::map<int, int>& elementPositionInGridSrc2AxisPosition, |
---|
| 146 | std::map<int, int>& elementPositionInGridSrc2DomainPosition, |
---|
| 147 | std::map<int, int>& elementPositionInGridDst2ScalarPosition, |
---|
| 148 | std::map<int, int>& elementPositionInGridDst2AxisPosition, |
---|
| 149 | std::map<int, int>& elementPositionInGridDst2DomainPosition) |
---|
| 150 | { |
---|
| 151 | return CDomainAlgorithmGenerateRectilinear::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, |
---|
| 152 | elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, |
---|
| 153 | elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition); |
---|
| 154 | } |
---|
[687] | 155 | } |
---|