- # On stocke dans l'attribut _naming_service, une reference sur
- # le Naming Service CORBA
- self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
- self.case = None
- self.wrapperDescription = ""
-
-######################################################################
-# This is the Wrapper part of the GENERICSOLVER module, ie
-# the three following methods are used by generic controlling
-# modules like OpenTURNS in order to launch a computation.
-# The interface is declared in GENERICSOLVER_Gen.idl. The methods
-# are free to call the legacy interface (see below).
-######################################################################
-
-
- def Init ( self, studyId, caseEntry, wrapperDescription ):
- """
- This method is an implementation for the GENERICSOLVER interface.
- It sets the component with some deterministic parametrization.
- """
- print "GENERICSOLVER.Init : enter"
- print "GENERICSOLVER.Init : studyId = %d - caseEntry = %s - wrapperDescription = %s" % ( studyId, caseEntry, wrapperDescription )
- self.wrapperDescription = wrapperDescription
- salome.salome_init()
-
- try:
- self.case = GetDataFromCase( studyId, caseEntry )
- except:
- traceback.print_exc()
- if self.case is None:
- return 1
- print "GENERICSOLVER.Init : exit"
- return 0
-
- def Exec ( self , inPoint ):
- """
- This method is an implementation for the GENERICSOLVER interface.
- It runs the component with some new parameters compared with the deterministic ones.
- """
- if self.case is None :
- print "GENERICSOLVER.Exec : Init not run"
- return 1, None
-
- print "GENERICSOLVER.Exec (1): inPoint = ", inPoint
-
- try:
- case = dict( self.case )
- if self.wrapperDescription != "":
- import sys
- print "sys.path = ", sys.path
- import openturns.wrapper
- wrapper = openturns.wrapper.WrapperFile.BuildWrapperFromStream( self.wrapperDescription )
- data = wrapper.getWrapperData()
- variableList = data.getVariableList()
- i = 0
- for idx in range( variableList.getSize() ):
- variable = variableList[ idx ]
- if variable.type_ == 0:
- print "variable %s <-> index %d" % ( variable.id_, i )
- case[ variable.id_ ] = inPoint[ i ]
- i += 1
-
- print "Case = ", case
- outPoint = self.BeamModel( **case )
- except:
- traceback.print_exc()
- return 1, None
-
-
- print "GENERICSOLVER.Exec (2): inPoint = ", inPoint
- print "GENERICSOLVER.Exec (2): outPoint = ", outPoint
- return 0, outPoint
-
- def Finalize ( self ):
- """
- This method is an implementation for the GENERICSOLVER interface.
- It cleans everything set so far.
- """
- print "GENERICSOLVER.Finalize : enter"
- print "GENERICSOLVER.Finalize : exit"
- return 0
-######################################################################
-# This is the computation part of the GENERICSOLVER module, ie
-# the following method realizes what the solver is intended to do.
-# The interface of this method (and maybe other ones) is absolutely
-# free and depends on the module (legacy interface).
-######################################################################
-
- def BeamModel ( self , E=1., F=0., L=0., I=1. ):
- """
- This method implements a beam bending model based on the following formula:
- deviation = ( Force * Length^3 ) / ( 3 * YoungModulus * InertiaSection )
- """
- d = ( F * L*L*L ) / ( 3. * E * I )
- print "GENERICSOLVER.Exec (2): BeamModel (E=%g, F=%g, L=%g, I=%g) = %g" % (E,F,L,I,d)
-
- return (d,)