]> SALOME platform Git repositories - samples/genericsolver.git/commitdiff
Salome HOME
Changed the exchange types to the structure InputDescription and the sequence ValueList
authorRenaud Barate <renaud.barate@edf.fr>
Mon, 23 Aug 2010 10:04:16 +0000 (10:04 +0000)
committerRenaud Barate <renaud.barate@edf.fr>
Mon, 23 Aug 2010 10:04:16 +0000 (10:04 +0000)
idl/DEVIATION_Gen.idl
resources/GENERICSOLVERCatalog.xml.in
src/GENERICSOLVER/DEVIATION.py

index c851a006efd538e4dabef63c092d875cb93c1666..78cac6cedec8bcbf028b99fcdb8cae8b356427b6 100644 (file)
 module GENERICSOLVER_ORB
 {
 
-  typedef sequence<double> Point;
-  typedef SALOMEDS::ID ID;
+  typedef sequence<double> Value;
   typedef sequence<string> VarList;
+  typedef sequence<Value> ValueList;
+
+  struct InputDescription {
+    VarList inputVarList;
+    VarList outputVarList;
+    ValueList inputValues;
+  };
 
   interface DEVIATION_Gen : Engines::Component, SALOMEDS::Driver
   {
@@ -45,29 +51,25 @@ module GENERICSOLVER_ORB
      * stores this data along with the lists of input and output variables to
      * identify them in future calls to Exec.
      *
-     * @param inputVarList   a list of strings containing the names of the input
-     *                       variables in the same order as in subsequent calls to Exec.
-     * @param outputVarList  a list of strings containing the names of the output
-     *                       variables in the same order as they should be returned
-     *                       in subsequent calls to Exec.
      * @param studyID        the identifier of the study containing the deterministic data
      * @param entry          the identifier of the deterministic case within the study
      */
-    void Init(in VarList inputVarList, in VarList outputVarList, in long studyID, in ID entry)
+    void Init(in long studyID, in SALOMEDS::ID entry)
       raises (SALOME::SALOME_Exception);
 
     /**
      * @brief Execute a computation with a given sample of variables.
      *
-     * The Exec method realizes the computation with some parameters (within
-     * inPoint) corresponding to the variables set previously with the method
-     * Init. The result is put in outPoint in the order specified by
-     * outputVarList of Init method.
+     * The Exec method realizes the computation with the probabilistic variables
+     * described in inputDesc and the deterministic variables set previously with
+     * the Init method. The result is put in outputValues in the order specified by
+     * inputDesc.outputVarList.
      *
-     * @param inPoint   a vector of floating point values to be evaluated
-     * @param outPoint  the result of the computation as a vector of floating point values
+     * @param inputDesc     a structure describing the probabilistic variables and the order
+     *                      of the output variables.
+     * @param outputValues  the result of the computation
      */
-    void Exec(in Point inPoint, out Point outPoint)
+    void Exec(in InputDescription inputDesc, out ValueList outputValues)
       raises (SALOME::SALOME_Exception);
 
     /**
index c20d05cd14ac6aee809798c499c3693eaa78209f..d4ef765c2a439b600ca1af0343c58027557d9a10 100644 (file)
        <type-list>
                <sequence name="Point" content="double"/>
                <objref name="pyobj" id="python:obj:1.0"/>
+
+        <sequence content="double" name="GENERICSOLVER_ORB/Value"></sequence>
+        <sequence content="string" name="GENERICSOLVER_ORB/VarList"></sequence>
+        <sequence content="GENERICSOLVER_ORB/Value" name="GENERICSOLVER_ORB/ValueList"></sequence>
+        <struct name="GENERICSOLVER_ORB/InputDescription">
+            <member type="GENERICSOLVER_ORB/VarList" name="inputVarList"></member>
+            <member type="GENERICSOLVER_ORB/VarList" name="outputVarList"></member>
+            <member type="GENERICSOLVER_ORB/ValueList" name="inputValues"></member>
+        </struct>
        </type-list>
 
        <!-- Component list -->
                                                <service-by-default>0</service-by-default>
                                                <!-- service-connexion -->
                                                <inParameter-list>
-                                                       <inParameter>
-                                                               <inParameter-name>inputVarList</inParameter-name>
-                                                               <inParameter-type>stringvec</inParameter-type>
-                                                       </inParameter>
-                                                       <inParameter>
-                                                               <inParameter-name>outputVarList</inParameter-name>
-                                                               <inParameter-type>stringvec</inParameter-type>
-                                                       </inParameter>
                                                        <inParameter>
                                                                <inParameter-name>studyID</inParameter-name>
                                                                <inParameter-type>long</inParameter-type>
                                                <service-comment></service-comment>
                                                <service-by-default>0</service-by-default>
                                                <!-- service-connexion -->
-                                               <inParameter-list>
-                                                       <inParameter>
-                                                               <inParameter-name>inPoint</inParameter-name>
-                                                               <inParameter-type>Point</inParameter-type>
-                                                       </inParameter>
-                                               </inParameter-list>
-                                               <outParameter-list>
-                                                       <outParameter>
-                                                               <outParameter-name>outPoint</outParameter-name>
-                                                               <outParameter-type>Point</outParameter-type>
-                                                       </outParameter>
-                                               </outParameter-list>
+                        <inParameter-list>
+                            <inParameter>
+                                <inParameter-name>inputDesc</inParameter-name>
+                                <inParameter-type>GENERICSOLVER_ORB/InputDescription</inParameter-type>
+                            </inParameter>
+                        </inParameter-list>
+                        <outParameter-list>
+                            <outParameter>
+                                <outParameter-name>outputValues</outParameter-name>
+                                <outParameter-type>GENERICSOLVER_ORB/ValueList</outParameter-type>
+                            </outParameter>
+                        </outParameter-list>
                                        </component-service>
                                        <component-service>
                                                <!-- service-identification -->
index 7df999a39c1362f97b8681aed4a19defefdd4090..8d1a37c91ec69cdcebf31bcf60955304aa30fca8 100644 (file)
@@ -101,16 +101,14 @@ class DEVIATION(GENERICSOLVER_ORB__POA.DEVIATION_Gen,
     """
     def __init__ ( self, orb, poa, contID, containerName, instanceName, 
                    interfaceName ):
-        logger.info("DEVIATION.__init__: " + containerName + ' ; ' + instanceName)
+        logger.info("__init__: " + containerName + ' ; ' + instanceName)
         SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
                     contID, containerName, instanceName, interfaceName, 0)
         SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
         # On stocke dans l'attribut _naming_service, une reference sur
         # le Naming Service CORBA
         self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
-        self.inputVarList = None
-        self.outputVarList = None
-        self.evalPoint = None
+        self.deterministicValues = {}
 
 ######################################################################
 # This is the Wrapper part of the GENERICSOLVER module, ie
@@ -128,53 +126,48 @@ class DEVIATION(GENERICSOLVER_ORB__POA.DEVIATION_Gen,
                                      inspect.stack()[1][1], inspect.stack()[1][2])
         raise SALOME.SALOME_Exception(exc)
 
-    def Init(self, inputVarList, outputVarList, studyId, caseEntry):
+    def Init(self, studyId, caseEntry):
         """
         This method is an example for the initialization of a computation component for
         use with OpenTURNS in SALOME 5.1.5 and later (for YACS integration)
         """
         try:
-            logger.info("DEVIATION.Init: " + self._containerName +
-                        ' ; ' + self._instanceName)
+            logger.info("Init: " + self._containerName + ' ; ' + self._instanceName)
             DEVIATION.lock.acquire()
             salome.salome_init()
             DEVIATION.lock.release()
 
-            self.inputVarList = inputVarList
-            self.outputVarList = outputVarList
-            self.evalPoint = GetDataFromCase(studyId, caseEntry)
-            logger.debug("inputVarList: %s" % self.inputVarList)
-            logger.debug("outputVarList: %s" % self.outputVarList)
-            logger.debug("evalPoint: %s" % self.evalPoint)
+            self.deterministicValues = GetDataFromCase(studyId, caseEntry)
+            logger.debug("deterministic values: %s" % self.deterministicValues)
         except:
             self._raiseSalomeError()
 
-    def Exec(self, inPoint):
+    def Exec(self, inputDesc):
         """
         This method is an example for the execution of a computation component for
         use with OpenTURNS in SALOME 5.1.5 and later (for YACS integration)
         """
         try:
-            logger.info("DEVIATION.Exec: " + self._containerName +
-                        ' ; ' + self._instanceName)
-            if self.inputVarList is None:
-                raise Exception("Init not run")
-            if len(inPoint) != len(self.inputVarList):
+            logger.info("Exec: " + self._containerName + ' ; ' + self._instanceName)
+            logger.debug("inputVarList: %s" % inputDesc.inputVarList)
+            logger.debug("outputVarList: %s" % inputDesc.outputVarList)
+            logger.debug("inputValues: %s" % inputDesc.inputValues)
+            if len(inputDesc.inputValues) != len(inputDesc.inputVarList):
                 raise Exception("Size mismatch between inputVarList and point to evaluate")
 
-            logger.debug("DEVIATION.Exec (1): inPoint  = %s" % inPoint)
-            for i in range(len(self.inputVarList)):
-                self.evalPoint[self.inputVarList[i]] = inPoint[i]
-            logger.debug("evalPoint = %s" % self.evalPoint)
+            evalPoint = self.deterministicValues
+            for i in range(len(inputDesc.inputVarList)):
+                evalPoint[inputDesc.inputVarList[i]] = inputDesc.inputValues[i][0]
+            logger.debug("evalPoint = %s" % evalPoint)
 
             resDict = {}
-            resDict["dev"] = self.BeamModel(**self.evalPoint)
+            resDict["dev"] = self.BeamModel(**evalPoint)
 
-            outPoint = []
-            for outputVar in self.outputVarList:
-                outPoint.append(resDict[outputVar])
-            logger.debug("DEVIATION.Exec (2): outPoint = %s" % outPoint)
-            return outPoint
+            outputValues = []
+            for outputVar in inputDesc.outputVarList:
+                outputValues.append([resDict[outputVar]])
+            logger.debug("outputValues: %s" % outputValues)
+            return outputValues
         except:
             self._raiseSalomeError()
 
@@ -184,7 +177,7 @@ class DEVIATION(GENERICSOLVER_ORB__POA.DEVIATION_Gen,
         It cleans everything set so far.
         """
         try:
-            logger.info("DEVIATION.Finalize: " + self._containerName + ' ; ' + self._instanceName)
+            logger.info("Finalize: " + self._containerName + ' ; ' + self._instanceName)
         except:
             self._raiseSalomeError()
         
@@ -201,5 +194,5 @@ class DEVIATION(GENERICSOLVER_ORB__POA.DEVIATION_Gen,
        deviation = ( Force * Length^3 ) / ( 3 * YoungModulus * InertiaSection )
        """
        d = (F * L * L * L) / (3. * E * I)
-       logger.debug("DEVIATION.BeamModel (E=%g, F=%g, L=%g, I=%g) = %g" % (E, F, L, I, d))
+       logger.debug("BeamModel (E=%g, F=%g, L=%g, I=%g) = %g" % (E, F, L, I, d))
        return d