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