return numpy.array( HX )
# ==============================================================================
-from ApproximatedDerivatives import FDApproximation
+from daNumerics.ApproximatedDerivatives import FDApproximation
FDA = FDApproximation( DirectOperator )
TangentOperator = FDA.TangentOperator
AdjointOperator = FDA.AdjointOperator
#
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
"Directory",
"Debug",
"NoDebug",
+ "RegulationParameters",
"Observer",
]
#
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":
)
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,
#
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):
"""
# -----
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()
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):
"""
"APosterioriVariances",
"Residu",
]
+
+# Regulation : # of containers, 0 for no container
+UseYACSContainer = 1
else:
base_repertory = ""
repertory = False
+ if UseYACSContainer:
+ mycontainer = proc.createContainer("AdaoContainer")
# Create ADAO case bloc
ADAO_Case = runtime.createBloc("ADAO_Case_Bloc")
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:
# 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:
# 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:
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'])
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'])