Salome HOME
Merge branch 'master' into gni/adaptation
[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 #--- Clean
37 del objet_adapt
38
39
40
41 # Test 2 : remeshing with a background size, volume
42 #--- Creation of the object for the adaptation ---
43 objet_adapt = smesh.Adaptation('MG_Adapt')
44
45 #--- Initial mesh ---
46 objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.02.med"))
47 #--- Background mesh ---
48 objet_adapt.setMEDFileBackground(rootdir, "maill.size.02.med"))
49 #--- Final mesh ---
50 objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.02.adapt.med"))
51
52 #--- Creation of the hypothesis ---
53 hypo = smesh.CreateAdaptationHypothesis()
54 #    Options
55 hypo.setSizeMapType('Background')
56 hypo.setSizeMapFieldName('TAILLE')
57 hypo.setTimeStepRank(1,1)
58 hypo.setOptionValue("adaptation", "both")
59
60 #--- Link between hypothesis and object ---
61 objet_adapt.AddHypothesis(hypo)
62
63 #--- Compute without publication
64 err = objet_adapt.Compute(False)
65
66 #--- Clean
67 del objet_adapt
68