#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# ==================================
PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
# Repertoire des scripts utilitaires
# ==================================
PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
# Repertoire des scripts utilitaires
from test_util import get_dir
from test_util import test_results
# ==================================
from test_util import get_dir
from test_util import test_results
# ==================================
-REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
-# ==================================
+REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
+#========================================================================
-import iparameters
-IPAR = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1))
-IPAR.append("AP_MODULES_LIST", "Homard")
-#
-#========================================================================
maillage_3d = ml.MEDCouplingUMesh(MESH_NAME, 2)
maillage_3d.setMeshDimension(3)
maillage_3d = ml.MEDCouplingUMesh(MESH_NAME, 2)
maillage_3d.setMeshDimension(3)
delta_x = LG_X / float(NBCELL_X)
delta_y = LG_Y / float(NBCELL_Y)
delta_z = LG_Z / float(NBCELL_Z)
delta_x = LG_X / float(NBCELL_X)
delta_y = LG_Y / float(NBCELL_Y)
delta_z = LG_Z / float(NBCELL_Z)
-#
- nbr_nodes = nbno_x*nbno_y*nbno_z
- les_coords = ml.DataArrayDouble(coordinates, nbr_nodes, 3)
+
+ nbno = nbno_x*nbno_y*nbno_z
+ les_coords = ml.DataArrayDouble(coordinates, nbno, 3)
decala_z = nbno_x*nbno_y
# kaux = numero de la tranche en z
for kaux in range(1, nbno_z) :
decala_z = nbno_x*nbno_y
# kaux = numero de la tranche en z
for kaux in range(1, nbno_z) :
#print ". Tranche en z numero %d" % kaux
decala = decala_z*(kaux-1)
# jaux = numero de la tranche en y
for jaux in range(1, nbno_y) :
#print ". Tranche en z numero %d" % kaux
decala = decala_z*(kaux-1)
# jaux = numero de la tranche en y
for jaux in range(1, nbno_y) :
#print ". Tranche en y numero %d" % jaux
# iaux = numero de la tranche en x
for iaux in range(1, nbno_x) :
#print ". Tranche en y numero %d" % jaux
# iaux = numero de la tranche en x
for iaux in range(1, nbno_x) :
#print ". Tranche en x numero %d" % iaux
nref = decala+iaux-1
laux = [nref, nref+nbno_x, nref+1+nbno_x, nref+1, nref+decala_z, nref+nbno_x+decala_z, nref+1+nbno_x+decala_z, nref+1+decala_z]
#print ". Tranche en x numero %d" % iaux
nref = decala+iaux-1
laux = [nref, nref+nbno_x, nref+1+nbno_x, nref+1, nref+decala_z, nref+nbno_x+decala_z, nref+1+nbno_x+decala_z, nref+1+decala_z]
- #if self.verbose_max :
- #if ( ( iaux==1 and jaux==1 and kaux==1 ) or ( iaux==(nbr_nodes_x-1) and jaux==(nbr_nodes_y-1) and kaux==(nbr_nodes_z-1) ) ) :
- #print ". Maille %d : " % (iaux*jaux*kaux), laux
+ if VERBOSE:
+ if ( ( iaux==1 and jaux==1 and kaux==1 ) or ( iaux==(nbno_x-1) and jaux==(nbno_y-1) and kaux==(nbno_z-1) ) ) :
+ print (". Maille {} : {}".format((iaux*jaux*kaux),laux))
try:
ficmed = os.path.join(DIRCASE, 'maill.00.med')
#print "Ecriture du maillage dans le fichier", ficmed
meshMEDFile3D.write(ficmed, 2)
except IOError as eee:
error = 2
try:
ficmed = os.path.join(DIRCASE, 'maill.00.med')
#print "Ecriture du maillage dans le fichier", ficmed
meshMEDFile3D.write(ficmed, 2)
except IOError as eee:
error = 2
ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter)
meshMEDFileRead = ml.MEDFileMesh.New(ficmed)
mesh_read0 = meshMEDFileRead.getMeshAtLevel(0)
ficmed = os.path.join(DIRCASE, 'maill.%02d.med' % niter)
meshMEDFileRead = ml.MEDFileMesh.New(ficmed)
mesh_read0 = meshMEDFileRead.getMeshAtLevel(0)
xyz_p = np.zeros(3, dtype=np.float)
xyz_p[0] = -0.20*float(1-niter) * LG_X
xyz_p[1] = -0.15*float(1-niter) * LG_Y
xyz_p[2] = -0.10*float(1-niter) * LG_Z
xyz_p = np.zeros(3, dtype=np.float)
xyz_p[0] = -0.20*float(1-niter) * LG_X
xyz_p[1] = -0.15*float(1-niter) * LG_Y
xyz_p[2] = -0.10*float(1-niter) * LG_Z
nbr_cell_3d = mesh_read0.getNumberOfCells()
valeur = mc.DataArrayDouble(nbr_cell_3d)
for num_mail in range(nbr_cell_3d) :
nbr_cell_3d = mesh_read0.getNumberOfCells()
valeur = mc.DataArrayDouble(nbr_cell_3d)
for num_mail in range(nbr_cell_3d) :
valeur[num_mail] = 1.e0 / max ( 1.e-5, distance)
#print ". valeur", valeur
nparr = valeur.toNumPyArray()
valeur[num_mail] = 1.e0 / max ( 1.e-5, distance)
#print ". valeur", valeur
nparr = valeur.toNumPyArray()
- print(". mini/maxi", nparr.min(), nparr.max())
- #
- # Creation of the field
- # =====================
+ print(". mini/maxi {}/{}".format(nparr.min(),nparr.max()))
+
+# Creation of the field
+# =====================
field = ml.MEDCouplingFieldDouble(ml.ON_CELLS, ml.ONE_TIME)
field.setArray(valeur)
field.setMesh(mesh_read0)
field.setName("DISTANCE")
field = ml.MEDCouplingFieldDouble(ml.ON_CELLS, ml.ONE_TIME)
field.setArray(valeur)
field.setMesh(mesh_read0)
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
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
- #
- HOMARD.SetCurrentStudy(theStudy)
- #
- # Creation of the hypothese DISTANCE INVERSE
- # ==========================================
+
+# Creation of the hypothese DISTANCE INVERSE
+# ==========================================
hyponame = "DISTANCE INVERSE"
print("-------- Creation of the hypothesis", hyponame)
hypo_5 = HOMARD.CreateHypothesis(hyponame)
hyponame = "DISTANCE INVERSE"
print("-------- Creation of the hypothesis", hyponame)
hypo_5 = HOMARD.CreateHypothesis(hyponame)
hypo_5.SetUnRefThr(1, 0.015)
print(hyponame, " : champ utilisé :", hypo_5.GetFieldName())
print(".. caractéristiques de l'adaptation :", hypo_5.GetField())
hypo_5.SetUnRefThr(1, 0.015)
print(hyponame, " : champ utilisé :", hypo_5.GetFieldName())
print(".. caractéristiques de l'adaptation :", hypo_5.GetField())
print("-------- Creation of the case", TEST_NAME)
mesh_file = os.path.join(DIRCASE, 'maill.00.med')
case_test_5 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
case_test_5.SetDirName(DIRCASE)
case_test_5.SetConfType(1)
case_test_5.SetExtType(1)
print("-------- Creation of the case", TEST_NAME)
mesh_file = os.path.join(DIRCASE, 'maill.00.med')
case_test_5 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
case_test_5.SetDirName(DIRCASE)
case_test_5.SetConfType(1)
case_test_5.SetExtType(1)
iter_name = "I_" + TEST_NAME + "_" + s_niterp1
print("-------- Creation of the iteration", iter_name)
if ( niter == 0 ) :
iter_name = "I_" + TEST_NAME + "_" + s_niterp1
print("-------- Creation of the iteration", iter_name)
if ( niter == 0 ) :
HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
assert HOMARD is not None, "Impossible to load homard engine"
HOMARD.SetLanguageShort("fr")
HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
assert HOMARD is not None, "Impossible to load homard engine"
HOMARD.SetLanguageShort("fr")
if ERROR :
raise Exception('Pb in homard_exec at iteration %d' %ERROR )
except RuntimeError as eee:
raise Exception('Pb in homard_exec: '+str(eee.message))
if ERROR :
raise Exception('Pb in homard_exec at iteration %d' %ERROR )
except RuntimeError as eee:
raise Exception('Pb in homard_exec: '+str(eee.message))
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)
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)