+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_1
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_1"
-DEBUG = False
-N_ITER_TEST_FILE = 3
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- error = 0
-#
- while not error :
- #
- HOMARD.SetCurrentStudy(theStudy)
- #
- # Creation of the zones
- # =====================
- # Creation of the box zone_1_1
- zone_1_1 = HOMARD.CreateZoneBox('Zone_1_1', -0.01, 1.01, -0.01, 0.4, -0.01, 0.6)
-
- # Creation of the sphere zone_1_2
- zone_1_2 = HOMARD.CreateZoneSphere('Zone_1_2', 0.5, 0.6, 0.7, 0.75)
- #
- # Creation of the hypotheses
- # ==========================
- dico = {}
- dico["1"] = "raffinement"
- dico["-1"] = "deraffinement"
- # Creation of the hypothesis a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM
- hyponame_1 = "a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM"
- print "-------- Creation of the hypothesis", hyponame_1
- hypo_1_1 = HOMARD.CreateHypothesis(hyponame_1)
- hypo_1_1.SetField('RESU____ERRE_ELEM_SIGM__________')
- hypo_1_1.SetUseComp(0)
- hypo_1_1.AddComp('ERREST')
- hypo_1_1.SetRefinThr(3, 10.1)
- hypo_1_1.AddFieldInterp('RESU____DEPL____________________')
- hypo_1_1.AddFieldInterp('RESU____ERRE_ELEM_SIGM__________')
- print hyponame_1, " : champ utilisé :", hypo_1_1.GetFieldName()
- print hyponame_1, " : composantes utilisées :", hypo_1_1.GetComps()
- if ( len (hypo_1_1.GetFieldName()) > 0 ) :
- print ".. caractéristiques de l'adaptation :", hypo_1_1.GetField()
- print hyponame_1, " : champs interpolés :", hypo_1_1.GetFieldInterps()
- # Creation of the hypothesis Zones_1_et_2
- hyponame_2 = "Zones_1_et_2"
- print "-------- Creation of the hypothesis", hyponame_2
- zones_1_et_2 = HOMARD.CreateHypothesis(hyponame_2)
- zones_1_et_2.AddZone('Zone_1_1', 1)
- zones_1_et_2.AddZone('Zone_1_2', 1)
- laux = zones_1_et_2.GetZones()
- nbzone = len(laux)/2
- jaux = 0
- for iaux in range(nbzone) :
- print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
- jaux += 2
- print hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName()
- if ( len (zones_1_et_2.GetFieldName()) > 0 ) :
- print ".. caractéristiques de l'adaptation :", zones_1_et_2.GetField()
- print hyponame_2, " : champs interpolés :", zones_1_et_2.GetFieldInterps()
- #
- # Creation of the cases
- # =====================
- # Creation of the case
- print "-------- Creation of the case", TEST_NAME
- mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med')
- case_test_1 = HOMARD.CreateCase(TEST_NAME, 'MAILL', mesh_file)
- case_test_1.SetDirName(DIRCASE)
- #
- # Creation of the iterations
- # ==========================
- # Creation of the iteration 1
- iter_name = "I_" + TEST_NAME + "_1"
- print "-------- Creation of the iteration", iter_name
- iter_test_1_1 = case_test_1.NextIteration(iter_name)
- iter_test_1_1.AssociateHypo(hyponame_1)
- print ". Hypothese :", hyponame_1
- iter_test_1_1.SetMeshName('M1')
- iter_test_1_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
- iter_test_1_1.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.00.med'))
- iter_test_1_1.SetTimeStepRank(1, 1)
- iter_test_1_1.SetFieldInterpTimeStep('RESU____DEPL____________________', 1)
- iter_test_1_1.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1)
- print ". Instants d'interpolation :", iter_test_1_1.GetFieldInterpsTimeStepRank()
- error = iter_test_1_1.Compute(1, 1)
- if error :
- error = 1
- break
-
- # Creation of the iteration 2
- iter_name = "I_" + TEST_NAME + "_2"
- print "-------- Creation of the iteration", iter_name
- iter_test_1_2 = iter_test_1_1.NextIteration(iter_name)
- iter_test_1_2.AssociateHypo(hyponame_1)
- print ". Hypothese :", hyponame_1
- iter_test_1_2.SetMeshName('M2')
- iter_test_1_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
- iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.01.med'))
- iter_test_1_2.SetTimeStepRank(1, 1)
- iter_test_1_2.SetFieldInterpTimeStep('RESU____DEPL____________________', 1)
- iter_test_1_2.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1)
- print ". Instants d'interpolation :", iter_test_1_2.GetFieldInterpsTimeStepRank()
- error = iter_test_1_2.Compute(1, 1)
- if error :
- error = 2
- break
-
- # Creation of the iteration 3
- iter_name = "I_" + TEST_NAME + "_3"
- print "-------- Creation of the iteration", iter_name
- iter_test_1_3 = iter_test_1_2.NextIteration(iter_name)
- iter_test_1_3.AssociateHypo(hyponame_2)
- print ". Hypothese :", hyponame_2
- iter_test_1_3.SetMeshName('M3')
- iter_test_1_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
- iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.02.med'))
- print ". Instants d'interpolation :", iter_test_1_3.GetFieldInterpsTimeStepRank()
- error = iter_test_1_3.Compute(1, 1)
- if error :
- error = 3
- break
- #
- # Creation of the schema YACS
- # ===========================
- scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py")
- scriptfile = os.path.normpath(scriptfile)
- dirname = DIRCASE
- yacs_test_1 = case_test_1.CreateYACSSchema("YACS_test_1", scriptfile, dirname, mesh_file)
- error = yacs_test_1.Write()
- if error :
- error = 4
- break
- #
- break
- #
- return error
-
-#========================================================================
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load homard engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_2
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_2"
-DEBUG = False
-N_ITER_TEST_FILE = 3
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- error = 0
-#
- while not error :
- #
- HOMARD.SetCurrentStudy(theStudy)
- #
- # Creation of the boundaries
- # ==========================
- # Creation of the discrete boundary boundary_1
- boundary_1 = HOMARD.CreateBoundaryDi('internal_boundary', 'plaque', os.path.join(REP_DATA, TEST_NAME + '.fr.med'))
- #
- # Creation of the hypotheses
- # ==========================
- # Creation of the hypothesis 1
- hyponame_1 = "hypo_" + TEST_NAME + "_1"
- print "-------- Creation of the hypothesis", hyponame_1
- hypo_test_2_1 = HOMARD.CreateHypothesis(hyponame_1)
- hypo_test_2_1.SetUnifRefinUnRef(1)
- hypo_test_2_1.AddGroup('EG')
- hypo_test_2_1.AddGroup('BANDE')
- print hyponame_1, " : zones utilisées :", hypo_test_2_1.GetZones()
- print hyponame_1, " : champ utilisé :", hypo_test_2_1.GetFieldName()
- print hyponame_1, " : composantes utilisées :", hypo_test_2_1.GetComps()
- if ( len (hypo_test_2_1.GetFieldName()) > 0 ) :
- print ".. caractéristiques de l'adaptation :", hypo_test_2_1.GetField()
-
- # Creation of the hypothesis 2
- hyponame_2 = "hypo_" + TEST_NAME + "_2"
- print "-------- Creation of the hypothesis", hyponame_2
- hypo_test_2_2 = HOMARD.CreateHypothesis(hyponame_2)
- hypo_test_2_2.SetUnifRefinUnRef(1)
- hypo_test_2_2.AddGroup('M_D')
- print hyponame_2, " : zones utilisées :", hypo_test_2_2.GetZones()
- print hyponame_2, " : champ utilisé :", hypo_test_2_2.GetFieldName()
- print hyponame_2, " : composantes utilisées :", hypo_test_2_2.GetComps()
- if ( len (hypo_test_2_2.GetFieldName()) > 0 ) :
- print ".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField()
- #
- # Creation of the cases
- # =====================
- # Creation of the case
- mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med')
- case_test_2 = HOMARD.CreateCase(TEST_NAME, 'PLAQUE_0', mesh_file)
- case_test_2.SetDirName(DIRCASE)
- case_test_2.AddBoundaryGroup('internal_boundary', '')
- #
- # Creation of the iterations
- # ==========================
- # Creation of the iteration 1
- iter_name = "I_" + TEST_NAME + "_1"
- iter_test_2_1 = case_test_2.NextIteration(iter_name)
- iter_test_2_1.SetMeshName('PLAQUE_1')
- iter_test_2_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
- iter_test_2_1.AssociateHypo(hyponame_1)
- error = iter_test_2_1.Compute(1, 1)
- if error :
- error = 1
- break
-
- # Creation of the iteration 2
- iter_name = "I_" + TEST_NAME + "_2"
- iter_test_2_2 = iter_test_2_1.NextIteration(iter_name)
- iter_test_2_2.SetMeshName('PLAQUE_2')
- iter_test_2_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
- iter_test_2_2.AssociateHypo(hyponame_1)
- error = iter_test_2_2.Compute(1, 1)
- if error :
- error = 2
- break
-
- # Creation of the iteration 3
- iter_name = "I_" + TEST_NAME + "_3"
- iter_test_2_3 = iter_test_2_2.NextIteration(iter_name)
- iter_test_2_3.SetMeshName('PLAQUE_3')
- iter_test_2_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
- iter_test_2_3.AssociateHypo(hyponame_2)
- error = iter_test_2_3.Compute(1, 1)
- if error :
- error = 3
- break
- #
- # Creation of the schema YACS
- # ===========================
- scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py")
- scriptfile = os.path.normpath(scriptfile)
- dirname = DIRCASE
- yacs_test_2 = case_test_2.CreateYACSSchema("YACS_test_2", scriptfile, dirname, mesh_file)
- yacs_test_2.SetMaxIter(4)
- yacs_test_2.SetType(1)
- filexml = os.path.join(DIRCASE, 'yacs_test_2.xml')
- error = yacs_test_2.WriteOnFile(filexml)
- if error :
- error = 4
- break
- #
- break
- #
- return error
-
-#========================================================================
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load homard engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_4
-"""
-__revision__ = "V2.1"
-
-#========================================================================
-TEST_NAME = "test_4"
-DEBUG = False
-N_ITER_TEST_FILE = 3
-DX = 600.
-DY = 400.
-DZ = 200.
-#========================================================================
-import os
-import tempfile
-import sys
-import numpy as np
-import salome
-import GEOM
-import SMESH
-import HOMARD
-import MEDCoupling as mc
-import MEDLoader as ml
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# ==================================
-
-salome.salome_init()
-
-import SALOMEDS
-from salome.geom import geomBuilder
-from salome.smesh import smeshBuilder
-from salome.StdMeshers import StdMeshersBuilder
-#
-from MEDLoader import MEDLoader
-from MEDCouplingRemapper import MEDCouplingRemapper
-
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def geom_smesh_exec(theStudy):
- """
-Python script for GEOM and SMESH
- """
- error = 0
-#
- while not error :
- #
- geompy = geomBuilder.New(theStudy)
- #
- # Creation of the box
- # ===================
- box_g = geompy.MakeBoxDXDYDZ(DX, DY, DZ, "BOX")
-
- # Creation of the mesh
- # ====================
- smesh = smeshBuilder.New(theStudy)
- box_m = smesh.Mesh(box_g)
- smesh.SetName(box_m.GetMesh(), 'MESH')
- #
- # Creation of the hypotheses
- # ==========================
- regular_1d = box_m.Segment()
- smesh.SetName(regular_1d.GetAlgorithm(), 'Regular_1D')
- length = min(DX, DY, DZ) / 5.
- local_length = regular_1d.LocalLength(length, None, 1e-07)
- smesh.SetName(local_length, 'Local Length')
- #
- quadrangle_2d = box_m.Quadrangle(algo=smeshBuilder.QUADRANGLE)
- smesh.SetName(quadrangle_2d.GetAlgorithm(), 'Quadrangle_2D')
- quadrangle_parameters = quadrangle_2d.QuadrangleParameters(StdMeshersBuilder.QUAD_STANDARD, -1, [], [])
- smesh.SetName(quadrangle_parameters, 'Quadrangle Parameters')
- #
- hexa_3d = box_m.Hexahedron(algo=smeshBuilder.Hexa)
- smesh.SetName(hexa_3d.GetAlgorithm(), 'Hexa_3D')
- #
- # Computation
- # ===========
- #
- isDone = box_m.Compute()
- if not isDone :
- error = 1
- break
- #
- # MED exportation
- # ===============
- #
- try:
- ficmed = os.path.join(DIRCASE, 'maill.00.med')
- box_m.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1, None, 1)
- except Exception, eee:
- error = 2
- raise Exception('ExportToMEDX() failed. '+eee.message)
- #
- break
- #
- return error
-
-#========================================================================
-#
-#========================================================================
-def field_exec(theStudy, niter):
- """
-Python script for MEDCoupling
- """
- error = 0
-#
- while not error :
- #
- # The mesh
- # ========
- ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter)
- meshMEDFileRead = ml.MEDFileMesh.New(ficmed)
- meshRead0 = meshMEDFileRead.getMeshAtLevel(0)
- # Valeurs of the field
- # ====================
- nbNodes = meshRead0.getNumberOfNodes()
- valeur = mc.DataArrayDouble(nbNodes)
- for iaux, taux in enumerate(meshRead0.getCoords()) :
- #ligne = "x = %f" % taux[0]
- #ligne += ", y = %f" % taux[1]
- #ligne += ", z = %f" % taux[2]
- #print ligne
- #distance = (taux[0]-DX*0.2)**2 + (taux[1]-DY*0.2)**2 + (taux[2]-DZ*0.4)**2
- distance = min(abs(taux[0]-DX*0.4), abs(taux[1]-DY*0.2), abs(taux[2]-DZ*0.4))
- valeur[iaux] = 1.e0 / max ( 1.e-5, np.sqrt(distance) )
- #print ". valeur", valeur
- nparr = valeur.toNumPyArray()
- print ". mini/maxi", nparr.min(), nparr.max()
- #
- # Creation of the field
- # =====================
- field = ml.MEDCouplingFieldDouble(ml.ON_NODES, ml.ONE_TIME)
- field.setArray(valeur)
- field.setMesh(meshRead0)
- field.setName("DISTANCE")
- #
- fMEDFile_ch = ml.MEDFileField1TS()
- fMEDFile_ch.setFieldNoProfileSBT(field) # No profile desired on the field, Sort By Type
- fMEDFile_ch.write(ficmed, 0) # 0 to indicate that we *append* (and no overwrite) to the MED file
- #
- break
- #
- return error
-
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- error = 0
-#
- while not error :
- #
- HOMARD.SetCurrentStudy(theStudy)
- #
- # Creation of the zones
- # =====================
- #
- epsilon = min(DX, DY, DZ) / 100.
- # Creation of the box zone_4_1
- zone_4_1 = HOMARD.CreateZoneBox('Zone_4_1', -epsilon, DX/3.+epsilon, DY/4.-epsilon, 3.*DY/4.+epsilon, 4.*DZ/5.-epsilon, DZ+epsilon)
-
- # Creation of the sphere zone_4_2
- rayon = min(DX, DY, DZ) / 4.
- zone_4_2 = HOMARD.CreateZoneSphere('Zone_4_2', DX/3., DY*0.3, DZ*0.6, rayon)
- #
- # Creation of the hypotheses
- # ==========================
- dico = {}
- dico["1"] = "raffinement"
- dico["-1"] = "deraffinement"
- # Creation of the hypothesis hypo_4_1
- hyponame_1 = "Zone_1"
- print "-------- Creation of the hypothesis", hyponame_1
- hypo_4_1 = HOMARD.CreateHypothesis(hyponame_1)
- hypo_4_1.AddZone('Zone_4_1', 1)
- hypo_4_1.SetExtraOutput(2)
- laux = hypo_4_1.GetZones()
- nbzone = len(laux)/2
- jaux = 0
- for iaux in range(nbzone) :
- print hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
- jaux += 2
- # Creation of the hypothesis hypo_4_2
- hyponame_2 = "Zone_2"
- print "-------- Creation of the hypothesis", hyponame_2
- hypo_4_2 = HOMARD.CreateHypothesis(hyponame_2)
- hypo_4_2.AddZone('Zone_4_2', 1)
- hypo_4_2.SetExtraOutput(2)
- laux = hypo_4_2.GetZones()
- nbzone = len(laux)/2
- jaux = 0
- for iaux in range(nbzone) :
- print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
- jaux += 2
- # Creation of the hypothesis DISTANCE INVERSE
- hyponame_3 = "DISTANCE INVERSE"
- print "-------- Creation of the hypothesis", hyponame_3
- hypo_4_3 = HOMARD.CreateHypothesis(hyponame_3)
- hypo_4_3.SetField('DISTANCE')
- hypo_4_3.SetUseComp(0)
- hypo_4_3.SetRefinThr(1, 0.3)
- hypo_4_3.SetUnRefThr(1, 0.2)
- hypo_4_3.AddFieldInterp('DISTANCE')
- hypo_4_3.SetExtraOutput(2)
- print hyponame_3, " : zones utilisées :", hypo_4_3.GetZones()
- print hyponame_3, " : champ utilisé :", hypo_4_3.GetFieldName()
- print hyponame_3, " : composantes utilisées :", hypo_4_3.GetComps()
- if ( len (hypo_4_3.GetFieldName()) > 0 ) :
- print ".. caractéristiques de l'adaptation :", hypo_4_3.GetField()
- print hyponame_3, " : champs interpolés :", hypo_4_3.GetFieldInterps()
- #
- # Creation of the cases
- # =====================
- # Creation of the case
- print "-------- Creation of the case", TEST_NAME
- mesh_file = os.path.join(DIRCASE, 'maill.00.med')
- case_test_4 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
- case_test_4.SetDirName(DIRCASE)
- #
- # Creation of the iterations
- # ==========================
- # Creation of the iteration 1
- iter_name = "I_" + TEST_NAME + "_1"
- print "-------- Creation of the iteration", iter_name
- iter_test_4_1 = case_test_4.NextIteration(iter_name)
- iter_test_4_1.AssociateHypo(hyponame_1)
- print ". Hypothese :", hyponame_1
- iter_test_4_1.SetMeshName('M1')
- iter_test_4_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
- error = iter_test_4_1.Compute(1, 2)
- if error :
- error = 1
- break
-
- # Creation of the iteration 2
- iter_name = "I_" + TEST_NAME + "_2"
- print "-------- Creation of the iteration", iter_name
- iter_test_4_2 = iter_test_4_1.NextIteration(iter_name)
- iter_test_4_2.AssociateHypo(hyponame_2)
- print ". Hypothese :", hyponame_2
- iter_test_4_2.SetMeshName('M2')
- iter_test_4_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
- error = iter_test_4_2.Compute(1, 2)
- if error :
- error = 2
- break
-
- # Creation of the iteration 3
- #
- error = field_exec(theStudy, 2)
- if error :
- error = 30
- break
- #
- iter_name = "I_" + TEST_NAME + "_3"
- print "-------- Creation of the iteration", iter_name
- iter_test_4_3 = iter_test_4_2.NextIteration(iter_name)
- iter_test_4_3.AssociateHypo(hyponame_3)
- print ". Hypothese :", hyponame_3
- iter_test_4_3.SetMeshName('M3')
- iter_test_4_3.SetFieldFile(os.path.join(DIRCASE, 'maill.02.med'))
- iter_test_4_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
- error = iter_test_4_3.Compute(1, 2)
- if error :
- error = 3
- break
- #
- break
- #
- return error
-
-#========================================================================
-#
-# Geometry and Mesh
-#
-try :
- ERROR = geom_smesh_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in geom_smesh_exec')
-except Exception, eee:
- raise Exception('Pb in geom_smesh_exec: '+eee.message)
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load homard engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_11 associe au tutorial 1
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_11"
-DEBUG = False
-N_ITER_TEST_FILE = 3
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# Repertoire des donnees du tutorial
-DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
-sys.path.append(DATA_TUTORIAL)
-from tutorial_util import gzip_gunzip
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 1, -1)
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- #
- homard.SetCurrentStudy(theStudy)
- #
- # Hypotheses
- # ==========
- hypo_1 = homard.CreateHypothesis('hypo_1')
- hypo_1.SetUnifRefinUnRef(1)
- #
- # Cas
- # ===
- case_1 = homard.CreateCase('case_1', 'MAILL', DATA_TUTORIAL+'/tutorial_1.00.med')
- case_1.SetDirName(DIRCASE)
- #
- # Iterations
- # ==========
- # Iteration "iter_1_1"
- iter_1_1 = case_1.NextIteration('iter_1_1')
- iter_1_1.SetMeshName('MESH')
- iter_1_1.SetMeshFile(DIRCASE+'/maill.01.med')
- iter_1_1.AssociateHypo('hypo_1')
- error = iter_1_1.Compute(1, 2)
-
- # Iteration "iter_1_2"
- iter_1_2 = iter_1_1.NextIteration('iter_1_2')
- iter_1_2.SetMeshName('MESH')
- iter_1_2.SetMeshFile(DIRCASE+'/maill.02.med')
- iter_1_2.AssociateHypo('hypo_1')
- error = iter_1_2.Compute(1, 2)
-
- # Iteration "iter_1_3"
- iter_1_3 = iter_1_2.NextIteration('iter_1_3')
- iter_1_3.SetMeshName('MESH')
- iter_1_3.SetMeshFile(DIRCASE+'/maill.03.med')
- iter_1_3.AssociateHypo('hypo_1')
- error = iter_1_3.Compute(1, 2)
- #
- return error
-
-#========================================================================
-
-homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert homard is not None, "Impossible to load homard engine"
-homard.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 1, 1)
-# ==================================
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_12 associe au tutorial 2
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_12"
-DEBUG = False
-N_ITER_TEST_FILE = 2
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# Repertoire des donnees du tutorial
-DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
-sys.path.append(DATA_TUTORIAL)
-from tutorial_util import gzip_gunzip
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 2, -1)
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- #
- HOMARD.SetCurrentStudy(theStudy)
- #
- # Creation des zones
- # ==================
- # Box "Zone_12_0"
- zone_12_0 = HOMARD.CreateZoneBox ('Zone_12_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
- #
- # Sphere "Zone_12_1"
- zone_12_1 = HOMARD.CreateZoneSphere ('Zone_12_1', 0., 0., 0., 1.05)
- #
- # Box "Zone_12_2"
- zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
- #
- # Hypothese "hypo_2"
- # ==================
- hypo_2 = HOMARD.CreateHypothesis('hypo_2')
- hypo_2.AddZone('Zone_12_1', 1)
- hypo_2.AddZone('Zone_12_0', 1)
- #
- # Hypothese "hypo_2_bis"
- # ======================
- hypo_2_bis = HOMARD.CreateHypothesis('hypo_2_bis')
- hypo_2_bis.AddZone('Zone_12_0', -1)
- hypo_2_bis.AddZone('Zone_12_2', 1)
- #
- # Cas
- # ===
- case_2 = HOMARD.CreateCase('case_2', 'MZERO', DATA_TUTORIAL+'/tutorial_2.00.med')
- case_2.SetDirName(DIRCASE)
- #
- # Iteration "iter_2_1"
- # ====================
- iter_2_1 = case_2.NextIteration('iter_2_1')
- iter_2_1.SetMeshName('M_1')
- iter_2_1.SetMeshFile(DIRCASE+'/maill.01.med')
- iter_2_1.AssociateHypo('hypo_2')
- error = iter_2_1.Compute(1, 2)
- #
- # Iteration "iter_2_2"
- # ====================
- iter_2_2 = iter_2_1.NextIteration('iter_2_2')
- iter_2_2.SetMeshName('M_2')
- iter_2_2.SetMeshFile(DIRCASE+'/maill.02.med')
- iter_2_2.AssociateHypo('hypo_2_bis')
- error = iter_2_2.Compute(1, 2)
- #
- return error
-
-#========================================================================
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load HOMARD engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 2, 1)
-# ==================================
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_13 associe au tutorial 3
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_13"
-DEBUG = False
-N_ITER_TEST_FILE = 2
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# Repertoire des donnees du tutorial
-DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
-sys.path.append(DATA_TUTORIAL)
-from tutorial_util import gzip_gunzip
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 3, -1)
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- #
- HOMARD.SetCurrentStudy(theStudy)
- #
- # Hypothese "hypo_0vers1"
- # =======================
- hypo_0vers1 = HOMARD.CreateHypothesis('hypo_0vers1')
- # Characterization of the field
- hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
- hypo_0vers1.SetUseComp(0)
- hypo_0vers1.AddComp('ERREST ')
- hypo_0vers1.SetRefinThr(3, 1.0)
- hypo_0vers1.SetTypeFieldInterp(2)
- hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
- hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
- #
- # Hypothese "hypo_1vers2"
- # =======================
- hypo_1vers2 = HOMARD.CreateHypothesis('hypo_1vers2')
- # Characterization of the field
- hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
- hypo_1vers2.SetUseComp(0)
- hypo_1vers2.AddComp('ERREST ')
- hypo_1vers2.SetRefinThr(3, 1.5)
- hypo_1vers2.SetUnRefThr(3, 6.)
- hypo_1vers2.SetTypeFieldInterp(2)
- hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
- hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
- #
- # Hypothese "hypo_1vers2_bis"
- # ===========================
- hypo_1vers2_bis = HOMARD.CreateHypothesis('hypo_1vers2_bis')
- # Characterization of the field
- hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
- hypo_1vers2_bis.SetUseComp(1)
- hypo_1vers2_bis.AddComp('DX')
- hypo_1vers2_bis.AddComp('DY')
- hypo_1vers2_bis.AddComp('DZ')
- hypo_1vers2_bis.SetRefinThr(1, 0.0001)
- hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
- hypo_1vers2_bis.SetTypeFieldInterp(0)
- #
- # Cas
- # ===
- case_3 = HOMARD.CreateCase('case_3', 'G_0', DATA_TUTORIAL+'/tutorial_3.00.med')
- case_3.SetDirName(DIRCASE)
- #
- # Iteration "iter_3_1"
- # ====================
- iter_3_1 = case_3.NextIteration('iter_3_1')
- iter_3_1.SetMeshName('H_1')
- iter_3_1.SetMeshFile(DIRCASE+'/maill.01.med')
- iter_3_1.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.00.med')
- iter_3_1.SetTimeStepRank( 1, 1)
- iter_3_1.AssociateHypo('hypo_0vers1')
- error = iter_3_1.Compute(1, 2)
- #
- # Iteration "iter_3_2"
- # ====================
- iter_3_2 = iter_3_1.NextIteration('iter_3_2')
- iter_3_2.SetMeshName('H_2')
- iter_3_2.SetMeshFile(DIRCASE+'/maill.02.med')
- iter_3_2.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.01.med')
- iter_3_2.SetTimeStepRank(1, 1)
- iter_3_2.AssociateHypo('hypo_1vers2')
- error = iter_3_2.Compute(1, 2)
- #
- # Iteration "iter_3_2_bis"
- # ========================
- iter_3_2_bis = iter_3_1.NextIteration('iter_3_2_bis')
- iter_3_2_bis.SetMeshName('H_2_bis')
- iter_3_2_bis.SetMeshFile(DIRCASE+'/maill.02.bis.med')
- iter_3_2_bis.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.01.med')
- iter_3_2_bis.SetTimeStepRank(1, 1)
- iter_3_2_bis.AssociateHypo('hypo_1vers2_bis')
- error = iter_3_2_bis.Compute(1, 2)
- #
- return error
-
-#========================================================================
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load HOMARD engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = 3
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 3, 1)
-# ==================================
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_14 associe au tutorial 4
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_14"
-DEBUG = False
-N_ITER_TEST_FILE = 3
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# Repertoire des donnees du tutorial
-DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
-sys.path.append(DATA_TUTORIAL)
-from tutorial_util import gzip_gunzip
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 4, -1)
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- #
- HOMARD.SetCurrentStudy(theStudy)
-#
- # Frontieres
- # ==========
- boun_4_1 = HOMARD.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med')
- #
- boun_4_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
- #
- boun_4_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
- #
- boun_4_4 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
- #
- boun_4_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
- #
- # Hypotheses
- # ==========
- # Creation of the hypothesis hypo_4
- hypo_4 = HOMARD.CreateHypothesis('hypo_4')
- hypo_4.SetUnifRefinUnRef(1)
- hypo_4.AddGroup('T1_INT_I')
- hypo_4.AddGroup('T1_INT_O')
- hypo_4.AddGroup('T2_INT')
- # Creation of the hypothesis hypo_4_bis
- hypo_4_bis = HOMARD.CreateHypothesis('hypo_4_bis')
- hypo_4_bis.SetUnifRefinUnRef(1)
- hypo_4_bis.AddGroup('T1_EXT_I')
- hypo_4_bis.AddGroup('T1_EXT_O')
- hypo_4_bis.AddGroup('T2_EXT')
- #
- # Cas
- # ===
- case_4 = HOMARD.CreateCase('case_4', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.00.med')
- case_4.SetDirName(DIRCASE)
- case_4.AddBoundaryGroup( 'intersection', '' )
- case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
- case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
- case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
- case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
- case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
- case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
- #
- # Iterations
- # ==========
- # Iteration iter_4_1 : raffinement selon les faces internes
- iter_4_1 = case_4.NextIteration('iter_4_1')
- iter_4_1.SetMeshName('PIQUAGE_1')
- iter_4_1.SetMeshFile(DIRCASE+'/maill.01.med')
- iter_4_1.AssociateHypo('hypo_4')
- error = iter_4_1.Compute(1, 2)
- # Iteration iter_4_2 : raffinement selon les faces externes
- iter_4_2 = iter_4_1.NextIteration('iter_4_2')
- iter_4_2.SetMeshName('PIQUAGE_2')
- iter_4_2.SetMeshFile(DIRCASE+'/maill.02.med')
- iter_4_2.AssociateHypo('hypo_4_bis')
- error = iter_4_2.Compute(1, 2)
- # Iteration iter_4_3 : second raffinement selon les faces externes
- iter_4_3 = iter_4_2.NextIteration('iter_4_3')
- iter_4_3.SetMeshName('PIQUAGE_3')
- iter_4_3.SetMeshFile(DIRCASE+'/maill.03.med')
- iter_4_3.AssociateHypo('hypo_4_bis')
- error = iter_4_3.Compute(1, 2)
- #
- return error
-
-#========================================================================
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load HOMARD engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 4, 1)
-# ==================================
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-"""
-Python script for HOMARD
-Test test_15 associe au tutorial 5
-"""
-__revision__ = "V3.1"
-
-#========================================================================
-TEST_NAME = "test_15"
-DEBUG = False
-N_ITER_TEST_FILE = 2
-#========================================================================
-import os
-import tempfile
-import sys
-import HOMARD
-import salome
-#
-# ==================================
-PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
-# Repertoire des scripts utilitaires
-REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
-REP_PYTHON = os.path.normpath(REP_PYTHON)
-sys.path.append(REP_PYTHON)
-from test_util import remove_dir
-from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
-# Repertoire des donnees du tutorial
-DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
-DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
-sys.path.append(DATA_TUTORIAL)
-from tutorial_util import gzip_gunzip
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 5, -1)
-# ==================================
-
-salome.salome_init()
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
-#========================================================================
-def homard_exec(theStudy):
- """
-Python script for HOMARD
- """
- #
- HOMARD.SetCurrentStudy(theStudy)
-#
- # Frontiere
- # =========
- # Creation of the discrete boundary Boun_5_1
- boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med')
- #
- # Creation des zones
- # ==================
- # Creation of the disk with hole enveloppe
- enveloppe = HOMARD.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
- # Creation of the rectangle quart_sup
- quart_sup = HOMARD.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
- #
- # Hypotheses
- # ==========
- # Creation of the hypothesis hypo_5
- hypo_5 = HOMARD.CreateHypothesis('hypo_5')
- hypo_5.AddZone('enveloppe', 1)
- # Creation of the hypothesis hypo_5_bis
- hypo_5_bis = HOMARD.CreateHypothesis('hypo_5_bis')
- hypo_5_bis.AddZone('quart_sup', 1)
- #
- # Cas
- # ===
- case_5 = HOMARD.CreateCase('case_5', 'COEUR_2D', DATA_TUTORIAL+'/tutorial_5.00.med')
- case_5.SetDirName(DIRCASE)
- case_5.SetConfType(1)
- case_5.AddBoundaryGroup('Boun_5_1', '')
- #
- # Iteration "iter_5_1"
- # ====================
- iter_5_1 = case_5.NextIteration('iter_5_1')
- iter_5_1.SetMeshName('COEUR_2D_01')
- iter_5_1.SetMeshFile(DIRCASE+'/maill.01.med')
- iter_5_1.AssociateHypo('hypo_5')
- error = iter_5_1.Compute(1, 2)
- #
- # Iteration "iter_5_2"
- # ====================
- iter_5_2 = iter_5_1.NextIteration('iter_5_2')
- iter_5_2.SetMeshName('COEUR_2D_02')
- iter_5_2.SetMeshFile(DIRCASE+'/maill.02.med')
- iter_5_2.AssociateHypo('hypo_5_bis')
- error = iter_5_2.Compute(1, 2)
- #
- return error
-
-#========================================================================
-
-HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
-assert HOMARD is not None, "Impossible to load HOMARD engine"
-HOMARD.SetLanguageShort("fr")
-#
-# Exec of HOMARD-SALOME
-#
-try :
- ERROR = homard_exec(salome.myStudy)
- if ERROR :
- raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
- raise Exception('Pb in homard_exec: '+eee.message)
-#
-# Test of the results
-#
-N_REP_TEST_FILE = N_ITER_TEST_FILE
-DESTROY_DIR = not DEBUG
-test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
-#
-# ==================================
-gzip_gunzip(DATA_TUTORIAL, 5, 1)
-# ==================================
-#
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(1)
- iparameters.getSession().restoreVisualState(1)
-
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_1
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_1"
+DEBUG = False
+N_ITER_TEST_FILE = 3
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ error = 0
+#
+ while not error :
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+ #
+ # Creation of the zones
+ # =====================
+ # Creation of the box zone_1_1
+ zone_1_1 = HOMARD.CreateZoneBox('Zone_1_1', -0.01, 1.01, -0.01, 0.4, -0.01, 0.6)
+
+ # Creation of the sphere zone_1_2
+ zone_1_2 = HOMARD.CreateZoneSphere('Zone_1_2', 0.5, 0.6, 0.7, 0.75)
+ #
+ # Creation of the hypotheses
+ # ==========================
+ dico = {}
+ dico["1"] = "raffinement"
+ dico["-1"] = "deraffinement"
+ # Creation of the hypothesis a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM
+ hyponame_1 = "a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM"
+ print "-------- Creation of the hypothesis", hyponame_1
+ hypo_1_1 = HOMARD.CreateHypothesis(hyponame_1)
+ hypo_1_1.SetField('RESU____ERRE_ELEM_SIGM__________')
+ hypo_1_1.SetUseComp(0)
+ hypo_1_1.AddComp('ERREST')
+ hypo_1_1.SetRefinThr(3, 10.1)
+ hypo_1_1.AddFieldInterp('RESU____DEPL____________________')
+ hypo_1_1.AddFieldInterp('RESU____ERRE_ELEM_SIGM__________')
+ print hyponame_1, " : champ utilisé :", hypo_1_1.GetFieldName()
+ print hyponame_1, " : composantes utilisées :", hypo_1_1.GetComps()
+ if ( len (hypo_1_1.GetFieldName()) > 0 ) :
+ print ".. caractéristiques de l'adaptation :", hypo_1_1.GetField()
+ print hyponame_1, " : champs interpolés :", hypo_1_1.GetFieldInterps()
+ # Creation of the hypothesis Zones_1_et_2
+ hyponame_2 = "Zones_1_et_2"
+ print "-------- Creation of the hypothesis", hyponame_2
+ zones_1_et_2 = HOMARD.CreateHypothesis(hyponame_2)
+ zones_1_et_2.AddZone('Zone_1_1', 1)
+ zones_1_et_2.AddZone('Zone_1_2', 1)
+ laux = zones_1_et_2.GetZones()
+ nbzone = len(laux)/2
+ jaux = 0
+ for iaux in range(nbzone) :
+ print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
+ jaux += 2
+ print hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName()
+ if ( len (zones_1_et_2.GetFieldName()) > 0 ) :
+ print ".. caractéristiques de l'adaptation :", zones_1_et_2.GetField()
+ print hyponame_2, " : champs interpolés :", zones_1_et_2.GetFieldInterps()
+ #
+ # Creation of the cases
+ # =====================
+ # Creation of the case
+ print "-------- Creation of the case", TEST_NAME
+ mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med')
+ case_test_1 = HOMARD.CreateCase(TEST_NAME, 'MAILL', mesh_file)
+ case_test_1.SetDirName(DIRCASE)
+ #
+ # Creation of the iterations
+ # ==========================
+ # Creation of the iteration 1
+ iter_name = "I_" + TEST_NAME + "_1"
+ print "-------- Creation of the iteration", iter_name
+ iter_test_1_1 = case_test_1.NextIteration(iter_name)
+ iter_test_1_1.AssociateHypo(hyponame_1)
+ print ". Hypothese :", hyponame_1
+ iter_test_1_1.SetMeshName('M1')
+ iter_test_1_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
+ iter_test_1_1.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.00.med'))
+ iter_test_1_1.SetTimeStepRank(1, 1)
+ iter_test_1_1.SetFieldInterpTimeStep('RESU____DEPL____________________', 1)
+ iter_test_1_1.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1)
+ print ". Instants d'interpolation :", iter_test_1_1.GetFieldInterpsTimeStepRank()
+ error = iter_test_1_1.Compute(1, 1)
+ if error :
+ error = 1
+ break
+
+ # Creation of the iteration 2
+ iter_name = "I_" + TEST_NAME + "_2"
+ print "-------- Creation of the iteration", iter_name
+ iter_test_1_2 = iter_test_1_1.NextIteration(iter_name)
+ iter_test_1_2.AssociateHypo(hyponame_1)
+ print ". Hypothese :", hyponame_1
+ iter_test_1_2.SetMeshName('M2')
+ iter_test_1_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
+ iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.01.med'))
+ iter_test_1_2.SetTimeStepRank(1, 1)
+ iter_test_1_2.SetFieldInterpTimeStep('RESU____DEPL____________________', 1)
+ iter_test_1_2.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1)
+ print ". Instants d'interpolation :", iter_test_1_2.GetFieldInterpsTimeStepRank()
+ error = iter_test_1_2.Compute(1, 1)
+ if error :
+ error = 2
+ break
+
+ # Creation of the iteration 3
+ iter_name = "I_" + TEST_NAME + "_3"
+ print "-------- Creation of the iteration", iter_name
+ iter_test_1_3 = iter_test_1_2.NextIteration(iter_name)
+ iter_test_1_3.AssociateHypo(hyponame_2)
+ print ". Hypothese :", hyponame_2
+ iter_test_1_3.SetMeshName('M3')
+ iter_test_1_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
+ iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.02.med'))
+ print ". Instants d'interpolation :", iter_test_1_3.GetFieldInterpsTimeStepRank()
+ error = iter_test_1_3.Compute(1, 1)
+ if error :
+ error = 3
+ break
+ #
+ # Creation of the schema YACS
+ # ===========================
+ scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py")
+ scriptfile = os.path.normpath(scriptfile)
+ dirname = DIRCASE
+ yacs_test_1 = case_test_1.CreateYACSSchema("YACS_test_1", scriptfile, dirname, mesh_file)
+ error = yacs_test_1.Write()
+ if error :
+ error = 4
+ break
+ #
+ break
+ #
+ return error
+
+#========================================================================
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load homard engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_2
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_2"
+DEBUG = False
+N_ITER_TEST_FILE = 3
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ error = 0
+#
+ while not error :
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+ #
+ # Creation of the boundaries
+ # ==========================
+ # Creation of the discrete boundary boundary_1
+ boundary_1 = HOMARD.CreateBoundaryDi('internal_boundary', 'plaque', os.path.join(REP_DATA, TEST_NAME + '.fr.med'))
+ #
+ # Creation of the hypotheses
+ # ==========================
+ # Creation of the hypothesis 1
+ hyponame_1 = "hypo_" + TEST_NAME + "_1"
+ print "-------- Creation of the hypothesis", hyponame_1
+ hypo_test_2_1 = HOMARD.CreateHypothesis(hyponame_1)
+ hypo_test_2_1.SetUnifRefinUnRef(1)
+ hypo_test_2_1.AddGroup('EG')
+ hypo_test_2_1.AddGroup('BANDE')
+ print hyponame_1, " : zones utilisées :", hypo_test_2_1.GetZones()
+ print hyponame_1, " : champ utilisé :", hypo_test_2_1.GetFieldName()
+ print hyponame_1, " : composantes utilisées :", hypo_test_2_1.GetComps()
+ if ( len (hypo_test_2_1.GetFieldName()) > 0 ) :
+ print ".. caractéristiques de l'adaptation :", hypo_test_2_1.GetField()
+
+ # Creation of the hypothesis 2
+ hyponame_2 = "hypo_" + TEST_NAME + "_2"
+ print "-------- Creation of the hypothesis", hyponame_2
+ hypo_test_2_2 = HOMARD.CreateHypothesis(hyponame_2)
+ hypo_test_2_2.SetUnifRefinUnRef(1)
+ hypo_test_2_2.AddGroup('M_D')
+ print hyponame_2, " : zones utilisées :", hypo_test_2_2.GetZones()
+ print hyponame_2, " : champ utilisé :", hypo_test_2_2.GetFieldName()
+ print hyponame_2, " : composantes utilisées :", hypo_test_2_2.GetComps()
+ if ( len (hypo_test_2_2.GetFieldName()) > 0 ) :
+ print ".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField()
+ #
+ # Creation of the cases
+ # =====================
+ # Creation of the case
+ mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med')
+ case_test_2 = HOMARD.CreateCase(TEST_NAME, 'PLAQUE_0', mesh_file)
+ case_test_2.SetDirName(DIRCASE)
+ case_test_2.AddBoundaryGroup('internal_boundary', '')
+ #
+ # Creation of the iterations
+ # ==========================
+ # Creation of the iteration 1
+ iter_name = "I_" + TEST_NAME + "_1"
+ iter_test_2_1 = case_test_2.NextIteration(iter_name)
+ iter_test_2_1.SetMeshName('PLAQUE_1')
+ iter_test_2_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
+ iter_test_2_1.AssociateHypo(hyponame_1)
+ error = iter_test_2_1.Compute(1, 1)
+ if error :
+ error = 1
+ break
+
+ # Creation of the iteration 2
+ iter_name = "I_" + TEST_NAME + "_2"
+ iter_test_2_2 = iter_test_2_1.NextIteration(iter_name)
+ iter_test_2_2.SetMeshName('PLAQUE_2')
+ iter_test_2_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
+ iter_test_2_2.AssociateHypo(hyponame_1)
+ error = iter_test_2_2.Compute(1, 1)
+ if error :
+ error = 2
+ break
+
+ # Creation of the iteration 3
+ iter_name = "I_" + TEST_NAME + "_3"
+ iter_test_2_3 = iter_test_2_2.NextIteration(iter_name)
+ iter_test_2_3.SetMeshName('PLAQUE_3')
+ iter_test_2_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
+ iter_test_2_3.AssociateHypo(hyponame_2)
+ error = iter_test_2_3.Compute(1, 1)
+ if error :
+ error = 3
+ break
+ #
+ # Creation of the schema YACS
+ # ===========================
+ scriptfile = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "en", "_downloads", "yacs_script_test.py")
+ scriptfile = os.path.normpath(scriptfile)
+ dirname = DIRCASE
+ yacs_test_2 = case_test_2.CreateYACSSchema("YACS_test_2", scriptfile, dirname, mesh_file)
+ yacs_test_2.SetMaxIter(4)
+ yacs_test_2.SetType(1)
+ filexml = os.path.join(DIRCASE, 'yacs_test_2.xml')
+ error = yacs_test_2.WriteOnFile(filexml)
+ if error :
+ error = 4
+ break
+ #
+ break
+ #
+ return error
+
+#========================================================================
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load homard engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_4
+"""
+__revision__ = "V2.1"
+
+#========================================================================
+TEST_NAME = "test_4"
+DEBUG = False
+N_ITER_TEST_FILE = 3
+DX = 600.
+DY = 400.
+DZ = 200.
+#========================================================================
+import os
+import tempfile
+import sys
+import numpy as np
+import salome
+import GEOM
+import SMESH
+import HOMARD
+import MEDCoupling as mc
+import MEDLoader as ml
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# ==================================
+
+salome.salome_init()
+
+import SALOMEDS
+from salome.geom import geomBuilder
+from salome.smesh import smeshBuilder
+from salome.StdMeshers import StdMeshersBuilder
+#
+from MEDLoader import MEDLoader
+from MEDCouplingRemapper import MEDCouplingRemapper
+
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def geom_smesh_exec(theStudy):
+ """
+Python script for GEOM and SMESH
+ """
+ error = 0
+#
+ while not error :
+ #
+ geompy = geomBuilder.New(theStudy)
+ #
+ # Creation of the box
+ # ===================
+ box_g = geompy.MakeBoxDXDYDZ(DX, DY, DZ, "BOX")
+
+ # Creation of the mesh
+ # ====================
+ smesh = smeshBuilder.New(theStudy)
+ box_m = smesh.Mesh(box_g)
+ smesh.SetName(box_m.GetMesh(), 'MESH')
+ #
+ # Creation of the hypotheses
+ # ==========================
+ regular_1d = box_m.Segment()
+ smesh.SetName(regular_1d.GetAlgorithm(), 'Regular_1D')
+ length = min(DX, DY, DZ) / 5.
+ local_length = regular_1d.LocalLength(length, None, 1e-07)
+ smesh.SetName(local_length, 'Local Length')
+ #
+ quadrangle_2d = box_m.Quadrangle(algo=smeshBuilder.QUADRANGLE)
+ smesh.SetName(quadrangle_2d.GetAlgorithm(), 'Quadrangle_2D')
+ quadrangle_parameters = quadrangle_2d.QuadrangleParameters(StdMeshersBuilder.QUAD_STANDARD, -1, [], [])
+ smesh.SetName(quadrangle_parameters, 'Quadrangle Parameters')
+ #
+ hexa_3d = box_m.Hexahedron(algo=smeshBuilder.Hexa)
+ smesh.SetName(hexa_3d.GetAlgorithm(), 'Hexa_3D')
+ #
+ # Computation
+ # ===========
+ #
+ isDone = box_m.Compute()
+ if not isDone :
+ error = 1
+ break
+ #
+ # MED exportation
+ # ===============
+ #
+ try:
+ ficmed = os.path.join(DIRCASE, 'maill.00.med')
+ box_m.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1, None, 1)
+ except Exception, eee:
+ error = 2
+ raise Exception('ExportToMEDX() failed. '+eee.message)
+ #
+ break
+ #
+ return error
+
+#========================================================================
+#
+#========================================================================
+def field_exec(theStudy, niter):
+ """
+Python script for MEDCoupling
+ """
+ error = 0
+#
+ while not error :
+ #
+ # The mesh
+ # ========
+ ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter)
+ meshMEDFileRead = ml.MEDFileMesh.New(ficmed)
+ meshRead0 = meshMEDFileRead.getMeshAtLevel(0)
+ # Valeurs of the field
+ # ====================
+ nbNodes = meshRead0.getNumberOfNodes()
+ valeur = mc.DataArrayDouble(nbNodes)
+ for iaux, taux in enumerate(meshRead0.getCoords()) :
+ #ligne = "x = %f" % taux[0]
+ #ligne += ", y = %f" % taux[1]
+ #ligne += ", z = %f" % taux[2]
+ #print ligne
+ #distance = (taux[0]-DX*0.2)**2 + (taux[1]-DY*0.2)**2 + (taux[2]-DZ*0.4)**2
+ distance = min(abs(taux[0]-DX*0.4), abs(taux[1]-DY*0.2), abs(taux[2]-DZ*0.4))
+ valeur[iaux] = 1.e0 / max ( 1.e-5, np.sqrt(distance) )
+ #print ". valeur", valeur
+ nparr = valeur.toNumPyArray()
+ print ". mini/maxi", nparr.min(), nparr.max()
+ #
+ # Creation of the field
+ # =====================
+ field = ml.MEDCouplingFieldDouble(ml.ON_NODES, ml.ONE_TIME)
+ field.setArray(valeur)
+ field.setMesh(meshRead0)
+ field.setName("DISTANCE")
+ #
+ fMEDFile_ch = ml.MEDFileField1TS()
+ fMEDFile_ch.setFieldNoProfileSBT(field) # No profile desired on the field, Sort By Type
+ fMEDFile_ch.write(ficmed, 0) # 0 to indicate that we *append* (and no overwrite) to the MED file
+ #
+ break
+ #
+ return error
+
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ error = 0
+#
+ while not error :
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+ #
+ # Creation of the zones
+ # =====================
+ #
+ epsilon = min(DX, DY, DZ) / 100.
+ # Creation of the box zone_4_1
+ zone_4_1 = HOMARD.CreateZoneBox('Zone_4_1', -epsilon, DX/3.+epsilon, DY/4.-epsilon, 3.*DY/4.+epsilon, 4.*DZ/5.-epsilon, DZ+epsilon)
+
+ # Creation of the sphere zone_4_2
+ rayon = min(DX, DY, DZ) / 4.
+ zone_4_2 = HOMARD.CreateZoneSphere('Zone_4_2', DX/3., DY*0.3, DZ*0.6, rayon)
+ #
+ # Creation of the hypotheses
+ # ==========================
+ dico = {}
+ dico["1"] = "raffinement"
+ dico["-1"] = "deraffinement"
+ # Creation of the hypothesis hypo_4_1
+ hyponame_1 = "Zone_1"
+ print "-------- Creation of the hypothesis", hyponame_1
+ hypo_4_1 = HOMARD.CreateHypothesis(hyponame_1)
+ hypo_4_1.AddZone('Zone_4_1', 1)
+ hypo_4_1.SetExtraOutput(2)
+ laux = hypo_4_1.GetZones()
+ nbzone = len(laux)/2
+ jaux = 0
+ for iaux in range(nbzone) :
+ print hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
+ jaux += 2
+ # Creation of the hypothesis hypo_4_2
+ hyponame_2 = "Zone_2"
+ print "-------- Creation of the hypothesis", hyponame_2
+ hypo_4_2 = HOMARD.CreateHypothesis(hyponame_2)
+ hypo_4_2.AddZone('Zone_4_2', 1)
+ hypo_4_2.SetExtraOutput(2)
+ laux = hypo_4_2.GetZones()
+ nbzone = len(laux)/2
+ jaux = 0
+ for iaux in range(nbzone) :
+ print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
+ jaux += 2
+ # Creation of the hypothesis DISTANCE INVERSE
+ hyponame_3 = "DISTANCE INVERSE"
+ print "-------- Creation of the hypothesis", hyponame_3
+ hypo_4_3 = HOMARD.CreateHypothesis(hyponame_3)
+ hypo_4_3.SetField('DISTANCE')
+ hypo_4_3.SetUseComp(0)
+ hypo_4_3.SetRefinThr(1, 0.3)
+ hypo_4_3.SetUnRefThr(1, 0.2)
+ hypo_4_3.AddFieldInterp('DISTANCE')
+ hypo_4_3.SetExtraOutput(2)
+ print hyponame_3, " : zones utilisées :", hypo_4_3.GetZones()
+ print hyponame_3, " : champ utilisé :", hypo_4_3.GetFieldName()
+ print hyponame_3, " : composantes utilisées :", hypo_4_3.GetComps()
+ if ( len (hypo_4_3.GetFieldName()) > 0 ) :
+ print ".. caractéristiques de l'adaptation :", hypo_4_3.GetField()
+ print hyponame_3, " : champs interpolés :", hypo_4_3.GetFieldInterps()
+ #
+ # Creation of the cases
+ # =====================
+ # Creation of the case
+ print "-------- Creation of the case", TEST_NAME
+ mesh_file = os.path.join(DIRCASE, 'maill.00.med')
+ case_test_4 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
+ case_test_4.SetDirName(DIRCASE)
+ #
+ # Creation of the iterations
+ # ==========================
+ # Creation of the iteration 1
+ iter_name = "I_" + TEST_NAME + "_1"
+ print "-------- Creation of the iteration", iter_name
+ iter_test_4_1 = case_test_4.NextIteration(iter_name)
+ iter_test_4_1.AssociateHypo(hyponame_1)
+ print ". Hypothese :", hyponame_1
+ iter_test_4_1.SetMeshName('M1')
+ iter_test_4_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
+ error = iter_test_4_1.Compute(1, 2)
+ if error :
+ error = 1
+ break
+
+ # Creation of the iteration 2
+ iter_name = "I_" + TEST_NAME + "_2"
+ print "-------- Creation of the iteration", iter_name
+ iter_test_4_2 = iter_test_4_1.NextIteration(iter_name)
+ iter_test_4_2.AssociateHypo(hyponame_2)
+ print ". Hypothese :", hyponame_2
+ iter_test_4_2.SetMeshName('M2')
+ iter_test_4_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
+ error = iter_test_4_2.Compute(1, 2)
+ if error :
+ error = 2
+ break
+
+ # Creation of the iteration 3
+ #
+ error = field_exec(theStudy, 2)
+ if error :
+ error = 30
+ break
+ #
+ iter_name = "I_" + TEST_NAME + "_3"
+ print "-------- Creation of the iteration", iter_name
+ iter_test_4_3 = iter_test_4_2.NextIteration(iter_name)
+ iter_test_4_3.AssociateHypo(hyponame_3)
+ print ". Hypothese :", hyponame_3
+ iter_test_4_3.SetMeshName('M3')
+ iter_test_4_3.SetFieldFile(os.path.join(DIRCASE, 'maill.02.med'))
+ iter_test_4_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
+ error = iter_test_4_3.Compute(1, 2)
+ if error :
+ error = 3
+ break
+ #
+ break
+ #
+ return error
+
+#========================================================================
+#
+# Geometry and Mesh
+#
+try :
+ ERROR = geom_smesh_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in geom_smesh_exec')
+except Exception, eee:
+ raise Exception('Pb in geom_smesh_exec: '+eee.message)
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load homard engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_11 associe au tutorial 1
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_11"
+DEBUG = False
+N_ITER_TEST_FILE = 3
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# Repertoire des donnees du tutorial
+DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
+DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
+sys.path.append(DATA_TUTORIAL)
+from tutorial_util import gzip_gunzip
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 1, -1)
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ #
+ homard.SetCurrentStudy(theStudy)
+ #
+ # Hypotheses
+ # ==========
+ hypo_1 = homard.CreateHypothesis('hypo_1')
+ hypo_1.SetUnifRefinUnRef(1)
+ #
+ # Cas
+ # ===
+ case_1 = homard.CreateCase('case_1', 'MAILL', DATA_TUTORIAL+'/tutorial_1.00.med')
+ case_1.SetDirName(DIRCASE)
+ #
+ # Iterations
+ # ==========
+ # Iteration "iter_1_1"
+ iter_1_1 = case_1.NextIteration('iter_1_1')
+ iter_1_1.SetMeshName('MESH')
+ iter_1_1.SetMeshFile(DIRCASE+'/maill.01.med')
+ iter_1_1.AssociateHypo('hypo_1')
+ error = iter_1_1.Compute(1, 2)
+
+ # Iteration "iter_1_2"
+ iter_1_2 = iter_1_1.NextIteration('iter_1_2')
+ iter_1_2.SetMeshName('MESH')
+ iter_1_2.SetMeshFile(DIRCASE+'/maill.02.med')
+ iter_1_2.AssociateHypo('hypo_1')
+ error = iter_1_2.Compute(1, 2)
+
+ # Iteration "iter_1_3"
+ iter_1_3 = iter_1_2.NextIteration('iter_1_3')
+ iter_1_3.SetMeshName('MESH')
+ iter_1_3.SetMeshFile(DIRCASE+'/maill.03.med')
+ iter_1_3.AssociateHypo('hypo_1')
+ error = iter_1_3.Compute(1, 2)
+ #
+ return error
+
+#========================================================================
+
+homard = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert homard is not None, "Impossible to load homard engine"
+homard.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 1, 1)
+# ==================================
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_12 associe au tutorial 2
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_12"
+DEBUG = False
+N_ITER_TEST_FILE = 2
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# Repertoire des donnees du tutorial
+DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
+DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
+sys.path.append(DATA_TUTORIAL)
+from tutorial_util import gzip_gunzip
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 2, -1)
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+ #
+ # Creation des zones
+ # ==================
+ # Box "Zone_12_0"
+ zone_12_0 = HOMARD.CreateZoneBox ('Zone_12_0', -0.1, 1.1, -0.1, 1.1, 0.9, 1.1)
+ #
+ # Sphere "Zone_12_1"
+ zone_12_1 = HOMARD.CreateZoneSphere ('Zone_12_1', 0., 0., 0., 1.05)
+ #
+ # Box "Zone_12_2"
+ zone_12_2 = HOMARD.CreateZoneBox ('Zone_12_2', -0.1, 0.51, -0.1, 0.51, -0.1, 0.51)
+ #
+ # Hypothese "hypo_2"
+ # ==================
+ hypo_2 = HOMARD.CreateHypothesis('hypo_2')
+ hypo_2.AddZone('Zone_12_1', 1)
+ hypo_2.AddZone('Zone_12_0', 1)
+ #
+ # Hypothese "hypo_2_bis"
+ # ======================
+ hypo_2_bis = HOMARD.CreateHypothesis('hypo_2_bis')
+ hypo_2_bis.AddZone('Zone_12_0', -1)
+ hypo_2_bis.AddZone('Zone_12_2', 1)
+ #
+ # Cas
+ # ===
+ case_2 = HOMARD.CreateCase('case_2', 'MZERO', DATA_TUTORIAL+'/tutorial_2.00.med')
+ case_2.SetDirName(DIRCASE)
+ #
+ # Iteration "iter_2_1"
+ # ====================
+ iter_2_1 = case_2.NextIteration('iter_2_1')
+ iter_2_1.SetMeshName('M_1')
+ iter_2_1.SetMeshFile(DIRCASE+'/maill.01.med')
+ iter_2_1.AssociateHypo('hypo_2')
+ error = iter_2_1.Compute(1, 2)
+ #
+ # Iteration "iter_2_2"
+ # ====================
+ iter_2_2 = iter_2_1.NextIteration('iter_2_2')
+ iter_2_2.SetMeshName('M_2')
+ iter_2_2.SetMeshFile(DIRCASE+'/maill.02.med')
+ iter_2_2.AssociateHypo('hypo_2_bis')
+ error = iter_2_2.Compute(1, 2)
+ #
+ return error
+
+#========================================================================
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load HOMARD engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 2, 1)
+# ==================================
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_13 associe au tutorial 3
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_13"
+DEBUG = False
+N_ITER_TEST_FILE = 2
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# Repertoire des donnees du tutorial
+DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
+DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
+sys.path.append(DATA_TUTORIAL)
+from tutorial_util import gzip_gunzip
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 3, -1)
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+ #
+ # Hypothese "hypo_0vers1"
+ # =======================
+ hypo_0vers1 = HOMARD.CreateHypothesis('hypo_0vers1')
+ # Characterization of the field
+ hypo_0vers1.SetField('SOLU_0__QIRE_ELEM_SIGM__________')
+ hypo_0vers1.SetUseComp(0)
+ hypo_0vers1.AddComp('ERREST ')
+ hypo_0vers1.SetRefinThr(3, 1.0)
+ hypo_0vers1.SetTypeFieldInterp(2)
+ hypo_0vers1.AddFieldInterp('SOLU_0__DEPL____________________')
+ hypo_0vers1.AddFieldInterp('SOLU_0__ERRE_ELEM_SIGM__________')
+ #
+ # Hypothese "hypo_1vers2"
+ # =======================
+ hypo_1vers2 = HOMARD.CreateHypothesis('hypo_1vers2')
+ # Characterization of the field
+ hypo_1vers2.SetField('SOLU_1__QIRE_ELEM_SIGM__________')
+ hypo_1vers2.SetUseComp(0)
+ hypo_1vers2.AddComp('ERREST ')
+ hypo_1vers2.SetRefinThr(3, 1.5)
+ hypo_1vers2.SetUnRefThr(3, 6.)
+ hypo_1vers2.SetTypeFieldInterp(2)
+ hypo_1vers2.AddFieldInterp('SOLU_1__DEPL____________________')
+ hypo_1vers2.AddFieldInterp('SOLU_1__QIRE_ELEM_SIGM__________')
+ #
+ # Hypothese "hypo_1vers2_bis"
+ # ===========================
+ hypo_1vers2_bis = HOMARD.CreateHypothesis('hypo_1vers2_bis')
+ # Characterization of the field
+ hypo_1vers2_bis.SetField('SOLU_1__DEPL____________________')
+ hypo_1vers2_bis.SetUseComp(1)
+ hypo_1vers2_bis.AddComp('DX')
+ hypo_1vers2_bis.AddComp('DY')
+ hypo_1vers2_bis.AddComp('DZ')
+ hypo_1vers2_bis.SetRefinThr(1, 0.0001)
+ hypo_1vers2_bis.SetUnRefThr(1, 0.000001)
+ hypo_1vers2_bis.SetTypeFieldInterp(0)
+ #
+ # Cas
+ # ===
+ case_3 = HOMARD.CreateCase('case_3', 'G_0', DATA_TUTORIAL+'/tutorial_3.00.med')
+ case_3.SetDirName(DIRCASE)
+ #
+ # Iteration "iter_3_1"
+ # ====================
+ iter_3_1 = case_3.NextIteration('iter_3_1')
+ iter_3_1.SetMeshName('H_1')
+ iter_3_1.SetMeshFile(DIRCASE+'/maill.01.med')
+ iter_3_1.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.00.med')
+ iter_3_1.SetTimeStepRank( 1, 1)
+ iter_3_1.AssociateHypo('hypo_0vers1')
+ error = iter_3_1.Compute(1, 2)
+ #
+ # Iteration "iter_3_2"
+ # ====================
+ iter_3_2 = iter_3_1.NextIteration('iter_3_2')
+ iter_3_2.SetMeshName('H_2')
+ iter_3_2.SetMeshFile(DIRCASE+'/maill.02.med')
+ iter_3_2.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.01.med')
+ iter_3_2.SetTimeStepRank(1, 1)
+ iter_3_2.AssociateHypo('hypo_1vers2')
+ error = iter_3_2.Compute(1, 2)
+ #
+ # Iteration "iter_3_2_bis"
+ # ========================
+ iter_3_2_bis = iter_3_1.NextIteration('iter_3_2_bis')
+ iter_3_2_bis.SetMeshName('H_2_bis')
+ iter_3_2_bis.SetMeshFile(DIRCASE+'/maill.02.bis.med')
+ iter_3_2_bis.SetFieldFile(DATA_TUTORIAL+'/tutorial_3.01.med')
+ iter_3_2_bis.SetTimeStepRank(1, 1)
+ iter_3_2_bis.AssociateHypo('hypo_1vers2_bis')
+ error = iter_3_2_bis.Compute(1, 2)
+ #
+ return error
+
+#========================================================================
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load HOMARD engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = 3
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 3, 1)
+# ==================================
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_14 associe au tutorial 4
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_14"
+DEBUG = False
+N_ITER_TEST_FILE = 3
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# Repertoire des donnees du tutorial
+DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
+DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
+sys.path.append(DATA_TUTORIAL)
+from tutorial_util import gzip_gunzip
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 4, -1)
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+#
+ # Frontieres
+ # ==========
+ boun_4_1 = HOMARD.CreateBoundaryDi('intersection', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.fr.med')
+ #
+ boun_4_2 = HOMARD.CreateBoundaryCylinder('cyl_1_ext', 0.0, 25., -25., 25., 50., 75., 100.)
+ #
+ boun_4_3 = HOMARD.CreateBoundaryCylinder('cyl_2_ext', 17.5, -2.5, -12.5, -100., -75., -25., 50.)
+ #
+ boun_4_4 = HOMARD.CreateBoundaryCylinder('cyl_1_int', 0.0, 25., -25., 25., 50., 75., 75.)
+ #
+ boun_4_5 = HOMARD.CreateBoundaryCylinder('cyl_2_int', 17.5, -2.5, -12.5, -100., -75., -25., 25.)
+ #
+ # Hypotheses
+ # ==========
+ # Creation of the hypothesis hypo_4
+ hypo_4 = HOMARD.CreateHypothesis('hypo_4')
+ hypo_4.SetUnifRefinUnRef(1)
+ hypo_4.AddGroup('T1_INT_I')
+ hypo_4.AddGroup('T1_INT_O')
+ hypo_4.AddGroup('T2_INT')
+ # Creation of the hypothesis hypo_4_bis
+ hypo_4_bis = HOMARD.CreateHypothesis('hypo_4_bis')
+ hypo_4_bis.SetUnifRefinUnRef(1)
+ hypo_4_bis.AddGroup('T1_EXT_I')
+ hypo_4_bis.AddGroup('T1_EXT_O')
+ hypo_4_bis.AddGroup('T2_EXT')
+ #
+ # Cas
+ # ===
+ case_4 = HOMARD.CreateCase('case_4', 'PIQUAGE', DATA_TUTORIAL+'/tutorial_4.00.med')
+ case_4.SetDirName(DIRCASE)
+ case_4.AddBoundaryGroup( 'intersection', '' )
+ case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_I' )
+ case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_I' )
+ case_4.AddBoundaryGroup( 'cyl_1_int', 'T1_INT_O' )
+ case_4.AddBoundaryGroup( 'cyl_1_ext', 'T1_EXT_O' )
+ case_4.AddBoundaryGroup( 'cyl_2_int', 'T2_INT' )
+ case_4.AddBoundaryGroup( 'cyl_2_ext', 'T2_EXT' )
+ #
+ # Iterations
+ # ==========
+ # Iteration iter_4_1 : raffinement selon les faces internes
+ iter_4_1 = case_4.NextIteration('iter_4_1')
+ iter_4_1.SetMeshName('PIQUAGE_1')
+ iter_4_1.SetMeshFile(DIRCASE+'/maill.01.med')
+ iter_4_1.AssociateHypo('hypo_4')
+ error = iter_4_1.Compute(1, 2)
+ # Iteration iter_4_2 : raffinement selon les faces externes
+ iter_4_2 = iter_4_1.NextIteration('iter_4_2')
+ iter_4_2.SetMeshName('PIQUAGE_2')
+ iter_4_2.SetMeshFile(DIRCASE+'/maill.02.med')
+ iter_4_2.AssociateHypo('hypo_4_bis')
+ error = iter_4_2.Compute(1, 2)
+ # Iteration iter_4_3 : second raffinement selon les faces externes
+ iter_4_3 = iter_4_2.NextIteration('iter_4_3')
+ iter_4_3.SetMeshName('PIQUAGE_3')
+ iter_4_3.SetMeshFile(DIRCASE+'/maill.03.med')
+ iter_4_3.AssociateHypo('hypo_4_bis')
+ error = iter_4_3.Compute(1, 2)
+ #
+ return error
+
+#========================================================================
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load HOMARD engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 4, 1)
+# ==================================
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+
--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+Python script for HOMARD
+Test test_15 associe au tutorial 5
+"""
+__revision__ = "V3.1"
+
+#========================================================================
+TEST_NAME = "test_15"
+DEBUG = False
+N_ITER_TEST_FILE = 2
+#========================================================================
+import os
+import tempfile
+import sys
+import HOMARD
+import salome
+#
+# ==================================
+PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
+# Repertoire des scripts utilitaires
+REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
+REP_PYTHON = os.path.normpath(REP_PYTHON)
+sys.path.append(REP_PYTHON)
+from test_util import remove_dir
+from test_util import test_results
+# Repertoire des donnees du test
+REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
+REP_DATA = os.path.normpath(REP_DATA)
+# Repertoire des resultats
+if DEBUG :
+ DIRCASE = os.path.join("/tmp", TEST_NAME)
+ if ( os.path.isdir(DIRCASE) ) :
+ remove_dir(DIRCASE)
+ os.mkdir(DIRCASE)
+else :
+ DIRCASE = tempfile.mkdtemp()
+# Repertoire des donnees du tutorial
+DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads")
+DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL)
+sys.path.append(DATA_TUTORIAL)
+from tutorial_util import gzip_gunzip
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 5, -1)
+# ==================================
+
+salome.salome_init()
+import iparameters
+IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
+IPAR.append("AP_MODULES_LIST", "Homard")
+#
+#========================================================================
+#========================================================================
+def homard_exec(theStudy):
+ """
+Python script for HOMARD
+ """
+ #
+ HOMARD.SetCurrentStudy(theStudy)
+#
+ # Frontiere
+ # =========
+ # Creation of the discrete boundary Boun_5_1
+ boun_5_1 = HOMARD.CreateBoundaryDi('Boun_5_1', 'MAIL_EXT', DATA_TUTORIAL+'/tutorial_5.fr.med')
+ #
+ # Creation des zones
+ # ==================
+ # Creation of the disk with hole enveloppe
+ enveloppe = HOMARD.CreateZoneDiskWithHole( 'enveloppe', 0., 0., 250., 193., 1 )
+ # Creation of the rectangle quart_sup
+ quart_sup = HOMARD.CreateZoneBox2D( 'quart_sup', 0., 250., 0., 250., 1 )
+ #
+ # Hypotheses
+ # ==========
+ # Creation of the hypothesis hypo_5
+ hypo_5 = HOMARD.CreateHypothesis('hypo_5')
+ hypo_5.AddZone('enveloppe', 1)
+ # Creation of the hypothesis hypo_5_bis
+ hypo_5_bis = HOMARD.CreateHypothesis('hypo_5_bis')
+ hypo_5_bis.AddZone('quart_sup', 1)
+ #
+ # Cas
+ # ===
+ case_5 = HOMARD.CreateCase('case_5', 'COEUR_2D', DATA_TUTORIAL+'/tutorial_5.00.med')
+ case_5.SetDirName(DIRCASE)
+ case_5.SetConfType(1)
+ case_5.AddBoundaryGroup('Boun_5_1', '')
+ #
+ # Iteration "iter_5_1"
+ # ====================
+ iter_5_1 = case_5.NextIteration('iter_5_1')
+ iter_5_1.SetMeshName('COEUR_2D_01')
+ iter_5_1.SetMeshFile(DIRCASE+'/maill.01.med')
+ iter_5_1.AssociateHypo('hypo_5')
+ error = iter_5_1.Compute(1, 2)
+ #
+ # Iteration "iter_5_2"
+ # ====================
+ iter_5_2 = iter_5_1.NextIteration('iter_5_2')
+ iter_5_2.SetMeshName('COEUR_2D_02')
+ iter_5_2.SetMeshFile(DIRCASE+'/maill.02.med')
+ iter_5_2.AssociateHypo('hypo_5_bis')
+ error = iter_5_2.Compute(1, 2)
+ #
+ return error
+
+#========================================================================
+
+HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
+assert HOMARD is not None, "Impossible to load HOMARD engine"
+HOMARD.SetLanguageShort("fr")
+#
+# Exec of HOMARD-SALOME
+#
+try :
+ ERROR = homard_exec(salome.myStudy)
+ if ERROR :
+ raise Exception('Pb in homard_exec at iteration %d' %ERROR )
+except Exception, eee:
+ raise Exception('Pb in homard_exec: '+eee.message)
+#
+# Test of the results
+#
+N_REP_TEST_FILE = N_ITER_TEST_FILE
+DESTROY_DIR = not DEBUG
+test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
+#
+# ==================================
+gzip_gunzip(DATA_TUTORIAL, 5, 1)
+# ==================================
+#
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(1)
+ iparameters.getSession().restoreVisualState(1)
+