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 | #include "transformation_path.hpp" |
---|
19 | #include "element.hpp" |
---|
20 | #include "local_connector.hpp" |
---|
21 | #include "scatterer_connector.hpp" |
---|
22 | #include "gatherer_connector.hpp" |
---|
23 | #include "distribution_type.hpp" |
---|
24 | #include "generic_algorithm_transformation.hpp" |
---|
25 | |
---|
26 | |
---|
27 | namespace xios |
---|
28 | { |
---|
29 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
30 | |
---|
31 | class CAxisGroup; |
---|
32 | class CAxisAttributes; |
---|
33 | class CAxis; |
---|
34 | |
---|
35 | ///-------------------------------------------------------------- |
---|
36 | |
---|
37 | // Declare/Define CAxisAttribute |
---|
38 | BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
39 | # include "axis_attribute.conf" |
---|
40 | END_DECLARE_ATTRIBUTE_MAP(CAxis) |
---|
41 | |
---|
42 | ///-------------------------------------------------------------- |
---|
43 | |
---|
44 | class CAxis |
---|
45 | : public CObjectTemplate<CAxis> |
---|
46 | , public CAxisAttributes |
---|
47 | { |
---|
48 | /// typedef /// |
---|
49 | typedef CObjectTemplate<CAxis> SuperClass; |
---|
50 | typedef CAxisAttributes SuperClassAttribute; |
---|
51 | |
---|
52 | public: |
---|
53 | enum EEventId |
---|
54 | { |
---|
55 | EVENT_ID_AXIS_DISTRIBUTION, |
---|
56 | EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE |
---|
57 | } ; |
---|
58 | |
---|
59 | public: |
---|
60 | typedef CAxisAttributes RelAttributes; |
---|
61 | typedef CAxisGroup RelGroup; |
---|
62 | |
---|
63 | public: |
---|
64 | /// Constructeurs /// |
---|
65 | CAxis(void); |
---|
66 | explicit CAxis(const StdString & id); |
---|
67 | CAxis(const CAxis & axis); // Not implemented yet. |
---|
68 | CAxis(const CAxis * const axis); // Not implemented yet. |
---|
69 | |
---|
70 | static CAxis* createAxis(); |
---|
71 | |
---|
72 | /// Accesseurs /// |
---|
73 | const std::set<StdString> & getRelFiles(void) const; |
---|
74 | |
---|
75 | std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, |
---|
76 | CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION); |
---|
77 | |
---|
78 | /// Test /// |
---|
79 | bool IsWritten(const StdString & filename) const; |
---|
80 | bool isWrittenCompressed(const StdString& filename) const; |
---|
81 | bool isDistributed(void) const; |
---|
82 | |
---|
83 | public: |
---|
84 | /*! |
---|
85 | \brief return if the axis can be written or not in a compressed way. |
---|
86 | ie if there are some masked or indexed point on the domain. Valid only on server side. |
---|
87 | \return true if domain can be writtedn in a compressed way |
---|
88 | */ |
---|
89 | bool isCompressible(void) { if (!isCompressibleComputed_) computeIsCompressible() ; return isCompressible_ ;} |
---|
90 | private: |
---|
91 | bool isCompressible_ ; /** specify if the domain can be written in a compressed way */ |
---|
92 | bool isCompressibleComputed_=false ; /** Indicate if compressability has been computed*/ |
---|
93 | void computeIsCompressible() ; |
---|
94 | |
---|
95 | public: |
---|
96 | |
---|
97 | /// Mutateur /// |
---|
98 | void addRelFile(const StdString & filename); |
---|
99 | void addRelFileCompressed(const StdString& filename); |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | /// Destructeur /// |
---|
104 | virtual ~CAxis(void); |
---|
105 | |
---|
106 | virtual void parse(xml::CXMLNode & node); |
---|
107 | |
---|
108 | void setContextClient(CContextClient* contextClient); |
---|
109 | |
---|
110 | /// Accesseurs statiques /// |
---|
111 | static StdString GetName(void); |
---|
112 | static StdString GetDefName(void); |
---|
113 | static ENodeType GetType(void); |
---|
114 | |
---|
115 | static bool dispatchEvent(CEventServer& event); |
---|
116 | |
---|
117 | /// Vérifications /// |
---|
118 | void checkAttributes(void); |
---|
119 | bool checkAttributes_done_ = false ; |
---|
120 | |
---|
121 | size_t getGlobalWrittenSize(void) ; |
---|
122 | |
---|
123 | ////////////////////////// |
---|
124 | ///// transformations //// |
---|
125 | ////////////////////////// |
---|
126 | public: |
---|
127 | typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; |
---|
128 | private: |
---|
129 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
130 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
131 | static bool dummyTransformationMapList_; |
---|
132 | TransMapTypes transformationMap_; |
---|
133 | |
---|
134 | public: |
---|
135 | CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
136 | CTransformation<CAxis>* addTransformation(ETranformationType transType, CTransformation<CAxis>* transformation) ; |
---|
137 | void setTransformations(const TransMapTypes&); |
---|
138 | void duplicateTransformation(CAxis*); |
---|
139 | TransMapTypes getAllTransformations(); |
---|
140 | bool hasTransformation(); |
---|
141 | void solveInheritanceTransformation_old(); // to remove later |
---|
142 | void solveInheritanceTransformation(); |
---|
143 | private: |
---|
144 | bool solveInheritanceTransformation_done_= false ; |
---|
145 | private: |
---|
146 | CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; |
---|
147 | public: |
---|
148 | void setTransformationAlgorithm(CGenericAlgorithmTransformation* transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;} |
---|
149 | CGenericAlgorithmTransformation* getTransformationAlgorithm(void) { return transformationAlgorithm_ ;} |
---|
150 | private: |
---|
151 | CTransformationPaths transformationPaths_ ; |
---|
152 | public: |
---|
153 | CTransformationPaths getTransformationPaths(void) {return transformationPaths_;} |
---|
154 | void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;} |
---|
155 | |
---|
156 | //////////////////////////// |
---|
157 | bool isEqual(CAxis* axis); |
---|
158 | |
---|
159 | public: |
---|
160 | bool hasValue; |
---|
161 | bool hasBounds; |
---|
162 | bool hasLabel; |
---|
163 | |
---|
164 | private: |
---|
165 | void checkData(); |
---|
166 | void checkMask(); |
---|
167 | void checkBounds(); |
---|
168 | void checkLabel(); |
---|
169 | |
---|
170 | public: |
---|
171 | void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ; |
---|
172 | private: |
---|
173 | std::set<CContextClient*> sendAxisToCouplerOut_done_ ; |
---|
174 | |
---|
175 | public: |
---|
176 | void makeAliasForCoupling(const string& fieldId, int posInGrid) ; |
---|
177 | string getCouplingAlias(const string& fieldId, int posInGrid) ; |
---|
178 | |
---|
179 | private: |
---|
180 | |
---|
181 | /** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */ |
---|
182 | std::list<CContextClient*> clients; |
---|
183 | std::set<CContextClient*> clientsSet; |
---|
184 | |
---|
185 | private: |
---|
186 | /** define if the axis is completed or not ie all attributes have been received before in case |
---|
187 | of grid reading from file or coupling */ |
---|
188 | bool isCompleted_=true ; |
---|
189 | public: |
---|
190 | /*! |
---|
191 | \brief Check if a axis is completed |
---|
192 | Before make any axis processing, we must be sure that all axis informations have |
---|
193 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
194 | other context (coupling). So all direct reference of the axis (axis_ref) must be also completed |
---|
195 | \return true if axis and axis reference are completed |
---|
196 | */ |
---|
197 | bool isCompleted(void) |
---|
198 | { |
---|
199 | if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false; |
---|
200 | else return isCompleted_ ; |
---|
201 | } |
---|
202 | void setCompleted(void) { isCompleted_=true ; } |
---|
203 | void unsetCompleted(void) { isCompleted_=false ; } |
---|
204 | |
---|
205 | private: |
---|
206 | bool isChecked; |
---|
207 | std::set<StdString> relFiles, relFilesCompressed; |
---|
208 | std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server |
---|
209 | std::map<int, std::vector<int> > connectedServerRank_; |
---|
210 | |
---|
211 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
212 | // this part is related to distribution, element definition, views and connectors // |
---|
213 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
214 | |
---|
215 | private: |
---|
216 | CLocalElement* localElement_ = nullptr ; |
---|
217 | void initializeLocalElement(void) ; |
---|
218 | public: |
---|
219 | CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; } |
---|
220 | CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;} |
---|
221 | private: |
---|
222 | void addFullView(void) ; |
---|
223 | void addWorkflowView(void) ; |
---|
224 | void addModelView(void) ; |
---|
225 | |
---|
226 | private: |
---|
227 | CLocalConnector* modelToWorkflowConnector_ ; |
---|
228 | void computeModelToWorkflowConnector(void) ; |
---|
229 | public: |
---|
230 | CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;} |
---|
231 | |
---|
232 | public: |
---|
233 | void computeRemoteElement(CContextClient* client, EDistributionType) ; |
---|
234 | void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector, |
---|
235 | const string& axisId="") ; |
---|
236 | |
---|
237 | static void recvAxisDistribution(CEventServer& event) ; |
---|
238 | void receivedAxisDistribution(CEventServer& event, int phasis) ; |
---|
239 | void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ; |
---|
240 | void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& axisId) ; |
---|
241 | static void recvDistributedAttributes(CEventServer& event) ; |
---|
242 | void recvDistributedAttributes(CEventServer& event, const string& type) ; |
---|
243 | private: |
---|
244 | map<CContextClient*, CDistributedElement*> remoteElement_ ; |
---|
245 | public: |
---|
246 | CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;} |
---|
247 | private: |
---|
248 | map<CContextClient*, CScattererConnector*> clientToServerConnector_ ; |
---|
249 | public: |
---|
250 | CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;} |
---|
251 | private: |
---|
252 | CGathererConnector* gathererConnector_ ; |
---|
253 | public: |
---|
254 | CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;} |
---|
255 | private: |
---|
256 | CGathererConnector* serverFromClientConnector_ ; |
---|
257 | CDistributedElement* elementFrom_ ; |
---|
258 | public: |
---|
259 | CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;} |
---|
260 | |
---|
261 | private: |
---|
262 | CScattererConnector* serverToClientConnector_ = nullptr ; |
---|
263 | public: |
---|
264 | CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;} |
---|
265 | |
---|
266 | private: |
---|
267 | map<CContextClient*,CGathererConnector*> clientFromServerConnector_ ; |
---|
268 | public: |
---|
269 | CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} |
---|
270 | |
---|
271 | DECLARE_REF_FUNC(Axis,axis) |
---|
272 | }; // class CAxis |
---|
273 | |
---|
274 | ///-------------------------------------------------------------- |
---|
275 | |
---|
276 | // Declare/Define CAxisGroup and CAxisDefinition |
---|
277 | DECLARE_GROUP(CAxis); |
---|
278 | } // namespace xios |
---|
279 | |
---|
280 | #endif // __XIOS_CAxis__ |
---|