]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Corrections and improvements for instances and regul/time
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 21 Feb 2018 21:47:16 +0000 (22:47 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 21 Feb 2018 21:47:16 +0000 (22:47 +0100)
examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py
src/daComposant/daCore/Aidsm.py
src/daComposant/daCore/BasicObjects.py
src/daComposant/daCore/Interfaces.py
src/daComposant/daCore/Persistence.py
src/daSalome/daYacsSchemaCreator/infos_daComposant.py
src/daSalome/daYacsSchemaCreator/methods.py

index c4299fb0595221c6bdb9f7cb3897b201767a3ce7..b8caec8359d19f596bb607010de700857717771f 100644 (file)
@@ -49,7 +49,7 @@ def DirectOperator( XX ):
     return numpy.array( HX )
 
 # ==============================================================================
-from ApproximatedDerivatives import FDApproximation
+from daNumerics.ApproximatedDerivatives import FDApproximation
 FDA = FDApproximation( DirectOperator )
 TangentOperator = FDA.TangentOperator
 AdjointOperator = FDA.AdjointOperator
index d951a0e97dd675777bcdae735534e54b35aba85c..29d9143364f9afb6e80cee2e0b1622a60851e925 100644 (file)
@@ -31,7 +31,7 @@ import sys
 #
 from daCore.BasicObjects import State, Covariance, FullOperator, Operator
 from daCore.BasicObjects import AlgorithmAndParameters, DataObserver
-from daCore.BasicObjects import CaseLogger
+from daCore.BasicObjects import RegulationAndParameters, CaseLogger
 from daCore import PlatformInfo
 #
 from daCore import ExtendedLogging ; ExtendedLogging.ExtendedLogging() # A importer en premier
@@ -65,6 +65,7 @@ class Aidsm(object):
             "Directory",
             "Debug",
             "NoDebug",
+            "RegulationParameters",
             "Observer",
             ]
         #
@@ -119,6 +120,8 @@ class Aidsm(object):
                          Script, Stored, ObjectMatrix, Checked )
             elif Concept == "AlgorithmParameters":
                 self.setAlgorithmParameters( Algorithm, Parameters, Script )
+            elif Concept == "RegulationParameters":
+                self.setRegulationParameters( Algorithm, Parameters, Script )
             elif Concept == "Name":
                 self.setName(String)
             elif Concept == "Directory":
@@ -461,6 +464,21 @@ class Aidsm(object):
             )
         return 0
 
+    def setRegulationParameters(self,
+            Algorithm  = None,
+            Parameters = None,
+            Script     = None):
+        "Definition d'un concept de calcul"
+        Concept = "RegulationParameters"
+        self.__case.register("set"+Concept, dir(), locals())
+        self.__adaoObject[Concept] = RegulationAndParameters(
+            name          = Concept,
+            asAlgorithm   = Algorithm,
+            asDict        = Parameters,
+            asScript      = self.with_directory(Script),
+            )
+        return 0
+
     def setObserver(self,
             Variable       = None,
             Template       = None,
index e44ff41d3db758bca737ed57b26eacf809996e8e..64e8a6e6079d98406f494a54fe27846cb30d971e 100644 (file)
@@ -1095,6 +1095,45 @@ class AlgorithmAndParameters(object):
         #
         return 1
 
+# ==============================================================================
+class RegulationAndParameters(object):
+    """
+    Classe générale d'interface d'action pour la régulation et ses paramètres
+    """
+    def __init__(self,
+                 name               = "GenericRegulation",
+                 asAlgorithm        = None,
+                 asDict             = None,
+                 asScript           = None,
+                ):
+        """
+        """
+        self.__name       = str(name)
+        self.__P          = {}
+        #
+        if asAlgorithm is None and asScript is not None:
+            __Algo = ImportFromScript(asScript).getvalue( "Algorithm" )
+        else:
+            __Algo = asAlgorithm
+        #
+        if asDict is None and asScript is not None:
+            __Dict = ImportFromScript(asScript).getvalue( self.__name, "Parameters" )
+        else:
+            __Dict = asDict
+        #
+        if __Dict is not None:
+            self.__P.update( dict(__Dict) )
+        #
+        if __Algo is not None:
+            self.__P.update( {"Algorithm":self.__A} )
+
+    def get(self, key = None):
+        "Vérifie l'existence d'une clé de variable ou de paramètres"
+        if key in self.__P:
+            return self.__P[key]
+        else:
+            return self.__P
+
 # ==============================================================================
 class DataObserver(object):
     """
index 3f9e8e904cfa8fac05b8132494a542b09d183b11..be7a61203a1b9c797e3616f1ace7e8f194541ae0 100644 (file)
@@ -687,9 +687,9 @@ class _YACSViewer(GenericCaseViewer):
         # -----
         if not PlatformInfo.has_salome or \
             not PlatformInfo.has_adao:
-            raise ImportError("\n\n"+\
-                "Unable to get SALOME or ADAO environnement variables.\n"+\
-                "Please load the right environnement before trying to use it.\n")
+            raise ImportError(
+                "Unable to get SALOME or ADAO environnement variables for YACS conversion.\n"+\
+                "Please load the right environnement before trying to use it.")
         elif __convertSCDinMemory:
             __file    = os.path.abspath(__filename)
             __SCDdump = self.__internalSCD.dump()
index 858c86551f86c529b0c1cd110b7feb67b91fa8b0..2b8608717c69a44108aa7c89873cce87622e53d8 100644 (file)
@@ -670,6 +670,21 @@ class Persistence(object):
     def hasDataObserver(self):
         return bool(len(self.__dataobservers) > 0)
 
+# ==============================================================================
+class SchedulerTrigger(object):
+    """
+    Classe générale d'interface de type Scheduler/Trigger
+    """
+    def __init__(self,
+                 simplifiedCombo = None,
+                 startTime       = 0,
+                 endTime         = int( 1e9 ),
+                 timeDelay       = 1,
+                 timeUnit        = 1,
+                 frequency       = None,
+                ):
+        pass
+
 # ==============================================================================
 class OneScalar(Persistence):
     """
index a9a0c0913a1ee2355cfa217d2132cdb7540276ad..9dd9ec973eaead35188c945b556845aa37687b30 100644 (file)
@@ -286,3 +286,6 @@ ObserversList = [
     "APosterioriVariances",
     "Residu",
     ]
+
+# Regulation : # of containers, 0 for no container
+UseYACSContainer = 1
index c21aa42063e8238c196dd1cde78796dfdc1963f2..32a9f3ca11492b38542caecd258b41e9196b8bb6 100644 (file)
@@ -77,6 +77,8 @@ def create_yacs_proc(study_config):
   else:
     base_repertory = ""
     repertory = False
+  if UseYACSContainer:
+    mycontainer = proc.createContainer("AdaoContainer")
 
   # Create ADAO case bloc
   ADAO_Case = runtime.createBloc("ADAO_Case_Bloc")
@@ -408,6 +410,9 @@ def create_yacs_proc(study_config):
       break
     # We create a new pyscript node
     opt_script_nodeOO = runtime.createScriptNode("", "FunctionNodeOO")
+    if UseYACSContainer:
+      opt_script_nodeOO.setExecutionMode(SALOMERuntime.PythonNode.REMOTE_STR)
+      opt_script_nodeOO.setContainer(mycontainer)
     if repertory and os.path.exists(os.path.join(base_repertory, os.path.basename(script_filename))):
       script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
     try:
@@ -436,6 +441,9 @@ def create_yacs_proc(study_config):
 
     # We create a new pyscript node
     opt_script_nodeOO = runtime.createScriptNode("", "FunctionNodeOO")
+    if UseYACSContainer:
+      opt_script_nodeOO.setExecutionMode(SALOMERuntime.PythonNode.REMOTE_STR)
+      opt_script_nodeOO.setContainer(mycontainer)
     if repertory and os.path.exists(os.path.join(base_repertory, os.path.basename(script_filename))):
       script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
     try:
@@ -516,6 +524,9 @@ def create_yacs_proc(study_config):
 
     # We create a new pyscript node
     opt_script_nodeOO = runtime.createScriptNode("", "FunctionNodeOO")
+    if UseYACSContainer:
+      opt_script_nodeOO.setExecutionMode(SALOMERuntime.PythonNode.REMOTE_STR)
+      opt_script_nodeOO.setContainer(mycontainer)
     if repertory and os.path.exists(os.path.join(base_repertory, os.path.basename(script_filename))):
       script_filename = os.path.join(base_repertory, os.path.basename(script_filename))
     try:
@@ -542,7 +553,7 @@ def create_yacs_proc(study_config):
     node_script += """    DirectOperator\n"""
     node_script += """except NameError:\n"""
     node_script += """    raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
-    node_script += """import ApproximatedDerivatives\n"""
+    node_script += """from daNumerics import ApproximatedDerivatives\n"""
     node_script += """FDA = ApproximatedDerivatives.FDApproximation(\n"""
     node_script += """    Function   = DirectOperator,\n"""
     node_script += """    increment  = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])
@@ -739,7 +750,7 @@ def create_yacs_proc(study_config):
       node_script += """    DirectOperator\n"""
       node_script += """except NameError:\n"""
       node_script += """    raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
-      node_script += """import ApproximatedDerivatives\n"""
+      node_script += """from daNumerics import ApproximatedDerivatives\n"""
       node_script += """FDA = ApproximatedDerivatives.FDApproximation(\n"""
       node_script += """    Function   = DirectOperator,\n"""
       node_script += """    increment  = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])