Back to index

salome-med  6.5.0
TestMedCorba1.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 import os
00025 BASE = os.environ["MED_ROOT_DIR"]
00026 BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' )
00027 
00028 fileName = os.path.join( BASE, 'pointe.med' )
00029 fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' )
00030 fileName = os.path.join( BASE, 'test_hydro_darcy1a_out.med' )
00031 
00032 # MED Mesh read from a (local) file
00033 
00034 from libMEDMEM_Swig import *
00035 
00036 md = MED()
00037 
00038 mdDriver = MED_MED_RDONLY_DRIVER(fileName, md)
00039 
00040 mdDriver.open()
00041 mdDriver.readFileStruct()
00042 mdDriver.close()
00043 
00044 mLocal = md.getMesh(md.getMeshName(0))
00045 mLocal.read()
00046 
00047 # MED Mesh recieved from a distant component (via CORBA)
00048 
00049 from omniORB import CORBA
00050 from LifeCycleCORBA import *
00051 #CCRTfrom libSALOME_Swig import *
00052 
00053 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
00054 lcc = LifeCycleCORBA(orb)
00055 
00056 C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py")
00057 C.Initialise(fileName)
00058 
00059 mDistant = C.Calcul1()
00060 
00061 # Compare local and distant copies
00062 
00063 def ecart(x, y):
00064     s = 0.
00065     if (len(x) != len(y)):
00066         return 1.
00067     
00068     for i in xrange(len(x)):
00069         s = s + abs(x[i] - y[i]);
00070     return s
00071 
00072 def compare(x, y):
00073     if (len(x) != len(y)):
00074         return 0
00075     for i in xrange(len(x)):
00076         if x[i] != y[i]:
00077             return 0
00078     return 1
00079 
00080 print "Name              : ", mDistant.getName()
00081 if (mLocal.getName() != mDistant.getName()):
00082     raise RuntimeError, "MESH::getName()"
00083 
00084 print "SpaceDimension    : ", mDistant.getSpaceDimension()
00085 if (mLocal.getSpaceDimension() != mDistant.getSpaceDimension()):
00086     raise RuntimeError, "MESH::getSpaceDimension()"
00087 
00088 print "MeshDimension     : ", mDistant.getMeshDimension()
00089 if (mLocal.getMeshDimension() != mDistant.getMeshDimension()):
00090     raise RuntimeError, "MESH::getMeshDimension()"
00091 
00092 print "CoordinatesSystem : ", mDistant.getCoordinatesSystem()
00093 if (mLocal.getCoordinatesSystem() != mDistant.getCoordinatesSystem()):
00094     raise RuntimeError, "MESH::getCoordinatesSystem()"
00095 
00096 print "NumberOfNodes     : ", mDistant.getNumberOfNodes()
00097 if (mLocal.getNumberOfNodes() != mDistant.getNumberOfNodes()):
00098     raise RuntimeError, "MESH::getNumberOfNodes()"
00099 
00100 
00101 print
00102 print "All tests passed"