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