From a1043dddacefb56a058e9167b6c3ec810e64a7cf Mon Sep 17 00:00:00 2001 From: Renaud Barate Date: Tue, 17 May 2011 09:36:29 +0000 Subject: [PATCH] Updated YACSGEN example --- resources/yacsgen_example.py | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/resources/yacsgen_example.py b/resources/yacsgen_example.py index 1a2f0aa..53e3247 100755 --- a/resources/yacsgen_example.py +++ b/resources/yacsgen_example.py @@ -31,6 +31,7 @@ from module_generator import * prerequisites_script_path = "/path/to/prerequisites.sh" kernel_path = "/path/to/KERNEL_install" openturns_module_path = "/path/to/OPENTURNS_install" +eficas_module_path = "/path/to/EFICAS_install" c1 = PYComponent("EXAMPLE_COMPONENT", services=[ @@ -49,33 +50,22 @@ self.deterministicValues = {'E' : 210.e9, Service("Exec", inport=[("paramInput", "SALOME_TYPES/ParametricInput"),], outport=[("paramOutput", "SALOME_TYPES/ParametricOutput")], - defs = "import SALOME_TYPES", + defs = "from salome.kernel.parametric.compo_utils import \ + create_input_dict, create_normal_parametric_output, create_error_parametric_output", body=""" -# This section creates the point to evaluate "evalPoint" -evalPoint = self.deterministicValues -for i in range(len(paramInput.inputVarList)): - evalPoint[paramInput.inputVarList[i]] = paramInput.inputValues[i][0][0] +# This section creates the point to evaluate "inputDict" +inputDict = create_input_dict(self.deterministicValues, paramInput) # This section should be modified according to your needs (it's the evaluation itself) -if evalPoint["L"] <= 0: # Test for an invalid parameter and return an error in this case - paramOutput = SALOME_TYPES.ParametricOutput( - outputValues = [], - specificOutputInfos = [], - returnCode = 1, - errorMessage = "Invalid value: L must be positive") +if inputDict["L"] <= 0: # Test for an invalid parameter and return an error in this case + paramOutput = create_error_parametric_output("Invalid value: L must be positive") else: - resDict = {} - resDict["dev"] = (evalPoint["F"] * evalPoint["L"] * evalPoint["L"] * evalPoint["L"]) / \ - (3. * evalPoint["E"] * evalPoint["I"]) + outputDict = {} + outputDict["dev"] = (inputDict["F"] * inputDict["L"] * inputDict["L"] * inputDict["L"]) / \ + (3. * inputDict["E"] * inputDict["I"]) # This section builds the returned object - outputValues = [] - for outputVar in paramInput.outputVarList: - outputValues.append([[resDict[outputVar]]]) - paramOutput = SALOME_TYPES.ParametricOutput(outputValues, - specificOutputInfos = [], - returnCode = 0, - errorMessage = "") + paramOutput = create_normal_parametric_output(outputDict, paramInput) """, ), Service("Finalize"), @@ -95,4 +85,5 @@ g.configure() g.make() g.install() g.make_appli("example_appli", - altmodules={"OPENTURNS":openturns_module_path}) + altmodules={"OPENTURNS":openturns_module_path, + "EFICAS":eficas_module_path}) -- 2.39.2