From 5c79b298dac9a473ac3c9ed5b5a892a116d53bdf Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 20 Aug 2018 18:00:59 +0300 Subject: [PATCH] Provide missing TUI examples of some algorithms --- doc/salome/examples/cartesian_algo.py | 1 - .../defining_hypotheses_len_near_vertex.py | 29 ++++++ doc/salome/examples/quad_medial_axis_algo.py | 30 +++++++ doc/salome/examples/tests.set | 2 + .../gui/SMESH/input/constructing_meshes.rst | 2 +- .../gui/SMESH/input/quad_from_ma_algo.rst | 4 + .../input/segments_around_vertex_algo.rst | 5 +- .../gui/SMESH/input/smeshpy_interface.rst | 4 - .../gui/SMESH/input/tui_cartesian_algo.rst | 13 --- .../SMESH/input/tui_defining_hypotheses.rst | 90 +++++++++++++++++-- .../input/tui_generate_flat_elements.rst | 47 ---------- .../gui/SMESH/input/tui_modifying_meshes.rst | 41 +++++++++ .../gui/SMESH/input/tui_prism_3d_algo.rst | 19 ---- .../SMESH/input/tui_use_existing_faces.rst | 20 ----- src/SMESH_SWIG/smeshBuilder.py | 4 +- 15 files changed, 196 insertions(+), 115 deletions(-) create mode 100644 doc/salome/examples/defining_hypotheses_len_near_vertex.py create mode 100644 doc/salome/examples/quad_medial_axis_algo.py delete mode 100644 doc/salome/gui/SMESH/input/tui_cartesian_algo.rst delete mode 100644 doc/salome/gui/SMESH/input/tui_generate_flat_elements.rst delete mode 100644 doc/salome/gui/SMESH/input/tui_prism_3d_algo.rst delete mode 100644 doc/salome/gui/SMESH/input/tui_use_existing_faces.rst diff --git a/doc/salome/examples/cartesian_algo.py b/doc/salome/examples/cartesian_algo.py index e9d7748c7..26bdb8bf0 100644 --- a/doc/salome/examples/cartesian_algo.py +++ b/doc/salome/examples/cartesian_algo.py @@ -10,7 +10,6 @@ geompy = geomBuilder.New() import SMESH, SALOMEDS from salome.smesh import smeshBuilder smesh = smeshBuilder.New() -import salome_notebook # create a sphere diff --git a/doc/salome/examples/defining_hypotheses_len_near_vertex.py b/doc/salome/examples/defining_hypotheses_len_near_vertex.py new file mode 100644 index 000000000..6d8ab44b2 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_len_near_vertex.py @@ -0,0 +1,29 @@ +# Usage of Segments around Vertex algorithm + +# for meshing a box with quadrangles with refinement near vertices + +import salome +salome.salome_init() +from salome.geom import geomBuilder +geompy = geomBuilder.New() +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# create a box +box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) + +# make a mesh +mesh = smesh.Mesh( box ) + +# define quadrangle meshing +algo1d = mesh.Segment() +algo1d.LocalLength( 1. ) +mesh.Quadrangle() + +# add Hexahedron algo to assure that there are no triangles +mesh.Hexahedron() + +# define refinement near vertices +algo1d.LengthNearVertex( 0.2 ) + +mesh.Compute() diff --git a/doc/salome/examples/quad_medial_axis_algo.py b/doc/salome/examples/quad_medial_axis_algo.py new file mode 100644 index 000000000..42aea882e --- /dev/null +++ b/doc/salome/examples/quad_medial_axis_algo.py @@ -0,0 +1,30 @@ +# Usage of Medial Axis Projection algorithm + +# for meshing a ring face with quadrangles + +import salome +salome.salome_init() +from salome.geom import geomBuilder +geompy = geomBuilder.New() +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New() + +# create a ring face +circleEdge1 = geompy.MakeCircleR( 3 ) +circleEdge2 = geompy.MakeCircleR( 7 ) +ring = geompy.MakeFaceWires( [ circleEdge1, circleEdge2 ], True, theName='Ring' ) +circleLen1 = geompy.BasicProperties( circleEdge1 )[0] +circleLen2 = geompy.BasicProperties( circleEdge2 )[0] + +# make a mesh + +mesh = smesh.Mesh( ring ) + +circNbSeg = 60 +algo1d = mesh.Segment() +algo1d.NumberOfSegments( circNbSeg ) # division of circle edges + +algo2d = mesh.Quadrangle( smeshBuilder.QUAD_MA_PROJ ) +algo2d.StartEndLength( circleLen2 / circNbSeg, circleLen1 / circNbSeg ) # radial division + +mesh.Compute() diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index 1a2dd8105..f5fddb582 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -175,6 +175,8 @@ SET(GOOD_TESTS use_existing_faces.py viewing_meshes_ex02.py split_biquad.py + quad_medial_axis_algo.py + defining_hypotheses_len_near_vertex.py ) SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} testme.py) diff --git a/doc/salome/gui/SMESH/input/constructing_meshes.rst b/doc/salome/gui/SMESH/input/constructing_meshes.rst index bb269953a..d26102f43 100644 --- a/doc/salome/gui/SMESH/input/constructing_meshes.rst +++ b/doc/salome/gui/SMESH/input/constructing_meshes.rst @@ -136,7 +136,7 @@ To construct a mesh: * **Applied algorithms** folder containing the references to the algorithms chosen at the construction of the mesh. * **SubMeshes on Face** folder containing the sub-meshes defined on geometrical faces. There also can be folders for sub-meshes on vertices, edges, wires, shells, solids and compounds. * **Groups of Faces** folder containing the groups of mesh faces. There also can be folders for groups of nodes, edges, volumes 0D elements and balls. - + There is an alternative way to assign Algorithms and Hypotheses by clicking **Assign a set of hypotheses** button and selecting among pre-defined sets of algorithms and hypotheses. In addition to the built-in sets of hypotheses, it is possible to create custom sets by editing CustomMeshers.xml file located in the home directory. CustomMeshers.xml file must describe sets of hypotheses in the same way as ${SMESH_ROOT_DIR}/share/salome/resources/smesh/StdMeshers.xml file does (sets of hypotheses are enclosed between \ tags). For example: :: diff --git a/doc/salome/gui/SMESH/input/quad_from_ma_algo.rst b/doc/salome/gui/SMESH/input/quad_from_ma_algo.rst index 92413e496..b9b7cd482 100644 --- a/doc/salome/gui/SMESH/input/quad_from_ma_algo.rst +++ b/doc/salome/gui/SMESH/input/quad_from_ma_algo.rst @@ -40,3 +40,7 @@ The Medial Axis is used in two ways: .. centered:: Mesh depends on defined sub-meshes: to the left - sub-meshes on both wires, to the right - a sub-mesh on internal wire only + + +**See Also** a sample TUI Script of a :ref:`tui_quad_ma_proj_algo`. + diff --git a/doc/salome/gui/SMESH/input/segments_around_vertex_algo.rst b/doc/salome/gui/SMESH/input/segments_around_vertex_algo.rst index 811ba0254..e70c160a6 100644 --- a/doc/salome/gui/SMESH/input/segments_around_vertex_algo.rst +++ b/doc/salome/gui/SMESH/input/segments_around_vertex_algo.rst @@ -10,6 +10,8 @@ the local size of the segments in the neighborhood of a certain vertex. If we assign this algorithm to a geometrical object of higher dimension, it applies to all its vertices. +.. _note: To create 0D elements, use :ref:`adding_nodes_and_elements_page` operation. + Length of segments near vertex is defined by **Length Near Vertex** hypothesis. This hypothesis is used by :ref:`Wire Discretization ` or :ref:`Composite Side Discretization ` algorithms as @@ -20,5 +22,4 @@ segment length required by **Length Near Vertex** hypothesis. .. image:: ../images/lengthnearvertex.png :align: center - - +**See also** a sample :ref:`TUI Script `. diff --git a/doc/salome/gui/SMESH/input/smeshpy_interface.rst b/doc/salome/gui/SMESH/input/smeshpy_interface.rst index 0e209705a..ce80d7411 100644 --- a/doc/salome/gui/SMESH/input/smeshpy_interface.rst +++ b/doc/salome/gui/SMESH/input/smeshpy_interface.rst @@ -104,10 +104,6 @@ the following links: tui_measurements tui_work_on_objects_from_gui tui_notebook_smesh - tui_cartesian_algo - tui_use_existing_faces - tui_prism_3d_algo - tui_generate_flat_elements .. toctree:: :hidden: diff --git a/doc/salome/gui/SMESH/input/tui_cartesian_algo.rst b/doc/salome/gui/SMESH/input/tui_cartesian_algo.rst deleted file mode 100644 index 2dd01be13..000000000 --- a/doc/salome/gui/SMESH/input/tui_cartesian_algo.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. _tui_cartesian_algo: - -Usage of Body Fitting algorithm -############################### - -.. literalinclude:: ../../../examples/cartesian_algo.py - :linenos: - :language: python - -:download:`Download this script <../../../examples/cartesian_algo.py>` - - - diff --git a/doc/salome/gui/SMESH/input/tui_defining_hypotheses.rst b/doc/salome/gui/SMESH/input/tui_defining_hypotheses.rst index 0642126ba..c839e94b9 100644 --- a/doc/salome/gui/SMESH/input/tui_defining_hypotheses.rst +++ b/doc/salome/gui/SMESH/input/tui_defining_hypotheses.rst @@ -10,7 +10,7 @@ and hypotheses. * Wire discretisation 1D algorithm * :ref:`tui_1d_adaptive` hypothesis - * :ref:`rithmetic Progression ` hypothesis + * :ref:`Arithmetic Progression ` hypothesis * :ref:`Geometric Progression ` hypothesis * :ref:`Deflection and Number of Segments ` hypotheses * :ref:`Start and End Length ` hypothesis @@ -24,20 +24,23 @@ and hypotheses. * :ref:`tui_max_element_area` hypothesis * :ref:`tui_length_from_edges` hypothesis +* Quadrangle: Mapping 2D algorithm + + * :ref:`Quadrangle Parameters ` hypothesis +* :ref:`Radial Quadrangle 1D-2D ` algorithm * NETGEN 3D algorithm * :ref:`tui_max_element_volume` hypothesis * :ref:`Viscous layers ` hypotheses * :ref:`tui_projection` -* :ref:`Radial Quadrangle 1D-2D ` algorithm -* Quadrangle: Mapping 2D algorithm - - * :ref:`Quadrangle Parameters ` hypothesis - -* :ref:`tui_radial_prism` +* :ref:`Extrusion 3D ` algorithm +* :ref:`Radial Prism ` algorithm +* :ref:`Body Fitting ` algorithm * :ref:`Import 1D-2D Elements from Another Mesh ` algorithm +* :ref:`Use Faces to be Created Manually ` algorithm +* :ref:`Segments around Vertex ` algorithm @@ -262,3 +265,76 @@ Radial Prism example :language: python :download:`Download this script <../../../examples/radial_prism_3d_algo.py>` + +.. _tui_cartesian_algo: + +Usage of Body Fitting algorithm +############################### + +.. literalinclude:: ../../../examples/cartesian_algo.py + :linenos: + :language: python + +:download:`Download this script <../../../examples/cartesian_algo.py>` + +.. _tui_use_existing_faces: + +Usage of "Use Faces to be Created Manually" algorithm +##################################################### + +This sample demonstrates how to use **Use Faces to be Created Manually** algorithm, +which is actually just a stub allowing to use your own 2D algorithm +implemented in Python. + +.. literalinclude:: ../../../examples/use_existing_faces.py + :linenos: + :language: python + +:download:`Download this script <../../../examples/use_existing_faces.py>` + +Resulting mesh: + +.. image:: ../images/use_existing_face_sample_mesh.png + :align: center + + +.. _tui_prism_3d_algo: + +Usage of Extrusion 3D meshing algorithm +######################################## + +.. literalinclude:: ../../../examples/prism_3d_algo.py + :linenos: + :language: python + +:download:`Download this script <../../../examples/prism_3d_algo.py>` + +The result geometry and mesh is shown below + +.. image:: ../images/prism_tui_sample.png + :align: center + + +.. _tui_quad_ma_proj_algo: + +Usage of Medial Axis Projection algorithm +######################################### + +.. literalinclude:: ../../../examples/quad_medial_axis_algo.py + :linenos: + :language: python + +:download:`Download this script <../../../examples/quad_medial_axis_algo.py>` + + +.. _tui_segments_around_vertex: + +Usage of Segments around Vertex algorithm +######################################### + +.. literalinclude:: ../../../examples/defining_hypotheses_len_near_vertex.py + :linenos: + :language: python + +:download:`Download this script <../../../examples/defining_hypotheses_len_near_vertex.py>` + diff --git a/doc/salome/gui/SMESH/input/tui_generate_flat_elements.rst b/doc/salome/gui/SMESH/input/tui_generate_flat_elements.rst deleted file mode 100644 index 6a6790eac..000000000 --- a/doc/salome/gui/SMESH/input/tui_generate_flat_elements.rst +++ /dev/null @@ -1,47 +0,0 @@ -.. _tui_generate_flat_elements_page: - -********************** -Generate flat elements -********************** - - -.. _tui_double_nodes_on_group_boundaries: - -Double nodes on groups boundaries -################################# - -Double nodes on shared faces between groups of volumes and create flat elements on demand. - -The list of groups must contain at least two groups. The groups have to be disjoint: no common element into two different groups. - -The nodes of the internal faces at the boundaries of the groups are doubled. Optionally, the internal faces are replaced by flat elements. - -Triangles are transformed into prisms, and quadrangles into hexahedrons. - -The flat elements are stored in groups of volumes. - -These groups are named according to the position of the group in the list: -the group j_n_p is the group of the flat elements that are built between the group \#n and the group \#p in the list. -If there is no shared faces between the group \#n and the group \#p in the list, the group j_n_p is not created. -All the flat elements are gathered into the group named "joints3D" (or "joints2D" in 2D situation). -The flat element of the multiple junctions between the simple junction are stored in a group named "jointsMultiples". - -This example represents an iron cable (a thin cylinder) in a concrete bloc (a big cylinder). -The big cylinder is defined by two geometric volumes. - -.. literalinclude:: ../../../examples/generate_flat_elements.py - :linenos: - :language: python - -:download:`Download this script <../../../examples/generate_flat_elements.py>` - -Here, the 4 groups of volumes [Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1] constitute a partition of the mesh. -The flat elements on group boundaries and on faces are built with the -2 last lines of the code above. - -If the last argument (Boolean) in DoubleNodesOnGroupBoundaries is set to 1, -the flat elements are built, otherwise, there is only a duplication of the nodes. - -To observe flat element groups, save the resulting mesh on a MED file and reload it. - - diff --git a/doc/salome/gui/SMESH/input/tui_modifying_meshes.rst b/doc/salome/gui/SMESH/input/tui_modifying_meshes.rst index 25783ad85..e90ba3726 100644 --- a/doc/salome/gui/SMESH/input/tui_modifying_meshes.rst +++ b/doc/salome/gui/SMESH/input/tui_modifying_meshes.rst @@ -313,3 +313,44 @@ Split bi-quadratic into linear :language: python :download:`Download this script <../../../examples/split_biquad.py>` + +.. _tui_double_nodes_on_group_boundaries: + +Double nodes on groups boundaries +================================= + +Double nodes on shared faces between groups of volumes and create flat elements on demand. + +The list of groups must contain at least two groups. The groups have to be disjoint: no common element into two different groups. + +The nodes of the internal faces at the boundaries of the groups are doubled. Optionally, the internal faces are replaced by flat elements. + +Triangles are transformed into prisms, and quadrangles into hexahedrons. + +The flat elements are stored in groups of volumes. + +These groups are named according to the position of the group in the list: +the group j_n_p is the group of the flat elements that are built between the group \#n and the group \#p in the list. +If there is no shared faces between the group \#n and the group \#p in the list, the group j_n_p is not created. +All the flat elements are gathered into the group named "joints3D" (or "joints2D" in 2D situation). +The flat element of the multiple junctions between the simple junction are stored in a group named "jointsMultiples". + +This example represents an iron cable (a thin cylinder) in a concrete bloc (a big cylinder). +The big cylinder is defined by two geometric volumes. + +.. literalinclude:: ../../../examples/generate_flat_elements.py + :linenos: + :language: python + +:download:`Download this script <../../../examples/generate_flat_elements.py>` + +Here, the 4 groups of volumes [Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1] constitute a partition of the mesh. +The flat elements on group boundaries and on faces are built with the +2 last lines of the code above. + +If the last argument (Boolean) in DoubleNodesOnGroupBoundaries is set to 1, +the flat elements are built, otherwise, there is only a duplication of the nodes. + +To observe flat element groups, save the resulting mesh on a MED file and reload it. + + diff --git a/doc/salome/gui/SMESH/input/tui_prism_3d_algo.rst b/doc/salome/gui/SMESH/input/tui_prism_3d_algo.rst deleted file mode 100644 index 6bc69d49f..000000000 --- a/doc/salome/gui/SMESH/input/tui_prism_3d_algo.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. _tui_prism_3d_algo: - -********************************** -Use Extrusion 3D meshing algorithm -********************************** - -.. literalinclude:: ../../../examples/prism_3d_algo.py - :linenos: - :language: python - -:download:`Download this script <../../../examples/prism_3d_algo.py>` - -The result geometry and mesh is shown below - -.. image:: ../images/prism_tui_sample.png - :align: center - - - diff --git a/doc/salome/gui/SMESH/input/tui_use_existing_faces.rst b/doc/salome/gui/SMESH/input/tui_use_existing_faces.rst deleted file mode 100644 index baaf81a09..000000000 --- a/doc/salome/gui/SMESH/input/tui_use_existing_faces.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. _tui_use_existing_faces: - -***************************************************** -Usage of "Use Faces to be Created Manually" algorithm -***************************************************** - -This sample demonstrates how to use **Use Faces to be Created Manually** algorithm, -which is actually just a stub allowing to use your own 2D algorithm -implemented in Python. - -.. literalinclude:: ../../../examples/use_existing_faces.py - :linenos: - :language: python - -:download:`Download this script <../../../examples/use_existing_faces.py>` - -Resulting mesh: - -.. image:: ../images/use_existing_face_sample_mesh.png - :align: center diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index c21f7f008..864e69598 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -3679,7 +3679,9 @@ class Mesh(metaclass = MeshMeta): isElem2: *True* if *id2* is element id, *False* if it is node id Returns: - minimum distance value **GetMinDistance()** + minimum distance value + See Also: + :meth:`GetMinDistance` """ aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2) -- 2.39.2