1 | #include "reduce_domain_to_axis.hpp" |
---|
2 | #include "axis_algorithm_reduce_domain.hpp" |
---|
3 | #include "type.hpp" |
---|
4 | #include "axis.hpp" |
---|
5 | #include "domain.hpp" |
---|
6 | |
---|
7 | namespace xios { |
---|
8 | |
---|
9 | /// ////////////////////// Définitions ////////////////////// /// |
---|
10 | |
---|
11 | CReduceDomainToAxis::CReduceDomainToAxis(void) |
---|
12 | : CObjectTemplate<CReduceDomainToAxis>(), CReduceDomainToAxisAttributes(), CTransformation<CAxis>() |
---|
13 | { /* Ne rien faire de plus */ } |
---|
14 | |
---|
15 | CReduceDomainToAxis::CReduceDomainToAxis(const StdString & id) |
---|
16 | : CObjectTemplate<CReduceDomainToAxis>(id), CReduceDomainToAxisAttributes(), CTransformation<CAxis>() |
---|
17 | { /* Ne rien faire de plus */ } |
---|
18 | |
---|
19 | CReduceDomainToAxis::~CReduceDomainToAxis(void) |
---|
20 | {} |
---|
21 | |
---|
22 | CTransformation<CAxis>* CReduceDomainToAxis::create(const StdString& id, xml::CXMLNode* node) |
---|
23 | { |
---|
24 | CReduceDomainToAxis* reduceDomain = CReduceDomainToAxisGroup::get("reduce_domain_to_axis_definition")->createChild(id); |
---|
25 | if (node) reduceDomain->parse(*node); |
---|
26 | return static_cast<CTransformation<CAxis>*>(reduceDomain); |
---|
27 | } |
---|
28 | |
---|
29 | bool CReduceDomainToAxis::registerTrans() |
---|
30 | { |
---|
31 | return registerTransformation(TRANS_REDUCE_DOMAIN_TO_AXIS, {create, getTransformation}); |
---|
32 | } |
---|
33 | |
---|
34 | bool CReduceDomainToAxis::_dummyRegistered = CReduceDomainToAxis::registerTrans(); |
---|
35 | |
---|
36 | //---------------------------------------------------------------- |
---|
37 | |
---|
38 | StdString CReduceDomainToAxis::GetName(void) { return StdString("reduce_domain_to_axis"); } |
---|
39 | StdString CReduceDomainToAxis::GetDefName(void) { return StdString("reduce_domain_to_axis"); } |
---|
40 | ENodeType CReduceDomainToAxis::GetType(void) { return eReduceDomainToAxis; } |
---|
41 | |
---|
42 | void CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc) |
---|
43 | { |
---|
44 | if (CDomain::type_attr::unstructured == domainSrc->type) |
---|
45 | ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", |
---|
46 | << "Domain reduction is only supported for rectilinear or curvillinear grid." |
---|
47 | << "Domain source " <<domainSrc->getId() << std::endl |
---|
48 | << "Axis destination " << axisDst->getId()); |
---|
49 | |
---|
50 | int axis_n_glo = axisDst->n_glo; |
---|
51 | int domain_ni_glo = domainSrc->ni_glo; |
---|
52 | int domain_nj_glo = domainSrc->nj_glo; |
---|
53 | |
---|
54 | if (this->operation.isEmpty()) |
---|
55 | ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", |
---|
56 | << "An operation must be defined." |
---|
57 | << "Domain source " <<domainSrc->getId() << std::endl |
---|
58 | << "Axis destination " << axisDst->getId()); |
---|
59 | |
---|
60 | if (this->direction.isEmpty()) |
---|
61 | ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", |
---|
62 | << "A direction to apply the operation must be defined. It should be: 'iDir' or 'jDir'" |
---|
63 | << "Domain source " <<domainSrc->getId() << std::endl |
---|
64 | << "Axis destination " << axisDst->getId()); |
---|
65 | if (this->local.isEmpty()) local=false ; |
---|
66 | |
---|
67 | switch (direction) |
---|
68 | { |
---|
69 | case direction_attr::jDir: |
---|
70 | if (axis_n_glo != domain_ni_glo) |
---|
71 | ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", |
---|
72 | << "Extract domain along j, axis destination should have n_glo equal to ni_glo of domain source" |
---|
73 | << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_ni_glo << std::endl |
---|
74 | << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); |
---|
75 | break; |
---|
76 | |
---|
77 | case direction_attr::iDir: |
---|
78 | if (axis_n_glo != domain_nj_glo) |
---|
79 | ERROR("CReduceDomainToAxis::checkValid(CAxis* axisDst, CDomain* domainSrc)", |
---|
80 | << "Extract domain along i, axis destination should have n_glo equal to nj_glo of domain source" |
---|
81 | << "Domain source " <<domainSrc->getId() << " has nj_glo " << domain_nj_glo << std::endl |
---|
82 | << "Axis destination " << axisDst->getId() << " has n_glo " << axis_n_glo); |
---|
83 | break; |
---|
84 | |
---|
85 | default: |
---|
86 | break; |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | CGenericAlgorithmTransformation* CReduceDomainToAxis::createAlgorithm(bool isSource, |
---|
91 | CGrid* gridDst, CGrid* gridSrc, |
---|
92 | int elementPositionInGrid, |
---|
93 | std::map<int, int>& elementPositionInGridSrc2ScalarPosition, |
---|
94 | std::map<int, int>& elementPositionInGridSrc2AxisPosition, |
---|
95 | std::map<int, int>& elementPositionInGridSrc2DomainPosition, |
---|
96 | std::map<int, int>& elementPositionInGridDst2ScalarPosition, |
---|
97 | std::map<int, int>& elementPositionInGridDst2AxisPosition, |
---|
98 | std::map<int, int>& elementPositionInGridDst2DomainPosition) |
---|
99 | { |
---|
100 | return CAxisAlgorithmReduceDomain::create(isSource, gridDst, gridSrc, this, elementPositionInGrid, |
---|
101 | elementPositionInGridSrc2ScalarPosition, elementPositionInGridSrc2AxisPosition, elementPositionInGridSrc2DomainPosition, |
---|
102 | elementPositionInGridDst2ScalarPosition, elementPositionInGridDst2AxisPosition, elementPositionInGridDst2DomainPosition) ; |
---|
103 | } |
---|
104 | } |
---|