Commit 57d9f01f authored by Valentin Vallaeys's avatar Valentin Vallaeys Committed by Philippe Delandmeter
Browse files

interface3D : rm duplicate slimExtrude

parent 56868c17
import extrude as extrudeDG
import mesh
import numpy as np
import slim_private
import dgpy
def extrude(mesh_file_name, bath_file_name, nb_layers=None, z_layers=None, layers_function=None, mesh_file_name_out='', factor_show=0):
if (nb_layers and z_layers) or (nb_layers and layers_function) or (z_layers and layers_function):
dgpy.Msg.Fatal("Only one among nb_layers, z_layers and layers_function can be defined!")
groups = dgpy.dgGroupCollection(mesh_file_name)
bathFunc = slim_private._load_function(bath_file_name, groups)
bathDof = dgpy.dgDofContainer(groups, 1)
globNodeId2Bath = {}
dataProx = dgpy.fullMatrixDouble()
for iGroup in range(groups.getNbElementGroups()) :
group = groups.getElementGroup(iGroup)
for iElement in range(group.getNbElements()) :
el = group.getElement(iElement)
bathDof.getElementProxy(iGroup,iElement, dataProx)
for iPt in range(group.getNbNodes()) :
vId = groups.mesh().gmshVertexId(el.vertex(iPt))
globNodeId2Bath[vId] = dataProx(iPt,0)
def layersForZ(h) :
for i in range(len(z_layers)) :
if z_layers[i] > h :
return i
return len(z_layers)
def getLayers(e, v) :
h = globNodeId2Bath[v[3]]
if nb_layers:
return [z * h /nb_layers for z in range(nb_layers + 1)]
elif z_layers:
return [z_layers[i] for i in range(layersForZ(h))]
elif layers_function:
return layers_function(v[0], v[1], h)
dgpy.Msg.Fatal("Neither nb_layers nor z_layers nor layers_function was defined")
def getLayersShow(e, v) :
layers = getLayers(e, v)
for i in range(len(layers)):
layers[i] = factor_show * layers[i]
return layers
if mesh_file_name_out:
mesh3d = mesh_file_name_out
mesh3dShow = mesh_file_name_out[:-4] + '_show.msh'
mesh3d = mesh_file_name[:-4] + '_3d.msh'
mesh3dShow = mesh_file_name[:-4] + '_3d_show.msh'
extrudeDG.extrude(mesh.mesh(mesh_file_name), getLayers).write(mesh3d)
if factor_show > 0:
extrudeDG.extrude(mesh.mesh(mesh_file_name), getLayersShow).write(mesh3dShow)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment