-# Construction of a Submesh
+# Construction of a Sub-mesh
import salome
salome.salome_init()
geompy.addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
# create a hexahedral mesh on the box
-quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
+mesh = smesh.Mesh(box, "Box : hexahedral 3D mesh")
-# create a regular 1D algorithm for the faces
-algo1D = quadra.Segment()
+# create a Regular_1D algorithm for discretization of edges
+algo1D = mesh.Segment()
# define "NumberOfSegments" hypothesis to cut
# all the edges in a fixed number of segments
algo1D.NumberOfSegments(4)
# create a quadrangle 2D algorithm for the faces
-quadra.Quadrangle()
+mesh.Quadrangle()
-# construct a submesh on the edge with a local hypothesis
-algo_local = quadra.Segment(EdgeX)
+# construct a sub-mesh on the edge with a local Regular_1D algorithm
+algo_local = mesh.Segment(EdgeX)
-# define "Arithmetic1D" hypothesis to cut the edge in several segments with increasing arithmetic length
+# define "Arithmetic1D" hypothesis to cut EdgeX in several segments with length arithmetically
+# increasing from 1.0 to 4.0
algo_local.Arithmetic1D(1, 4)
-# define "Propagation" hypothesis that propagates all other hypotheses
-# on all edges of the opposite side in case of quadrangular faces
+# define "Propagation" hypothesis that propagates algo_local and "Arithmetic1D" hypothesis
+# on all parallel edges of the box
algo_local.Propagation()
+# assign a hexahedral algorithm
+mesh.Hexahedron()
+
# compute the mesh
-quadra.Compute()
+mesh.Compute()
-# Change priority of submeshes in Mesh
+# Change priority of sub-meshes in Mesh
import salome
salome.salome_init()
# create Mesh object on Box shape
Mesh_1 = smesh.Mesh(Box_1)
-# assign mesh algorithms
+# assign mesh algorithms and hypotheses
Regular_1D = Mesh_1.Segment()
Nb_Segments_1 = Regular_1D.NumberOfSegments(20)
-Nb_Segments_1.SetDistrType( 0 )
MEFISTO_2D = Mesh_1.Triangle()
Max_Element_Area_1 = MEFISTO_2D.MaxElementArea(1200)
Tetrahedron = Mesh_1.Tetrahedron()
Max_Element_Volume_1 = Tetrahedron.MaxElementVolume(40000)
-# create submesh and assign algorithms on Face_1
+# create sub-mesh and assign algorithms on Face_1
Regular_1D_1 = Mesh_1.Segment(geom=Face_1)
Nb_Segments_2 = Regular_1D_1.NumberOfSegments(4)
-Nb_Segments_2.SetDistrType( 0 )
MEFISTO_2D_1 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_1)
-Length_From_Edges_2D = MEFISTO_2D_1.LengthFromEdges()
SubMesh_1 = MEFISTO_2D_1.GetSubMesh()
-# create submesh and assign algorithms on Face_2
+# create sub-mesh and assign algorithms on Face_2
Regular_1D_2 = Mesh_1.Segment(geom=Face_2)
Nb_Segments_3 = Regular_1D_2.NumberOfSegments(8)
-Nb_Segments_3.SetDistrType( 0 )
MEFISTO_2D_2 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_2)
-Length_From_Edges_2D_1 = MEFISTO_2D_2.LengthFromEdges()
SubMesh_2 = MEFISTO_2D_2.GetSubMesh()
-# create submesh and assign algorithms on Face_3
+# create sub-mesh and assign algorithms on Face_3
Regular_1D_3 = Mesh_1.Segment(geom=Face_3)
Nb_Segments_4 = Regular_1D_3.NumberOfSegments(12)
-Nb_Segments_4.SetDistrType( 0 )
MEFISTO_2D_3 = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO,geom=Face_3)
-Length_From_Edges_2D_2 = MEFISTO_2D_3.LengthFromEdges()
SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
-# check exisiting submesh priority order
+# check exisiting sub-mesh priority order
[ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
-# set new submesh order
+isDone = Mesh_1.Compute()
+print "Nb elements at initial order of sub-meshes:", Mesh_1.NbElements()
+
+# set new sub-mesh order
isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
# compute mesh
isDone = Mesh_1.Compute()
+print "Nb elements at new order of sub-meshes:", Mesh_1.NbElements()
-# clear mesh result and compute with other submesh order
-Mesh_1.Clear()
+# compute with other sub-mesh order
isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
isDone = Mesh_1.Compute()
+print "Nb elements at another order of sub-meshes:", Mesh_1.NbElements()
<li> 1D algorithm and hypothesis that will be applied for meshing
(logically) vertical edges of the prism (which connect the top and the
base faces of the prism). In the sample picture above these are
- "Regular_1D" algorithm and "Nb. Segments_1" hypothesis.</li>
+ "Regular_1D" algorithm and "Nb. Segments" hypothesis named "Vertical
+ Nb. Segments".</li>
</ul>
The \b Local algorithms and hypotheses to be chosen at
meshing the top and the base prism faces. These faces can be meshed
with any type of 2D elements: quadrangles, triangles, polygons or
their mix. It is enough to define a sub-mesh on either the top or the base
- face. In the sample picture above, "BLSURF" algorithm meshes
- "Face_1" base surface with triangles. (1D algorithm is not
- assigned as "BLSURF" does not require divided edges to create a 2D mesh.)
+ face. In the sample picture above, "NETGEN_1D2D" algorithm meshes
+ "bottom disk" face with triangles. (1D algorithm is not
+ assigned as "NETGEN_1D2D" does not require divided edges to create a 2D mesh.)
</li>
<li> Optionally you can define a 1D sub-mesh on some vertical edges
of stacked prisms, which will override the global 1D hypothesis mentioned
more than four edges, four most sharp vertices are considered as
corners of the quadrangle and all edges between these vertices are
treated as quadrangle sides. In the case of three edges, the vertex
-specified by the user is considered as a degenerated side of the
-quadrangle.
+specified by the user is considered as a fourth degenerated side of the
+quadrangle.
\image html quad_meshes.png "Algorithm generates a structured mesh on complex faces provided that edges are properly discretized"
// update state of sub-meshes (mostly in order to erase improper errors)
SMESH_subMesh* sm = myHelper->GetMesh()->GetSubMesh( thePrism.myShape3D );
- SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/false);
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true);
while ( smIt->more() )
{
sm = smIt->next();
int prevChainSize = aChain.Extent();
if ( aChain.Add(anOppE) > prevChainSize ) { // ... anOppE is not in aChain
// Add found edge to the chain oriented so that to
- // have it co-directed with a forward MainEdge
+ // have it co-directed with a fromEdge
TopAbs_Orientation ori = anE.Orientation();
if ( anOppE.Orientation() == fourEdges[found].Orientation() )
ori = TopAbs::Reverse( ori );
helper1.SetSubShape( face1 );
helper2.SetSubShape( face2 );
- if ( helper1.HasSeam() != helper2.HasSeam() )
+ if ( helper1.HasRealSeam() != helper2.HasRealSeam() )
RETURN_BAD_RESULT("Different faces' geometry");
// Data to call SMESH_MeshEditor::FindMatchingNodes():
// find trsf
const int totNbSeg = 50;
vector< gp_XY > srcPnts, tgtPnts;
- srcPnts.resize( totNbSeg );
- tgtPnts.resize( totNbSeg );
+ srcPnts.reserve( totNbSeg );
+ tgtPnts.reserve( totNbSeg );
for ( size_t iW = 0; iW < srcWires.size(); ++iW )
{
const double minSegLen = srcWires[iW]->Length() / totNbSeg;
}
}
}
- else if ( nbEdgesInWires.front() == 1 )
+ else if ( nbEdgesInWires.front() == 1 ) // a sole edge in a wire
{
- // TODO::Compare orientation of curves in a sole edge
- //RETURN_BAD_RESULT("Not implemented case");
+ TopoDS_Edge srcE1 = srcEdges.front(), tgtE1 = tgtEdges.front();
+ for ( size_t iW = 0; iW < srcWires.size(); ++iW )
+ {
+ StdMeshers_FaceSidePtr srcWire = srcWires[iW];
+ for ( int iE = 0; iE < srcWire->NbEdges(); ++iE )
+ if ( srcE1.IsSame( srcWire->Edge( iE )))
+ {
+ reverse = ( tgtE1.Orientation() != tgtWires[iW]->Edge( iE ).Orientation() );
+ break;
+ }
+ }
}
else
{