Ejemplo n.º 1
0
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "Mesh")

import sys
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

coordsArr = DataArrayDouble(range(5))
mesh1 = MEDCouplingCMesh("mesh")
mesh1.setCoords(coordsArr, coordsArr)
mesh1 = mesh1.buildUnstructured()

from MEDLoader import WriteMesh
WriteMesh("mesh1.med", mesh1, True)

m2 = mesh1.computeSkin()
WriteMesh("mesh2.med", m2, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
([mesh_2], status) = smesh.CreateMeshesFromMED(r'mesh2.med')
Ejemplo n.º 2
0
src.allocateCells()
src.insertNextCell(NORM_QUAD4, [0, 3, 4, 1])
src.insertNextCell(NORM_QUAD4, [1, 4, 5, 2])
src.simplexize(0)

m2 = MEDCoupling1SGTUMesh(src)
dual = m2.computeDualMesh()

trgCoo = DataArrayDouble([(0.5, 0.5), (1.5, 0.5), (1.5, 1.5)])
trg = MEDCouplingUMesh("trg", 2)
trg.setCoords(trgCoo)
trg.allocateCells()
trg.insertNextCell(NORM_TRI3, [0, 2, 1])

from MEDLoader import WriteMesh
WriteMesh("mesh1.med", dual, True)
WriteMesh("mesh2.med", trg, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
([mesh_2], status) = smesh.CreateMeshesFromMED(r'mesh2.med')

### Store presentation parameters of displayed objects
import iparameters
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *
from MEDLoader import WriteMesh

arr=DataArrayDouble(range(2))
mc=MEDCouplingCMesh("m1")
mc.setCoords(arr,arr)
m1=mc.buildUnstructured()
m2=m1.deepCopy()
m2.translate([1.5,0])
m1.convertLinearCellsToQuadratic(0)
m2.convertLinearCellsToQuadratic(1)
m2.setName("m2")
WriteMesh("mesh1.med",m1,True)
WriteMesh("mesh1.med",m2,False)

###
### SMESH component
###

import  SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1,mesh_2], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
g1 = mesh_1.MakeGroupByIds("all nodes", SMESH.NODE, range(1,10))
g2 = mesh_2.MakeGroupByIds("all nodes", SMESH.NODE, range(1,10))

### Store presentation parameters of displayed objects
Ejemplo n.º 4
0
import sys
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

from MEDLoader import WriteMesh

m = MEDCouplingCurveLinearMesh("myCurveLinearMesh")
m.setNodeGridStructure([2, 3])
coords = DataArrayDouble(
    [0., 0., 2., 0., 0., 1., 1.9, 1.1, 0.3, 1.9, 2.2, 2.1], 6, 2)
coords.setInfoOnComponents(["X [m]", "Y [m]"])
m.setCoords(coords)

WriteMesh("mesh1.med", m, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')

### Store presentation parameters of displayed objects
import iparameters
ipar = iparameters.IParameters(
    theStudy.GetModuleParameters("Interface Applicative", "SMESH", 1))
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

coordsArr = DataArrayDouble(range(6))
mesh1 = MEDCouplingCMesh("mesh")
mesh1.setCoords(coordsArr, coordsArr[:3])

from MEDLoader import WriteMesh

mesh1.translate([6.5, 0])
mesh2 = mesh1.buildUnstructured()
part = mesh2[1, 2, 4, 5, 7, 8]
WriteMesh("part.med", part, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)
([mesh], status) = smesh.CreateMeshesFromMED(r'part.med')

## Set names of Mesh objects
smesh.SetName(mesh.GetMesh(), 'mesh')

### Store presentation parameters of displayed objects
medfile1 = "mesh1.med"
medfile2 = "mesh2.med"

m4 = MEDCouplingCMesh("box")
coo = DataArrayDouble(range(7))
m4.setCoords(coo[:5], coo[:5], coo)
m4 = m4.buildUnstructured()
valsArr1 = m4.computeCellCenterOfMass()
valsArr1.applyFunc(1, "sqrt(X*X+Y*Y+Z*Z)")
field4 = MEDCouplingFieldDouble(ON_CELLS)
field4.setArray(valsArr1)
field4.setMesh(m4)
field4.setName("field4")

WriteMesh(medfile1, m4, True)
WriteFieldUsingAlreadyWrittenMesh(medfile1, field4)

origin = [0, 0, 2]
normvec = [-4, -4, 6]
slice4 = field4.extractSlice3D(origin, normvec, 1e-10)
slice4.getMesh().translate([6, 0, 0])

WriteMesh(medfile2, slice4.getMesh(), True)
WriteFieldUsingAlreadyWrittenMesh(medfile2, slice4)

###
### PARAVIS component
###

import pvsimple
Ejemplo n.º 7
0
m2 = MEDCouplingCurveLinearMesh("myCurveLinearMesh")
m2.setNodeGridStructure([1, nb])
coo = DataArrayDouble(coords, nb, 3)
m2.setCoords(coo)
m2 = m2.buildUnstructured()

m3 = mesh1.buildExtrudedMesh(m2, 1)

skin = m3.computeSkin()
skin.setName("skin")
ortho = skin.buildOrthogonalField()
ortho.setName("ortho_field")

from MEDLoader import WriteField, WriteMesh
medfile = "mesh1.med"
WriteMesh(medfile, ortho.getMesh(), True)
WriteField(medfile, ortho, False)

import sys
import salome

salome.salome_init()
theStudy = salome.myStudy

import iparameters
ipar = iparameters.IParameters(
    salome.myStudy.GetCommonParameters("Interface Applicative", 1), True)

#Set up visual properties:
ipar.setProperty("AP_ACTIVE_VIEW", "ParaView_0_0")
ipar.setProperty(
Ejemplo n.º 8
0
ipar.append("ParaView_1", "empty")
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "ParaViS")

medfile = os.path.join(os.getenv("MEDCOUPLING_ROOT_DIR"), "share", "resources",
                       "med", "pointe.med")

from MEDLoader import ReadField, WriteField, WriteMesh
f = ReadField(medfile, "fieldnodeint")  # field on 19 nodes
f4 = f[(range(19 / 2))]
f4.getMesh().translate([5, 0, 0])

import tempfile
medfile2 = tempfile.NamedTemporaryFile().name + ".med"

WriteMesh(medfile2, f4.getMesh(), True)
WriteField(medfile2, f4, False)

# ###
### PARAVIS component
###

import pvsimple
pvsimple.ShowParaviewView()
#### import the simple module from the paraview
from pvsimple import *
#### disable automatic camera reset on 'Show'
pvsimple._DisableFirstRenderCameraReset()

# create a new 'MED Reader'
pointemed = MEDReader(FileName=medfile)
srcCoo = DataArrayDouble([(0, 0), (1, 0), (3, 0), (0, 1), (1, 1), (3, 1)])
src = MEDCouplingUMesh("src", 2)
src.setCoords(srcCoo)
src.allocateCells()
src.insertNextCell(NORM_QUAD4, [0, 3, 4, 1])
src.insertNextCell(NORM_QUAD4, [1, 4, 5, 2])

trgCoo = DataArrayDouble([(0.5, 0.5), (1.5, 0.5), (1.5, 1.5)])
trg = MEDCouplingUMesh("trg", 2)
trg.setCoords(trgCoo)
trg.allocateCells()
trg.insertNextCell(NORM_TRI3, [0, 2, 1])

from MEDLoader import WriteMesh
WriteMesh("mesh1.med", src, True)
WriteMesh("mesh2.med", trg, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
([mesh_2], status) = smesh.CreateMeshesFromMED(r'mesh2.med')

### Store presentation parameters of displayed objects
import iparameters
Ejemplo n.º 10
0
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "Mesh")

import sys
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

coordsArr=DataArrayDouble(range(3))
mesh1=MEDCouplingCMesh("mesh")
mesh1.setCoords(coordsArr,coordsArr,coordsArr[:1])
mesh1 = mesh1.buildUnstructured()

from MEDLoader import WriteMesh
WriteMesh("mesh1.med",mesh1,True)

import math
r = 3.
nb = 10
a = 5.
coords = []
for i in range( nb ):
  x = r * math.cos( math.radians( i*a )) - r
  z = r * math.sin( math.radians( i*a ))
  coords.extend([ x, 0, z ])

m2=MEDCouplingCurveLinearMesh("myCurveLinearMesh")
m2.setNodeGridStructure([1,nb])
coo=DataArrayDouble(coords,nb,3)
m2.setCoords(coo)
Ejemplo n.º 11
0
    <Background Value="bt=1;fn=;tm=0;ts=false;c1=#5a5a5a;c2=#000000;gt=-1;gr="/>
</ViewState>
""")
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "Mesh")

if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *
from MEDLoader import WriteMesh

coordsArr = DataArrayDouble(range(6))
mesh2d = MEDCouplingCMesh("mesh2")
mesh2d.setCoords(coordsArr, coordsArr[:2])
WriteMesh("mesh1.med", mesh2d, True)

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)
([m_2d], status) = smesh.CreateMeshesFromMED(r'mesh1.med')

m2 = m_2d.TranslateObjectMakeMesh(m_2d, [-6, 0, 0])
m2.Reorient([2, 4])

### Store presentation parameters of displayed objects
import iparameters
ipar = iparameters.IParameters(
    theStudy.GetModuleParameters("Interface Applicative", "SMESH", 1))
    from MEDCoupling import *

from MEDLoader import WriteMesh

coordsArr = DataArrayDouble(range(6))

m1d = MEDCouplingUMesh("m1d", 1)
m1d.setCoords(coordsArr)
m1d.allocateCells(5)
m1d.insertNextCell(NORM_SEG2, [3, 4])
m1d.insertNextCell(NORM_SEG2, [5, 4])
m1d.insertNextCell(NORM_SEG2, [3, 2])
m1d.insertNextCell(NORM_SEG2, [2, 1])
m1d.insertNextCell(NORM_SEG2, [0, 1])
m1d.finishInsertingCells()
WriteMesh("mesh1.med", m1d, True)

m1d.renumberCells(m1d.orderConsecutiveCells1D().invertArrayN2O2O2N(5), True)
m1d.setName("renumberCells")
WriteMesh("mesh1.med", m1d, False)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)
([m_1d, m_renum], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
""")
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "Mesh")

if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

from MEDLoader import WriteMesh

coordsArr = DataArrayDouble(range(2))
m = MEDCouplingCMesh("m1")
m.setCoords(coordsArr, coordsArr)
m = m.buildUnstructured()
WriteMesh("mesh1.med", m, True)

m.setName("m2")
m.renumberNodes([2, 1, 0, -1], 3)
WriteMesh("mesh1.med", m, False)

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)
([Mesh_1, Mesh_2], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
Mesh_2.TranslateObject(Mesh_2, [2, 0, 0], 0)

### Store presentation parameters of displayed objects
import iparameters
ipar = iparameters.IParameters(
Ejemplo n.º 14
0
MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO)
isDone = Mesh_1.Compute()
isDone = Mesh_1.RemoveElements( range( 1,13 ))
Mesh_1.ExportMED( r'mesh1.med', overwrite=1 )


#from MEDCoupling import *
from MEDLoader import ReadMeshFromFile, WriteMesh
m = ReadMeshFromFile("mesh1.med")

from MEDRenumber import RenumberingFactory
ren=RenumberingFactory("BOOST")
a,b=m.computeNeighborsOfCells()
n2o,_=ren.renumber(a,b)
mrenum=m[n2o]
WriteMesh("mesh2.med",mrenum,True)

([Mesh_renum], status) = smesh.CreateMeshesFromMED(r'mesh2.med')
Mesh_renum.TranslateObject( Mesh_renum, [ 120, 0, 0 ], 0 )


### Store presentation parameters of displayed objects
import iparameters
ipar = iparameters.IParameters(theStudy.GetModuleParameters("Interface Applicative", "SMESH", 1))

#Set up entries:
# set up entry SMESH_3 (Mesh_1) parameters
ipar.setParameter("SMESH_3", "VTKViewer_0_Visibility", "On")
ipar.setParameter("SMESH_3", "VTKViewer_0_Representation", "2")
ipar.setParameter("SMESH_3", "VTKViewer_0_IsShrunk", "0")
ipar.setParameter("SMESH_3", "VTKViewer_0_Entities", "e:0:f:1:v:0:0d:0:b:0")
Ejemplo n.º 15
0
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "Mesh")

import sys
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *
from MEDLoader import WriteMesh

coords = DataArrayDouble(range(6))
cmesh = MEDCouplingCMesh("cmesh")
cmesh.setCoords(coords, coords[:2])
# make a mesh with two zones
zmesh = cmesh.buildUnstructured()[0, 1, 3, 4]
WriteMesh("mesh1.med", zmesh, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')

### Store presentation parameters of displayed objects
import iparameters
ipar = iparameters.IParameters(
    theStudy.GetModuleParameters("Interface Applicative", "SMESH", 1))
src.setCoords(srcCoo)
src.allocateCells()
src.insertNextCell(NORM_QUAD4, [0, 3, 4, 1])
src.insertNextCell(NORM_QUAD4, [1, 4, 5, 2])

trgCoo = DataArrayDouble([(0.5, 0.5), (1.5, 0.5), (1.5, 1.5)])
trg = MEDCouplingUMesh("trg", 2)
trg.setCoords(trgCoo)
trg.allocateCells()
trg.insertNextCell(NORM_TRI3, [0, 2, 1])

m2 = MEDCoupling1SGTUMesh(trg)
dual = m2.computeDualMesh()

from MEDLoader import WriteMesh
WriteMesh("mesh1.med", src, True)
WriteMesh("mesh2.med", dual, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
([mesh_2], status) = smesh.CreateMeshesFromMED(r'mesh2.med')

### Store presentation parameters of displayed objects
import iparameters
Ejemplo n.º 17
0
coordsArr = DataArrayDouble(range(6))
mesh2d = MEDCouplingCMesh("mesh2")
mesh2d.setCoords(coordsArr, coordsArr[:2])
mesh2d = mesh2d.buildUnstructured()

mesh1d = mesh2d.deepCopy()
mesh1d.rotate([2.3, 0], math.radians(25))
#mesh1d.translate( [0.2,0.4] )
mesh1d.setName("mesh1")

m2d, a2d, a1d = MEDCouplingUMesh.Intersect2DMeshes(mesh2d, mesh1d, 1e-12)

from MEDLoader import WriteMesh

WriteMesh("mesh1.med", mesh2d, True)
WriteMesh("mesh1.med", mesh1d, False)
WriteMesh("mesh1.med", m2d, False)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(theStudy)
([m_2d, mesh_1d, mesh_2d], status) = smesh.CreateMeshesFromMED(r'mesh1.med')

m_2d.TranslateObject(m_2d, [6, 0, 0], False)
Ejemplo n.º 18
0
""")
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "Mesh")

import sys
if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

coordsArr = DataArrayDouble(range(3))
mesh1 = MEDCouplingCMesh("mesh")
mesh1.setCoords(coordsArr, coordsArr, coordsArr)

from MEDLoader import WriteMesh
WriteMesh("mesh1.med", mesh1, True)

mesh2 = mesh1.buildUnstructured()
mesh2.simplexize(PLANAR_FACE_5)
WriteMesh("part.med", mesh2, True)

###
### SMESH component
###

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New(salome.myStudy)
([mesh_1], status) = smesh.CreateMeshesFromMED(r'mesh1.med')
([mesh_2], status) = smesh.CreateMeshesFromMED(r'part.med')
Ejemplo n.º 19
0
#

from MEDLoader import *
import os

from MEDLoaderDataForTest import MEDLoaderDataForTest

m = MEDLoaderDataForTest.build1DMesh_1()
m.setName("mesh2")
#! [UG_ReadMeshFromFile_3]
m.checkConsecutiveCellTypesForMEDFileFrmt()
#! [UG_ReadMeshFromFile_3]
#! [UG_ReadMeshFromFile_0]
from MEDLoader import WriteMesh

WriteMesh("file2.med", m, True)
#! [UG_ReadMeshFromFile_0]
#! [UG_ReadMeshFromFile_1]
from MEDLoader import ReadMeshFromFile

m = ReadMeshFromFile("file2.med")
#! [UG_ReadMeshFromFile_1]
#! [UG_ReadMeshFromFile_2]
m = ReadMeshFromFile("file2.med", "mesh2")
assert (m.getName() == "mesh2")
#! [UG_ReadMeshFromFile_2]

mesh3D = MEDLoaderDataForTest.build3DMesh_1()
mesh2D = mesh3D.computeSkin()
mesh1D = mesh2D.computeSkin()
#! [UG_ReadMeshFromFile_4]
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

from MEDLoader import WriteMesh, WriteFieldUsingAlreadyWrittenMesh

medfile = "mesh1.med"
XCoords = [-0.3, 0., 0.1, 0.3, 0.45, 0.47, 0.49, 1., 1.22]  # 9 values along X
YCoords = [0., 0.1, 0.37, 0.45, 0.47, 0.49, 1.007]  # 7 values along Y
arrX = DataArrayDouble(XCoords)
arrX.setInfoOnComponent(0, "X [m]")
arrY = DataArrayDouble(YCoords)
arrY.setInfoOnComponent(0, "Y [m]")
mesh = MEDCouplingCMesh("CMesh")
mesh.setCoords(arrX, arrY)
WriteMesh(medfile, mesh, True)

f = mesh.getMeasureField(True)
WriteFieldUsingAlreadyWrittenMesh(medfile, f)

import iparameters
ipar = iparameters.IParameters(
    salome.myStudy.GetCommonParameters("Interface Applicative", 1), True)

#Set up visual properties:
ipar.setProperty("AP_ACTIVE_VIEW", "ParaView_0_0")
ipar.setProperty(
    "AP_WORKSTACK_INFO",
    "0000000100000000000000020100000001000003b5000000040000000100000001000000080000001800500061007200610056006900650077005f0030005f00300000000102"
)
ipar.setProperty("AP_ACTIVE_MODULE", "ParaViS")
m = m.buildUnstructured()
#m.rotate([3.5,3.5],math.pi/4.)

#WriteMesh("mesh1.med",m,True)

from MEDCoupling import MEDCouplingSkyLineArray
import MEDPartitioner
a, b = m.computeNeighborsOfCells()
sk = MEDCouplingSkyLineArray(b, a)
g = MEDPartitioner.MEDPartitioner.Graph(sk)
g.partGraph(4)
procIdOnCells = g.getPartition().getValuesArray()
p0 = procIdOnCells.findIdsEqual(0)
part0 = m[p0]

WriteMesh("part.med", part0, True)

boundary_nodes_part0 = part0.findBoundaryNodes()
boundary_cells_part0 = p0[part0.getCellIdsLyingOnNodes(boundary_nodes_part0,
                                                       False)]
# starting from knowledge of neighborhood it s possible to know the neighbors of boundary_cells_part0
neighbors_boundary_cells_part0 = MEDCouplingUMesh.ExtractFromIndexedArrays(
    boundary_cells_part0, a, b)[0]
neighbors_boundary_cells_part0.sort()
neighbors_boundary_cells_part0 = neighbors_boundary_cells_part0.buildUnique()
#
layer_of_part0 = neighbors_boundary_cells_part0.buildSubstraction(p0)
#
whole_part_with_layer = DataArrayInt.Aggregate([p0, layer_of_part0])
whole_part_with_layer.sort()
part0_with_layer = m[whole_part_with_layer]
Ejemplo n.º 22
0
ipar.append("AP_MODULES_LIST", "Mesh")

if sys.platform == "win32":
    from MEDCouplingCompat import *
else:
    from MEDCoupling import *

from MEDLoader import ReadMeshFromFile, WriteMesh

coordsArr = DataArrayDouble(range(8))
m = MEDCouplingCMesh("mesh")
m.setCoords(coordsArr, coordsArr)
m = m.buildUnstructured()
#m.rotate([3.5,3.5],math.pi/4.)

WriteMesh("mesh1.med", m, True)

from MEDCoupling import MEDCouplingSkyLineArray
import MEDPartitioner
a, b = m.computeNeighborsOfCells()
sk = MEDCouplingSkyLineArray(b, a)
g = MEDPartitioner.MEDPartitioner.Graph(sk)
g.partGraph(4)
procIdOnCells = g.getPartition().getValuesArray()
p0 = procIdOnCells.findIdsEqual(0)
part0 = m[p0]

WriteMesh("part.med", part0, True)

import SMESH, SALOMEDS
from salome.smesh import smeshBuilder