// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-//=============================================================================
-// File : Calculator.idl
-// Created : jeu nov 08 12:08:17 CEST 2001
-// Author : Laurent DADA CEA
-// Project : SALOME
-//=============================================================================
+//============================================================================
+// File : PYCALCULATOR.idl
+// Author : Vadim SANDLER, OPEN CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//============================================================================
#ifndef PYCALCULATOR_IDL
#define PYCALCULATOR_IDL
#include "SALOME_Component.idl"
-#include "MED.idl"
+#include "MEDCouplingCorbaServant.idl"
+/*!
+ \ingroup examples
+ This package contains the interface for %PYCALCULATOR component
+ as an example in %SALOME application.
+*/
module PYCALCULATOR_ORB {
-interface PYCALCULATOR_Gen : Engines::EngineComponent
-{
+ /*!
+ \brief Interface of the %PYCALCULATOR component
+ */
+ interface PYCALCULATOR_Gen : Engines::EngineComponent
+ {
+ /*!
+ \brief Clone field.
+ \param field a field
+ \return a field which is a copy of \a field
+ */
+ SALOME_MED::MEDCouplingFieldDoubleCorbaInterface
+ Clone(in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field);
- SALOME_MED::FIELDDOUBLE Add(in SALOME_MED::FIELDDOUBLE field1, in SALOME_MED::FIELDDOUBLE field2);
- SALOME_MED::FIELDDOUBLE Mul(in SALOME_MED::FIELDDOUBLE field1, in double x1);
- SALOME_MED::FIELDDOUBLE Constant(in SALOME_MED::FIELDDOUBLE field1, in double x1);
- void writeMEDfile(in SALOME_MED::FIELDDOUBLE field1, in string fileName);
-
-};
-};
+ /*!
+ \brief Add two fields.
+ \param field1 first field
+ \param field2 second field
+ \return a field which is result of addition of \a field1 and \a field2
+ */
+ SALOME_MED::MEDCouplingFieldDoubleCorbaInterface
+ Add(in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field1,
+ in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field2);
+ /*!
+ \brief Multiply two fields.
+ \param field1 first field
+ \param field2 second field
+ \return a field which is result of multiplication of \a field1 and \a field2
+ */
+ SALOME_MED::MEDCouplingFieldDoubleCorbaInterface
+ Mul(in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field1,
+ in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field2);
+ /*!
+ \brief Add a constant to a field.
+ \param field a field
+ \param val a constant
+ \return a field which is result of addition of \a val to \a field
+ */
+ SALOME_MED::MEDCouplingFieldDoubleCorbaInterface
+ AddConstant(in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field,
+ in double val);
+ /*!
+ \brief Multiply a field to a constant.
+ \param field a field
+ \param val a constant
+ \return a field which is result of multiplication of \a field to \a val
+ */
+ SALOME_MED::MEDCouplingFieldDoubleCorbaInterface
+ MulConstant(in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface field,
+ in double val);
+ };
+};
#endif
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+#============================================================================
+# File : PYCALCULATOR.py
+# Author : Vadim SANDLER, OPEN CASCADE S.A.S. (vadim.sandler@opencascade.com)
+#============================================================================
+
# Instruct Python to load dynamic libraries using global resolution of symbols
# This is necessary to ensure that different modules will have the same definition
# of dynamic types and C++ RTTI will work between them
import SALOME_ComponentPy
import SALOME_MED
-from libMEDMEM_Swig import *
-from libMedCorba_Swig import *
-from libMEDClient import *
+from MEDCouplingClient import *
+from MEDCouplingCorba import *
+
+from salome_utils import verbose
-class PYCALCULATOR (PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SALOME_ComponentPy_i ):
+class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SALOME_ComponentPy_i):
+ ## Constructor
def __init__(self, orb, poa, contID, containerName, instanceName,
interfaceName):
- print "Begin of PYCALCULATOR::__init__"
- notif = 0
- SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
- contID, containerName, instanceName, interfaceName, notif)
- self._naming_service=SALOME_ComponentPy.SALOME_NamingServicePy_i(self._orb)
- print "End of PYCALCULATOR::__init__"
+ if verbose(): print "Begin of PYCALCULATOR::__init__"
+
+ SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(
+ self,
+ orb, # ORB instance
+ poa, # POA instance
+ contID, # SALOME container id
+ containerName, # SALOME container name
+ instanceName, # component instance name
+ interfaceName, # component interface name
+ 0) # notification flag (for notification server)
+
+ self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i(self._orb)
+
+ if verbose(): print "End of PYCALCULATOR::__init__"
+
+ pass
+
+ ## base interface method: get version of the component
def getVersion( self ):
import salome_version
return salome_version.getVersion("PYCALCULATOR", True)
+ ## interface service: clone field
+ def Clone(self, field):
+ self.beginService("PYCALCULATOR::Clone")
+
+ if verbose():
+ print "Begin of PYCALCULATOR::Clone"
+ print " field : ", field
+ pass
+
+ frescorba = None
+
+ try:
+ # create local field from corba field
+ f = MEDCouplingFieldDoubleClient.New(field)
+
+ # create CORBA field
+ frescorba = MEDCouplingFieldDoubleServant._this(f)
+
+ except Exception, e:
+ if verbose(): print e
+ pass
+
+ if verbose():
+ print "End of PYCALCULATOR::Clone"
+ pass
+
+ self.endService("PYCALCULATOR::Clone")
+
+ return frescorba
+
+ ## interface service: add two fields
def Add(self, field1, field2):
- print "Begin of PYCALCULATOR::Add"
- print "pointeur on first argument : ",field1
- print " second : ",field2
-
- bool = 1
- nbOfComp1 = field1.getNumberOfComponents()
- name1 = field1.getName()
- description1 = field1.getDescription()
-
- nbOfComp2 = field2.getNumberOfComponents()
- name2 = field2.getName()
- description2 = field2.getDescription()
-
- if (nbOfComp1 != nbOfComp2): bool = 0
-
- compName = []
- compUnit = []
- for k in range(nbOfComp1):
- kp1 = k+1
- compName.append(field1.getComponentName(kp1))
- compUnit.append(field1.getComponentUnit(kp1))
- if (bool):
- if ((compName[k] != field2.getComponentName(kp1)) or (compUnit[k] != field2.getComponentUnit(kp1))):
- bool = 0
-
- support1 = field1.getSupport()
- entity1 = support1.getEntity()
- mesh1 = support1.getMesh()
-
- support2 = field2.getSupport()
- entity2 = support2.getEntity()
- mesh2 = support2.getMesh()
-
- if (support1.isOnAllElements()):
- lengthValue1 = mesh1.getNumberOfElements(entity1,SALOME_MED.MED_ALL_ELEMENTS)
- number1 = []
- for k in range(lengthValue1):
- number1.append(k)
- else:
- lengthValue1 = support1.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
- number1 = support1.getNumber(SALOME_MED.MED_ALL_ELEMENTS)
-
- if (support2.isOnAllElements()):
- lengthValue2 = mesh2.getNumberOfElements(entity2,SALOME_MED.MED_ALL_ELEMENTS)
- number2 = []
- for k in range(lengthValue2):
- number2.append(k)
- else:
- lengthValue2 = support2.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
- number2 = support2.getNumber(SALOME_MED.MED_ALL_ELEMENTS)
-
- # comparision of each support: due to the fact that they are CORBA
- # pointers, the comparision will be done directly throught the numbers
-
- if (bool):
- if ((lengthValue1 != lengthValue2) or (entity1 != entity2)):
- bool = 0
-
- if (bool):
- for k in range(lengthValue1):
- if (number1[k] != number2[k]):
- bool = 0
-
- value1 = field1.getValue(SALOME_MED.MED_FULL_INTERLACE)
-
- value2 = []
- if (bool):
- value2 = field2.getValue(SALOME_MED.MED_FULL_INTERLACE)
-
- valueOut = []
- if (bool):
- print "CALCULATORPY::Add : The fields have the same support, they then can be added"
- for k in range(lengthValue1*nbOfComp1):
- valueOut.append((value1[k]+value2[k]))
- else:
- print "CALCULATORPY::Add : WARNING !! For some reason the fields have not the same support"
- for k in range(lengthValue1*nbOfComp1):
- valueOut.append(value1[k])
-
- supportOutLocal = SUPPORTClient( support1 )
- supportOutCorba = createCorbaSupport( supportOutLocal )
-
- print "CALCULATORPY::Add : Creation of the local field, nbOfComp = ",nbOfComp1, " length = ",lengthValue1
-
- fieldOutLocal = createLocalFieldDouble(nbOfComp1,lengthValue1)
- fieldOutLocal.setValue(valueOut)
- fieldOutLocal.setName("-new_Add_Field-")
- fieldOutLocal.setDescription(description1)
- fieldOutLocal.setSupport( supportOutLocal )
-
- for k in range(nbOfComp1):
- kp1 = k + 1
- fieldOutLocal.setComponentName(kp1,compName[k])
- fieldOutLocal.setMEDComponentUnit(kp1,compUnit[k])
-
- print "CALCULATORPY::Add : Creation of the CORBA field"
-
- fieldOutCorba = createCorbaFieldDouble(supportOutCorba,fieldOutLocal)
-
- print "End of CALCULATORPY::Add"
- return fieldOutCorba
-
- def Mul(self, field1, x1):
- print "Begin of CALCULATORPY::Mul"
- print "pointeur on first argument : ",field1
- print " second : ",x1
-
- nbOfComp = field1.getNumberOfComponents()
- name = field1.getName()
- description = field1.getDescription()
- support = field1.getSupport()
- print ".... get Names and Unit"
- compName = []
- compUnit = []
- for k in range(nbOfComp):
- kp1 = k+1
- compName.append(field1.getComponentName(kp1))
- compUnit.append(field1.getComponentUnit(kp1))
-
-
- print ".... get mesh"
- mesh = support.getMesh()
-
- if (support.isOnAllElements()):
- lengthValue = mesh.getNumberOfElements(support.getEntity(),SALOME_MED.MED_ALL_ELEMENTS)
- else:
- lengthValue = support.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
-
- value1 = field1.getValue(SALOME_MED.MED_FULL_INTERLACE)
- valueOut = []
- for k in range(lengthValue*nbOfComp):
- valueOut.append(x1*value1[k])
-
- supportOutLocal = SUPPORTClient( support )
- supportOutCorba = createCorbaSupport( supportOutLocal )
-
- print "CALCULATORPY::Mul : Creation of the local field, nbOfComp = ",nbOfComp, " length = ",lengthValue
-
- fieldOutLocal = createLocalFieldDouble(nbOfComp,lengthValue)
- fieldOutLocal.setValue(valueOut)
- fieldOutLocal.setName("-new_Mul_Field-")
- fieldOutLocal.setDescription(description)
- fieldOutLocal.setSupport( supportOutLocal )
-
- for k in range(nbOfComp):
- kp1 = k + 1
- fieldOutLocal.setComponentName(kp1,compName[k])
- fieldOutLocal.setMEDComponentUnit(kp1,compUnit[k])
-
- print "CALCULATORPY::Mul : Creation of the CORBA field"
-
- fieldOutCorba = createCorbaFieldDouble(supportOutCorba,fieldOutLocal)
-
- print "End of CALCULATORPY::Mul"
- return fieldOutCorba
-
- def Constant(self, field1, x1):
- print "Begin of CALCULATORPY::Constant"
- print "pointeur on first argument : ",field1
- print " second : ",x1
-
- nbOfComp = field1.getNumberOfComponents()
- name = field1.getName()
- description = field1.getDescription()
- support = field1.getSupport()
- compName = []
- compUnit = []
- for k in range(nbOfComp):
- kp1 = k+1
- compName.append(field1.getComponentName(kp1))
- compUnit.append(field1.getComponentUnit(kp1))
-
- mesh = support.getMesh()
-
- if (support.isOnAllElements()):
- lengthValue = mesh.getNumberOfElements(support.getEntity(),SALOME_MED.MED_ALL_ELEMENTS)
- else:
- lengthValue = support.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
-
- valueOut = []
- for k in range(lengthValue*nbOfComp):
- valueOut.append(x1)
-
- print "CALCULATORPY::Constant : Creation of the local field, nbOfComp = ",nbOfComp, " length = ",lengthValue
-
- supportOutLocal = SUPPORTClient( support )
- supportOutCorba = createCorbaSupport( supportOutLocal )
-
- fieldOutLocal = createLocalFieldDouble(nbOfComp,lengthValue)
- fieldOutLocal.setValue(valueOut)
- fieldOutLocal.setName("-new_Const_Field-")
- fieldOutLocal.setDescription(description)
- fieldOutLocal.setSupport( supportOutLocal )
-
- for k in range(nbOfComp):
- kp1 = k + 1
- fieldOutLocal.setComponentName(kp1,compName[k])
- fieldOutLocal.setMEDComponentUnit(kp1,compUnit[k])
-
- print "CALCULATORPY::Constant : Creation of the CORBA field"
-
- fieldOutCorba = createCorbaFieldDouble(supportOutCorba,fieldOutLocal)
-
- print "End of CALCULATORPY::Constant"
- return fieldOutCorba
-
- def writeMEDfile(self, field1, fileName):
- print "Begin of CALCULATORPY::writeMEDfile"
- print "CALCULATORPY::writeMEDfile : pointeur on first argument : ",field1
- print " second : ",fileName
- print "CALCULATORPY::writeMEDfile : NOT YET IMPLEMENTED"
- print "End of CALCULATORPY::writeMEDfile"
+ self.beginService("PYCALCULATOR::Add")
+
+ if verbose():
+ print "Begin of PYCALCULATOR::Add"
+ print " field 1 : ", field1
+ print " field 2 : ", field2
+ pass
+
+ frescorba = None
+
+ try:
+ # create local fields from corba fields
+ f1 = MEDCouplingFieldDoubleClient.New(field1)
+ f2 = MEDCouplingFieldDoubleClient.New(field2)
+
+ # add fields
+ f2.changeUnderlyingMesh(f1.getMesh(), 0, 1e-12)
+ fres = f1 + f2
+
+ # create CORBA field
+ frescorba = MEDCouplingFieldDoubleServant._this(fres)
+
+ except Exception, e:
+ if verbose(): print e
+ pass
+
+ if verbose():
+ print "End of PYCALCULATOR::Add"
+ pass
+
+ self.endService("PYCALCULATOR::Add")
+
+ return frescorba
+
+ ## interface service: multiply two fields
+ def Mul(self, field1, field2):
+ self.beginService("PYCALCULATOR::Mul")
+
+ if verbose():
+ print "Begin of PYCALCULATOR::Mul"
+ print " field 1 : ", field1
+ print " field 2 : ", field2
+ pass
+
+ frescorba = None
+
+ try:
+ # create local fields from corba fields
+ f1 = MEDCouplingFieldDoubleClient.New(field1)
+ f2 = MEDCouplingFieldDoubleClient.New(field2)
+
+ # multiply fields
+ f2.changeUnderlyingMesh(f1.getMesh(), 0, 1e-12)
+ fres = f1 * f2
+
+ # create CORBA field
+ frescorba = MEDCouplingFieldDoubleServant._this(fres)
+
+ except Exception, e:
+ if verbose(): print e
+ pass
+
+ if verbose():
+ print "End of PYCALCULATOR::Mul"
+ pass
+
+ self.endService("PYCALCULATOR::Mul")
+
+ return frescorba
+
+ ## interface service: add a constant to a field
+ def AddConstant(self, field, val):
+ self.beginService("PYCALCULATOR::AddConstant")
+
+ if verbose():
+ print "Begin of PYCALCULATOR::AddConstant"
+ print " field : ", field
+ print " constant : ", val
+ pass
+
+ frescorba = None
+
+ try:
+ # create local field from corba field
+ f = MEDCouplingFieldDoubleClient.New(field)
+
+ # add constant to a field
+ fres = f + val
+
+ # create CORBA field
+ frescorba = MEDCouplingFieldDoubleServant._this(fres)
+
+ except Exception, e:
+ if verbose(): print e
+ pass
+
+ if verbose():
+ print "End of PYCALCULATOR::AddConstant"
+ pass
+
+ self.endService("PYCALCULATOR::AddConstant")
+
+ return frescorba
+
+ ## interface service: multiply a field to a constant
+ def MulConstant(self, field, val):
+ self.beginService("PYCALCULATOR::MulConstant")
+
+ if verbose():
+ print "Begin of PYCALCULATOR::MulConstant"
+ print " field : ", field
+ print " constant : ", val
+ pass
+
+ frescorba = None
+
+ try:
+ # create local field from corba field
+ f = MEDCouplingFieldDoubleClient.New(field)
+
+ # multiply field to a constant
+ fres = f * val
+
+ # create CORBA field
+ frescorba = MEDCouplingFieldDoubleServant._this(fres)
+
+ except Exception, e:
+ if verbose(): print e
+ pass
+
+ if verbose():
+ print "End of PYCALCULATOR::MulConstant"
+ pass
+
+ self.endService("PYCALCULATOR::MulConstant")
+
+ return frescorba
+
+ pass # end of class PYCALCULATOR
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-import salome
-import SALOME
-import SALOME_MED
-import PYCALCULATOR_ORB
-import os
-
-#==============================================================================
-
-def AnalyzeField(field):
- name = field.getName()
- desc = field.getDescription()
- nbComp = field.getNumberOfComponents()
- itNum = field.getIterationNumber()
- ordNum = field.getOrderNumber()
-
- print "Analysis of the field ",name," with the description ",desc
- print "iteration number ",itNum," order Number ",ordNum
- print "It has ",nbComp," component(s)"
-
- fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE)
- fieldSupport = field.getSupport()
- fieldMesh = fieldSupport.getMesh()
- fieldEntity = fieldSupport.getEntity()
- bool = fieldSupport.isOnAllElements()
-
- if bool:
- print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName()
- if fieldEntity == SALOME_MED.MED_NODE:
- nbValByComp = fieldMesh.getNumberOfNodes()
- else:
- nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS)
- print "and its dimension (number of values by component of the field) is ",nbValByComp
- else:
- print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName()
- nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS)
- print "and its dimension (number of values by component of the field) is ",nbValByComp
-
- for i in range(nbComp):
- compName = field.getComponentName(i+1)
- compUnit = field.getComponentUnit(i+1)
- print "The ",(i+1),"-th component ",compName," with the unit ",compUnit
-
- for i in range(nbValByComp):
- print " * ",fieldValue[i*nbComp:(i+1)*nbComp]
-
-#==============================================================================
-
-def getFieldIntObjectFromStudy(number,subnumber):
- mySO = salome.myStudy.FindObject("MEDFIELD")
- mysub = mySO.FindSubObject(number)[1]
- if mysub:
- mysubsub = mysub.FindSubObject(subnumber)[1]
- if mysubsub:
- Builder = salome.myStudy.NewBuilder()
- anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
- obj = salome.orb.string_to_object(anAttr.Value())
- myObj = obj._narrow(SALOME_MED.FIELDINT)
- return myObj
- else:
- print "ERROR: No FieldInt Object stored in this Study"
- return None
- else:
- print "ERROR: No FieldInt Object stored in this Study"
- return None
-
-#==============================================================================
-
-def getFieldDoubleObjectFromStudy(number,subnumber):
- mySO = salome.myStudy.FindObject("MEDFIELD")
- mysub = mySO.FindSubObject(number)[1]
- if mysub:
- mysubsub = mysub.FindSubObject(subnumber)[1]
- if mysubsub:
- Builder = salome.myStudy.NewBuilder()
- anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
- obj = salome.orb.string_to_object(anAttr.Value())
- myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
- return myObj
- else:
- print "ERROR: No FieldDouble Object stored in this Study"
- return None
- else:
- print "ERROR: No FieldDouble Object stored in this Study"
- return None
+#============================================================================
+# File : PYCALCULATOR_TEST.py
+# Author : Vadim SANDLER, OPEN CASCADE S.A.S. (vadim.sandler@opencascade.com)
+#============================================================================
-#==============================================================================
-
-studyname = salome.myStudyName
-studynameId = salome.myStudyId
-
-print "We are working in the study ",studyname," with the ID ",studynameId
-print ""
-
-filePath=os.environ["MED_ROOT_DIR"]
-filePath=filePath+"/share/salome/resources/med/"
-medFile=filePath+"pointe.med"
-fieldname = "fieldcelldoublevector"
-
-print "Load the Med Component "
-med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
-
-try:
- fieldcell = med_comp.readFieldInFile(medFile,studyname,fieldname,-1,-1)
-except SALOME.SALOME_Exception, ex:
- print ex.details
- print ex.details.type
- print ex.details.text
- print ex.details.sourceFile
- print ex.details.lineNumber
- raise
-
-print fieldcell
-print fieldcell.getName()
-print fieldcell.getDescription()
-print fieldcell.getNumberOfComponents()
-
-
-AnalyzeField(fieldcell)
-
-
-
-print "Loading of the CalculatorPy Component "
-calculator = salome.lcc.FindOrLoadComponent("FactoryServerPy", "PYCALCULATOR")
-print "calculator = ", calculator
+import os
-alpha = 2.0
-print "Multiplication of fieldcelldouble by alpha"
-fieldcellalpha = calculator.Mul(fieldcell,alpha)
-print fieldcellalpha
-AnalyzeField(fieldcellalpha)
+import salome
+salome.salome_init()
-print "Adding of alpha*fieldcelldouble and fieldcelldouble"
-fieldcelladd = calculator.Add(fieldcell,fieldcellalpha)
-print fieldcelladd
-AnalyzeField(fieldcelladd)
+import PYCALCULATOR_ORB
-print "Put fieldcelladd in study"
-fieldcelladd.addInStudy(salome.myStudy,fieldcelladd)
+from MEDCouplingCorba import *
+from MEDCoupling import *
+from MEDLoader import *
-print "update Salome GUI"
-salome.sg.updateObjBrowser(1)
+pc = salome.lcc.FindOrLoadComponent('FactoryServer','PYCALCULATOR')
-print "Get back Field from study"
-# we grab the second field in MEDFIELD - first iteration
-fieldcelldouble = getFieldDoubleObjectFromStudy(1,1)
-print fieldcelldouble
-AnalyzeField(fieldcelldouble)
+medFile = os.path.join(os.getenv("MED_ROOT_DIR"), "share/salome/resources/med/pointe.med")
+meshName = "maa1"
+fieldName = "fieldcelldoublevector"
+print medFile, meshName, fieldName
+f = MEDLoader.ReadFieldCell(medFile, meshName, 0, fieldName, -1, -1)
+forig = MEDCouplingFieldDoubleServant._this(f)
-print "Fin du test PYCALCULATOR"
+fcopy = pc.Clone(forig)
+f1 = pc.Add(forig, fcopy)
+f2 = pc.Mul(forig, fcopy)
+f3 = pc.AddConstant(forig, 3.5)
+f4 = pc.MulConstant(forig, 3.5)