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