[887] | 1 | #ifndef __XIOS_CScalar__ |
---|
| 2 | #define __XIOS_CScalar__ |
---|
| 3 | |
---|
| 4 | /// XIOS headers /// |
---|
| 5 | #include "xios_spl.hpp" |
---|
| 6 | #include "declare_group.hpp" |
---|
| 7 | #include "declare_ref_func.hpp" |
---|
| 8 | #include "group_template.hpp" |
---|
| 9 | #include "array_new.hpp" |
---|
| 10 | #include "attribute_enum.hpp" |
---|
| 11 | #include "attribute_enum_impl.hpp" |
---|
[1436] | 12 | #include "attribute_array.hpp" |
---|
[887] | 13 | #include "transformation.hpp" |
---|
| 14 | #include "transformation_enum.hpp" |
---|
[1984] | 15 | #include "transformation_path.hpp" |
---|
[1930] | 16 | #include "element.hpp" |
---|
| 17 | #include "local_connector.hpp" |
---|
| 18 | #include "scatterer_connector.hpp" |
---|
| 19 | #include "gatherer_connector.hpp" |
---|
| 20 | #include "distribution_type.hpp" |
---|
[1984] | 21 | #include "generic_algorithm_transformation.hpp" |
---|
[1930] | 22 | |
---|
| 23 | |
---|
[887] | 24 | namespace xios |
---|
| 25 | { |
---|
[1984] | 26 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
[887] | 27 | |
---|
[1984] | 28 | class CScalarGroup; |
---|
| 29 | class CScalarAttributes; |
---|
| 30 | class CScalar; |
---|
| 31 | ///-------------------------------------------------------------- |
---|
[887] | 32 | |
---|
[1984] | 33 | // Declare/Define CVarAttribute |
---|
| 34 | BEGIN_DECLARE_ATTRIBUTE_MAP(CScalar) |
---|
[887] | 35 | #include "scalar_attribute.conf" |
---|
[1984] | 36 | END_DECLARE_ATTRIBUTE_MAP(CScalar) |
---|
[887] | 37 | |
---|
[1984] | 38 | ///-------------------------------------------------------------- |
---|
[887] | 39 | |
---|
[1984] | 40 | class CScalar: public CObjectTemplate<CScalar> |
---|
| 41 | , public CScalarAttributes |
---|
| 42 | { |
---|
| 43 | friend class CScalarGroup; |
---|
[1940] | 44 | |
---|
[1984] | 45 | /// typedef /// |
---|
| 46 | typedef CObjectTemplate<CScalar> SuperClass; |
---|
| 47 | typedef CScalarAttributes SuperClassAttribute; |
---|
[887] | 48 | |
---|
[1984] | 49 | public: |
---|
| 50 | enum EEventId |
---|
| 51 | { |
---|
| 52 | EVENT_ID_SCALAR_DISTRIBUTION, |
---|
| 53 | EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE, |
---|
| 54 | } ; |
---|
| 55 | static bool dispatchEvent(CEventServer& event); |
---|
[1940] | 56 | |
---|
[887] | 57 | |
---|
[1984] | 58 | public : |
---|
[887] | 59 | |
---|
[1984] | 60 | typedef CScalarAttributes RelAttributes; |
---|
| 61 | typedef CScalarGroup RelGroup; |
---|
[887] | 62 | |
---|
[1984] | 63 | /// Constructeurs /// |
---|
| 64 | CScalar(void); |
---|
| 65 | explicit CScalar(const StdString & id); |
---|
| 66 | CScalar(const CScalar & var); // Not implemented yet. |
---|
| 67 | CScalar(const CScalar * const var); // Not implemented yet. |
---|
[887] | 68 | |
---|
[1984] | 69 | /// Destructeur /// |
---|
| 70 | virtual ~CScalar(void); |
---|
[887] | 71 | |
---|
[1984] | 72 | public : |
---|
| 73 | /// Accesseurs statiques /// |
---|
| 74 | static StdString GetName(void); |
---|
| 75 | static StdString GetDefName(void); |
---|
| 76 | static ENodeType GetType(void); |
---|
[887] | 77 | |
---|
[1984] | 78 | public: |
---|
| 79 | static CScalar* createScalar(); |
---|
[887] | 80 | |
---|
[1984] | 81 | public: |
---|
| 82 | void checkAttributes(void); |
---|
| 83 | bool checkAttributes_done_ = false ; |
---|
[1869] | 84 | |
---|
[1984] | 85 | void addRelFile(const StdString& filename); |
---|
| 86 | bool IsWritten(const StdString& filename) const; |
---|
| 87 | virtual void parse(xml::CXMLNode & node); |
---|
[1875] | 88 | |
---|
[1984] | 89 | public: |
---|
| 90 | void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ; |
---|
| 91 | private: |
---|
| 92 | std::set<CContextClient*> sendScalarToCouplerOut_done_ ; |
---|
[1875] | 93 | |
---|
[1984] | 94 | public: |
---|
| 95 | void makeAliasForCoupling(const string& fieldId, int posInGrid) ; |
---|
[1875] | 96 | |
---|
[1984] | 97 | //////////////////////////////// |
---|
| 98 | //// TRANSFORMATIONS //// |
---|
| 99 | //////////////////////////////// |
---|
| 100 | public: |
---|
| 101 | typedef CTransformation<CScalar>::TransformationMapTypes TransMapTypes; |
---|
| 102 | private: |
---|
| 103 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
| 104 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
| 105 | static bool dummyTransformationMapList_; TransMapTypes transformationMap_; |
---|
| 106 | void setTransformations(const TransMapTypes&); |
---|
| 107 | |
---|
| 108 | public: |
---|
| 109 | bool hasTransformation(); |
---|
| 110 | TransMapTypes getAllTransformations(); |
---|
| 111 | void duplicateTransformation(CScalar*); |
---|
| 112 | CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
| 113 | |
---|
| 114 | void solveInheritanceTransformation_old(); |
---|
| 115 | void solveInheritanceTransformation(); |
---|
| 116 | private: |
---|
| 117 | bool solveInheritanceTransformation_done_= false ; |
---|
| 118 | private: |
---|
| 119 | CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; |
---|
| 120 | public: |
---|
| 121 | void setTransformationAlgorithm(CGenericAlgorithmTransformation* transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;} |
---|
| 122 | CGenericAlgorithmTransformation* getTransformationAlgorithm(void) { return transformationAlgorithm_ ;} |
---|
| 123 | private: |
---|
| 124 | CTransformationPaths transformationPaths_ ; |
---|
| 125 | public: |
---|
| 126 | CTransformationPaths getTransformationPaths(void) {return transformationPaths_;} |
---|
| 127 | void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;} |
---|
| 128 | //////////////////////////////// |
---|
| 129 | //////////////////////////////// |
---|
| 130 | |
---|
| 131 | bool isEqual(CScalar* scalar); |
---|
| 132 | private: |
---|
[1875] | 133 | /** Clients that have to send a scalar. There can be multiple clients in case of secondary server, otherwise only one client. */ |
---|
[1984] | 134 | std::list<CContextClient*> clients; |
---|
| 135 | std::set<CContextClient*> clientsSet; |
---|
| 136 | public: |
---|
| 137 | void setContextClient(CContextClient* contextClient) ; |
---|
[1875] | 138 | |
---|
[1984] | 139 | private: |
---|
| 140 | std::set<StdString> relFiles; |
---|
[887] | 141 | |
---|
[1984] | 142 | private: |
---|
| 143 | /** define if the scalar is completed or not ie all attributes have been received before in case |
---|
| 144 | of grid reading from file or coupling */ |
---|
| 145 | bool isCompleted_=true ; |
---|
| 146 | public: |
---|
| 147 | /*! |
---|
| 148 | \brief Check if a scalar is completed |
---|
| 149 | Before make any scalar processing, we must be sure that all scalar informations have |
---|
| 150 | been sent, for exemple when reading a grid in a file or when grid elements are sent by an |
---|
| 151 | other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed |
---|
| 152 | \return true if scalar and scalar reference are completed |
---|
| 153 | */ |
---|
| 154 | bool isCompleted(void) |
---|
| 155 | { |
---|
| 156 | if (hasDirectScalarReference()) if (!getDirectScalarReference()->isCompleted()) return false; |
---|
| 157 | else return isCompleted_ ; |
---|
| 158 | } |
---|
| 159 | void setCompleted(void) { isCompleted_=true ; } |
---|
| 160 | void unsetCompleted(void) { isCompleted_=false ; } |
---|
[888] | 161 | |
---|
| 162 | |
---|
| 163 | |
---|
[1984] | 164 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
| 165 | // this part is related to distribution, element definition, views and connectors // |
---|
| 166 | ////////////////////////////////////////////////////////////////////////////////////// |
---|
| 167 | private: |
---|
| 168 | CLocalElement* localElement_ = nullptr ; |
---|
| 169 | void initializeLocalElement(void) ; |
---|
[1930] | 170 | |
---|
[1984] | 171 | public: |
---|
| 172 | CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; } |
---|
| 173 | CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;} |
---|
[1930] | 174 | |
---|
[1984] | 175 | private: |
---|
| 176 | void addFullView(void) ; |
---|
| 177 | void addWorkflowView(void) ; |
---|
| 178 | void addModelView(void) ; |
---|
[1930] | 179 | |
---|
[1984] | 180 | private: |
---|
| 181 | CLocalConnector* modelToWorkflowConnector_ ; |
---|
| 182 | void computeModelToWorkflowConnector(void) ; |
---|
| 183 | public: |
---|
| 184 | CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;} |
---|
[1930] | 185 | |
---|
[1984] | 186 | public: |
---|
| 187 | void computeRemoteElement(CContextClient* client, EDistributionType) ; |
---|
| 188 | void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector, |
---|
[1958] | 189 | const string& scalarId="") ; |
---|
| 190 | |
---|
[1984] | 191 | static void recvScalarDistribution(CEventServer& event) ; |
---|
| 192 | void receivedScalarDistribution(CEventServer& event, int phasis) ; |
---|
| 193 | void setServerMask(CArray<bool,1>& serverMask, CContextClient* client) ; |
---|
| 194 | void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& scalarId) ; |
---|
| 195 | static void recvDistributedAttributes(CEventServer& event) ; |
---|
| 196 | void recvDistributedAttributes(CEventServer& event, const string& type) ; |
---|
[1940] | 197 | |
---|
[1984] | 198 | private: |
---|
| 199 | map<CContextClient*, CDistributedElement*> remoteElement_ ; |
---|
| 200 | public: |
---|
| 201 | CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;} |
---|
| 202 | private: |
---|
| 203 | map<CContextClient*, CScattererConnector*> clientToServerConnector_ ; |
---|
| 204 | public: |
---|
| 205 | CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;} |
---|
[1930] | 206 | |
---|
[1984] | 207 | private: |
---|
| 208 | CGathererConnector* gathererConnector_ ; |
---|
| 209 | public: |
---|
| 210 | CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;} |
---|
| 211 | private: |
---|
| 212 | CGathererConnector* serverFromClientConnector_ ; |
---|
| 213 | CDistributedElement* elementFrom_ ; |
---|
| 214 | public: |
---|
| 215 | CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;} |
---|
[1930] | 216 | |
---|
[1984] | 217 | private: |
---|
| 218 | CScattererConnector* serverToClientConnector_ = nullptr ; |
---|
| 219 | public: |
---|
| 220 | CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;} |
---|
[1930] | 221 | |
---|
[1984] | 222 | private: |
---|
| 223 | map<CContextClient*,CGathererConnector*> clientFromServerConnector_ ; |
---|
| 224 | public: |
---|
| 225 | CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} |
---|
[1930] | 226 | |
---|
[1984] | 227 | private: |
---|
| 228 | DECLARE_REF_FUNC(Scalar,scalar) |
---|
[887] | 229 | |
---|
[1984] | 230 | }; // class CVar |
---|
| 231 | ///-------------------------------------------------------------- |
---|
[887] | 232 | |
---|
[1984] | 233 | // Declare/Define CScalarGroup and CScalarDefinition |
---|
| 234 | DECLARE_GROUP(CScalar); |
---|
[887] | 235 | } // namespace xios |
---|
| 236 | |
---|
| 237 | #endif // __XIOS_CScalar__ |
---|