]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Ajout d'un nouvel exemple
authorAndré Ribes <andre.ribes@edf.fr>
Thu, 26 May 2011 13:59:53 +0000 (15:59 +0200)
committerAndré Ribes <andre.ribes@edf.fr>
Thu, 26 May 2011 13:59:53 +0000 (15:59 +0200)
configure.ac
examples/daSalome/Makefile.am
examples/daSalome/test005_ADAO_Operators.comm.in [new file with mode: 0644]
examples/daSalome/test005_ADAO_scripts_for_JDC.py [new file with mode: 0644]

index 885875e1ee57c5ea37b71f719fd71815e5650778..6c6ae7a0f23e615b919e2b846ef6b95f990a909b 100644 (file)
@@ -126,6 +126,7 @@ AC_CONFIG_FILES([
         examples/daSalome/Makefile
         examples/daSalome/test003_ADAO_JDC_using_scripts.comm
         examples/daSalome/test004_ADAO_JDC_using_scripts.comm
+        examples/daSalome/test005_ADAO_Operators.comm
         bin/Makefile
         bin/qtEficas_adao_study.py
         doc/Makefile
index 77d4f1d0ba84d1f6c79e0e36c2b757b395134eec..f149f4dcad8d8a843eaeee9b3de6250d7c92fdd1 100644 (file)
@@ -6,7 +6,9 @@ DATA_INST = \
            test003_ADAO_JDC_using_scripts.comm \
            test003_ADAO_scripts_for_JDC.py \
            test004_ADAO_JDC_using_scripts.comm \
-           test004_ADAO_scripts_for_JDC.py
+           test004_ADAO_scripts_for_JDC.py \
+           test005_ADAO_Operators.comm \
+           test005_ADAO_scripts_for_JDC.py
 
 examplesdasalome_DATA = ${DATA_INST}
 
@@ -16,4 +18,6 @@ EXTRA_DIST = \
             test003_ADAO_JDC_using_scripts.comm.in \
             test003_ADAO_scripts_for_JDC.py \
             test004_ADAO_JDC_using_scripts.comm.in \
-            test004_ADAO_scripts_for_JDC.py
+            test004_ADAO_scripts_for_JDC.py \
+            test005_ADAO_Operators.comm.in \
+            test005_ADAO_scripts_for_JDC.py
diff --git a/examples/daSalome/test005_ADAO_Operators.comm.in b/examples/daSalome/test005_ADAO_Operators.comm.in
new file mode 100644 (file)
index 0000000..160a7fe
--- /dev/null
@@ -0,0 +1,31 @@
+
+ASSIMILATION_STUDY(Study_name='Test',
+                   Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
+                   Debug=0,
+                   Algorithm='3DVAR',
+                   Background=_F(INPUT_TYPE='Vector',
+                                 data=_F(FROM='String',
+                                         STRING='0 0 0',),),
+                   BackgroundError=_F(INPUT_TYPE='Matrix',
+                                      data=_F(FROM='String',
+                                              STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),
+                   Observation=_F(INPUT_TYPE='Vector',
+                                  data=_F(FROM='String',
+                                          STRING='1 1 1',),),
+                   ObservationError=_F(INPUT_TYPE='Matrix',
+                                       data=_F(FROM='String',
+                                               STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),
+                   ObservationOperator=_F(INPUT_TYPE='Function',
+                                          data=_F(FROM='FunctionDict',
+                                                  FUNCTIONDICT_FILE='test005_ADAO_scripts_for_JDC.py',),),
+                   UserPostAnalysis=_F(FROM='String',
+                                       STRING=
+"""import numpy
+Xb = Study.getBackground()
+Xa = ADD.get("Analysis").valueserie(-1)
+print
+print "Size of Background...........= %i"%len(Xb.A1)
+print "Size of Analysis.............= %i"%len(Xa)
+print "Min, mean, max of Analysis...= %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
+print
+""",),);
diff --git a/examples/daSalome/test005_ADAO_scripts_for_JDC.py b/examples/daSalome/test005_ADAO_scripts_for_JDC.py
new file mode 100644 (file)
index 0000000..78ef8a3
--- /dev/null
@@ -0,0 +1,66 @@
+#-*-coding:iso-8859-1-*-
+import numpy
+import logging
+logging.info("ComputationFunctionNode: Begin")
+# ==============================================================================
+# Input data and parameters: all is in the required input variable
+# "computation", containing for example:
+#      {'inputValues': [[[[0.0, 0.0, 0.0]]]],
+#       'inputVarList': ['adao_default'],
+#       'outputVarList': ['adao_default'],
+#       'specificParameters': [{'name': 'method', 'value': 'Direct'}]}
+# ==============================================================================
+#
+# Recovering the type of computation: "Direct", "Tangent" or "Adjoint"
+# --------------------------------------------------------------------
+method = ""
+for param in computation["specificParameters"]:
+    if param["name"] == "method":
+        method = param["value"]
+logging.info("ComputationFunctionNode: Found method is \'%s\'"%method)
+#
+# Recovering the current control state X
+# --------------------------------------
+Xcurrent = computation["inputValues"][0][0][0]
+#
+# Building explicit calculation or requiring external ones
+# --------------------------------------------------------
+dimension = len( Xcurrent )
+H  = numpy.matrix(numpy.core.identity(dimension))
+#
+def FunctionH( X ):
+    return H * X
+#
+def AdjointH( (X, Y) ):
+    return H.T * Y
+#
+# The possible computations
+# -------------------------
+if method == "Direct":
+    logging.info("ComputationFunctionNode: Direct computation")
+    data = FunctionH(numpy.matrix( Xcurrent ).T)
+#
+if method == "Tangent":
+    logging.info("ComputationFunctionNode: Tangent computation")
+    data = FunctionH(numpy.matrix( Xcurrent ).T)
+#
+if method == "Adjoint":
+    logging.info("ComputationFunctionNode: Adjoint computation")
+    Ycurrent = computation["inputValues"][0][0][1]
+    data = AdjointH((numpy.matrix( Xcurrent ).T, numpy.matrix( Ycurrent ).T))
+#
+# Formatting the output
+# ---------------------
+logging.info("ComputationFunctionNode: Formatting the output")
+it = data.flat
+outputValues = [[[[]]]]
+for val in it:
+  outputValues[0][0][0].append(val)
+#
+result = {}
+result["outputValues"]        = outputValues
+result["specificOutputInfos"] = []
+result["returnCode"]          = 0
+result["errorMessage"]        = ""
+#
+logging.info("ComputationFunctionNode: End")