Salome HOME
exemple de python
authorGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Mon, 8 Feb 2021 16:19:42 +0000 (17:19 +0100)
committerGERALD NICOLAS <D68518@dsp0864451.atlas.edf.fr>
Mon, 8 Feb 2021 16:19:42 +0000 (17:19 +0100)
doc/salome/examples/adaptation_ex01.py [new file with mode: 0644]
doc/salome/gui/SMESH/input/tui_adaptation.rst

diff --git a/doc/salome/examples/adaptation_ex01.py b/doc/salome/examples/adaptation_ex01.py
new file mode 100644 (file)
index 0000000..1a91fac
--- /dev/null
@@ -0,0 +1,62 @@
+# Remeshing with MG-Adapt
+import os
+import salome
+salome.salome_init()
+
+import SMESH
+from salome.smesh import smeshBuilder
+smesh = smeshBuilder.New()
+
+# directory
+rootdir = ...
+
+# Test 1 : remeshing with a local size, surface
+#--- Creation of the object for the adaptation ---
+objet_adapt = smesh.Adaptation('MG_Adapt')
+
+#--- Initial mesh ---
+objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.01.med"))
+#--- Final mesh ---
+objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.01.adapt.med"))
+
+#--- Creation of the hypothesis ---
+hypo = smesh.CreateAdaptationHypothesis()
+#    Options
+hypo.setSizeMapType('Local')
+hypo.setSizeMapFieldName('TAILLE')
+hypo.setTimeStepRankLast()
+hypo.setOptionValue("adaptation", "surface")
+
+#--- Link between hypothesis and object ---
+objet_adapt.AddHypothesis(hypo)
+
+#--- Compute without publication
+err = objet_adapt.Compute(False)
+
+
+
+# Test 2 : remeshing with a background size, volume
+#--- Creation of the object for the adaptation ---
+objet_adapt = smesh.Adaptation('MG_Adapt')
+
+#--- Initial mesh ---
+objet_adapt.setMEDFileIn(os.path.join(rootdir, "maill.02.med"))
+#--- Background mesh ---
+objet_adapt.setMEDFileBackground(rootdir, "maill.size.02.med"))
+#--- Final mesh ---
+objet_adapt.setMEDFileOut(os.path.join(rootdir, "maill.02.adapt.med"))
+
+#--- Creation of the hypothesis ---
+hypo = smesh.CreateAdaptationHypothesis()
+#    Options
+hypo.setSizeMapType('Background')
+hypo.setSizeMapFieldName('TAILLE')
+hypo.setTimeStepRank(1,1)
+hypo.setOptionValue("adaptation", "both")
+
+#--- Link between hypothesis and object ---
+objet_adapt.AddHypothesis(hypo)
+
+#--- Compute without publication
+err = objet_adapt.Compute(False)
+
index 9bf8a29a4ead199630dc58a61d7998ec53350842..7db15c66a0acb2096fe84b89ad45133684386e39 100644 (file)
@@ -1,6 +1,5 @@
 .. _tui_adaptation_page:
 
 .. _tui_adaptation_page:
 
-
 **********
 Adaptation
 **********
 **********
 Adaptation
 **********
@@ -10,6 +9,10 @@ Adaptation
 MG_Adapt
 ========
 
 MG_Adapt
 ========
 
+.. literalinclude:: ../../../examples/adaptation_ex01.py
+    :language: python
+
+:download:`Download this script <../../../examples/adaptation_ex01.py>`
 
 
 **See Also** the GUI :ref:`adaptation_page`.
 
 
 **See Also** the GUI :ref:`adaptation_page`.