smesh/src/Tools/blocFissure/gmu/mailleFacesPeau.py

158 lines
6.9 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2021-03-23 17:44:27 +03:00
# Copyright (C) 2014-2021 EDF R&D
2019-02-14 14:55:47 +03:00
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
2021-01-28 15:06:48 +01:00
"""maillage faces de peau"""
import logging
2021-04-01 16:19:17 +02:00
import SMESH
from salome.smesh import smeshBuilder
2017-03-20 13:27:30 +01:00
from .geomsmesh import geompy
from .geomsmesh import geomPublishInFather
from .geomsmesh import smesh
2021-04-01 16:19:17 +02:00
from . import initLog
2017-03-20 13:27:30 +01:00
from .putName import putName
2021-03-16 16:52:38 +01:00
def mailleFacesPeau(partitionsPeauFissFond, idFillingFromBout, facesDefaut, \
facesPeaux, edCircPeau, ptCircPeau, gpedgeBord, gpedgeVifs, edFissPeau, \
bordsLibres, grpEdgesPeauFissureExterne, grpAretesVives, \
edgesCircPipeGroup, dmoyen, rayonPipe, nbsegRad, \
2021-04-06 17:43:34 +02:00
mailleur="MeshGems", nro_cas=None):
2021-01-28 15:06:48 +01:00
"""maillage faces de peau"""
logging.info('start')
2021-04-02 17:59:18 +02:00
logging.info("Maillage avec %s pour le cas n°%d", mailleur, nro_cas)
nbFacesFilling = len(partitionsPeauFissFond)
2021-04-01 16:19:17 +02:00
boutFromIfil = [None for _ in range(nbFacesFilling)]
if idFillingFromBout[0] != idFillingFromBout[1]: # repérage des extremites du pipe quand elles débouchent sur des faces différentes
boutFromIfil[idFillingFromBout[0]] = 0
boutFromIfil[idFillingFromBout[1]] = 1
2021-01-26 18:34:02 +01:00
2021-02-19 17:56:38 +01:00
logging.info("---------------------------- maillage faces de peau --------------")
logging.info("nbFacesFilling = %d", nbFacesFilling)
meshesFacesPeau = list()
for ifil in range(nbFacesFilling):
meshFacePeau = None
if partitionsPeauFissFond[ifil] is None: # face de peau maillage sain intacte
logging.debug("meshFacePeau %d intacte", ifil)
# --- edges de bord de la face de filling
filling = facesDefaut[ifil]
edgesFilling = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], False)
groupEdgesBordPeau = geompy.CreateGroup(filling, geompy.ShapeType["EDGE"])
geompy.UnionList(groupEdgesBordPeau, edgesFilling)
geomPublishInFather(initLog.debug,filling, groupEdgesBordPeau , "EdgesBords")
2021-01-26 18:34:02 +01:00
meshFacePeau = smesh.Mesh(facesDefaut[ifil])
2021-01-26 18:34:02 +01:00
algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas)
putName(algo1d, "algo1d_bordsLibres", ifil, nro_cas)
putName(hypo1d, "hypo1d_bordsLibres", ifil, nro_cas)
2021-01-26 18:34:02 +01:00
else:
2021-01-26 18:34:02 +01:00
2021-02-19 17:56:38 +01:00
logging.info("meshFacePeau %d coupée par la fissure", ifil)
facePeau = facesPeaux[ifil] # pour chaque face : la face de peau finale a mailler (percée des faces débouchantes)
edgesCircPeau = edCircPeau[ifil] # pour chaque face de peau : [subshape edge circulaire aux débouchés du pipe]
2021-03-16 16:52:38 +01:00
_ = ptCircPeau[ifil] # pour chaque face de peau : [subshape point sur edge circulaire aux débouchés du pipe]
groupEdgesBordPeau = gpedgeBord[ifil] # pour chaque face de peau : groupe subshape des edges aux bords liés à la partie saine
bordsVifs = gpedgeVifs[ifil] # pour chaque face de peau : groupe subshape des edges aux bords correspondant à des arêtes vives
edgesFissurePeau = edFissPeau[ifil] # pour chaque face de peau : [subshape edge en peau des faces de fissure externes]
2021-03-16 16:52:38 +01:00
logging.info("a")
meshFacePeau = smesh.Mesh(facePeau)
2021-01-26 18:34:02 +01:00
algo1d = meshFacePeau.UseExisting1DElements(geom=groupEdgesBordPeau)
hypo1d = algo1d.SourceEdges([ bordsLibres ],0,0)
putName(algo1d.GetSubMesh(), "bordsLibres", ifil, nro_cas)
putName(algo1d, "algo1d_bordsLibres", ifil, nro_cas)
putName(hypo1d, "hypo1d_bordsLibres", ifil, nro_cas)
2021-01-26 18:34:02 +01:00
2021-03-16 16:52:38 +01:00
logging.info("b")
algo1d = meshFacePeau.UseExisting1DElements(geom=geompy.MakeCompound(edgesFissurePeau))
hypo1d = algo1d.SourceEdges([ grpEdgesPeauFissureExterne ],0,0)
putName(algo1d.GetSubMesh(), "edgePeauFiss", ifil, nro_cas)
putName(algo1d, "algo1d_edgePeauFiss", ifil, nro_cas)
putName(hypo1d, "hypo1d_edgePeauFiss", ifil, nro_cas)
2021-01-26 18:34:02 +01:00
if bordsVifs is not None:
algo1d = meshFacePeau.UseExisting1DElements(geom=bordsVifs)
hypo1d = algo1d.SourceEdges([ grpAretesVives ],0,0)
putName(algo1d.GetSubMesh(), "bordsVifs", ifil, nro_cas)
putName(algo1d, "algo1d_bordsVifs", ifil, nro_cas)
putName(hypo1d, "hypo1d_bordsVifs", ifil, nro_cas)
2021-01-26 18:34:02 +01:00
2021-04-01 16:19:17 +02:00
for i_aux, edgeCirc in enumerate(edgesCircPeau):
texte = "i_aux = {}".format(i_aux)
logging.info(texte)
if edgeCirc is not None:
2021-03-29 08:47:53 +02:00
algo1d = meshFacePeau.UseExisting1DElements(geom=edgeCirc) # addToStudy() failed ?
if boutFromIfil[ifil] is None:
2021-04-01 16:19:17 +02:00
hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[i_aux] ],0,0)
else:
hypo1d = algo1d.SourceEdges([ edgesCircPipeGroup[boutFromIfil[ifil]] ],0,0)
2021-04-01 16:19:17 +02:00
name = "cercle{}".format(i_aux)
putName(algo1d.GetSubMesh(), name, ifil, nro_cas)
putName(algo1d, "algo1d_" + name, ifil, nro_cas)
putName(hypo1d, "hypo1d_" + name, ifil, nro_cas)
2021-01-26 18:34:02 +01:00
2021-03-16 16:52:38 +01:00
logging.info("c")
logging.info("Maillage avec %s", mailleur)
if ( mailleur == "MeshGems"):
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.MG_CADSurf)
hypo2d = algo2d.Parameters()
hypo2d.SetPhySize( dmoyen )
hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
hypo2d.SetMaxSize( dmoyen*2. )
hypo2d.SetChordalError( dmoyen*0.25 )
hypo2d.SetVerbosity( 0 )
else:
algo2d = meshFacePeau.Triangle(algo=smeshBuilder.NETGEN_1D2D)
hypo2d = algo2d.Parameters()
hypo2d.SetMaxSize( dmoyen )
hypo2d.SetOptimize( 1 )
hypo2d.SetFineness( 2 )
hypo2d.SetMinSize( rayonPipe/float(nbsegRad) )
hypo2d.SetQuadAllowed( 0 )
logging.info("d")
putName(algo2d.GetSubMesh(), "facePeau", ifil, nro_cas)
putName(algo2d, "algo2d_facePeau", ifil, nro_cas)
putName(hypo2d, "hypo2d_facePeau", ifil, nro_cas)
2021-01-26 18:34:02 +01:00
is_done = meshFacePeau.Compute()
text = "meshFacePeau {} .Compute".format(ifil)
if is_done:
logging.info(text+" OK")
else:
text = "Erreur au calcul du maillage.\n" + text
logging.info(text)
raise Exception(text)
2021-01-27 11:51:06 +01:00
GroupFaces = meshFacePeau.CreateEmptyGroup( SMESH.FACE, "facePeau%d"%ifil )
2021-03-16 16:52:38 +01:00
_ = GroupFaces.AddFrom( meshFacePeau.GetMesh() )
meshesFacesPeau.append(meshFacePeau)
2021-01-26 18:34:02 +01:00
return meshesFacesPeau