1 | #ifndef __XIOS_CAxis__ |
---|
2 | #define __XIOS_CAxis__ |
---|
3 | |
---|
4 | /// XIOS headers /// |
---|
5 | #include "xios_spl.hpp" |
---|
6 | #include "group_factory.hpp" |
---|
7 | #include "virtual_node.hpp" |
---|
8 | |
---|
9 | #include "declare_group.hpp" |
---|
10 | #include "declare_ref_func.hpp" |
---|
11 | #include "declare_virtual_node.hpp" |
---|
12 | #include "attribute_array.hpp" |
---|
13 | #include "attribute_enum.hpp" |
---|
14 | #include "attribute_enum_impl.hpp" |
---|
15 | #include "server_distribution_description.hpp" |
---|
16 | #include "transformation.hpp" |
---|
17 | #include "transformation_enum.hpp" |
---|
18 | |
---|
19 | namespace xios { |
---|
20 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
21 | |
---|
22 | class CAxisGroup; |
---|
23 | class CAxisAttributes; |
---|
24 | class CAxis; |
---|
25 | |
---|
26 | ///-------------------------------------------------------------- |
---|
27 | |
---|
28 | // Declare/Define CAxisAttribute |
---|
29 | BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
30 | # include "axis_attribute.conf" |
---|
31 | # include "axis_attribute_private.conf" |
---|
32 | END_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
33 | |
---|
34 | ///-------------------------------------------------------------- |
---|
35 | |
---|
36 | class CAxis |
---|
37 | : public CObjectTemplate<CAxis> |
---|
38 | , public CAxisAttributes |
---|
39 | { |
---|
40 | /// typedef /// |
---|
41 | typedef CObjectTemplate<CAxis> SuperClass; |
---|
42 | typedef CAxisAttributes SuperClassAttribute; |
---|
43 | |
---|
44 | public : |
---|
45 | enum EEventId |
---|
46 | { |
---|
47 | EVENT_ID_SERVER_ATTRIBUT, |
---|
48 | EVENT_ID_INDEX, |
---|
49 | EVENT_ID_DISTRIBUTED_VALUE, |
---|
50 | EVENT_ID_NON_DISTRIBUTED_VALUE |
---|
51 | } ; |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | public : |
---|
56 | |
---|
57 | typedef CAxisAttributes RelAttributes; |
---|
58 | typedef CAxisGroup RelGroup; |
---|
59 | typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; |
---|
60 | |
---|
61 | public: |
---|
62 | /// Constructeurs /// |
---|
63 | CAxis(void); |
---|
64 | explicit CAxis(const StdString & id); |
---|
65 | CAxis(const CAxis & axis); // Not implemented yet. |
---|
66 | CAxis(const CAxis * const axis); // Not implemented yet. |
---|
67 | |
---|
68 | static CAxis* createAxis(); |
---|
69 | |
---|
70 | /// Accesseurs /// |
---|
71 | const std::set<StdString> & getRelFiles(void) const; |
---|
72 | |
---|
73 | const std::vector<int>& getIndexesToWrite(void) const; |
---|
74 | int getNumberWrittenIndexes() const; |
---|
75 | int getTotalNumberWrittenIndexes() const; |
---|
76 | int getOffsetWrittenIndexes() const; |
---|
77 | |
---|
78 | std::map<int, StdSize> getAttributesBufferSize(); |
---|
79 | |
---|
80 | /// Test /// |
---|
81 | bool IsWritten(const StdString & filename) const; |
---|
82 | bool isWrittenCompressed(const StdString& filename) const; |
---|
83 | bool isDistributed(void) const; |
---|
84 | bool isCompressible(void) const; |
---|
85 | |
---|
86 | /// Mutateur /// |
---|
87 | void addRelFile(const StdString & filename); |
---|
88 | void addRelFileCompressed(const StdString& filename); |
---|
89 | |
---|
90 | /// Vérifications /// |
---|
91 | void checkAttributes(void); |
---|
92 | |
---|
93 | /// Destructeur /// |
---|
94 | virtual ~CAxis(void); |
---|
95 | |
---|
96 | virtual void parse(xml::CXMLNode & node); |
---|
97 | |
---|
98 | /// Accesseurs statiques /// |
---|
99 | static StdString GetName(void); |
---|
100 | static StdString GetDefName(void); |
---|
101 | static ENodeType GetType(void); |
---|
102 | |
---|
103 | void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
104 | CServerDistributionDescription::ServerDistributionType distType); |
---|
105 | static bool dispatchEvent(CEventServer& event); |
---|
106 | static void recvServerAttribut(CEventServer& event); |
---|
107 | void recvServerAttribut(CBufferIn& buffer) ; |
---|
108 | void checkAttributesOnClient(); |
---|
109 | void checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
110 | CServerDistributionDescription::ServerDistributionType distType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
111 | void sendCheckedAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
112 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
113 | |
---|
114 | void checkEligibilityForCompressedOutput(); |
---|
115 | |
---|
116 | bool hasTransformation(); |
---|
117 | void solveInheritanceTransformation(); |
---|
118 | TransMapTypes getAllTransformations(); |
---|
119 | void fillInValues(const CArray<double,1>& values); |
---|
120 | void duplicateTransformation(CAxis*); |
---|
121 | CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
122 | |
---|
123 | public: |
---|
124 | int zoom_begin_srv, zoom_end_srv, zoom_size_srv; |
---|
125 | int ni_srv, begin_srv, end_srv; |
---|
126 | CArray<double,1> value_srv; |
---|
127 | CArray<double,2> bound_srv; |
---|
128 | bool hasValue; |
---|
129 | CArray<int,1> globalDimGrid; |
---|
130 | int orderPosInGrid; |
---|
131 | |
---|
132 | private: |
---|
133 | void checkData(); |
---|
134 | void checkMask(); |
---|
135 | void checkZoom(); |
---|
136 | void checkBounds(); |
---|
137 | void checkTransformations(); |
---|
138 | void sendValue(); |
---|
139 | void computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
140 | CServerDistributionDescription::ServerDistributionType distType); |
---|
141 | void sendDistributedValue(); |
---|
142 | void sendNonDistributedValue(); |
---|
143 | |
---|
144 | static void recvIndex(CEventServer& event); |
---|
145 | static void recvDistributedValue(CEventServer& event); |
---|
146 | static void recvNonDistributedValue(CEventServer& event); |
---|
147 | void recvIndex(int rank, CBufferIn& buffer); |
---|
148 | void recvDistributedValue(int rank, CBufferIn& buffer); |
---|
149 | void recvNonDistributedValue(int rank, CBufferIn& buffer); |
---|
150 | |
---|
151 | void setTransformations(const TransMapTypes&); |
---|
152 | |
---|
153 | private: |
---|
154 | bool isChecked; |
---|
155 | bool areClientAttributesChecked_; |
---|
156 | bool isClientAfterTransformationChecked; |
---|
157 | std::set<StdString> relFiles, relFilesCompressed; |
---|
158 | TransMapTypes transformationMap_; |
---|
159 | bool isDistributed_; |
---|
160 | //! True if and only if the data defined on the axis can be outputted in a compressed way |
---|
161 | bool isCompressible_; |
---|
162 | std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server |
---|
163 | std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server |
---|
164 | std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server |
---|
165 | std::vector<int> indexesToWrite; |
---|
166 | int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
167 | std::vector<int> connectedServerRank_; |
---|
168 | std::map<int, CArray<int,1> > indiSrv_; |
---|
169 | bool hasBounds_; |
---|
170 | |
---|
171 | private: |
---|
172 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
173 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
174 | static bool dummyTransformationMapList_; |
---|
175 | |
---|
176 | DECLARE_REF_FUNC(Axis,axis) |
---|
177 | }; // class CAxis |
---|
178 | |
---|
179 | ///-------------------------------------------------------------- |
---|
180 | |
---|
181 | // Declare/Define CAxisGroup and CAxisDefinition |
---|
182 | DECLARE_GROUP(CAxis); |
---|
183 | } // namespace xios |
---|
184 | |
---|
185 | #endif // __XIOS_CAxis__ |
---|