1 #-*-coding:iso-8859-1-*-
3 # Copyright (C) 2008-2015 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 ADAO skeleton case, for wide script usage in case definition
25 ------------------------------------------------------------
27 Script defining the ObservationOperator
29 __author__ = "Jean-Philippe ARGAUD"
31 # ==============================================================================
33 import Physical_simulation_functions
36 # -----------------------------------------------------------------------
37 # SALOME input data and parameters: all information are the required input
38 # variable "computation", containing for example:
39 # {'inputValues': [[[[0.0, 0.0, 0.0]]]],
40 # 'inputVarList': ['adao_default'],
41 # 'outputVarList': ['adao_default'],
42 # 'specificParameters': [{'name': 'method', 'value': 'Direct'}]}
43 # -----------------------------------------------------------------------
45 # Recovering the type of computation: "Direct", "Tangent" or "Adjoint"
46 # --------------------------------------------------------------------
48 for param in computation["specificParameters"]:
49 if param["name"] == "method":
50 method = param["value"]
51 logging.info("ComputationFunctionNode: Found method is \'%s\'"%method)
53 # Loading the H operator functions from external definitions
54 # ----------------------------------------------------------
55 logging.info("ComputationFunctionNode: Loading operator functions")
56 DirectOperator = Physical_simulation_functions.DirectOperator
57 TangentOperator = Physical_simulation_functions.TangentOperator
58 AdjointOperator = Physical_simulation_functions.AdjointOperator
60 # Executing the possible computations
61 # -----------------------------------
62 if method == "Direct":
63 logging.info("ComputationFunctionNode: Direct computation")
64 Xcurrent = computation["inputValues"][0][0][0]
65 data = DirectOperator(numpy.matrix( Xcurrent ).T)
67 if method == "Tangent":
68 logging.info("ComputationFunctionNode: Tangent computation")
69 Xcurrent = computation["inputValues"][0][0][0]
70 data = TangentOperator(numpy.matrix( Xcurrent ).T)
72 if method == "Adjoint":
73 logging.info("ComputationFunctionNode: Adjoint computation")
74 Xcurrent = computation["inputValues"][0][0][0]
75 Ycurrent = computation["inputValues"][0][0][1]
76 data = AdjointOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( Ycurrent ).T))
78 # Formatting the output
79 # ---------------------
80 logging.info("ComputationFunctionNode: Formatting the output")
82 outputValues = [[[[]]]]
84 outputValues[0][0][0].append(val)
86 # Creating the required ADAO variable
87 # -----------------------------------
89 result["outputValues"] = outputValues
90 result["specificOutputInfos"] = []
91 result["returnCode"] = 0
92 result["errorMessage"] = ""
94 # ==============================================================================