]> SALOME platform Git repositories - tools/solverlab.git/commitdiff
Salome HOME
Added 3D tetrahedron meshes
authormichael <michael@localhost.localdomain>
Mon, 18 Jan 2021 15:51:00 +0000 (16:51 +0100)
committermichael <michael@localhost.localdomain>
Mon, 18 Jan 2021 15:51:00 +0000 (16:51 +0100)
CDMATH/tests/ressources/3DTetrahedron/Tetrahedron.py [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.med [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.png [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.med [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.png [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.med [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.png [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.med [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.png [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.med [new file with mode: 0644]
CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.png [new file with mode: 0644]

diff --git a/CDMATH/tests/ressources/3DTetrahedron/Tetrahedron.py b/CDMATH/tests/ressources/3DTetrahedron/Tetrahedron.py
new file mode 100644 (file)
index 0000000..43bee77
--- /dev/null
@@ -0,0 +1,58 @@
+from __future__ import division\r
+\r
+from salome.geom import geomBuilder\r
+from salome.smesh import smeshBuilder\r
+\r
+import sys\r
+import os\r
+\r
+from math import pi, cos, sin, sqrt\r
+import SMESH\r
+\r
+geompy = geomBuilder.New()\r
+smesh = smeshBuilder.New()\r
+\r
+\r
+def create_group_from(name, mother_shape, list_elem, type="EDGE"):\r
+    new = geompy.CreateGroup(mother_shape, geompy.ShapeType[type])\r
+    geompy.UnionList(new, list_elem)\r
+    new.SetName(name)\r
+    geompy.addToStudyInFather(mother_shape, new, name)\r
+    return new\r
+\r
+# We build a regular tetrahedron with center of mass at (0,0,0) and \r
+r = 1.#distance between any two vertices\r
+h = sqrt(6.) / 3. * r # height of the tetrahedron (distance between a vertex and the opposite plane)\r
+\r
+points = [geompy.MakeVertex(r * cos(2 * i * pi / 3), r * sin(2 * i * pi / 3), -1./4 * h) for i in range(3)]\r
+points.append(geompy.MakeVertex(0., 0., 3./4 * h))\r
+\r
+faces_connectivity = [[0, 1, 2], [0, 1, 3], [1, 2, 3], [2, 3, 0]]\r
+\r
+faces = []\r
+for fc in faces_connectivity:\r
+    fc2 = fc + [fc[0]]\r
+    edges = [geompy.MakeEdge(points[fc2[i]], points[fc2[i + 1]]) for i in range(len(fc2) - 1)]\r
+    faces.append(geompy.MakeFace(geompy.MakeWire(edges), True))\r
+\r
+tetra_skin = geompy.MakeShell(faces)\r
+tetra = geompy.MakeSolid(tetra_skin)\r
+geompy.addToStudy(tetra, "Tetrahedron")\r
+g = create_group_from("TetrahedronBoundary", tetra, [geompy.GetInPlace(tetra, tetra_skin, 1)], type="FACE")\r
+\r
+### Mesh ###\r
+number_of_segments = 50\r
+\r
+TetrahedronMesh = smesh.Mesh(tetra, "Tetrahedron"+str(number_of_segments))\r
+NETGEN_1D_2D_3D = TetrahedronMesh.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)\r
+NETGEN_3D_Simple_Parameters_1 = NETGEN_1D_2D_3D.Parameters(smeshBuilder.SIMPLE)\r
+\r
+NETGEN_3D_Simple_Parameters_1.SetNumberOfSegments(number_of_segments)\r
+NETGEN_3D_Simple_Parameters_1.LengthFromEdges()\r
+NETGEN_3D_Simple_Parameters_1.LengthFromFaces()\r
+\r
+TetrahedronBoundary_1 = TetrahedronMesh.GroupOnGeom(g, 'BoundaryFaces', SMESH.FACE)\r
+TetrahedronBoundary_2 = TetrahedronMesh.GroupOnGeom(g, 'BoundaryNodes', SMESH.NODE)\r
+isDone = TetrahedronMesh.Compute()\r
+\r
+TetrahedronMesh.ExportMED("meshTetrahedron" + str(number_of_segments) + ".med")\r
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.med b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.med
new file mode 100644 (file)
index 0000000..685ed0e
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.med differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.png b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.png
new file mode 100644 (file)
index 0000000..34d5f52
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron10.png differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.med b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.med
new file mode 100644 (file)
index 0000000..c60c072
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.med differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.png b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.png
new file mode 100644 (file)
index 0000000..6c7102f
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron20.png differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.med b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.med
new file mode 100644 (file)
index 0000000..f08a122
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.med differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.png b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.png
new file mode 100644 (file)
index 0000000..9015184
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron30.png differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.med b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.med
new file mode 100644 (file)
index 0000000..3991523
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.med differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.png b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.png
new file mode 100644 (file)
index 0000000..3216970
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron40.png differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.med b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.med
new file mode 100644 (file)
index 0000000..6beee3f
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.med differ
diff --git a/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.png b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.png
new file mode 100644 (file)
index 0000000..a2135c9
Binary files /dev/null and b/CDMATH/tests/ressources/3DTetrahedron/meshTetrahedron50.png differ