mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-24 16:30:34 +05:00
Adding user documentation
This commit is contained in:
parent
7d1a127bbb
commit
b131becc08
@ -1,8 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# Creating dual Mesh
|
||||
|
||||
###
|
||||
### This file is generated automatically by SALOME v9.9.0 with dump python functionality
|
||||
###
|
||||
|
||||
import sys
|
||||
import salome
|
||||
@ -22,6 +19,7 @@ import math
|
||||
import SALOMEDS
|
||||
|
||||
|
||||
# Creating a sphere
|
||||
geompy = geomBuilder.New()
|
||||
|
||||
O = geompy.MakeVertex(0, 0, 0)
|
||||
@ -36,20 +34,20 @@ geompy.addToStudy( OY, 'OY' )
|
||||
geompy.addToStudy( OZ, 'OZ' )
|
||||
geompy.addToStudy( Sphere_1, 'Sphere_1' )
|
||||
|
||||
###
|
||||
### SMESH component
|
||||
###
|
||||
|
||||
import SMESH, SALOMEDS
|
||||
from salome.smesh import smeshBuilder
|
||||
|
||||
smesh = smeshBuilder.New()
|
||||
|
||||
# Meshing sphere in Tetrahedron
|
||||
NETGEN_3D_Parameters_1 = smesh.CreateHypothesisByAverageLength( 'NETGEN_Parameters', 'NETGENEngine', 34.641, 0 )
|
||||
Mesh_1 = smesh.Mesh(Sphere_1,'Mesh_1')
|
||||
status = Mesh_1.AddHypothesis( Sphere_1, NETGEN_3D_Parameters_1 )
|
||||
NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
|
||||
isDone = Mesh_1.Compute()
|
||||
|
||||
|
||||
# Creating Dual mesh
|
||||
dual_Mesh_1 = smesh.CreateDualMesh( Mesh_1, 'dual_Mesh_1', True)
|
||||
|
||||
|
@ -128,6 +128,7 @@ SET(BAD_TESTS
|
||||
transforming_meshes_ex06.py
|
||||
viewing_meshes_ex01.py
|
||||
radial_prism_3d_algo.py
|
||||
create_dual_mesh.py
|
||||
)
|
||||
IF(NOT WIN32)
|
||||
LIST(APPEND BAD_TESTS
|
||||
|
@ -57,7 +57,7 @@ SET(_cmd_smeshBuilder_gen_options ${smesh_merge_file} -o tmp2/smeshBuilder.py sm
|
||||
SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd_smeshBuilder_gen env_script "${PYTHON_EXECUTABLE}" "${_cmd_smeshBuilder_gen_options}" CONTEXT "SMESH_DOC" ADDITIONAL_VARIABLES ${ADD_VAR})
|
||||
|
||||
ADD_CUSTOM_TARGET(pre_usr_docs
|
||||
# 1. Make temporary directories for python modules
|
||||
# 1. Make temporary directories for python modules
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory tmp1
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory tmp2
|
||||
|
||||
|
BIN
doc/gui/images/create_dual_mesh_dlg.png
Normal file
BIN
doc/gui/images/create_dual_mesh_dlg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -1,8 +1,8 @@
|
||||
.. _about_meshes_page:
|
||||
.. _about_meshes_page:
|
||||
|
||||
************
|
||||
About meshes
|
||||
************
|
||||
************
|
||||
|
||||
**MESH** represents a discrete approximation of a subset of the three-dimensional space by `elementary geometrical elements`_.
|
||||
|
||||
@ -10,7 +10,7 @@ A SALOME study can contain multiple meshes, but they do not implicitly compose o
|
||||
|
||||
Mesh module provides several ways to create the mesh:
|
||||
|
||||
* The main way is to :ref:`construct the mesh <constructing_meshes_page>` on the basis of the geometrical shape produced in the Geometry module. This way implies selection of
|
||||
* The main way is to :ref:`construct the mesh <constructing_meshes_page>` on the basis of the geometrical shape produced in the Geometry module. This way implies selection of
|
||||
|
||||
* a geometrical object (*main shape*) and
|
||||
* *meshing parameters* (:ref:`meshing algorithms <basic_meshing_algos_page>` and characteristics (e.g. element size) of a required mesh encapsulated in :ref:`hypothesis <about_hypo_page>` objects).
|
||||
@ -20,19 +20,21 @@ Mesh module provides several ways to create the mesh:
|
||||
|
||||
.. note::
|
||||
Algorithms and hypotheses used at mesh level are referred to as *global* ones and those used at sub-mesh level are referred to as *local* ones.
|
||||
|
||||
|
||||
* Bottom-up way, using :ref:`mesh modification <modifying_meshes_page>` operations, especially :ref:`extrusion <extrusion_page>` and :ref:`revolution <revolution_page>`. To create an empty mesh not based on geometry, use the same dialog as to :ref:`construct the mesh on geometry <constructing_meshes_page>` but specify neither the geometry nor meshing algorithms.
|
||||
|
||||
|
||||
* The mesh can be :ref:`imported <importing_exporting_meshes_page>` from (and exported to) the file in MED, UNV, STL, CGNS, DAT and GMF formats.
|
||||
|
||||
|
||||
* The 3D mesh can be generated from the 2D mesh not based on geometry, which was either :ref:`imported <importing_exporting_meshes_page>` or created in other way. To setup the meshing parameters of a mesh not based on geometry, just invoke :ref:`Edit mesh / sub-mesh <editing_meshes_page>` command on your 2D mesh.
|
||||
|
||||
|
||||
* Several meshes can be :ref:`combined <building_compounds_page>` into a new mesh.
|
||||
|
||||
|
||||
* The whole mesh or its part (sub-mesh or group) can be :ref:`copied <copy_mesh_page>` into a new mesh.
|
||||
|
||||
|
||||
* A new mesh can be created from a transformed, e.g. :ref:`translated <translation_page>`, part of the mesh.
|
||||
|
||||
* A new mesh can be created from the gernation of the :ref:`dual <create_dual_mesh_page>` of a Tetrahedron Mesh.
|
||||
|
||||
|
||||
Meshes can be edited using the MESH functions destined for :ref:`modification <modifying_meshes_page>` of meshes.
|
||||
|
||||
@ -82,4 +84,5 @@ Quadratic mesh can be obtained in three ways:
|
||||
importing_exporting_meshes.rst
|
||||
building_compounds.rst
|
||||
copy_mesh.rst
|
||||
create_dual_mesh.rst
|
||||
connectivity.rst
|
||||
|
42
doc/gui/input/create_dual_mesh.rst
Normal file
42
doc/gui/input/create_dual_mesh.rst
Normal file
@ -0,0 +1,42 @@
|
||||
.. _create_dual_mesh_page:
|
||||
|
||||
****************
|
||||
Create Dual Mesh
|
||||
****************
|
||||
|
||||
We can create the dual of a Tetrahedron Mesh which will be a polyhedron mesh.
|
||||
The Mesh is created using MEDCoupling computeDualMesh function.
|
||||
|
||||
*To create a dual mesh:*
|
||||
|
||||
.. |img| image:: ../images/create_dual_mesh_icon.png
|
||||
|
||||
From the contextual menu in the Object Browser of from the **Mesh** menu select
|
||||
**Create Dual Mesh** or click *"Create Dual Mesh"* button |img| in the toolbar.
|
||||
|
||||
The following dialog box will appear:
|
||||
|
||||
.. image:: ../images/create_dual_mesh_dlg.png
|
||||
:align: center
|
||||
|
||||
In the dialog:
|
||||
|
||||
* specify the mesh for which to create the dual mesh:
|
||||
* **Select whole mesh** from the study tree. If a mesh was selected before calling function it will be preselected.
|
||||
* If the mesh is not made of only Tetrahedrons a error message will be displayed and you won't be allowed to go through.
|
||||
* specify the **New Mesh Name**;
|
||||
* activate **Project boundary elements on shape** for the boundary points of the
|
||||
dual mesh to be projected on their associated shape.
|
||||
|
||||
* Click **Apply** or **Apply and Close** button to confirm the operation.
|
||||
|
||||
----------------------------
|
||||
Limitations of the dual mesh
|
||||
----------------------------
|
||||
|
||||
Only 2d groups will be transferred to the dual mesh.
|
||||
|
||||
If you have convex shape the projection might not improve the mesh.
|
||||
|
||||
|
||||
**See Also** a sample script of :ref:`tui_create_dual_mesh`.
|
@ -70,7 +70,7 @@ Export of a Mesh
|
||||
|
||||
:download:`Download this script <../../examples/creating_meshes_ex05.py>`
|
||||
|
||||
.. _how_to_mesh_a_cylinder_with_hexahedrons:
|
||||
.. _how_to_mesh_a_cylinder_with_hexahedrons:
|
||||
|
||||
How to mesh a cylinder with hexahedrons?
|
||||
========================================
|
||||
@ -84,10 +84,10 @@ demonstrates the resulting mesh.
|
||||
:download:`Download this script <../../examples/creating_meshes_ex06.py>`
|
||||
|
||||
.. image:: ../images/mesh_cylinder_hexa.png
|
||||
:align: center
|
||||
:align: center
|
||||
|
||||
|
||||
.. _tui_building_compound:
|
||||
.. _tui_building_compound:
|
||||
|
||||
Building a compound of meshes
|
||||
=============================
|
||||
@ -107,3 +107,13 @@ Mesh Copying
|
||||
|
||||
:download:`Download this script <../../examples/creating_meshes_ex08.py>`
|
||||
|
||||
.. _tui_create_dual_mesh:
|
||||
|
||||
Creating Dual Mesh
|
||||
==================
|
||||
|
||||
.. literalinclude:: ../../examples/create_dual_mesh.py
|
||||
:language: python
|
||||
|
||||
:download:`Download this script <../../examples/create_dual_mesh.py>`
|
||||
|
||||
|
@ -150,9 +150,10 @@ void SMESHGUI_CreateDualMeshOp::selectionDone()
|
||||
{
|
||||
SMESH::SMESH_subMesh_var subMesh =
|
||||
SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pObj );
|
||||
// TODO: Check that mesh is only tetra
|
||||
// Check that mesh is only tetra
|
||||
if (!checkMesh(idSource)){
|
||||
myDlg->ShowWarning( true );
|
||||
myDlg->setButtonEnabled(false, QtxDialog::OK|QtxDialog::Apply);
|
||||
}
|
||||
}
|
||||
std::string mesh_name = "dual_" + pObj->GetName();
|
||||
|
@ -2885,6 +2885,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh
|
||||
|
||||
SMESH_Mesh& newMesh2 = newMesh_i->GetImpl();
|
||||
|
||||
MESSAGE("Loading file: " << dual_mesh_file.string() << " with mesh " << mesh_name);
|
||||
newMesh2.MEDToMesh(dual_mesh_file.c_str(), meshName);
|
||||
|
||||
MESSAGE("Imported created MED")
|
||||
|
@ -4,6 +4,7 @@ import sys
|
||||
import salome
|
||||
import medcoupling as mc
|
||||
from math import pi
|
||||
import numpy as np
|
||||
|
||||
#salome.salome_init()
|
||||
|
||||
@ -17,6 +18,10 @@ from salome.smesh import smeshBuilder
|
||||
|
||||
smesh = smeshBuilder.New()
|
||||
|
||||
from salome.kernel.logger import Logger
|
||||
logger = Logger("salome.smesh.smesh_tools")
|
||||
logger.setLevel("DEBUG")
|
||||
|
||||
def smesh_create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True, mesh_name="MESH"):
|
||||
""" Create a dual of the mesh in input_file into output_file
|
||||
|
||||
@ -31,15 +36,51 @@ def smesh_create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True, mesh_name
|
||||
|
||||
shape = mesh.GetShapeToMesh()
|
||||
|
||||
# Creating output file
|
||||
myfile = mc.MEDFileUMesh()
|
||||
myfile.setName(mesh_name)
|
||||
|
||||
|
||||
# We got a meshProxy so we need to convert pointer to MEDCoupling
|
||||
int_ptr = mesh.ExportMEDCoupling(True, True)
|
||||
dab = mc.FromPyIntPtrToDataArrayByte(int_ptr)
|
||||
tetras = mc.MEDFileMesh.New(dab)[0]
|
||||
mc_mesh_file = mc.MEDFileMesh.New(dab)
|
||||
tetras = mc_mesh_file[0]
|
||||
# End of SMESH -> MEDCoupling part for dualmesh
|
||||
|
||||
tetras = mc.MEDCoupling1SGTUMesh(tetras)
|
||||
polyh = tetras.computeDualMesh()
|
||||
dual_volume_raw = polyh.getMeasureField(True).accumulate()[0]
|
||||
|
||||
## Adding skin + transfering groups on faces from tetras mesh
|
||||
mesh2d = polyh.buildUnstructured().computeSkin()
|
||||
mesh2d.setName(mesh_name)
|
||||
myfile.setMeshAtLevel(-1, mesh2d)
|
||||
|
||||
|
||||
for grp_name in mc_mesh_file.getGroupsOnSpecifiedLev(-1):
|
||||
logger.debug("Transferring group: "+ grp_name)
|
||||
grp_tria = mc_mesh_file.getGroup(-1, grp_name)
|
||||
# Retrieve the nodes in group
|
||||
grp_nodes = grp_tria.computeFetchedNodeIds()
|
||||
# Find all the cells lying on one of the nodes
|
||||
id_grp_poly = mesh2d.getCellIdsLyingOnNodes(grp_nodes, False)
|
||||
|
||||
grp_poly = mesh2d[id_grp_poly]
|
||||
|
||||
# We use the interpolation to remove the element that are not really in
|
||||
# the group (the ones that are next to a nodes nut not in the group
|
||||
# will have the sum of their column in the enterpolation matrix equal
|
||||
# to zero)
|
||||
rem = mc.MEDCouplingRemapper()
|
||||
|
||||
rem.prepare(grp_poly, grp_tria, "P0P0")
|
||||
m = rem.getCrudeCSRMatrix()
|
||||
_, id_to_keep = np.where(m.sum(dtype=np.int64, axis=0) >= 1e-07)
|
||||
|
||||
id_grp_poly = id_grp_poly[id_to_keep.tolist()]
|
||||
id_grp_poly.setName(grp_name)
|
||||
|
||||
myfile.addGroup(-1, id_grp_poly)
|
||||
|
||||
# Getting list of new points added on the skin
|
||||
skin = tetras.buildUnstructured().computeSkin()
|
||||
@ -50,6 +91,7 @@ def smesh_create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True, mesh_name
|
||||
ptsAddedMesh = mc.MEDCouplingUMesh.Build0DMeshFromCoords( skin_polyh.getCoords()[ptsAdded] )
|
||||
|
||||
if adapt_to_shape:
|
||||
logger.debug("Adapting to shape")
|
||||
ptsAddedCoo = ptsAddedMesh.getCoords()
|
||||
ptsAddedCooModified = ptsAddedCoo[:]
|
||||
|
||||
@ -58,7 +100,6 @@ def smesh_create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True, mesh_name
|
||||
id2face = {}
|
||||
for face in faces:
|
||||
id2face[face.GetSubShapeIndices()[0]] = face
|
||||
print(id2face)
|
||||
|
||||
## Projecting each points added by the dual mesh on the surface it is
|
||||
# associated with
|
||||
@ -74,4 +115,7 @@ def smesh_create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True, mesh_name
|
||||
polyh.getCoords()[ptsAdded] = ptsAddedCooModified
|
||||
|
||||
polyh.setName(mesh_name)
|
||||
polyh.write(output_file)
|
||||
myfile.setMeshAtLevel(0, polyh)
|
||||
|
||||
logger.debug("Writting dual mesh in :"+output_file)
|
||||
myfile.write(output_file, 2)
|
||||
|
@ -80,6 +80,8 @@ isDone = Mesh_1.Compute()
|
||||
dual_Mesh_1 = smesh.CreateDualMesh(Mesh_1, 'dual_Mesh_1', True)
|
||||
dual_Mesh_raw_1 = smesh.CreateDualMesh(Mesh_1, 'dual_Mesh_1', False)
|
||||
|
||||
[ top_2, middle_2, bottom_2 ] = dual_Mesh_1.GetGroups()
|
||||
|
||||
#Comparing volumes
|
||||
dual_volume = dual_Mesh_1.GetVolume()
|
||||
dual_raw_volume = dual_Mesh_raw_1.GetVolume()
|
||||
|
@ -62,7 +62,6 @@ SET(BAD_TESTS
|
||||
SMESH_test1.py
|
||||
SMESH_test2.py
|
||||
SMESH_test4.py
|
||||
SMESH_create_dual_mesh.py
|
||||
SMESH_create_dual_mesh_adapt.py
|
||||
)
|
||||
IF(NOT WIN32)
|
||||
|
Loading…
Reference in New Issue
Block a user