[630] | 1 | #include "interpolate_axis.hpp" |
---|
[2011] | 2 | #include "axis_algorithm_interpolate_coordinate.hpp" |
---|
| 3 | #include "axis_algorithm_interpolate.hpp" |
---|
[630] | 4 | #include "type.hpp" |
---|
[827] | 5 | #include "field.hpp" |
---|
[630] | 6 | |
---|
| 7 | namespace xios { |
---|
| 8 | |
---|
| 9 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 10 | |
---|
| 11 | CInterpolateAxis::CInterpolateAxis(void) |
---|
| 12 | : CObjectTemplate<CInterpolateAxis>(), CInterpolateAxisAttributes(), CTransformation<CAxis>() |
---|
| 13 | { /* Ne rien faire de plus */ } |
---|
| 14 | |
---|
| 15 | CInterpolateAxis::CInterpolateAxis(const StdString & id) |
---|
| 16 | : CObjectTemplate<CInterpolateAxis>(id), CInterpolateAxisAttributes(), CTransformation<CAxis>() |
---|
| 17 | { /* Ne rien faire de plus */ } |
---|
| 18 | |
---|
| 19 | CInterpolateAxis::~CInterpolateAxis(void) |
---|
| 20 | {} |
---|
| 21 | |
---|
[836] | 22 | CTransformation<CAxis>* CInterpolateAxis::create(const StdString& id, xml::CXMLNode* node) |
---|
| 23 | { |
---|
| 24 | CInterpolateAxis* interpAxis = CInterpolateAxisGroup::get("interpolate_axis_definition")->createChild(id); |
---|
| 25 | if (node) interpAxis->parse(*node); |
---|
| 26 | return static_cast<CTransformation<CAxis>*>(interpAxis); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | bool CInterpolateAxis::registerTrans() |
---|
| 30 | { |
---|
[1984] | 31 | return registerTransformation(TRANS_INTERPOLATE_AXIS, {create, getTransformation}); |
---|
[836] | 32 | } |
---|
| 33 | |
---|
| 34 | bool CInterpolateAxis::_dummyRegistered = CInterpolateAxis::registerTrans(); |
---|
| 35 | |
---|
[630] | 36 | //---------------------------------------------------------------- |
---|
| 37 | |
---|
| 38 | StdString CInterpolateAxis::GetName(void) { return StdString("interpolate_axis"); } |
---|
| 39 | StdString CInterpolateAxis::GetDefName(void) { return StdString("interpolate_axis"); } |
---|
| 40 | ENodeType CInterpolateAxis::GetType(void) { return eInterpolateAxis; } |
---|
| 41 | |
---|
[827] | 42 | void CInterpolateAxis::checkValid(CAxis* axisSrc) |
---|
[630] | 43 | { |
---|
[937] | 44 | if (this->order.isEmpty()) this->order.setValue(1); |
---|
[827] | 45 | int order = this->order.getValue(); |
---|
| 46 | if (order >= axisSrc->n_glo.getValue()) |
---|
| 47 | { |
---|
| 48 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 49 | << "Order of interpolation is greater than global size of axis source" |
---|
| 50 | << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue() << std::endl |
---|
| 51 | << "Order of interpolation is " << order ); |
---|
| 52 | } |
---|
| 53 | |
---|
[937] | 54 | if (order < 1) |
---|
| 55 | { |
---|
| 56 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 57 | << "Order of interpolation is smaller than 1" |
---|
| 58 | << "Size of axis source " <<axisSrc->getId() << " is " << axisSrc->n_glo.getValue() << std::endl |
---|
| 59 | << "Order of interpolation is " << order ); |
---|
| 60 | } |
---|
[827] | 61 | |
---|
[2122] | 62 | if (!this->coordinate.isEmpty() && (!this->coordinate_src.isEmpty() || !this->coordinate_dst.isEmpty())) |
---|
| 63 | { |
---|
| 64 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 65 | << "<coordinate> is incompatible with <coordinate_src> or <coordinate_dst> attributes. <coordinate> attribute is present only for backward" |
---|
| 66 | << "compatibility and is now declared obsolete") ; |
---|
| 67 | } |
---|
[937] | 68 | |
---|
[827] | 69 | if (!this->coordinate.isEmpty()) |
---|
| 70 | { |
---|
| 71 | if (!CField::has(coordinate)) |
---|
| 72 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 73 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 74 | << "Please define one"); |
---|
| 75 | } |
---|
[2122] | 76 | |
---|
| 77 | if (!this->coordinate_src.isEmpty()) |
---|
| 78 | { |
---|
| 79 | if (!CField::has(coordinate_src)) |
---|
| 80 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 81 | << "Coordinate field whose id " << coordinate_src << "does not exist " |
---|
| 82 | << "Please define one"); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | if (!this->coordinate_dst.isEmpty()) |
---|
| 86 | { |
---|
| 87 | if (!CField::has(coordinate_dst)) |
---|
| 88 | ERROR("CInterpolateAxis::checkValid(CAxis* axisSrc)", |
---|
| 89 | << "Coordinate field whose id " << coordinate_dst << "does not exist " |
---|
| 90 | << "Please define one"); |
---|
| 91 | } |
---|
[630] | 92 | } |
---|
| 93 | |
---|
[827] | 94 | std::vector<StdString> CInterpolateAxis::checkAuxInputs_() |
---|
| 95 | { |
---|
| 96 | std::vector<StdString> auxInputs; |
---|
[2122] | 97 | |
---|
| 98 | if (!this->coordinate.isEmpty() && (!this->coordinate_src.isEmpty() || !this->coordinate_dst.isEmpty())) |
---|
| 99 | { |
---|
| 100 | ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", |
---|
| 101 | << "<coordinate> is incompatible with <coordinate_src> or <coordinate_dst> attributes. <coordinate> attribute is present only for backward" |
---|
| 102 | << "compatibility and is now declared obsolete") ; |
---|
| 103 | } |
---|
| 104 | |
---|
[827] | 105 | if (!this->coordinate.isEmpty()) |
---|
| 106 | { |
---|
| 107 | StdString coordinate = this->coordinate.getValue(); |
---|
| 108 | if (!CField::has(coordinate)) |
---|
[2122] | 109 | ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", |
---|
[827] | 110 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 111 | << "Please define one"); |
---|
| 112 | auxInputs.push_back(coordinate); |
---|
| 113 | } |
---|
| 114 | |
---|
[2122] | 115 | if (!this->coordinate_src.isEmpty()) |
---|
| 116 | { |
---|
| 117 | StdString coordinate = this->coordinate_src.getValue(); |
---|
| 118 | if (!CField::has(coordinate)) |
---|
| 119 | ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", |
---|
| 120 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 121 | << "Please define one"); |
---|
| 122 | auxInputs.push_back(coordinate); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | if (!this->coordinate_dst.isEmpty()) |
---|
| 126 | { |
---|
| 127 | StdString coordinate = this->coordinate_dst.getValue(); |
---|
| 128 | if (!CField::has(coordinate)) |
---|
| 129 | ERROR("std::vector<StdString> CInterpolateAxis::checkAuxInputs_()", |
---|
| 130 | << "Coordinate field whose id " << coordinate << "does not exist " |
---|
| 131 | << "Please define one"); |
---|
| 132 | auxInputs.push_back(coordinate); |
---|
| 133 | } |
---|
| 134 | |
---|
[827] | 135 | return auxInputs; |
---|
| 136 | } |
---|
[2011] | 137 | |
---|
| 138 | CGenericAlgorithmTransformation* CInterpolateAxis::createAlgorithm(bool isSource, |
---|
| 139 | CGrid* gridDst, CGrid* gridSrc, |
---|
| 140 | int elementPositionInGrid, |
---|
| 141 | std::map<int, int>& elementPositionInGridSrc2ScalarPosition, |
---|
| 142 | std::map<int, int>& elementPositionInGridSrc2AxisPosition, |
---|
| 143 | std::map<int, int>& elementPositionInGridSrc2DomainPosition, |
---|
| 144 | std::map<int, int>& elementPositionInGridDst2ScalarPosition, |
---|
| 145 | std::map<int, int>& elementPositionInGridDst2AxisPosition, |
---|
| 146 | std::map<int, int>& elementPositionInGridDst2DomainPosition) |
---|
| 147 | { |
---|
[2122] | 148 | if (!coordinate.isEmpty() || !coordinate_src.isEmpty() || !coordinate_dst.isEmpty()) |
---|
| 149 | return CAxisAlgorithmInterpolateCoordinate::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, |
---|
| 150 | elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, |
---|
| 151 | elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition); |
---|
| 152 | |
---|
[2011] | 153 | else return CAxisAlgorithmInterpolate::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, |
---|
| 154 | elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, |
---|
| 155 | elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition); |
---|
| 156 | } |
---|
[630] | 157 | } |
---|