From cbe42c38485d446ae172e977a2b01f3aff13bbc9 Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Mon, 23 Aug 2010 10:04:16 +0000 Subject: [PATCH] Changed the exchange types to the structure InputDescription and the sequence ValueList --- idl/DEVIATION_Gen.idl | 32 ++++++++-------- resources/GENERICSOLVERCatalog.xml.in | 41 ++++++++++---------- src/GENERICSOLVER/DEVIATION.py | 55 ++++++++++++--------------- 3 files changed, 62 insertions(+), 66 deletions(-) diff --git a/idl/DEVIATION_Gen.idl b/idl/DEVIATION_Gen.idl index c851a00..78cac6c 100644 --- a/idl/DEVIATION_Gen.idl +++ b/idl/DEVIATION_Gen.idl @@ -29,9 +29,15 @@ module GENERICSOLVER_ORB { - typedef sequence Point; - typedef SALOMEDS::ID ID; + typedef sequence Value; typedef sequence VarList; + typedef sequence 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); /** diff --git a/resources/GENERICSOLVERCatalog.xml.in b/resources/GENERICSOLVERCatalog.xml.in index c20d05c..d4ef765 100644 --- a/resources/GENERICSOLVERCatalog.xml.in +++ b/resources/GENERICSOLVERCatalog.xml.in @@ -33,6 +33,15 @@ + + + + + + + + + @@ -148,14 +157,6 @@ 0 - - inputVarList - stringvec - - - outputVarList - stringvec - studyID long @@ -174,18 +175,18 @@ 0 - - - inPoint - Point - - - - - outPoint - Point - - + + + inputDesc + GENERICSOLVER_ORB/InputDescription + + + + + outputValues + GENERICSOLVER_ORB/ValueList + + diff --git a/src/GENERICSOLVER/DEVIATION.py b/src/GENERICSOLVER/DEVIATION.py index 7df999a..8d1a37c 100644 --- a/src/GENERICSOLVER/DEVIATION.py +++ b/src/GENERICSOLVER/DEVIATION.py @@ -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 -- 2.39.2