Salome HOME
exemple de python
[modules/smesh.git] / doc / salome / examples / adaptation_ex01.py
1 # Remeshing with MG-Adapt
2 import os
3 import salome
4 salome.salome_init()
5
6 import SMESH
7 from salome.smesh import smeshBuilder
8 smesh = smeshBuilder.New()
9
10 # directory
11 rootdir = ...
12
13 # Test 1 : remeshing with a local size, surface
14 #--- Creation of the object for the adaptation ---
15 objet_adapt = smesh.Adaptation('MG_Adapt')
16
17 #--- Initial mesh ---
18 objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.01.med"))
19 #--- Final mesh ---
20 objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.01.adapt.med"))
21
22 #--- Creation of the hypothesis ---
23 hypo = smesh.CreateAdaptationHypothesis()
24 #    Options
25 hypo.setSizeMapType('Local')
26 hypo.setSizeMapFieldName('TAILLE')
27 hypo.setTimeStepRankLast()
28 hypo.setOptionValue("adaptation", "surface")
29
30 #--- Link between hypothesis and object ---
31 objet_adapt.AddHypothesis(hypo)
32
33 #--- Compute without publication
34 err = objet_adapt.Compute(False)
35
36
37
38 # Test 2 : remeshing with a background size, volume
39 #--- Creation of the object for the adaptation ---
40 objet_adapt = smesh.Adaptation('MG_Adapt')
41
42 #--- Initial mesh ---
43 objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.02.med"))
44 #--- Background mesh ---
45 objet_adapt.setMEDFileBackground(rootdir, "maill.size.02.med"))
46 #--- Final mesh ---
47 objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.02.adapt.med"))
48
49 #--- Creation of the hypothesis ---
50 hypo = smesh.CreateAdaptationHypothesis()
51 #    Options
52 hypo.setSizeMapType('Background')
53 hypo.setSizeMapFieldName('TAILLE')
54 hypo.setTimeStepRank(1,1)
55 hypo.setOptionValue("adaptation", "both")
56
57 #--- Link between hypothesis and object ---
58 objet_adapt.AddHypothesis(hypo)
59
60 #--- Compute without publication
61 err = objet_adapt.Compute(False)
62